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