perf dwarf-aux: Handle bitfield members from pointer access
authorNamhyung Kim <namhyung@kernel.org>
Wed, 21 Aug 2024 23:26:25 +0000 (16:26 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 22 Aug 2024 15:32:18 +0000 (12:32 -0300)
The __die_find_member_offset_cb() missed to handle bitfield members
which don't have DW_AT_data_member_location.  Like in adding member
types in __add_member_cb() it should fallback to check the bit offset
when it resolves the member type for an offset.

Fixes: 437683a9941891c1 ("perf dwarf-aux: Handle type transfer for memory access")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240821232628.353177-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dwarf-aux.c

index 0151a8d..92eb9c8 100644 (file)
@@ -1977,8 +1977,15 @@ static int __die_find_member_offset_cb(Dwarf_Die *die_mem, void *arg)
                return DIE_FIND_CB_SIBLING;
 
        /* Unions might not have location */
-       if (die_get_data_member_location(die_mem, &loc) < 0)
-               loc = 0;
+       if (die_get_data_member_location(die_mem, &loc) < 0) {
+               Dwarf_Attribute attr;
+
+               if (dwarf_attr_integrate(die_mem, DW_AT_data_bit_offset, &attr) &&
+                   dwarf_formudata(&attr, &loc) == 0)
+                       loc /= 8;
+               else
+                       loc = 0;
+       }
 
        if (offset == loc)
                return DIE_FIND_CB_END;