[PATCH] D105469: [Debug-Info] [llvm-dwarfdump] Don't treat DW_FORM_data4/8 to be section offsets in DWARF3.

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 6 09:10:53 PDT 2021


probinson added a comment.

In DWARF2, there isn't a specific form-class for pointing to location lists.
DW_AT_byte_size is always a constant, so DW_FORM_data4/8 are not location-list pointers.
DW_AT_count is either a constant or a reference (to a DIE describing how to compute the count), so DW_FORM_data4/8 are not location-list pointers.
DW_AT_data_member_location is always a location description (either embedded in a block, or referring to .debug_loc), so DW_FORM_data4/8 are actually location-list pointers.

In DWARF3, the forms DW_FORM_data4 and DW_FORM_data8 can be class constant or class loclistptr, depending on the attribute, and if a given attribute allows both, loclistptr is assumed.
DW_AT_byte_size is either a block, constant, or reference, so DW_FORM_data4/8 are not location-list pointers.
DW_AT_count is either a block, constant, or reference, so DW_FORM_data4/8 are not location-list pointers.
DW_AT_data_member_location is either a block, constant, or loclistptr, so DW_FORM_data4/8 must be considered pointers to a location list.

Starting in DWARF4, attributes pointing to a location list would use DW_FORM_sec_offset, and forms data4/data8 are always class constant, never location-list pointers.

This means that DW_AT_byte_size can never point to a location list, and it was a bug to have it say it could (similarly for at least DW_AT_bit_size, and we probably should re-review the entire list).  I suppose as an extension it could point to a location list, which would allow different size values based on the current execution address, although the only case I'm familiar with would derive the size from a variable, and so not have to have an actual location list.

Similarly, DW_AT_count can never point to a location list, with the same caveat as for DW_AT_byte_size.

DW_AT_data_member_location is another story; FORM_data4/data8 are supposed to be interpreted as location-list pointers in DWARF 2 and 3.  I think the post-commit comments in D58698 <https://reviews.llvm.org/D58698> suggest that we could always have a version, and I doubt we'll get this completely sorted out until DWARFFormValue requires it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105469/new/

https://reviews.llvm.org/D105469



More information about the llvm-commits mailing list