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