diff options
author | Tiezhu Yang <yangtiezhu@loongson.cn> | 2022-06-25 09:21:16 +0800 |
---|---|---|
committer | Tiezhu Yang <yangtiezhu@loongson.cn> | 2022-06-25 10:12:55 +0800 |
commit | af6e3f77e939ecf85e18720925a4d8f355f90ee1 (patch) | |
tree | d773780616d692f0fe28dbd40839354f544531b4 /gdb/loongarch-linux-tdep.c | |
parent | 0757a50396e3638434f806aec2ee8c8f79a7026c (diff) | |
download | binutils-af6e3f77e939ecf85e18720925a4d8f355f90ee1.zip binutils-af6e3f77e939ecf85e18720925a4d8f355f90ee1.tar.gz binutils-af6e3f77e939ecf85e18720925a4d8f355f90ee1.tar.bz2 |
gdb: LoongArch: Implement loongarch_linux_syscall_next_pc()
When FRAME is at a syscall instruction, return the PC of the next
instruction to be executed.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb/loongarch-linux-tdep.c')
-rw-r--r-- | gdb/loongarch-linux-tdep.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c index 5da48a4..21fc67f 100644 --- a/gdb/loongarch-linux-tdep.c +++ b/gdb/loongarch-linux-tdep.c @@ -161,11 +161,35 @@ loongarch_iterate_over_regset_sections (struct gdbarch *gdbarch, LOONGARCH_LINUX_NUM_GREGSET * regsize, &loongarch_gregset, NULL, cb_data); } +/* The following value is derived from __NR_rt_sigreturn in + <include/uapi/asm-generic/unistd.h> from the Linux source tree. */ + +#define LOONGARCH_NR_rt_sigreturn 139 + +/* When FRAME is at a syscall instruction, return the PC of the next + instruction to be executed. */ + +static CORE_ADDR +loongarch_linux_syscall_next_pc (struct frame_info *frame) +{ + const CORE_ADDR pc = get_frame_pc (frame); + ULONGEST a7 = get_frame_register_unsigned (frame, LOONGARCH_A7_REGNUM); + + /* If we are about to make a sigreturn syscall, use the unwinder to + decode the signal frame. */ + if (a7 == LOONGARCH_NR_rt_sigreturn) + return frame_unwind_caller_pc (frame); + + return pc + 4; +} + /* Initialize LoongArch Linux ABI info. */ static void loongarch_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + loongarch_gdbarch_tdep *tdep = (loongarch_gdbarch_tdep *) gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch, 0); set_solib_svr4_fetch_link_map_offsets (gdbarch, @@ -187,6 +211,8 @@ loongarch_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Core file support. */ set_gdbarch_iterate_over_regset_sections (gdbarch, loongarch_iterate_over_regset_sections); + + tdep->syscall_next_pc = loongarch_linux_syscall_next_pc; } /* Initialize LoongArch Linux target support. */ |