From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22634 invoked by alias); 5 Aug 2013 17:47:36 -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 22606 invoked by uid 89); 5 Aug 2013 17:47:36 -0000 X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 05 Aug 2013 17:47:35 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r75HlRK5026770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Aug 2013 13:47:27 -0400 Received: from psique ([10.3.113.15]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r75HlOPe030172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 5 Aug 2013 13:47:26 -0400 From: Sergio Durigan Junior To: Samuel Bronson Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] ARM Linux support for `catch syscall' References: X-URL: http://www.redhat.com Date: Mon, 05 Aug 2013 17:47:00 -0000 In-Reply-To: (Samuel Bronson's message of "Wed, 31 Jul 2013 20:47:23 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-08/txt/msg00153.txt.bz2 On Wednesday, July 31 2013, Samuel Bronson wrote: > This works alright except for the incomplete syscalls/arm-linux.xml, > for which I am waiting on a copy of sergiodj's scripts. Hey Samuel, Thanks for the patch, and sorry about the delay. Well, when I told you about some scripts that I used (back in 2009), I was actually trying to say that it's just a matter of doing some grep's and sed's in the Linux files. I guess I didn't provide the script at that time because the indentation inside the files does not always follow a pattern, so I thought it would be easier to just deal with each file separately (and it took me less than 10 minutes to create the XML file, after all). Unfortunately, I don't have this script anymore, but if you really want it, I can create one for the ARM file and send it to you. > (It only fails one test in catch-syscall.exp, and that's because of a > syscall missing from the XML file, but I decided that adding just that > syscall to the XML file would be cheating.) I wouldn't call it "cheating" :-). > gdb/ > 2013-08-02 Samuel Bronson > > ARM Linux support for`catch syscall'. Missing space between "for`catch syscall'". > * syscalls/arm-linux.xml: New (stub) syscall file for ARM Linux. New file. > * arm-linux-tdep.c (arm_linux_get_syscall_number): New function. > (arm_linux_init_abi): Register the new function and syscall file. > * data-directory/Makefile.in: Install the new syscall file. > > gdb/testsuite/ > 2013-08-02 Samuel Bronson > > ARM Linux support for`catch syscall'. Missing space. > * gdb.base/catch-syscall.exp: Test this on ARM now. > (fill_all_syscalls_numbers): ARM has close/chroot on 6/61, too. > --- > gdb/arm-linux-tdep.c | 56 ++++++++++ > gdb/data-directory/Makefile.in | 1 + > gdb/syscalls/arm-linux.xml | 181 +++++++++++++++++++++++++++++++ > gdb/testsuite/gdb.base/catch-syscall.exp | 9 +- > 4 files changed, 243 insertions(+), 4 deletions(-) > create mode 100644 gdb/syscalls/arm-linux.xml > > diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c > index 1502bdc..9d8238f 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,57 @@ 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 SVC 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); > + } I find it a little odd to write comments in the front of the "if/else". I guess you could write them inside the blocks. > + } > + > + return svc_number; > +} > + Well, I'm not very familiar with ARM, but I guess your code looks OK according to your explanation. > 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 @@ > + > + > + > + > + > + This comment is unecessary IMO, given what I said above :-). The rest looks OK to me. I am not a GDB maintainer, so you may wish to wait until someone gives his final word. Thanks a lot, -- Sergio