* [PATCH] gdb: LoongArch: Implement the get_syscall_number gdbarch method
@ 2024-01-31 8:10 Tiezhu Yang
2024-02-06 10:55 ` Tiezhu Yang
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2024-01-31 8:10 UTC (permalink / raw)
To: gdb-patches
In the current code, the feature 'catch syscall' is not supported
on LoongArch, implement the "get_syscall_number" gdbarch method to
get the system call number from the register a7.
Without this patch:
(gdb) catch syscall
The feature 'catch syscall' is not supported on this architecture yet.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
gdb/loongarch-linux-tdep.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index 47f36a18931..54c3684eb46 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -297,6 +297,31 @@ loongarch_linux_syscall_next_pc (frame_info_ptr frame)
return pc + 4;
}
+/* Implement the "get_syscall_number" gdbarch method. */
+
+static LONGEST
+loongarch_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
+{
+ struct regcache *regcache = get_thread_regcache (thread);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int regsize = register_size (gdbarch, LOONGARCH_A7_REGNUM);
+ /* The content of a register. */
+ gdb_byte buf[8];
+ /* The result. */
+ LONGEST ret;
+
+ gdb_assert (regsize <= sizeof (buf));
+
+ /* Getting the system call number from the register.
+ When dealing with the LoongArch architecture, this information
+ is stored at the a7 register. */
+ regcache->cooked_read (LOONGARCH_A7_REGNUM, buf);
+
+ ret = extract_signed_integer (buf, regsize, byte_order);
+
+ return ret;
+}
+
/* Initialize LoongArch Linux ABI info. */
static void
@@ -327,6 +352,9 @@ loongarch_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_iterate_over_regset_sections (gdbarch, loongarch_iterate_over_regset_sections);
tdep->syscall_next_pc = loongarch_linux_syscall_next_pc;
+
+ /* Get the syscall number from the arch's register. */
+ set_gdbarch_get_syscall_number (gdbarch, loongarch_linux_get_syscall_number);
}
/* Initialize LoongArch Linux target support. */
--
2.42.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gdb: LoongArch: Implement the get_syscall_number gdbarch method
2024-01-31 8:10 [PATCH] gdb: LoongArch: Implement the get_syscall_number gdbarch method Tiezhu Yang
@ 2024-02-06 10:55 ` Tiezhu Yang
0 siblings, 0 replies; 2+ messages in thread
From: Tiezhu Yang @ 2024-02-06 10:55 UTC (permalink / raw)
To: gdb-patches
On 1/31/24 16:10, Tiezhu Yang wrote:
> In the current code, the feature 'catch syscall' is not supported
> on LoongArch, implement the "get_syscall_number" gdbarch method to
> get the system call number from the register a7.
>
> Without this patch:
>
> (gdb) catch syscall
> The feature 'catch syscall' is not supported on this architecture yet.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Pushed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-06 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31 8:10 [PATCH] gdb: LoongArch: Implement the get_syscall_number gdbarch method Tiezhu Yang
2024-02-06 10:55 ` Tiezhu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).