Skip to content

Commit 36b372d

Browse files
captain5050acmel
authored andcommitted
perf dwarf-regs: Add RISC-V perf to DWARF register number mapping functions
These functions allow the generic initial register state code in unwind-libdw to be used. 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 f005302 commit 36b372d

8 files changed

Lines changed: 18 additions & 64 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ 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
55
perf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
6+
perf-util-$(CONFIG_LIBDW) += dwarf-regs-riscv.o
67
perf-util-$(CONFIG_LIBDW) += dwarf-regs-x86.o
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <errno.h>
3+
#include <dwarf-regs.h>
4+
#include "../../../arch/riscv/include/uapi/asm/perf_regs.h"
5+
6+
int __get_dwarf_regnum_for_perf_regnum_riscv(int perf_regnum)
7+
{
8+
if (perf_regnum < 0 || perf_regnum >= PERF_REG_RISCV_MAX)
9+
return -ENOENT;
10+
11+
return perf_regnum;
12+
}

tools/perf/util/dwarf-regs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ int get_dwarf_regnum_for_perf_regnum(int perf_regnum, unsigned int machine,
209209
case EM_PPC64:
210210
reg = __get_dwarf_regnum_for_perf_regnum_powerpc(perf_regnum);
211211
break;
212+
case EM_RISCV:
213+
reg = __get_dwarf_regnum_for_perf_regnum_riscv(perf_regnum);
214+
break;
212215
case EM_LOONGARCH:
213216
reg = __get_dwarf_regnum_for_perf_regnum_loongarch(perf_regnum);
214217
break;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ int __get_dwarf_regnum_for_perf_regnum_arm64(int perf_regnum);
111111
int __get_dwarf_regnum_for_perf_regnum_csky(int perf_regnum, unsigned int flags);
112112
int __get_dwarf_regnum_for_perf_regnum_loongarch(int perf_regnum);
113113
int __get_dwarf_regnum_for_perf_regnum_powerpc(int perf_regnum);
114+
int __get_dwarf_regnum_for_perf_regnum_riscv(int perf_regnum);
114115

115116
/*
116117
* get_dwarf_regnum - Returns DWARF regnum from register name
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
perf-util-y += unwind-libdw-riscv.o
21
perf-util-y += unwind-libdw-s390.o

tools/perf/util/unwind-libdw-arch/unwind-libdw-riscv.c

Lines changed: 0 additions & 58 deletions
This file was deleted.

tools/perf/util/unwind-libdw.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,11 @@ static const Dwfl_Thread_Callbacks callbacks_generic = {
292292
.set_initial_registers = libdw_set_initial_registers_generic,
293293
};
294294

295-
DEFINE_DWFL_THREAD_CALLBACKS(riscv);
296295
DEFINE_DWFL_THREAD_CALLBACKS(s390);
297296

298297
static const Dwfl_Thread_Callbacks *get_thread_callbacks(const char *arch)
299298
{
300-
if (!strcmp(arch, "riscv"))
301-
return &callbacks_riscv;
302-
else if (!strcmp(arch, "s390"))
299+
if (!strcmp(arch, "s390"))
303300
return &callbacks_s390;
304301

305302
return &callbacks_generic;

tools/perf/util/unwind-libdw.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ struct perf_sample;
1010
struct thread;
1111

1212
bool libdw_set_initial_registers_mips(Dwfl_Thread *thread, void *arg);
13-
bool libdw_set_initial_registers_riscv(Dwfl_Thread *thread, void *arg);
1413
bool libdw_set_initial_registers_s390(Dwfl_Thread *thread, void *arg);
1514

1615
struct unwind_info {

0 commit comments

Comments
 (0)