18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <elfutils/libdwfl.h> 38c2ecf20Sopenharmony_ci#include "../../util/unwind-libdw.h" 48c2ecf20Sopenharmony_ci#include "../../util/perf_regs.h" 58c2ecf20Sopenharmony_ci#include "../../util/event.h" 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cibool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 88c2ecf20Sopenharmony_ci{ 98c2ecf20Sopenharmony_ci struct unwind_info *ui = arg; 108c2ecf20Sopenharmony_ci struct regs_dump *user_regs = &ui->sample->user_regs; 118c2ecf20Sopenharmony_ci Dwarf_Word dwarf_regs[PERF_REG_ARM_MAX]; 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define REG(r) ({ \ 148c2ecf20Sopenharmony_ci Dwarf_Word val = 0; \ 158c2ecf20Sopenharmony_ci perf_reg_value(&val, user_regs, PERF_REG_ARM_##r); \ 168c2ecf20Sopenharmony_ci val; \ 178c2ecf20Sopenharmony_ci}) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci dwarf_regs[0] = REG(R0); 208c2ecf20Sopenharmony_ci dwarf_regs[1] = REG(R1); 218c2ecf20Sopenharmony_ci dwarf_regs[2] = REG(R2); 228c2ecf20Sopenharmony_ci dwarf_regs[3] = REG(R3); 238c2ecf20Sopenharmony_ci dwarf_regs[4] = REG(R4); 248c2ecf20Sopenharmony_ci dwarf_regs[5] = REG(R5); 258c2ecf20Sopenharmony_ci dwarf_regs[6] = REG(R6); 268c2ecf20Sopenharmony_ci dwarf_regs[7] = REG(R7); 278c2ecf20Sopenharmony_ci dwarf_regs[8] = REG(R8); 288c2ecf20Sopenharmony_ci dwarf_regs[9] = REG(R9); 298c2ecf20Sopenharmony_ci dwarf_regs[10] = REG(R10); 308c2ecf20Sopenharmony_ci dwarf_regs[11] = REG(FP); 318c2ecf20Sopenharmony_ci dwarf_regs[12] = REG(IP); 328c2ecf20Sopenharmony_ci dwarf_regs[13] = REG(SP); 338c2ecf20Sopenharmony_ci dwarf_regs[14] = REG(LR); 348c2ecf20Sopenharmony_ci dwarf_regs[15] = REG(PC); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci return dwfl_thread_state_registers(thread, 0, PERF_REG_ARM_MAX, 378c2ecf20Sopenharmony_ci dwarf_regs); 388c2ecf20Sopenharmony_ci} 39