Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays are flattened when pahole --btf_encode_detached is used #33

Open
gcmoreira opened this issue Sep 11, 2022 · 0 comments
Open

Arrays are flattened when pahole --btf_encode_detached is used #33

gcmoreira opened this issue Sep 11, 2022 · 0 comments

Comments

@gcmoreira
Copy link

gcmoreira commented Sep 11, 2022

$ 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 gcmoreira changed the title Arrays are flattened when --btf_encode_detached is used Arrays are flattened when pahole --btf_encode_detached is used Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant