[Committing the `catch syscall' patch for ARM, from Samuel Bronson.]
authorSergio Durigan Junior <sergiodj@redhat.com>
Thu, 22 Aug 2013 20:32:54 +0000 (20:32 +0000)
committerSergio Durigan Junior <sergiodj@redhat.com>
Thu, 22 Aug 2013 20:32:54 +0000 (20:32 +0000)
This time, it passes all the tests and comes with a nearly complete
XML file (plus a script that can nearly regenerate the XML file).

(I elected to leave out __ARM_NR_cmpxchg, since it has dire warnings
to the effect that the only pieces of code that should be aware of it
are the implementation and the __kuser_cmpxchg code in entry-armv.S.)

gdb/
2013-08-14  Samuel Bronson  <naesten@gmail.com>

ARM Linux support for `catch syscall'.
* syscalls/arm-linux.py: New file.
* syscalls/arm-linux.xml: Likewise.
* arm-linux-tdep.c (arm_linux_get_syscall_number): New function.
(arm_linux_init_abi): Register the new function and syscall xml file.
* data-directory/Makefile.in: Install the new syscall xml file.
* NEWS: Brag about this.

gdb/testsuite/
2013-08-14  Samuel Bronson  <naesten@gmail.com>

ARM Linux support for `catch syscall'.
* gdb.base/catch-syscall.exp: Test this on ARM now.
(fill_all_syscalls_numbers): ARM has close/chroot on 6/61, too.

gdb/ChangeLog
gdb/NEWS
gdb/arm-linux-tdep.c
gdb/data-directory/Makefile.in
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/catch-syscall.exp

index 55e2337463f50394636839ff23a820f58210f7d7..8d939d96e551411aee36e4ca1f965cabd784f751 100644 (file)
@@ -1,3 +1,13 @@
+2013-08-22  Samuel Bronson  <naesten@gmail.com>
+
+       ARM Linux support for `catch syscall'.
+       * syscalls/arm-linux.py: New file.
+       * syscalls/arm-linux.xml: Likewise.
+       * arm-linux-tdep.c (arm_linux_get_syscall_number): New function.
+       (arm_linux_init_abi): Register the new function and syscall xml file.
+       * data-directory/Makefile.in: Install the new syscall xml file.
+       * NEWS: Brag about this.
+
 2013-08-22  Pedro Alves  <palves@redhat.com>
 
        PR gdb/15871
index 6ee82f7b63181ba9406ca246a5168702cf6b96f4..f246ee1d062bfa381c4c8ff3cf6fa724561d28bd 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,8 @@
 
 *** Changes since GDB 7.6
 
+* The "catch syscall" command now works on arm*-linux* targets.
+
 * Python scripting
 
   ** Frame filters and frame decorators have been added.
index 1502bdcfe639172b1c5b60c3c370fb0bd4658a53..6ac61cc1a14707178bf19bb184533e5d464b60db 100644 (file)
@@ -33,6 +33,7 @@
 #include "tramp-frame.h"
 #include "breakpoint.h"
 #include "auxv.h"
+#include "xml-syscall.h"
 
 #include "arm-tdep.h"
 #include "arm-linux-tdep.h"
@@ -794,6 +795,59 @@ arm_linux_sigreturn_return_addr (struct frame_info *frame,
   return 0;
 }
 
+/* At a ptrace syscall-stop, return the syscall number.  This either
+   comes from the SWI instruction (OABI) or from r7 (EABI).
+
+   When the function fails, it should return -1.  */
+
+static LONGEST
+arm_linux_get_syscall_number (struct gdbarch *gdbarch,
+                             ptid_t ptid)
+{
+  struct regcache *regs = get_thread_regcache (ptid);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  ULONGEST pc;
+  ULONGEST cpsr;
+  ULONGEST t_bit = arm_psr_thumb_bit (gdbarch);
+  int is_thumb;
+  ULONGEST svc_number = -1;
+
+  regcache_cooked_read_unsigned (regs, ARM_PC_REGNUM, &pc);
+  regcache_cooked_read_unsigned (regs, ARM_PS_REGNUM, &cpsr);
+  is_thumb = (cpsr & t_bit) != 0;
+
+  if (is_thumb)
+    {
+      regcache_cooked_read_unsigned (regs, 7, &svc_number);
+    }
+  else
+    {
+      enum bfd_endian byte_order_for_code = 
+       gdbarch_byte_order_for_code (gdbarch);
+
+      /* PC gets incremented before the syscall-stop, so read the
+        previous instruction.  */
+      unsigned long this_instr = 
+       read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code);
+
+      unsigned long svc_operand = (0x00ffffff & this_instr);
+
+      if (svc_operand)
+       {
+          /* OABI */
+         svc_number = svc_operand - 0x900000;
+       }
+      else
+       {
+          /* EABI */
+         regcache_cooked_read_unsigned (regs, 7, &svc_number);
+       }
+    }
+
+  return svc_number;
+}
+
 /* When FRAME is at a syscall instruction, return the PC of the next
    instruction to be executed.  */
 
@@ -1294,6 +1348,10 @@ arm_linux_init_abi (struct gdbarch_info info,
 
   tdep->syscall_next_pc = arm_linux_syscall_next_pc;
 
+  /* `catch syscall' */
+  set_xml_syscall_file_name ("syscalls/arm-linux.xml");
+  set_gdbarch_get_syscall_number (gdbarch, arm_linux_get_syscall_number);
+
   /* Syscall record.  */
   tdep->arm_swi_record = NULL;
 }
index dec62077f270603767fe00e1d245e0987f260dac..3d052137f2b93cda1a5970680b2a10014454c118 100644 (file)
@@ -45,6 +45,7 @@ SYSCALLS_DIR = syscalls
 SYSCALLS_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(SYSCALLS_DIR)
 SYSCALLS_FILES = \
        gdb-syscalls.dtd \
+       arm-linux.xml \
        ppc-linux.xml ppc64-linux.xml \
        i386-linux.xml amd64-linux.xml \
        sparc-linux.xml sparc64-linux.xml \
index 8d2605f29f2287cc4b275b9b756b6abc24073fe2..1c8b94732e55dd4c5d302bdfc39f64993e18cafb 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-22  Samuel Bronson  <naesten@gmail.com>
+
+       ARM Linux support for `catch syscall'.
+       * gdb.base/catch-syscall.exp: Test this on ARM now.
+       (fill_all_syscalls_numbers): ARM has close/chroot on 6/61, too.
+
 2013-08-22  Tom Tromey  <tromey@redhat.com>
 
        * lib/dwarf.exp (cu, tu): Handle addr_size of "default".  Change
index 395fcd44783a1a0dd6416efd53cf19b5487a6f96..1066caf7e2efd7c99587491a99a44aca87b936df 100644 (file)
@@ -34,7 +34,7 @@ if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
 if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
      && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
      && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"]
-     && ![istarget "mips*-linux*"] } {
+     && ![istarget "mips*-linux*"] && ![istarget "arm*-linux*"] } {
      continue
 }
 
@@ -407,11 +407,12 @@ proc do_syscall_tests_without_xml {} {
 proc fill_all_syscalls_numbers {} {
     global all_syscalls_numbers
 
-    # For Linux on x86, PPC, PPC64, SPARC and SPARC64, the numbers for the syscalls
-    # "close" and "chroot" are the same.
+    # For Linux on x86, PPC, PPC64, SPARC, SPARC64 and ARM,
+    # the numbers for the syscalls "close" and "chroot" are the same.
     if { [istarget "i\[34567\]86-*-linux*"]
          || [istarget "powerpc-*-linux*"] || [istarget "powerpc64-*-linux*"]
-         || [istarget "sparc-*-linux*"] || [istarget "sparc64-*-linux*"] } {
+         || [istarget "sparc-*-linux*"] || [istarget "sparc64-*-linux*"]
+         || [istarget "arm*-linux*"] } {
          set all_syscalls_numbers { "6" "61" }
     }
 }
This page took 0.039464 seconds and 4 git commands to generate.