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

pahole: expand named typedefs if expanding types is requested #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wafgo
Copy link

@wafgo wafgo commented Jan 3, 2023

If your code contains named typedefs like

typedef struct foo_s {
/some stuff here/
}foo;

and your run pahole with something like pahole -E -C foo it only prints something like this

typedef struct foo_s foo

I think what the user would like (at least this is what I was expecting) is that the typedef is expanded.

I know that this is irrelevant for the linux kernel because nobody is doing such silly stuff there. But there is a lot of strange software out there which typedefs nearly every structure for some reason.

I think applying this patch would make pahole -E more intuitive

Signed-off-by: Wadim Mueller [email protected]

If your code contains named typedefs like

typedef struct foo_s {
        /*some stuff here*/
}foo;

and your run pahole with something like pahole -E -C foo <ELF> it only
prints something like this

typedef struct foo_s foo

I think what the user would like (at least this is what I was expecting) is
that the typedef is expanded.

I know that this is irrelevant for the linux kernel because nobody is
doing such silly stuff there. But there is a lot of strange software
out there which typedefs nearly every structure for some reason.

I think applying this patch would make pahole -E more intuitive

Signed-off-by: Wadim Mueller <[email protected]>
@xaizek
Copy link

xaizek commented May 13, 2023

It used to print definition of the structure in this case and now even -E doesn't provide the previous behaviour. Mind that if you use the same name twice (quite common):

typedef struct foo {
    // ...
} foo;

the only way to see the definition seems to be to list all of them and find the needed one in the output (-C "struct foo" doesn't work), this makes pahole much less convenient to use in this situation.

EDIT: actually, looks like it works fine when struct is defined in typedef statement. It's a separate typedef which doesn't show the full struct and maybe it shouldn't.

@xaizek
Copy link

xaizek commented Nov 26, 2023

Needed to use pahole and hit this issue again. There should be some way to show struct foo in this case (same-name struct defined in a typedef). It's listed in the output of --structs, mentioned in the printed typedef struct foo foo, but is otherwise unaccessible. If not by default on -E, maybe when it's passed twice (-E -E).

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

Successfully merging this pull request may close these issues.

2 participants