1 // SPDX-License-Identifier: GPL-2.0
2 #include <elfutils/libdwfl.h>
3 #include "../../../util/unwind-libdw.h"
4 #include "../../../util/perf_regs.h"
5 #include "../../../util/sample.h"
6 
7 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
8 {
9 	struct unwind_info *ui = arg;
10 	struct regs_dump *user_regs = &ui->sample->user_regs;
11 	Dwarf_Word dwarf_regs[PERF_REG_ARM_MAX];
12 
13 #define REG(r) ({						\
14 	Dwarf_Word val = 0;					\
15 	perf_reg_value(&val, user_regs, PERF_REG_ARM_##r);	\
16 	val;							\
17 })
18 
19 	dwarf_regs[0]  = REG(R0);
20 	dwarf_regs[1]  = REG(R1);
21 	dwarf_regs[2]  = REG(R2);
22 	dwarf_regs[3]  = REG(R3);
23 	dwarf_regs[4]  = REG(R4);
24 	dwarf_regs[5]  = REG(R5);
25 	dwarf_regs[6]  = REG(R6);
26 	dwarf_regs[7]  = REG(R7);
27 	dwarf_regs[8]  = REG(R8);
28 	dwarf_regs[9]  = REG(R9);
29 	dwarf_regs[10] = REG(R10);
30 	dwarf_regs[11] = REG(FP);
31 	dwarf_regs[12] = REG(IP);
32 	dwarf_regs[13] = REG(SP);
33 	dwarf_regs[14] = REG(LR);
34 	dwarf_regs[15] = REG(PC);
35 
36 	return dwfl_thread_state_registers(thread, 0, PERF_REG_ARM_MAX,
37 					   dwarf_regs);
38 }
39