[PATCH v7.1 3/8] Use xml-syscall to compare syscall numbers in arm_linux_sigreturn_return-addr

Antoine Tremblay
2015-12-16T16:24:20Z

In this v7.1:

Use xml_get_syscall_number to return the number and compare with that.

Note the subsequent patches in the series have been updated with that change.

---

This patch changes checks for sigreturn and rt_sigreturn syscalls in
arm-linux-tdep.c from magic numbers to numbers computed from
syscall/arm-linux.xml.

It also adds a new function to xml-syscall.h/c to get the syscall number
called get_syscall_number.

No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/ChangeLog:

* arm-linux-tdep.c (arm_linux_sigreturn_return_addr): Use
get_syscall_number.
* xml-syscall.c (get_syscall_number): New function.
* xml-syscall.h (get_syscall_number): New declaration.
---
gdb/arm-linux-tdep.c | 5 ++++-
gdb/xml-syscall.c | 8 ++++++++
gdb/xml-syscall.h | 6 ++++++
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 73e1271..56131e5 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -788,8 +788,11 @@ arm_linux_sigreturn_return_addr (struct frame_info *frame,
unsigned long svc_number,
CORE_ADDR *pc, int *is_thumb)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+
/* Is this a sigreturn or rt_sigreturn syscall? */
- if (svc_number == 119 || svc_number == 173)
+ if (get_syscall_number (gdbarch, "sigreturn") == svc_number
+ || get_syscall_number (gdbarch, "rt_sigreturn") == svc_number)
{
if (get_frame_type (frame) == SIGTRAMP_FRAME)
{
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index 31a80a5..449539f 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -422,4 +422,12 @@ get_syscall_names (struct gdbarch *gdbarch)
return xml_list_of_syscalls (gdbarch);
}

+int get_syscall_number (struct gdbarch *gdbarch,
+ const char *syscall_name)
+{
+ init_syscalls_info (gdbarch);
+
+ return xml_get_syscall_number (gdbarch, syscall_name);
+}
+
#endif /* ! HAVE_LIBEXPAT */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 55c9696..2930982 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -50,4 +50,10 @@ void get_syscall_by_name (struct gdbarch *gdbarch,

const char **get_syscall_names (struct gdbarch *gdbarch);

+/* Return the syscall number associated with the SYSCALL_NAME given in
+ argument. */
+
+int get_syscall_number (struct gdbarch *gdbarch,
+ const char *syscall_name);
+
#endif /* XML_SYSCALL_H */
--
2.6.3