pahole issues with Rust DWARF was: Re: [PATCH 1/1] pahole/Rust: Check that we're adding DW_TAG_member sorted by byte offset

From: Arnaldo Carvalho de Melo
Date: Mon Feb 13 2023 - 07:10:15 EST


Em Fri, Feb 10, 2023 at 05:48:36PM -0300, Arnaldo Carvalho de Melo escreveu:
> I'll go thru the others to see if they are easy (or at least restricted
> to Rust CUs) as this one.

The namespace.o seems to be ok:

⬢[acme@toolbox pahole]$ cat ../pahole-rust-cases/namespace.rs
pub struct S {
pub a: i32,
}

pub static S: (i32, S) = (42, S { a: 42 });
⬢[acme@toolbox pahole]$

⬢[acme@toolbox pahole]$ pahole --show_private_classes ../pahole-rust-cases/namespace.o
struct S {
i32 a __attribute__((__aligned__(4))); /* 0 4 */

/* size: 4, cachelines: 1, members: 1 */
/* forced alignments: 1 */
/* last cacheline: 4 bytes */
} __attribute__((__aligned__(4)));
struct (i32, namespace::S) {
i32 __0 __attribute__((__aligned__(4))); /* 0 4 */
struct S __1 __attribute__((__aligned__(4))); /* 4 4 */

/* size: 8, cachelines: 1, members: 2 */
/* forced alignments: 2 */
/* last cacheline: 8 bytes */
} __attribute__((__aligned__(4)));
⬢[acme@toolbox pahole]$

And encoding/decoding BTF for it:

⬢[acme@toolbox pahole]$ cp ../pahole-rust-cases/namespace.o .
⬢[acme@toolbox pahole]$ pahole --btf_encode namespace.o
⬢[acme@toolbox pahole]$ pahole -F btf namespace.o
struct S {
i32 a; /* 0 4 */

/* size: 4, cachelines: 1, members: 1 */
/* last cacheline: 4 bytes */
};
struct (i32, namespace::S) {
i32 __0; /* 0 4 */
struct S __1; /* 4 4 */

/* size: 8, cachelines: 1, members: 2 */
/* last cacheline: 8 bytes */
};
⬢[acme@toolbox pahole]$ readelf -SW namespace.o | grep BTF
[18] .BTF PROGBITS 0000000000000000 00065c 000089 00 0 0 1
⬢[acme@toolbox pahole]$


The core one needs work:

⬢[acme@toolbox pahole]$ pahole ../pahole-rust-cases/core.o |& head
die__process_class: tag not supported 0x2f (template_type_parameter)!
die__process_class: tag not supported 0x33 (variant_part)!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2fd8d> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2fdf7> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2fe61> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2fecb> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2ff35> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x2ff9f> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x30009> not handled!
die__create_new_enumeration: DW_TAG_subprogram (0x2e) @ <0x30073> not handled!
⬢[acme@toolbox pahole]$

<1><90>: Abbrev Number: 7 (DW_TAG_namespace)
<91> DW_AT_name : (indirect string, offset: 0x147): core
<2><95>: Abbrev Number: 7 (DW_TAG_namespace)
<96> DW_AT_name : (indirect string, offset: 0x14c): str
<3><9a>: Abbrev Number: 7 (DW_TAG_namespace)
<9b> DW_AT_name : (indirect string, offset: 0x150): iter
<4><9f>: Abbrev Number: 8 (DW_TAG_structure_type)
<a0> DW_AT_name : (indirect string, offset: 0x2e1): Split<core::str::IsWhitespace>
<a4> DW_AT_byte_size : 64
<a5> DW_AT_alignment : 8
<5><a6>: Abbrev Number: 9 (DW_TAG_template_type_param)
<a7> DW_AT_type : <0x41fc>
<ab> DW_AT_name : (indirect string, offset: 0x162): P
<5><af>: Abbrev Number: 4 (DW_TAG_member)
<b0> DW_AT_name : (indirect string, offset: 0x164): __0
<b4> DW_AT_type : <0xbb>
<b8> DW_AT_alignment : 8
<b9> DW_AT_data_member_location: 0
<5><ba>: Abbrev Number: 0
<4><bb>: Abbrev Number: 8 (DW_TAG_structure_type)
<bc> DW_AT_name : (indirect string, offset: 0x2ba): SplitInternal<core::str::IsWhitespace>
<c0> DW_AT_byte_size : 64
<c1> DW_AT_alignment : 8
<5><c2>: Abbrev Number: 9 (DW_TAG_template_type_param)
<c3> DW_AT_type : <0x41fc>
<c7> DW_AT_name : (indirect string, offset: 0x162): P

- Arnaldo