From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4745 invoked by alias); 21 Dec 2009 20:49:01 -0000 Received: (qmail 4730 invoked by uid 22791); 21 Dec 2009 20:49:01 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Dec 2009 20:48:56 +0000 Received: from spaceape24.eur.corp.google.com (spaceape24.eur.corp.google.com [172.28.16.76]) by smtp-out.google.com with ESMTP id nBLKmr5M019841 for ; Mon, 21 Dec 2009 20:48:53 GMT Received: from ey-out-2122.google.com (eya25.prod.google.com [10.208.1.25]) by spaceape24.eur.corp.google.com with ESMTP id nBLKmpTo024835 for ; Mon, 21 Dec 2009 12:48:52 -0800 Received: by ey-out-2122.google.com with SMTP id 25so90987eya.29 for ; Mon, 21 Dec 2009 12:48:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.90.212 with SMTP id e62mr2920859wef.26.1261428531290; Mon, 21 Dec 2009 12:48:51 -0800 (PST) In-Reply-To: References: <20091221201033.2B76C84412@ruffy.mtv.corp.google.com> <20091221201921.GA27626@caradoc.them.org> Date: Mon, 21 Dec 2009 20:49:00 -0000 Message-ID: Subject: Re: [patch] fix tkill_failed gcc warning in gdbserver From: Doug Evans To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2009-12/txt/msg00323.txt.bz2 On Mon, Dec 21, 2009 at 12:36 PM, Doug Evans wrote: > On Mon, Dec 21, 2009 at 12:19 PM, Daniel Jacobowitz wrot= e: >> On Mon, Dec 21, 2009 at 12:10:33PM -0800, Doug Evans wrote: >>> Hi. >>> >>> android doesn't have SYS_tkill but it does have __NR_tkill. >> >> Does it have the other SYS_ constants? =A0It's a weird omission. >> Anyway, might as well use __NR_tkill unconditionally. > > The next question is, does gdbserver need to check for > syscall.h/syscall() like gdb does? > Or can I just replace #ifdef SYS_tkill with #ifdef __NR_tkill. > gdbserver includes sys/syscall.h unconditionally, gdb/linux-nat.c =A0does= not. > gdb also checks for __NR_tkill in a way that works if it were an enum. > Does one need to worry about that case? > How about this? 2009-12-21 Doug Evans gdb/ * linux-nat.c (kill_lwp): Minor cleanup, move definition of tkill_failed into ifdef HAVE_TKILL_SYSCALL. Move setting of errno there too. Delete unnecessary resetting of errno after syscall. Minor comment changes to match gdbserver/linux-low.c:kill_lwp. gdbserver/ * linux-low.c (kill_lwp): Use __NR_tkill instead of SYS_tkill. Move definition of tkill_failed to ifdef __NR_tkill to avoid gcc warning ifndef __NR_tkill. Move setting of errno there too. Delete unnecessary resetting of errno after syscall. Minor comment changes to match gdb/linux-nat.c:kill_lwp. Index: linux-nat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/linux-nat.c,v retrieving revision 1.156 diff -u -p -r1.156 linux-nat.c --- linux-nat.c 20 Nov 2009 19:48:45 -0000 1.156 +++ linux-nat.c 21 Dec 2009 20:39:15 -0000 @@ -2034,27 +2034,29 @@ linux_nat_resume (struct target_ops *ops target_async (inferior_event_handler, 0); } -/* Issue kill to specified lwp. */ - -static int tkill_failed; +/* Send a signal to an LWP. */ static int kill_lwp (int lwpid, int signo) { - errno =3D 0; - -/* Use tkill, if possible, in case we are using nptl threads. If tkill - fails, then we are not using nptl threads and we should be using kill. = */ + /* Use tkill, if possible, in case we are using nptl threads. If tkill + fails, then we are not using nptl threads and we should be using kill= . */ #ifdef HAVE_TKILL_SYSCALL - if (!tkill_failed) - { - int ret =3D syscall (__NR_tkill, lwpid, signo); - if (errno !=3D ENOSYS) - return ret; - errno =3D 0; - tkill_failed =3D 1; - } + { + static int tkill_failed; + + if (!tkill_failed) + { + int ret; + + errno =3D 0; + ret =3D syscall (__NR_tkill, lwpid, signo); + if (errno !=3D ENOSYS) + return ret; + tkill_failed =3D 1; + } + } #endif return kill (lwpid, signo); Index: gdbserver/linux-low.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.117 diff -u -p -r1.117 linux-low.c --- gdbserver/linux-low.c 21 Dec 2009 17:54:03 -0000 1.117 +++ gdbserver/linux-low.c 21 Dec 2009 20:39:15 -0000 @@ -1572,25 +1584,29 @@ linux_wait (ptid_t ptid, return event_ptid; } -/* Send a signal to an LWP. For LinuxThreads, kill is enough; however, if - thread groups are in use, we need to use tkill. */ +/* Send a signal to an LWP. */ static int kill_lwp (unsigned long lwpid, int signo) { - static int tkill_failed; + /* Use tkill, if possible, in case we are using nptl threads. If tkill + fails, then we are not using nptl threads and we should be using kill= . */ - errno =3D 0; +#ifdef __NR_tkill + { + static int tkill_failed; -#ifdef SYS_tkill - if (!tkill_failed) - { - int ret =3D syscall (SYS_tkill, lwpid, signo); - if (errno !=3D ENOSYS) - return ret; - errno =3D 0; - tkill_failed =3D 1; - } + if (!tkill_failed) + { + int ret; + + errno =3D 0; + ret =3D syscall (__NR_tkill, lwpid, signo); + if (errno !=3D ENOSYS) + return ret; + tkill_failed =3D 1; + } + } #endif return kill (lwpid, signo);