[Dwarf-Discuss] DW_OP_regX vs. DW_OP_bregX 0

Robinson, Paul T NonStop paul.t.robinson@hp.com
Thu Feb 12 23:01:21 GMT 2009

Roland McGrath wrote:
>> If the 0 offset happens really a lot, it could be worth doing something
>> about it.  Blessing GCC's current behavior doesn't feel right, though,
>> as it overloads DW_OP_regN to mean one thing when used by itself and 
>> another thing when embedded in a larger expression.  
>One could say that DW_OP_addr is overloaded in the same way.
>Alone it means "this address is the location".  Embedded it
>means "push this address on the expression stack".  The two
>(proposed) meanings for DW_OP_reg* are precisely analogous.
One could say that, but one would be wrong.

DW_OP_addr means "push this address onto the stack."  At the end 
of the expression, the location to use is at the top of the stack.
Which is where DW_OP_addr left it; no special cases.
There is only one interpretation, only one thing that the
interpreter has to do with the operator.  If your interpreter is
doing what you said, that is an implementation choice, not a
requirement of the standard.

Furthermore, the proposed meaning of DW_OP_reg* is not precisely
analogous; the original meaning is in effect "push the non-memory-address
location of this register on the stack" while the proposed meaning is
"fetch the content of this register and push that value on the stack,
but only if there's another operator after this one."
That's rather more work than even your interpretation of DW_OP_addr.

>> This puts an unnecessary burden on the interpreter.
>How so?  I think it is clear and unambiguous what DW_OP_reg* would mean in
>this case if not specifically disallowed.  How is this more of a burden
>than the use of any other new operation?

It's more of a burden because the proposed meaning is a whole lot more
complicated that the original meaning.  In effect, every operator would
have to peek at the stack, and if top-of-stack is a register location,
implicitly execute a deref.  Or, every existing consumer would have to
be modified to change its handling of an existing operator.  Neither of
those choices is attractive.


More information about the Dwarf-discuss mailing list