From 04d957ba3cdf1047525a5b8d7898914cbd566970 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 3 Jul 2020 09:55:32 -0300 Subject: [PATCH] pahole: Add variable for class name when traversing list of classes We'll have to at this point look for arguments, like a different way of finding the sizeof for a class, say: $ pahole perf_event_header struct perf_event_header { __u32 type; /* 0 4 */ __u16 misc; /* 4 2 */ __u16 size; /* 6 2 */ /* size: 8, cachelines: 1, members: 3 */ /* last cacheline: 8 bytes */ }; $ In a perf.data file we should consider sizeof(struct perf_event_header) to really be header->size, o that we can traverse the file one perf_event_header at a time. Signed-off-by: Arnaldo Carvalho de Melo --- pahole.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pahole.c b/pahole.c index 0bb2ffb..6da85b8 100644 --- a/pahole.c +++ b/pahole.c @@ -1440,14 +1440,16 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, pos = rb_entry(next, struct str_node, rb_node); next = rb_next(&pos->rb_node); + const char *name = pos->s; + static type_id_t class_id; bool include_decls = find_pointers_in_structs != 0 || stats_formatter == nr_methods_formatter; - struct tag *class = cu__find_type_by_name(cu, pos->s, include_decls, &class_id); + struct tag *class = cu__find_type_by_name(cu, name, include_decls, &class_id); if (class == NULL) { - class = cu__find_base_type_by_name(cu, pos->s, &class_id); + class = cu__find_base_type_by_name(cu, name, &class_id); if (class == NULL) { - if (strcmp(pos->s, "void")) + if (strcmp(name, "void")) continue; class_id = 0; }