From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20842 invoked by alias); 25 Sep 2008 13:21:47 -0000 Received: (qmail 20828 invoked by uid 22791); 25 Sep 2008 13:21:45 -0000 X-Spam-Check-By: sourceware.org Received: from igw3.br.ibm.com (HELO igw3.br.ibm.com) (32.104.18.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 25 Sep 2008 13:20:55 +0000 Received: from mailhub3.br.ibm.com (unknown [9.18.232.110]) by igw3.br.ibm.com (Postfix) with ESMTP id 54293390127 for ; Thu, 25 Sep 2008 09:58:49 -0300 (BRST) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m8PDEUw81847360 for ; Thu, 25 Sep 2008 10:14:36 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m8PDEMYu008608 for ; Thu, 25 Sep 2008 10:14:22 -0300 Received: from [9.18.238.184] (IBM-708585AE534-009018238184.br.ibm.com [9.18.238.184]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m8PDEMXq007447 for ; Thu, 25 Sep 2008 10:14:22 -0300 Subject: [PATCH] Fix argument-passing error in linux-nat.c From: =?ISO-8859-1?Q?S=E9rgio?= Durigan =?ISO-8859-1?Q?J=FAnior?= To: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary="=-EOb9X0ouS2ydMNdS4Ukg" Date: Thu, 25 Sep 2008 13:21:00 -0000 Message-Id: <1222348523.10481.5.camel@miki> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 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-09/txt/msg00501.txt.bz2 --=-EOb9X0ouS2ydMNdS4Ukg Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-length: 1591 Hi guys, This is a very trivial patch that I have done (while I don't have yet the 'catch syscall' patch! :D). Well, I found this little error in linux-nat.c. Basically, the 'status' variable in the function 'get_pending_status' is a pointer to an integer, but the macros from waitpid.h (WIFSTOPPED and WSTOPSIG) are being called with this pointer as the argument, instead of the integer itself. It was just a matter of putting a '*' in the front of the name ;-) This fix did not cause any improvement on the testsuite (for 32-bit PPC at least), but anyway it's better to do things right, huh? Also, as I'm sending this e-mail, I'd like to propose one little modification in the GDB code. As you all know GCC does not do type-checking in macros, which makes it hard to identify problems like this one. To avoid future issues, it would be a good thing to make a "wrapper" for these macros (specially for those in waitpid.h). This wrapper could be something like a "static inline", so we won't miss anything in the performance aspect. For example, in the case of WSTOPSIG: static inline int internal_WSTOPSIG (int status) { return WSTOPSIG (status); } So, whenever we call internal_WSTOPSIG (ugly name, we certainly may want to choose another one), we have *for free* a type-checking for its argument :-). I took a quick look at the code and there are not so many places to replace the calls, so I think it would not be a hard job to do... So, what do you think? Thanks, -- Sérgio Durigan Júnior Linux on Power Toolchain - Software Engineer Linux Technology Center - LTC IBM Brazil --=-EOb9X0ouS2ydMNdS4Ukg Content-Disposition: attachment; filename=linux-nat-status-pointer.patch Content-Type: text/x-patch; name=linux-nat-status-pointer.patch; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 559 diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 42e19b5..0851492 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1442,8 +1442,8 @@ get_pending_status (struct lwp_info *lp, int *status) queue. */ if (queued_waitpid (GET_LWP (lp->ptid), status, __WALL) != -1) { - if (WIFSTOPPED (status)) - signo = target_signal_from_host (WSTOPSIG (status)); + if (WIFSTOPPED (*status)) + signo = target_signal_from_host (WSTOPSIG (*status)); /* If not stopped, then the lwp is gone, no use in resending a signal. */ --=-EOb9X0ouS2ydMNdS4Ukg--