]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf annotate-data: Collect global variables without name
authorZecheng Li <zli94@ncsu.edu>
Mon, 9 Mar 2026 17:55:19 +0000 (13:55 -0400)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 19 Mar 2026 21:42:29 +0000 (14:42 -0700)
Previously, global_var__collect() required get_global_var_info() to
succeed (i.e., the variable must have a symbol name) before caching a
global variable. This prevented variables that exist in DWARF but lack
symbol table coverage from being cached.

Remove the symbol table requirement since DW_OP_addr already provides
the variable's address directly from DWARF. The symbol table lookup is
now optional to obtain the variable name when available.

Also remove the var_offset != 0 check, which was intended to skip
variables where the access address doesn't match the symbol start. The
symbol table lookup is now optional and I found removing this check has
no effect on the annotation results for both kernel and userspace
programs.

Test results show improved annotation coverage especially for userspace
programs with RIP-relative addressing instructions.

Signed-off-by: Zecheng Li <zli94@ncsu.edu>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/annotate-data.c

index 6fe2efd48a832de115e31ef003b9c49ea7e30dcd..301f73ea8275fddbd1a50014372fd6aa67f8c1c3 100644 (file)
@@ -774,12 +774,7 @@ static void global_var__collect(struct data_loc_info *dloc)
                        if (!dwarf_offdie(dwarf, pos->die_off, &type_die))
                                continue;
 
-                       if (!get_global_var_info(dloc, pos->addr, &var_name,
-                                                &var_offset))
-                               continue;
-
-                       if (var_offset != 0)
-                               continue;
+                       get_global_var_info(dloc, pos->addr, &var_name, &var_offset);
 
                        global_var__add(dloc, pos->addr, var_name, &type_die);
                }