Re: [PATCH dwarves v2 1/5] fprintf: Correct names for types with btf_type_tag attribute

Eduard Zingerman
2023-03-28T15:31:29Z

On Tue, 2023-03-28 at 12:26 -0300, Arnaldo Carvalho de Melo wrote:
[...]
> Sure, but look:
>
> > > - struct qdisc_size_table * stab; /* 32 8 */
> > > + struct qdisc_size_table stab; /* 32 8 */
>
> Its the DW_TAG_pointer_type that is getting lost somehow:
>
> <1><b0af32>: Abbrev Number: 81 (DW_TAG_structure_type)
> <b0af33> DW_AT_name : (indirect string, offset: 0xe825): Qdisc
> <b0af37> DW_AT_byte_size : 384
> <b0af39> DW_AT_decl_file : 223
> <b0af3a> DW_AT_decl_line : 72
>
> <SNIP>
>
> <2><b0af77>: Abbrev Number: 65 (DW_TAG_member)
> <b0af78> DW_AT_name : (indirect string, offset: 0x4745ff): stab
> <b0af7c> DW_AT_type : <0xb0b76b>
> <b0af80> DW_AT_decl_file : 223
> <b0af81> DW_AT_decl_line : 99
> <b0af82> DW_AT_data_member_location: 32
>
> <SNIP>
>
> <1><b0b76b>: Abbrev Number: 61 (DW_TAG_pointer_type)
> <b0b76c> DW_AT_type : <0xb0b77a>
> <2><b0b770>: Abbrev Number: 62 (User TAG value: 0x6000)
> <b0b771> DW_AT_name : (indirect string, offset: 0x378): btf_type_tag
> <b0b775> DW_AT_const_value : (indirect string, offset: 0x6e93): rcu
> <2><b0b779>: Abbrev Number: 0
> <1><b0b77a>: Abbrev Number: 69 (DW_TAG_structure_type)
> <b0b77b> DW_AT_name : (indirect string, offset: 0x6e5ed): qdisc_size_table
> <b0b77f> DW_AT_byte_size : 64
> <b0b780> DW_AT_decl_file : 223
> <b0b781> DW_AT_decl_line : 56
>
>
> So it's all there in the DWARF info:
>
> b0af77 has type 0xb0b76b which is a DW_TAG_pointer_type that has type
> 0xb0b77a, that is DW_TAG_structure_type.
>
> Now lets see how this was encoded into BTF:
>
> [4725] STRUCT 'Qdisc' size=384 vlen=28
> <SNIP>
> 'stab' type_id=4790 bits_offset=256
> <SNIP>
> [4790] PTR '(anon)' type_id=4789
> <SNIP>
> [4789] TYPE_TAG 'rcu' type_id=4791
> <SNIP>
> [4791] STRUCT 'qdisc_size_table' size=64 vlen=5
> 'rcu' type_id=320 bits_offset=0
> 'list' type_id=87 bits_offset=128
> 'szopts' type_id=4792 bits_offset=256
> 'refcnt' type_id=16 bits_offset=448
> 'data' type_id=4659 bits_offset=480
>
> So it all seems ok, we should keep all the info and teach fprintf to
> handle TYPE_TAG.
>
> Which you tried, but somehow the '*' link is missing.

Yep, thanks a lot for the analysis, I will take a look.
Hopefully will send v2 tomorrow.

>
> - Arnaldo