From 09de9781bdd949cdd00adec6e0693a0d79d70463 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 24 Feb 2010 15:14:31 +0000 Subject: [PATCH] gdb: Add sparc*-*-linux catch syscall support. 2010-02-24 David S. Miller * gdb_ptrace.h (PT_SYSCALL): If PTRACE_SYSCALL is available, use it. * syscalls/sparc-linux.xml: New. * syscalls/sparc64-linux.xml: New. * Makefile.in (XML_SYSCALL_FILES): Add new syscall XML files. * sparc-linux-tdep.c (XML_SYSCALL_FILENAME_SPARC32): Define. (sparc32_linux_get_syscall_number): New function. (sparc32_linux_init_abi): Set syscall XML file name and hook up syscall number fetcher. * sparc64-linux-tdep.c (XML_SYSCALL_FILENAME_SPARC64): Define. (sparc64_linux_get_syscall_number): New function. (sparc64_linux_init_abi): Set syscall XML file name and hook up syscall number fetcher. --- gdb/ChangeLog | 15 ++ gdb/Makefile.in | 3 +- gdb/gdb_ptrace.h | 6 +- gdb/sparc-linux-tdep.c | 30 +++ gdb/sparc64-linux-tdep.c | 30 +++ gdb/syscalls/sparc-linux.xml | 344 +++++++++++++++++++++++++++++++++ gdb/syscalls/sparc64-linux.xml | 326 +++++++++++++++++++++++++++++++ 7 files changed, 752 insertions(+), 2 deletions(-) create mode 100644 gdb/syscalls/sparc-linux.xml create mode 100644 gdb/syscalls/sparc64-linux.xml diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2b51c08f30..c10f54bd54 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +2010-02-24 David S. Miller + + * gdb_ptrace.h (PT_SYSCALL): If PTRACE_SYSCALL is available, use it. + * syscalls/sparc-linux.xml: New. + * syscalls/sparc64-linux.xml: New. + * Makefile.in (XML_SYSCALL_FILES): Add new syscall XML files. + * sparc-linux-tdep.c (XML_SYSCALL_FILENAME_SPARC32): Define. + (sparc32_linux_get_syscall_number): New function. + (sparc32_linux_init_abi): Set syscall XML file name and hook up + syscall number fetcher. + * sparc64-linux-tdep.c (XML_SYSCALL_FILENAME_SPARC64): Define. + (sparc64_linux_get_syscall_number): New function. + (sparc64_linux_init_abi): Set syscall XML file name and hook up + syscall number fetcher. + 2010-02-24 Vladimir Prus Multiexec MI diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 98f42b9792..8e68bb1765 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -845,7 +845,8 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ XML_SYSCALLS_DIR = syscalls/ XML_SYSCALLS_FILES = gdb-syscalls.dtd \ ppc-linux.xml ppc64-linux.xml \ - i386-linux.xml amd64-linux.xml + i386-linux.xml amd64-linux.xml \ + sparc-linux.xml sparc64-linux.xml TSOBS = inflow.o diff --git a/gdb/gdb_ptrace.h b/gdb/gdb_ptrace.h index 71b448fb03..8ee8c4eea3 100644 --- a/gdb/gdb_ptrace.h +++ b/gdb/gdb_ptrace.h @@ -115,7 +115,11 @@ and there is probably no special request that we would be required to use when resuming the execution of our program. */ #ifndef PT_SYSCALL -# define PT_SYSCALL PT_CONTINUE +# ifdef PTRACE_SYSCALL +# define PT_SYSCALL PTRACE_SYSCALL +#else +# define PT_SYSCALL PT_CONTINUE +# endif #endif /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64 diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c index d65db6cc2b..20644b471f 100644 --- a/gdb/sparc-linux-tdep.c +++ b/gdb/sparc-linux-tdep.c @@ -32,6 +32,10 @@ #include "symtab.h" #include "trad-frame.h" #include "tramp-frame.h" +#include "xml-syscall.h" + +/* The syscall's XML filename for sparc 32-bit. */ +#define XML_SYSCALL_FILENAME_SPARC32 "syscalls/sparc-linux.xml" #include "sparc-tdep.h" @@ -241,6 +245,27 @@ sparc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) regcache_cooked_write_unsigned (regcache, SPARC32_PSR_REGNUM, psr); } +static LONGEST +sparc32_linux_get_syscall_number (struct gdbarch *gdbarch, + ptid_t ptid) +{ + struct regcache *regcache = get_thread_regcache (ptid); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + /* The content of a register. */ + gdb_byte buf[4]; + /* The result. */ + LONGEST ret; + + /* Getting the system call number from the register. + When dealing with the sparc architecture, this information + is stored at the %g1 register. */ + regcache_cooked_read (regcache, SPARC_G1_REGNUM, buf); + + ret = extract_signed_integer (buf, 4, byte_order); + + return ret; +} + static void @@ -279,6 +304,11 @@ sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) dwarf2_append_unwinders (gdbarch); set_gdbarch_write_pc (gdbarch, sparc_linux_write_pc); + + /* Functions for 'catch syscall'. */ + set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC32); + set_gdbarch_get_syscall_number (gdbarch, + sparc32_linux_get_syscall_number); } /* Provide a prototype to silence -Wmissing-prototypes. */ diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index 8b7e9081b3..72bbb320f1 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -31,6 +31,10 @@ #include "symtab.h" #include "trad-frame.h" #include "tramp-frame.h" +#include "xml-syscall.h" + +/* The syscall's XML filename for sparc 64-bit. */ +#define XML_SYSCALL_FILENAME_SPARC64 "syscalls/sparc64-linux.xml" #include "sparc64-tdep.h" @@ -205,6 +209,27 @@ sparc64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) regcache_cooked_write_unsigned (regcache, SPARC64_STATE_REGNUM, state); } +static LONGEST +sparc64_linux_get_syscall_number (struct gdbarch *gdbarch, + ptid_t ptid) +{ + struct regcache *regcache = get_thread_regcache (ptid); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + /* The content of a register. */ + gdb_byte buf[8]; + /* The result. */ + LONGEST ret; + + /* Getting the system call number from the register. + When dealing with the sparc architecture, this information + is stored at the %g1 register. */ + regcache_cooked_read (regcache, SPARC_G1_REGNUM, buf); + + ret = extract_signed_integer (buf, 8, byte_order); + + return ret; +} + static void @@ -244,6 +269,11 @@ sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->step_trap = sparc64_linux_step_trap; set_gdbarch_write_pc (gdbarch, sparc64_linux_write_pc); + + /* Functions for 'catch syscall'. */ + set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC64); + set_gdbarch_get_syscall_number (gdbarch, + sparc64_linux_get_syscall_number); } diff --git a/gdb/syscalls/sparc-linux.xml b/gdb/syscalls/sparc-linux.xml new file mode 100644 index 0000000000..4e3bde072b --- /dev/null +++ b/gdb/syscalls/sparc-linux.xml @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/sparc64-linux.xml b/gdb/syscalls/sparc64-linux.xml new file mode 100644 index 0000000000..b701883f2c --- /dev/null +++ b/gdb/syscalls/sparc64-linux.xml @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.34.1