]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf dwarf-aux: Fix __die_find_scope_cb() for namespaces
authorZecheng Li <zecheng@google.com>
Mon, 25 Aug 2025 19:58:17 +0000 (19:58 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 19 Sep 2025 15:14:30 +0000 (12:14 -0300)
Currently __die_find_scope_cb() goes to check siblings when the DIE
doesn't include the given PC.

However namespaces don't have a PC and could contain children that have
that PC.

When we encounter a namespace, we should check both its children and
siblings.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Zecheng Li <zecheng@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xu Liu <xliuprof@google.com>
Link: https://lore.kernel.org/r/20250825195817.226560-1-zecheng@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dwarf-aux.c

index 6fd2db5d938117295bd7066694e7efac42e12789..9267af204c7d5df5e7c99bdd9536ef5521d46990 100644 (file)
@@ -1958,6 +1958,7 @@ struct find_scope_data {
 static int __die_find_scope_cb(Dwarf_Die *die_mem, void *arg)
 {
        struct find_scope_data *data = arg;
+       int tag = dwarf_tag(die_mem);
 
        if (dwarf_haspc(die_mem, data->pc)) {
                Dwarf_Die *tmp;
@@ -1971,6 +1972,14 @@ static int __die_find_scope_cb(Dwarf_Die *die_mem, void *arg)
                data->nr++;
                return DIE_FIND_CB_CHILD;
        }
+
+       /*
+        * If the DIE doesn't have the PC, we still need to check its children
+        * and siblings if it's a container like a namespace.
+        */
+       if (tag == DW_TAG_namespace)
+               return DIE_FIND_CB_CONTINUE;
+
        return DIE_FIND_CB_SIBLING;
 }