Hi Roland,
On Mon, 2009-07-20 at 12:12 -0700, Roland McGrath wrote:
Let's take the two separately. For the low-level stuff,
DW_OP_stack_value
is trivial to support. I added that.
Thanks. BTW. You removed DW_OP_GNU_push_tls_address in 96349f, I assume
by accident.
> - DW_OP_implicit_value = 0x9e, /* DW_FORM_block follows
opcode. */
> + DW_OP_implicit_value = 0x9e, /* ULEB128 size, followed by size bytes
> + in target memory representation. */
Um. So, that's what DW_FORM_block means.
The whole issue of the constant block being in target format is not new.
It's as it should be, and it's just the same as you already have for
e.g. DW_AT_const_value with a DW_FORM_block* (constant block) value.
Ah, yes. I clearly was a bit confused. I really wanted DW_FORM... to be
about the data type, but it isn't. Which is a pity since that does
indeed mean, there is no easy way of representing it in general. O well.
Here is an updated patch for readelf -w support, that doesn't try to be
clever and that just outputs the value bytes as is in hex. e.g.
"implicit_value 4 (ef be ad de)"
2009-07-20 Mark Wielaard <mjw(a)redhat.com>
* readelf.c (print_ops): Add handling of DW_OP_implicit_value
and DW_OP_stack_value.
My inclination is to make DW_OP_implicit_value a special case from
the
libdw API perspective. That is, the number/number2 fields will be
"internal form" rather than directly usable. Then we give a call you can
pass such a Dwarf_Op to yield a Dwarf_Block.
My inclination is to let this do some sanity-checking against bogus
Dwarf_Op's consed by callers, which means not just shoving pointers in
there. Instead, it means the implicit_value->block call would take not
just the Dwarf_Op but also something like the Dwarf_Attribute that was used
to retrieve it. With that, we could encode it as number=size,number2=secoff
where secoff is the offset into the .debug_{info,loc} section where the
data begins (i.e. after the size ULEB128). From the Dwarf_Attribute's form
we can tell whether this op should refer to .debug_loc or .debug_info, and
then partially sanity-check the offset and size.
That would certainly work for me. You would also need a variant that
takes a Dwarf_Frame to match up with .debug_frame/.eh_frame.
Thanks,
Mark