This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: fix PR mi/12661


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  <tromey@redhat.com>

	PR mi/12661:
	* mi/mi-interp.c (mi_inferior_exit): Print exit code.

2011-04-27  Tom Tromey  <tromey@redhat.com>

	* 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);  
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]