DWARF Standard


HOME
SPECIFICATIONS
FAQ
ISSUES



180426.2 Paul T Robinson Line table "comment" opcode Enhancement Open


Section 6.2.5.3, pg 165
There are times when it is useful to be able to introduce
padding or a no-op into a line-number program.  One example
is a producer that wants to leave room for expansion of a
function, in an incremental-linking scenario.  Another is
when a linker removes an unused function from a compilation
unit, and wants to "erase" the corresponding portion of the
line-number program without rewriting the entire .debug_line
section.

There are syntactically legal ways to do this in DWARF,
for example by using a series of DW_LNS_set_basic_block
opcodes.  However, a consumer would still have to parse
and execute these opcodes, which is less efficient than
we might like.  Or, if the area to be filled is preceded
by a DW_LNE_end_sequence opcode, the ULEB length of that 
opcode could be artificially padded with 0x80 bytes, in 
the hope that a consumer would be willing to parse an 
arbitrarily long ULEB number.  This is placing an unusual
expectation on consumers, however, who might reasonably
place an upper bound on the number of ULEB bytes they
are willing to parse without complaint.

To solve this, I propose a new DW_LNE_comment opcode.
It takes one operand, which can be zero length, and has
no effect on the line number program.  This opcode allows
efficiently skipping 3 or more bytes of the line number
program.  (Any extended opcode occupies a minimum of 3
bytes.)

In a related thread on dwarf-discuss, Cary pointed out
that given how DWARF works, any undefined extended opcode
could be used for this purpose.  The risk is that someday
we might actually define that opcode!  By reserving an
opcode for this purpose, we eliminate the risk; and,
existing producers can use the new opcode regardless of
the DWARF version, because consumers already know how to
skip an unrecognized extended opcode.

Proposed text:

6.2.5.3 Extended Opcodes

Add a new numbered entry:

  DW_LNE_comment
  The DW_LNE_comment opcode takes a single string
  parameter, which may be zero length.  The size of the
  operand is implicitly given by the unsigned LEB128
  integer that precedes the opcode.  The opcode and
  operand have no effect on the line number program.
  
  This permits a producer to pad or overwrite arbitrary
  parts of a line number program, with a minimum of the
  three bytes needed to encode any extended opcode.
  

7.22 Line Number Information

Add DW_LNE_comment to table 7.26 with the next available
opcode number.





All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2017 by DWARF Standards Committee.