dwarves icon indicating copy to clipboard operation
dwarves copied to clipboard

Arrays are flattened when pahole --btf_encode_detached is used

Open gcmoreira opened this issue 3 years ago • 0 comments

$ cat << EOF > struct_foo.c
struct foo {
    int array[10][20];
};

int main()
{
    struct foo bar;
}

EOF

$ gcc -ggdb struct_foo.c -o struct_foo

$ ../pahole_git/build/pahole struct_foo
struct foo {
        int                        array[10][20];        /*     0   800 */

        /* size: 800, cachelines: 13, members: 1 */
        /* last cacheline: 32 bytes */
};

The array member has not been flattened yet.

Let's detach the BTF to the struct_foo.btf file

$ ../pahole_git/build/pahole --btf_encode_detached struct_foo.btf struct_foo

$ ../pahole_git/build/pahole struct_foo.btf
struct foo {
        int                        array[200];           /*     0   800 */

        /* size: 800, cachelines: 13, members: 1 */
        /* last cacheline: 32 bytes */
};

As you can see above, even without using --flat_arrays, the arrays are flattened.

Tested with the latest repo changes

$ cd ../pahole_git
$ git rev-parse --short HEAD
de24234

gcmoreira avatar Sep 11 '22 11:09 gcmoreira