[Dwarf-discuss] EXTERNAL: Enhancement: Dynamic DW_AT_data_bit_offset
Todd Allen
Todd.Allen@concurrent-rt.com
Mon Apr 21 20:15:41 GMT 2025
Tom,
When I was adding DWARF support to my company's Ada compiler many years ago, using reference, exprloc, loclist, etc. forms on attributes that normally didn't allow them was a very common tactic. Ada is not a language that DWARF claims to support fully (not even close), so I always assumed this fell under the vendor extensibility rules. In the DWARF 5 document, 1.3.13, it says:
For language features that are not supported, implementors may use existing attributes in novel ways...
I read that as the permission you need.
Todd
On 4/17/25 13:58, Tom Tromey via Dwarf-discuss wrote:
CAUTION! External Email. Do not click links or open attachments unless you recognize the sender and are sure the content is safe.
If you think this is a phishing email, please report it by using the "Phish Alert Report" button in Outlook.
Consider the appended Ada program. Here, the offset of "Another_Field"
is a non-constant number of bits from the start of the object.
I think there is no way to represent this in DWARF 5. Section 5.7.6,
page 119 says:
For a DW_AT_data_bit_offset attribute, the value is an integer
constant (see Section 2.19 on page 55) that specifies the number of
bits from the beginning of the containing entity to the beginning of
the data member. This value must be greater than or equal to zero,
but is not limited to less than the number of bits per byte.
GNAT works around this using the deprecated-in-DWARF-4 DW_AT_bit_offset
in conjunction with DW_AT_data_member_location. (You need a patch to
GNAT to see this in action.)
One way to fix this would be to lift the "integer constant" restriction
and allow an expression here.
thanks,
Tom
procedure Exam is
type Small is range -7 .. -4;
for Small'Size use 2;
type Packed_Array is array (Integer range <>) of Small;
pragma pack (Packed_Array);
subtype Range_Int is Natural range 0 .. 7;
type Some_Packed_Record (Discr : Range_Int := 3) is record
Array_Field : Packed_Array (1 .. Discr);
Field: Small;
case Discr is
when 3 =>
Another_Field : Small;
when others =>
null;
end case;
end record;
pragma Pack (Some_Packed_Record);
pragma No_Component_Reordering (Some_Packed_Record);
SPR : Some_Packed_Record := (Discr => 3,
Field => -4,
Another_Field => -6,
Array_Field => (-5, -6, -7));
begin
null;
end Exam;
--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org<mailto:Dwarf-discuss@lists.dwarfstd.org>
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.dwarfstd.org%2Fmailman%2Flistinfo%2Fdwarf-discuss&data=05%7C02%7Ctodd.allen%40concurrent-rt.com%7Ca781a7e71ed64864bf9508dd7dea4196%7C6cce74a3397545e09893b072988b30b6%7C0%7C0%7C638805167263000504%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=3jf43IH3e0McKfaHoa88%2F%2F8mVougVyg2zdBPoT%2FWbSA%3D&reserved=0<https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20250421/7f94e900/attachment.htm>
More information about the Dwarf-discuss
mailing list