From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30087 invoked by alias); 4 Nov 2008 16:50:15 -0000 Received: (qmail 29973 invoked by uid 22791); 4 Nov 2008 16:50:14 -0000 X-Spam-Check-By: sourceware.org Received: from igw1.br.ibm.com (HELO igw1.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 04 Nov 2008 16:49:28 +0000 Received: from d24relay01.br.ibm.com (unknown [9.8.31.16]) by igw1.br.ibm.com (Postfix) with ESMTP id 92EC532C37E for ; Tue, 4 Nov 2008 14:47:22 -0200 (BRDT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mA4Gn3g94362240 for ; Tue, 4 Nov 2008 13:49:03 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mA4GnNhv015770 for ; Tue, 4 Nov 2008 14:49:24 -0200 Received: from [9.8.9.146] ([9.8.9.146]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id mA4GnNlN015748; Tue, 4 Nov 2008 14:49:23 -0200 Subject: Re: [PATCH 2/4] 'catch syscall' feature -- Architecture-dependent part From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= To: tromey@redhat.com Cc: gdb-patches@sourceware.org In-Reply-To: References: <1225773084.24532.54.camel@miki> Content-Type: text/plain; charset=iso-8859-1 Date: Tue, 04 Nov 2008 16:50:00 -0000 Message-Id: <1225817356.32321.25.camel@miki> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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 X-SW-Source: 2008-11/txt/msg00039.txt.bz2 Hi Tom, On Tue, 2008-11-04 at 09:15 -0700, Tom Tromey wrote: > >>>>> "Sérgio" == Sérgio Durigan Júnior writes: > > Sérgio> * i386-linux-tdep.c: Define the syscall's XML struct to hold > Sérgio> information about syscalls. > Sérgio> (init_sysinfo): New. > > There is some code duplication between this and ppc-linux-tdep.c. > It seems to me that much of the Linux code will be shared by all > ports. So, I think the duplicated stuff should go in linux-nat.c. Thank you so much for this comment! I was aware of this replication, but I still wasn't able to figure out a way to solve this. Now it looks so obvious! I'll put the common functions in linux-nat.c :-). > Sérgio> (i386_linux_get_syscall_number): New. > Sérgio> (i386_linux_syscall_name_from_number): New. > Sérgio> (i386_linux_syscall_number_from_name): New. > Sérgio> (i386_linux_get_syscalls_names): New. > > In the current patch, these could all be static. Aside from > i386_linux_get_syscall_number, perhaps they ought to be shared in > linux-nat.c though. The same applies for the equivalent PPC functions. Right, I'll do it for both. But I have a question. Depending on the architecture, I must pick the correct XML file to open and parse. That's why I've put these functions in separate files. So, do you have a clue on how to solve this? > Sérgio> +/* Return the current system call's number present in the > Sérgio> + r0 register. When the function fails, it returns -1. */ > Sérgio> +LONGEST > Sérgio> +ppc_linux_get_syscall_number (struct gdbarch *gdbarch, > Sérgio> + ptid_t ptid) > Sérgio> +{ > [...] > Sérgio> + buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte)); > > I suspect you need a cleanup here, rather than an explicit xfree. I > am not sure. If regcache_cooked_read can call error, then you need > one. Good point. I'll do that. Thanks. Regards, -- Sérgio Durigan Júnior Linux on Power Toolchain - Software Engineer Linux Technology Center - LTC IBM Brazil