aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-09-23 17:38:27 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-09-23 17:38:27 -0300
commitd7507140eab4bf9f1ae3d3721d7803fff9b0c175 (patch)
tree0dddd6e128def84a5ddad4679e02118b43d03ff1
parent843fe9bfab4859b4c718b87dccfb27f45833321f (diff)
downloadpahole-d7507140eab4bf9f1ae3d3721d7803fff9b0c175.tar.gz
emit: Don't mark a enum with nr_members == 0 as printed, its just a fwd declnex
And with this now we can do a 'pahole --compile' om vmlinux from DWARF info and it works :-) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarves_emit.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/dwarves_emit.c b/dwarves_emit.c
index 304d587d..7d90d42e 100644
--- a/dwarves_emit.c
+++ b/dwarves_emit.c
@@ -121,7 +121,13 @@ static int enumeration__emit_definitions(struct tag *tag,
enumeration__fprintf(tag, conf, fp);
fputs(";\n", fp);
- type_emissions__add_definition(emissions, etype);
+
+ // See comment on enumeration__fprintf(), it seems this happens with DWARF as well
+ // or BTF doesn't have type->declaration set because DWARF didn't have it set.
+ // But we consider type->nr_members == 0 as just a forward declaration, so don't
+ // mark it as defined because we may need it to __really__ printf it later.
+ if (etype->nr_members != 0)
+ type_emissions__add_definition(emissions, etype);
return 1;
}