From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31007 invoked by alias); 31 Jul 2013 21:04:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30966 invoked by uid 89); 31 Jul 2013 21:04:03 -0000 X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RDNS_NONE,SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO mail-qc0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 31 Jul 2013 21:04:02 +0000 Received: by mail-qc0-f177.google.com with SMTP id e11so654806qcx.36 for ; Wed, 31 Jul 2013 14:03:54 -0700 (PDT) X-Received: by 10.49.94.235 with SMTP id df11mr56517458qeb.92.1375304634489; Wed, 31 Jul 2013 14:03:54 -0700 (PDT) Received: from hydrogen (naesten-pt.tunnel.tserv4.nyc4.ipv6.he.net. [2001:470:1f06:57::2]) by mx.google.com with ESMTPSA id y1sm26767qaj.2.2013.07.31.14.03.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 31 Jul 2013 14:03:53 -0700 (PDT) Received: from naesten by hydrogen with local (Exim 4.80) (envelope-from ) id 1V4dYl-0006Y8-79 for gdb-patches@sourceware.org; Wed, 31 Jul 2013 17:03:51 -0400 From: Samuel Bronson Date: Wed, 31 Jul 2013 21:04:00 -0000 Subject: [RFC][PATCH] Preliminary `catch syscall' support for ARM Linux. To: gdb-patches@sourceware.org Message-Id: X-SW-Source: 2013-07/txt/msg00845.txt.bz2 This seems to work okay, but needs a better arm-linux.xml file and some cleanup, as well as a changelog. --- gdb/arm-linux-tdep.c | 61 ++++++++++++++ gdb/data-directory/Makefile.in | 1 + gdb/syscalls/arm-linux.xml | 181 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 gdb/syscalls/arm-linux.xml diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 1502bdc..449f87c 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -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,62 @@ arm_linux_sigreturn_return_addr (struct frame_info *frame, return 0; } +/* When FRAME is at a syscall instruction, return the syscall number. + This either comes from the SWI (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) + { + /* XXX ensure SWI? */ + regcache_cooked_read_unsigned (regs, 7, &svc_number); + } + else + { + enum bfd_endian byte_order_for_code = + gdbarch_byte_order_for_code (gdbarch); + unsigned long this_instr = + read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code); + + unsigned long svc_operand = (0x00ffffff & this_instr); + + /* + if ((this_instr & 0xff000000) != 0xef000000) + { + return -1; + } + */ + + 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 +1351,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; } diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index dec6207..3d05213 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -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 \ diff --git a/gdb/syscalls/arm-linux.xml b/gdb/syscalls/arm-linux.xml new file mode 100644 index 0000000..28e1b9d --- /dev/null +++ b/gdb/syscalls/arm-linux.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 1.7.10.4