From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1350 invoked by alias); 10 Nov 2005 21:40:44 -0000 Mailing-List: contact rda-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: rda-owner@sourceware.org Received: (qmail 1333 invoked by uid 22791); 10 Nov 2005 21:40:40 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 10 Nov 2005 21:40:40 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id jAALec8u027559 for ; Thu, 10 Nov 2005 16:40:38 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jAALeXV08406 for ; Thu, 10 Nov 2005 16:40:33 -0500 Received: from localhost.localdomain (vpn50-124.rdu.redhat.com [172.16.50.124]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id jAALeWt2001954 for ; Thu, 10 Nov 2005 16:40:32 -0500 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id jAALeRFO017200 for ; Thu, 10 Nov 2005 14:40:27 -0700 Date: Thu, 10 Nov 2005 21:40:00 -0000 From: Kevin Buettner To: rda@sources.redhat.com Subject: [commit] Handle LWPs that have died without leaving a status Message-ID: <20051110144027.4ba0c27d@ironwood.lan> Organization: Red Hat X-Mailer: Sylpheed-Claws 0.9.12cvs173.1 (GTK+ 2.4.14; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2005-q4/txt/msg00005.txt.bz2 I've just committed the patch below. It's been sitting in one of my trees for a while and I don't remember all that much about it. I do know that without this code, RDA will error out when using certain linux kernel versions with the message: <<< ERROR -- tkill (680, Stopped (signal)) failed: No such process >>> I believe that this would occur because RDA was attempting to stop a process which had already exited. Apparently, there were certain (buggy) kernels which would fail to leave an exit status. * lwp-pool.c (mark_lwp_as_dead_but_interesting): New function. (wait_and_handle): Replace lines of code implementing guts of new function mark_lwp_as_dead_but_interesting() with call to that function. Make a new call to this function after it has been determined that an lwp has exited without leaving a status. Index: lwp-pool.c =================================================================== RCS file: /cvs/src/src/rda/unix/lwp-pool.c,v retrieving revision 1.4 diff -u -p -r1.4 lwp-pool.c --- lwp-pool.c 9 Nov 2005 02:16:46 -0000 1.4 +++ lwp-pool.c 10 Nov 2005 21:26:30 -0000 @@ -796,6 +796,17 @@ debug_report_state_change (struct gdbser } } +/* Remove (dead) LWP from the hash table and put it on the `interesting' + queue. */ +static void +mark_lwp_as_dead_but_interesting (struct lwp *l) +{ + hash_delete (l); + l->state = lwp_state_dead_interesting; + if (l->next) + queue_delete (l); + queue_enqueue (&interesting_queue, l); +} /* Wait for a status from the LWP L (or any LWP, if L is NULL), passing FLAGS to waitpid, and record the resulting wait status in @@ -868,15 +879,7 @@ wait_and_handle (struct gdbserv *serv, s l->status = status; if (WIFEXITED (status) || WIFSIGNALED (status)) - { - /* Remove dead LWP's from the hash table, and put them in the - interesting queue. */ - hash_delete (l); - l->state = lwp_state_dead_interesting; - if (l->next) - queue_delete (l); - queue_enqueue (&interesting_queue, l); - } + mark_lwp_as_dead_but_interesting (l); else { int stopsig; @@ -1143,9 +1146,24 @@ lwp_pool_stop_all (struct gdbserv *serv) case lwp_state_running: /* A 'no such process' error here indicates an NPTL thread that has exited. */ - kill_lwp (l->pid, SIGSTOP); - l->state = lwp_state_running_stop_pending; - queue_enqueue (&stopping_queue, l); + if (kill_lwp (l->pid, SIGSTOP) < 0) + { + /* Thread has exited. See if a status is available. */ + if (wait_and_handle (serv, l, WNOHANG) < 0) + { + /* Nope, it's truly gone without providing a status. + Put it on the interesting queue so that GDB is + notified that it's gone. */ + l->status = 0; + mark_lwp_as_dead_but_interesting (l); + } + } + else + { + l->state = lwp_state_running_stop_pending; + queue_enqueue (&stopping_queue, l); + } + break; case lwp_state_stopped: