check for valid location of zero length dwarf block forms?
Cary Coutant
ccoutant@google.com
Tue Nov 24 19:15:00 GMT 2009
> I wonder if I could just do something like...
>
> case dw_val_class_loc:
> size = size_of_locs (AT_loc (a));
>
> /* Output the block length for this list of location operations. */
> dw2_asm_output_data (constant_size (size), size, "%s", name);
>
> if (dwarf_strict && (size == 0))
> break;
> else
> output_loc_sequence (AT_loc (a));
> break;
By the time we get to output_die(), the abbrev code has already been
chosen, DIE offsets have been calculated, and a DW_AT_location
attribute of a known size is expected. Skipping it completely here
will break the DWARF output.
I think what you would want to do instead is change resolve_addr()
either to remove the DW_AT_location attribute from the DIE instead of
setting dw_attr_val.v.val_loc to NULL, or to set dw_attr_val.v.val_loc
to a DWARF expression containing nothing but DW_OP_nop. In the
dw_val_class_loc_list case, I'm not sure if the Apple tool is picky
enough to complain about zero-length location expressions there, too;
if it is, you'll either need to remove a NULL expr from the location
list, or set it to a DW_OP_nop as well.
I haven't looked to see if there are other places besides
resolve_addr() that might generate a null location expression.
In the long run, though, the Apple tools should be fixed. An empty
DWARF location expression is well defined and valid.
-cary
More information about the Gdb
mailing list