From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: fix PR mi/12661
Date: Wed, 27 Apr 2011 18:08:00 -0000 [thread overview]
Message-ID: <m339l3in3a.fsf@fleche.redhat.com> (raw)
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);
}
next reply other threads:[~2011-04-27 18:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 18:08 Tom Tromey [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m339l3in3a.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox