Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: fix PR mi/12661
@ 2011-04-27 18:08 Tom Tromey
  2011-04-27 18:26 ` Pedro Alves
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2011-04-27 18:08 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-03 15:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 18:08 RFA: fix PR mi/12661 Tom Tromey
2011-04-27 18:26 ` Pedro Alves
2011-06-02 17:09   ` Tom Tromey
2011-06-02 17:35     ` Pedro Alves
2011-06-02 19:21       ` Tom Tromey
2011-06-02 20:54         ` Eli Zaretskii
2011-06-02 21:01           ` Tom Tromey
2011-06-02 21:24             ` Eli Zaretskii
2011-06-03 15:26               ` Tom Tromey
2011-06-03 15:14           ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox