diff --git a/pahole.c b/pahole.c index b6fb2da..3630988 100644 --- a/pahole.c +++ b/pahole.c @@ -163,8 +163,18 @@ static void print_classes(void (*formatter)(const struct structure *s)) const size_t orig_size = class__size(c); const size_t new_size = class__size(c->priv); const size_t savings = orig_size - new_size; + const char *name = class__name(c); + + /* Anonymous struct? Try finding a typedef */ + if (name == NULL) { + const struct tag *tdef = + cu__find_first_typedef_of_type(pos->cu, + class__tag(pos->class)->id); + if (tdef != NULL) + name = class__name(tag__class(tdef)); + } printf("%-32s %5zd %5zd %5zd\n", - class__name(c), orig_size, new_size, savings); + name, orig_size, new_size, savings); } else formatter(pos); }