From 0b1eb72e84e4d6cf89f0d019152050659dcd1980 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 4 Oct 2023 16:14:51 +0100 Subject: [PATCH] lisa._btf: Fix renaming of BTFForwardDecl FIX BTFForwardDecl should not be considered when deduplicating type names, as it will always "conflict" with the actual type definition. That is not a big problem though, as forward declarations are never useful (they are created as needed when dumping C code, we never rely on the BTF ones) --- lisa/_btf.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lisa/_btf.py b/lisa/_btf.py index 2295054df..a10e0d31c 100644 --- a/lisa/_btf.py +++ b/lisa/_btf.py @@ -1730,12 +1730,22 @@ def _dedup_names(typs): typedef_names = {} tagged_names = {} - enumerators = dict() + fwd_decl_names = {} + enumerators = {} for typ in typs: if isinstance(typ, BTFTypedef): cat = typedef_names - elif isinstance(typ, (BTFStruct, BTFUnion, BTFEnum, BTFForwardDecl)): + # BTFForwardDecl are not renamed since we don't know what they + # logically point to. It could be any of the types that share that + # name, or yet another unknown. Fortunately, they are kind of useless + # since we will create any actually needed forward decl when dumping C + # code. + elif isinstance(typ, (BTFStruct, BTFUnion, BTFEnum)): cat = tagged_names + # We still dedup names there, in case they end up being printed and + # there is e.g. "union foo;" and "struct foo;" + elif isinstance(typ, BTFForwardDecl): + cat = fwd_decl_names else: continue @@ -1760,7 +1770,7 @@ def _dedup_names(typs): _typs.append(typ) - for dup_names in (typedef_names, tagged_names): + for dup_names in (typedef_names, tagged_names, fwd_decl_names): for name, _typs in dup_names.items(): if len(_typs) > 1: dedup_typ_names(name, _typs) -- GitLab