This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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 compare syscalls numbers
called is_syscall.

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 is_syscall.
	* xml-syscall.c (is_syscall): New function.
	* xml-syscall.h (is_syscall): New declaration.
---
 gdb/arm-linux-tdep.c |  5 ++++-
 gdb/xml-syscall.c    | 13 +++++++++++++
 gdb/xml-syscall.h    |  6 ++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 73e1271..acb5701 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 (is_syscall (gdbarch, "sigreturn", svc_number)
+      || is_syscall (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..e6a6a2a 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -422,4 +422,17 @@ get_syscall_names (struct gdbarch *gdbarch)
   return xml_list_of_syscalls (gdbarch);
 }
 
+int
+is_syscall (struct gdbarch *gdbarch, const char *syscall_name,
+	    int syscall_number)
+{
+  struct syscall s;
+  get_syscall_by_name (gdbarch, syscall_name, &s);
+
+  if (s.number == syscall_number)
+    return 1;
+  else
+    return 0;
+}
+
 #endif /* ! HAVE_LIBEXPAT */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 55c9696..e232edc 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);
 
+/* Compare the syscall number with the syscall name given in argument.  If
+   they match return 1 otherwise return 0.  */
+
+int is_syscall (struct gdbarch *gdbarch, const char *syscall_name,
+		int syscall_number);
+
 #endif /* XML_SYSCALL_H */
-- 
2.6.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]