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 <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-07-03 09:55:32 -03:00
parent f3d9054ba8
commit 04d957ba3c
1 changed files with 5 additions and 3 deletions

View File

@ -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;
}