From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31768 invoked by alias); 27 Apr 2011 18:08:45 -0000 Received: (qmail 31748 invoked by uid 22791); 27 Apr 2011 18:08:44 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Apr 2011 18:08:28 +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 p3RI8S9u006463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Apr 2011 14:08:28 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3RI8R9P023310; Wed, 27 Apr 2011 14:08:27 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p3RI8RW5020857; Wed, 27 Apr 2011 14:08:27 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 8B6BB508612; Wed, 27 Apr 2011 12:08:26 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFA: fix PR mi/12661 Date: Wed, 27 Apr 2011 18:08:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-04/txt/msg00520.txt.bz2 This needs at least a doc review. In the absence of other comments I will self-approve the code bits. The bug here is that a thread-group exit looks like this in MI: =thread-group-exited,id="i1" *stopped,reason="exited",exit-code="02" That is, one notification contains the thread group ID, and the other contains the exit code, but neither contains both. This patch implements the second suggestion in the PR, namely to put the exit code into the exited event: =thread-group-exited,id="i1",exit-code="02" I took the same implementation approach as used by the python exit handler. Built and regtested on our internal buildbot. This showed some regressions in one mode (x86-64, Fedora 14, using .gdb_index for the tests), but I believe those to be some problem on the VM. The other 3 build modes went fine, modulo the usual inconsistent tests. Tom 2011-04-27 Tom Tromey PR mi/12661: * mi/mi-interp.c (mi_inferior_exit): Print exit code. 2011-04-27 Tom Tromey * gdb.texinfo (GDB/MI Async Records): Document exit-code. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 15ccf2e..472e0dc 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -25143,11 +25143,12 @@ was attached to a program. The @var{id} field contains the @value{GDBN} identifier of the thread group. The @var{pid} field contains process identifier, specific to the operating system. -@itemx =thread-group-exited,id="@var{id}" +@itemx =thread-group-exited,id="@var{id}",exit-code="@var{code}" A thread group is no longer associated with a running program, either because the program has exited, or because it was detached from. The @var{id} field contains the @value{GDBN} identifier of the -thread group. +thread group. The @var{code} field contains the exit code from the +inferior. @item =thread-created,id="@var{id}",group-id="@var{gid}" @itemx =thread-exited,id="@var{id}",group-id="@var{gid}" diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index c075b0c..9af6949 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -364,10 +364,16 @@ static void mi_inferior_exit (struct inferior *inf) { struct mi_interp *mi = top_level_interpreter_data (); + LONGEST exit_code; + struct target_waitstatus status; + ptid_t ptidp; target_terminal_ours (); - fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"", - inf->num); + get_last_target_status (&ptidp, &status); + exit_code = status.value.integer; + fprintf_unfiltered (mi->event_channel, + "thread-group-exited,id=\"i%d\",exit-code=\"%s\"", + inf->num, int_string (exit_code, 8, 0, 0, 1)); gdb_flush (mi->event_channel); }