From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2445 invoked by alias); 22 May 2013 21:47:28 -0000 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 Received: (qmail 2431 invoked by uid 89); 22 May 2013 21:47:27 -0000 X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SPF_PASS autolearn=ham version=3.3.1 Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 22 May 2013 21:47:27 +0000 Received: from EUSAAHC004.ericsson.se (Unknown_Domain [147.117.188.84]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 6A.19.06724.DEC3D915; Wed, 22 May 2013 23:47:25 +0200 (CEST) Received: from EUSAAMB101.ericsson.se ([147.117.188.118]) by EUSAAHC004.ericsson.se ([147.117.188.84]) with mapi id 14.02.0328.009; Wed, 22 May 2013 17:47:25 -0400 From: Simon Marchi To: "gdb-patches@sourceware.org" Subject: Exit code of exited inferiors Date: Wed, 22 May 2013 21:47:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-05/txt/msg00862.txt.bz2 Hi, The current behaviour in Eclipse's CDT when a debugged process exits normal= ly is to remove it from the list. We would like to change it so that they stay= in the process list after they exit, probably showing them as "Exited" and displaying the exit code. The problem is there is no way to query GDB for the exit code of an exited inferior. One way to do it would be to catch the thread-group-exited MI eve= nt, which contains the exit code. It means that the CDT view would be required = to keep a state and could not be reconstructed from scratch, simply by querying GDB. The current design seems to avoid keeping information in the view that= GDB can't give us. For this reason, I suggest adding an exit-code field in the -list-thread-gr= oup response when appropriate. Appropriate meaning after an inferior process has exited, and before it is run again. This field would contain the exit code = for the last run of the inferior. Doing so would require a little modification,= as the exit_code and has_exit_code fields in struct inferior are wiped in exit_inferior_1. I think it would be reasonable to keep them around until t= he inferior is started again. Is there any problem with this? There might be some cases where it does not make sense. For example, after the inferior exits, if you change the execut= able (using the "file" command), you have a state where the exit code does not m= atch the executable anymore. Not sure if this is an issue. I am sending this patch to illustrate the proposed change. Thanks for your comments! Simon 2013-05-22 Simon Marchi * gdb/inferior.c (exit_inferior_1): Remove exit code clear. (inferior_appeared): Add exit code clear. * gdb/mi/mi-main.c (print_one_inferior): Add printing of the exit code. --- gdb/inferior.c | 4 ++-- gdb/mi/mi-main.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index ed6b626..a145780 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -275,8 +275,6 @@ exit_inferior_1 (struct inferior *inftoex, int silent) inf->vfork_child =3D NULL; } =20 - inf->has_exit_code =3D 0; - inf->exit_code =3D 0; inf->pending_detach =3D 0; } =20 @@ -322,6 +320,8 @@ void inferior_appeared (struct inferior *inf, int pid) { inf->pid =3D pid; + inf->has_exit_code =3D 0; + inf->exit_code =3D 0; =20 observer_notify_inferior_appeared (inf); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 94fda8f..204ba34 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -568,6 +568,8 @@ print_one_inferior (struct inferior *inferior, void *xd= ata) =20 ui_out_field_fmt (uiout, "id", "i%d", inferior->num); ui_out_field_string (uiout, "type", "process"); + if (inferior->has_exit_code) + ui_out_field_int (uiout, "exit-code", inferior->exit_code); if (inferior->pid !=3D 0) ui_out_field_int (uiout, "pid", inferior->pid); =20 --=20 1.7.9.5