[Bug translator/29037] Systemtap unable to find struct bitfield members for gcc11 compiled code

wcohen at redhat dot com sourceware-bugzilla@sourceware.org
Wed Jun 15 14:00:59 GMT 2022


https://sourceware.org/bugzilla/show_bug.cgi?id=29037

--- Comment #3 from William Cohen <wcohen at redhat dot com> ---
Did some comparisons of rr recorded runs of process the rhel8 and f35 binary
with systemtap that a patch that recoginizes the DW_AT_data_bit_offset.
dwarf_getlocation_address() function doesn't handle DW_AT_data_bit_offset being
passed in as a Dwarf_Attribute and that later triggers the message seen in
comment#2.

Took a look at the dwarf generated for a couple different data structures to
see what is generated by the compiler for structures with bit fields.  The bit
fields don't have DW_AT_data_member_location regardless of where they are in
the data structure.  Thus something like following the later bit fields have
DW_AT_data_bit_offset from the beginning of the struct:

typedef unsigned char __u8;

struct fields {
        int     junk;
        __u8    icsk_ca_setsockopt:1,
                icsk_ca_dst_locked:1;
};

0x0000007c:   DW_TAG_typedef
                DW_AT_name      ("__u8")
                DW_AT_decl_file
("/home/wcohen/research/profiling/systemtap_write/gcc11_bitfield/loctest2.c")
                DW_AT_decl_line (4)
                DW_AT_decl_column       (0x17)
                DW_AT_type      (0x00000046 "unsigned char")

0x00000088:   DW_TAG_structure_type
                DW_AT_name      ("fields")
                DW_AT_byte_size (0x08)
                DW_AT_decl_file
("/home/wcohen/research/profiling/systemtap_write/gcc11_bitfield/loctest2.c")
                DW_AT_decl_line (6)
                DW_AT_decl_column       (0x08)
                DW_AT_sibling   (0x000000bb)

0x00000095:     DW_TAG_member
                  DW_AT_name    ("junk")
                  DW_AT_decl_file      
("/home/wcohen/research/profiling/systemtap_write/gcc11_bitfield/loctest2.c")
                  DW_AT_decl_line       (7)
                  DW_AT_decl_column     (0x0a)
                  DW_AT_type    (0x00000031 "int")
                  DW_AT_data_member_location    (0x00)

0x000000a2:     DW_TAG_member
                  DW_AT_name    ("icsk_ca_setsockopt")
                  DW_AT_decl_file      
("/home/wcohen/research/profiling/systemtap_write/gcc11_bitfield/loctest2.c")
                  DW_AT_decl_line       (8)
                  DW_AT_decl_column     (0x0a)
                  DW_AT_type    (0x0000007c "__u8")
                  DW_AT_bit_size        (1)
                  DW_AT_data_bit_offset (0x20)

0x000000ae:     DW_TAG_member
                  DW_AT_name    ("icsk_ca_dst_locked")
                  DW_AT_decl_file      
("/home/wcohen/research/profiling/systemtap_write/gcc11_bitfield/loctest2.c")
                  DW_AT_decl_line       (9)
                  DW_AT_decl_column     (0x03)
                  DW_AT_type    (0x0000007c "__u8")
                  DW_AT_bit_size        (1)
                  DW_AT_data_bit_offset (0x21)


gdb appears to handle bitfields properly with the existing elfutils. There
looks to be patches in gdb to address handling the DW_AT_data_bit_offset:

commit 6ad036d703099508c388038b57c77a8f7aaffb1d
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Aug 20 10:05:10 2021 -0600

    Fix handling of DW_AT_data_bit_offset

    A newer version of GCC will now emit member locations using just
    DW_AT_data_bit_offset, like:


commit 20a5fcbd5b28cca88511ac5a9ad5e54251e8fa6d
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Sep 23 09:39:24 2020 -0600

    Handle bit offset and bit size in base types

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Systemtap mailing list