Skip to content

Commit 406b51a

Browse files
captain5050acmel
authored andcommitted
perf dwarf-regs: Add MIPS perf to DWARF register number mapping functions
Despite an unused function declaration, there was no unwind-libdw for MIPS but there is a perf_regs.h and a libdw implementation. Fill in the pieces so hopefully MIPS unwinding with libdw works. Signed-off-by: Ian Rogers <[email protected]> Cc: Aditya Bodkhe <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexandre Ghiti <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Chun-Tse Shao <[email protected]> Cc: Dmitriy Vyukov <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: Guo Ren <[email protected]> Cc: Haibo Xu <[email protected]> Cc: Howard Chu <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Krzysztof Łopatowski <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Wielaard <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sergei Trofimovich <[email protected]> Cc: Shimin Guo <[email protected]> Cc: Stephen Brennan <[email protected]> Cc: Thomas Falcon <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1e452dd commit 406b51a

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

tools/perf/util/dwarf-regs-arch/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ perf-util-$(CONFIG_LIBDW) += dwarf-regs-arm64.o
22
perf-util-$(CONFIG_LIBDW) += dwarf-regs-arm.o
33
perf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
44
perf-util-$(CONFIG_LIBDW) += dwarf-regs-loongarch.o
5+
perf-util-$(CONFIG_LIBDW) += dwarf-regs-mips.o
56
perf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
67
perf-util-$(CONFIG_LIBDW) += dwarf-regs-riscv.o
78
perf-util-$(CONFIG_LIBDW) += dwarf-regs-s390.o
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <errno.h>
3+
#include <dwarf-regs.h>
4+
#include "../../../arch/mips/include/uapi/asm/perf_regs.h"
5+
6+
int __get_dwarf_regnum_for_perf_regnum_mips(int perf_regnum)
7+
{
8+
if (perf_regnum == PERF_REG_MIPS_PC)
9+
return 37;
10+
if (perf_regnum < 0 || perf_regnum >= PERF_REG_MIPS_MAX)
11+
return -ENOENT;
12+
13+
return perf_regnum;
14+
}

tools/perf/util/dwarf-regs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static int get_libdw_frame_nregs(unsigned int machine, unsigned int flags __mayb
179179
return 103;
180180
case EM_LOONGARCH:
181181
return 74;
182+
case EM_MIPS:
183+
return 71;
182184
default:
183185
return 0;
184186
}
@@ -218,6 +220,9 @@ int get_dwarf_regnum_for_perf_regnum(int perf_regnum, unsigned int machine,
218220
case EM_LOONGARCH:
219221
reg = __get_dwarf_regnum_for_perf_regnum_loongarch(perf_regnum);
220222
break;
223+
case EM_MIPS:
224+
reg = __get_dwarf_regnum_for_perf_regnum_mips(perf_regnum);
225+
break;
221226
default:
222227
pr_err("ELF MACHINE %x is not supported.\n", machine);
223228
return -ENOENT;

tools/perf/util/include/dwarf-regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ int __get_dwarf_regnum_for_perf_regnum_loongarch(int perf_regnum);
113113
int __get_dwarf_regnum_for_perf_regnum_powerpc(int perf_regnum);
114114
int __get_dwarf_regnum_for_perf_regnum_riscv(int perf_regnum);
115115
int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum);
116+
int __get_dwarf_regnum_for_perf_regnum_mips(int perf_regnum);
116117

117118
/*
118119
* get_dwarf_regnum - Returns DWARF regnum from register name

tools/perf/util/unwind-libdw.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ struct machine;
99
struct perf_sample;
1010
struct thread;
1111

12-
bool libdw_set_initial_registers_mips(Dwfl_Thread *thread, void *arg);
13-
1412
struct unwind_info {
1513
Dwfl *dwfl;
1614
struct perf_sample *sample;

0 commit comments

Comments
 (0)