summaryrefslogtreecommitdiff
path: root/tools/perf/util/include
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-01-16 21:28:38 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-01-20 15:43:56 -0300
commitd3ab52c31efab9e8a29b8fc1ae4c09ab41e0cf84 (patch)
tree962a3b3486e07165e463c5c7359d559f1228a48a /tools/perf/util/include
parentc31040085914f1188720073baa43d1483693c0a3 (diff)
perf dwarf-regs: Add get_dwarf_regnum_for_perf_regnum() and use for x86 unwinding
Add a utility to map a perf register number to a DWARF register number for a particular ELF machine type. Create a generic unwind-libdw initial register initialization routine that uses this function and thereby avoids arch specific initialization. The unwind-libdw code does: 1) compute the maximum DWARF register from the set of sampled user registers, 2) allocates a set of DWARF registers, 3) copies the sample registers into the appropriate DWARF registers. This generic solution is initially implemented for use with x86 as only get_dwarf_regnum_for_perf_regnum() support for x86 is currently present. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Guo Ren <guoren@kernel.org> Cc: Haibo Xu <haibo1.xu@intel.com> Cc: Howard Chu <howardchu95@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Krzysztof Ɓopatowski <krzysztof.m.lopatowski@gmail.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Mark Wielaard <mark@klomp.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sergei Trofimovich <slyich@gmail.com> Cc: Shimin Guo <shimin.guo@skydio.com> Cc: Stephen Brennan <stephen.s.brennan@oracle.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Will Deacon <will@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/include')
-rw-r--r--tools/perf/util/include/dwarf-regs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include/dwarf-regs.h
index bb5413b0fee4..00881f1d45d6 100644
--- a/tools/perf/util/include/dwarf-regs.h
+++ b/tools/perf/util/include/dwarf-regs.h
@@ -101,6 +101,8 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int
int __get_dwarf_regnum_i386(const char *name);
int __get_dwarf_regnum_x86_64(const char *name);
+int __get_dwarf_regnum_for_perf_regnum_i386(int perf_regnum);
+int __get_dwarf_regnum_for_perf_regnum_x86_64(int perf_regnum);
/*
* get_dwarf_regnum - Returns DWARF regnum from register name
@@ -109,6 +111,12 @@ int __get_dwarf_regnum_x86_64(const char *name);
*/
int get_dwarf_regnum(const char *name, unsigned int machine, unsigned int flags);
+/*
+ * get_dwarf_regnum - Returns DWARF regnum from perf register number.
+ */
+int get_dwarf_regnum_for_perf_regnum(int perf_regnum, unsigned int machine, unsigned int flags,
+ bool only_libdw_supported);
+
void get_powerpc_regs(u32 raw_insn, int is_source, struct annotated_op_loc *op_loc);
#else /* HAVE_LIBDW_SUPPORT */