gdb
* python/py-inferior.c (python_inferior_exit): Use inferior's exit code fields. * python/py-exitedevent.c (create_exited_event_object): Change type of 'exit_code'. Optionally add exit_code attribute. (emit_exited_event): Change type of 'exit_code'. * python/py-event.h (emit_exited_event): Update. * mi/mi-interp.c (mi_inferior_exit): Print exit code. * infrun.c (handle_inferior_event): Set exit code fields on inferior. * inferior.h (struct inferior) <has_exit_code, exit_code>: New fields. * inferior.c (exit_inferior_1): Initialize new fields. gdb/doc * gdb.texinfo (GDB/MI Async Records): Document 'exit-code' field. (Events In Python): Note that exit_code is optional.
This commit is contained in:
parent
8ddd9a20a7
commit
8cf64490f2
10 changed files with 59 additions and 20 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2011-06-03 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* python/py-inferior.c (python_inferior_exit): Use inferior's exit
|
||||||
|
code fields.
|
||||||
|
* python/py-exitedevent.c (create_exited_event_object): Change
|
||||||
|
type of 'exit_code'. Optionally add exit_code attribute.
|
||||||
|
(emit_exited_event): Change type of 'exit_code'.
|
||||||
|
* python/py-event.h (emit_exited_event): Update.
|
||||||
|
* mi/mi-interp.c (mi_inferior_exit): Print exit code.
|
||||||
|
* infrun.c (handle_inferior_event): Set exit code fields on
|
||||||
|
inferior.
|
||||||
|
* inferior.h (struct inferior) <has_exit_code, exit_code>: New
|
||||||
|
fields.
|
||||||
|
* inferior.c (exit_inferior_1): Initialize new fields.
|
||||||
|
|
||||||
2011-06-03 Tom Tromey <tromey@redhat.com>
|
2011-06-03 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* dwarf2expr.c (get_signed_type): New function.
|
* dwarf2expr.c (get_signed_type): New function.
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-06-03 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* gdb.texinfo (GDB/MI Async Records): Document 'exit-code' field.
|
||||||
|
(Events In Python): Note that exit_code is optional.
|
||||||
|
|
||||||
2011-05-17 Pedro Alves <pedro@codesourcery.com>
|
2011-05-17 Pedro Alves <pedro@codesourcery.com>
|
||||||
|
|
||||||
* gdb.texinfo (Remote Protocol) <Overview>: Mention vCont is
|
* gdb.texinfo (Remote Protocol) <Overview>: Mention vCont is
|
||||||
|
|
|
@ -22127,7 +22127,9 @@ inherited attribute refer to @code{gdb.ThreadEvent} above.
|
||||||
|
|
||||||
@item events.exited
|
@item events.exited
|
||||||
Emits @code{events.ExitedEvent} which indicates that the inferior has exited.
|
Emits @code{events.ExitedEvent} which indicates that the inferior has exited.
|
||||||
@code{events.ExitedEvent} has one attribute:
|
@code{events.ExitedEvent} has one optional attribute. This attribute
|
||||||
|
will exist only in the case that the inferior exited with some
|
||||||
|
status.
|
||||||
@table @code
|
@table @code
|
||||||
@defivar ExitedEvent exit_code
|
@defivar ExitedEvent exit_code
|
||||||
An integer representing the exit code which the inferior has returned.
|
An integer representing the exit code which the inferior has returned.
|
||||||
|
@ -25199,11 +25201,12 @@ was attached to a program. The @var{id} field contains the
|
||||||
@value{GDBN} identifier of the thread group. The @var{pid} field
|
@value{GDBN} identifier of the thread group. The @var{pid} field
|
||||||
contains process identifier, specific to the operating system.
|
contains process identifier, specific to the operating system.
|
||||||
|
|
||||||
@itemx =thread-group-exited,id="@var{id}"
|
@item =thread-group-exited,id="@var{id}"[,exit-code="@var{code}"]
|
||||||
A thread group is no longer associated with a running program,
|
A thread group is no longer associated with a running program,
|
||||||
either because the program has exited, or because it was detached
|
either because the program has exited, or because it was detached
|
||||||
from. The @var{id} field contains the @value{GDBN} identifier of the
|
from. The @var{id} field contains the @value{GDBN} identifier of the
|
||||||
thread group.
|
thread group. @var{code} is the exit code of the inferior; it exists
|
||||||
|
only when the inferior exited with some code.
|
||||||
|
|
||||||
@item =thread-created,id="@var{id}",group-id="@var{gid}"
|
@item =thread-created,id="@var{id}",group-id="@var{gid}"
|
||||||
@itemx =thread-exited,id="@var{id}",group-id="@var{gid}"
|
@itemx =thread-exited,id="@var{id}",group-id="@var{gid}"
|
||||||
|
|
|
@ -281,6 +281,9 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
|
||||||
inf->vfork_parent->vfork_child = NULL;
|
inf->vfork_parent->vfork_child = NULL;
|
||||||
inf->vfork_parent = NULL;
|
inf->vfork_parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inf->has_exit_code = 0;
|
||||||
|
inf->exit_code = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -517,6 +517,11 @@ struct inferior
|
||||||
/* Private data used by the target vector implementation. */
|
/* Private data used by the target vector implementation. */
|
||||||
struct private_inferior *private;
|
struct private_inferior *private;
|
||||||
|
|
||||||
|
/* HAS_EXIT_CODE is true if the inferior exited with an exit code.
|
||||||
|
In this case, the EXIT_CODE field is also valid. */
|
||||||
|
int has_exit_code;
|
||||||
|
LONGEST exit_code;
|
||||||
|
|
||||||
/* We keep a count of the number of times the user has requested a
|
/* We keep a count of the number of times the user has requested a
|
||||||
particular syscall to be tracked, and pass this information to the
|
particular syscall to be tracked, and pass this information to the
|
||||||
target. This lets capable targets implement filtering directly. */
|
target. This lets capable targets implement filtering directly. */
|
||||||
|
|
|
@ -3308,6 +3308,11 @@ handle_inferior_event (struct execution_control_state *ecs)
|
||||||
that the user can inspect this again later. */
|
that the user can inspect this again later. */
|
||||||
set_internalvar_integer (lookup_internalvar ("_exitcode"),
|
set_internalvar_integer (lookup_internalvar ("_exitcode"),
|
||||||
(LONGEST) ecs->ws.value.integer);
|
(LONGEST) ecs->ws.value.integer);
|
||||||
|
|
||||||
|
/* Also record this in the inferior itself. */
|
||||||
|
current_inferior ()->has_exit_code = 1;
|
||||||
|
current_inferior ()->exit_code = (LONGEST) ecs->ws.value.integer;
|
||||||
|
|
||||||
gdb_flush (gdb_stdout);
|
gdb_flush (gdb_stdout);
|
||||||
target_mourn_inferior ();
|
target_mourn_inferior ();
|
||||||
singlestep_breakpoints_inserted_p = 0;
|
singlestep_breakpoints_inserted_p = 0;
|
||||||
|
|
|
@ -366,8 +366,14 @@ mi_inferior_exit (struct inferior *inf)
|
||||||
struct mi_interp *mi = top_level_interpreter_data ();
|
struct mi_interp *mi = top_level_interpreter_data ();
|
||||||
|
|
||||||
target_terminal_ours ();
|
target_terminal_ours ();
|
||||||
fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"",
|
if (inf->has_exit_code)
|
||||||
inf->num);
|
fprintf_unfiltered (mi->event_channel,
|
||||||
|
"thread-group-exited,id=\"i%d\",exit-code=\"%s\"",
|
||||||
|
inf->num, int_string (inf->exit_code, 8, 0, 0, 1));
|
||||||
|
else
|
||||||
|
fprintf_unfiltered (mi->event_channel,
|
||||||
|
"thread-group-exited,id=\"i%d\"", inf->num);
|
||||||
|
|
||||||
gdb_flush (mi->event_channel);
|
gdb_flush (mi->event_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ typedef struct
|
||||||
} event_object;
|
} event_object;
|
||||||
|
|
||||||
extern int emit_continue_event (ptid_t ptid);
|
extern int emit_continue_event (ptid_t ptid);
|
||||||
extern int emit_exited_event (LONGEST exit_code);
|
extern int emit_exited_event (const LONGEST *exit_code);
|
||||||
|
|
||||||
extern int evpy_emit_event (PyObject *event,
|
extern int evpy_emit_event (PyObject *event,
|
||||||
eventregistry_object *registry);
|
eventregistry_object *registry);
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
static PyTypeObject exited_event_object_type;
|
static PyTypeObject exited_event_object_type;
|
||||||
|
|
||||||
PyObject *
|
static PyObject *
|
||||||
create_exited_event_object (LONGEST exit_code)
|
create_exited_event_object (const LONGEST *exit_code)
|
||||||
{
|
{
|
||||||
PyObject *exited_event;
|
PyObject *exited_event;
|
||||||
|
|
||||||
|
@ -31,9 +31,10 @@ create_exited_event_object (LONGEST exit_code)
|
||||||
if (!exited_event)
|
if (!exited_event)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (evpy_add_attribute (exited_event,
|
if (exit_code
|
||||||
"exit_code",
|
&& evpy_add_attribute (exited_event,
|
||||||
PyLong_FromLongLong (exit_code)) < 0)
|
"exit_code",
|
||||||
|
PyLong_FromLongLong (*exit_code)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
return exited_event;
|
return exited_event;
|
||||||
|
@ -47,7 +48,7 @@ create_exited_event_object (LONGEST exit_code)
|
||||||
will create a new Python exited event object. */
|
will create a new Python exited event object. */
|
||||||
|
|
||||||
int
|
int
|
||||||
emit_exited_event (LONGEST exit_code)
|
emit_exited_event (const LONGEST *exit_code)
|
||||||
{
|
{
|
||||||
PyObject *event;
|
PyObject *event;
|
||||||
|
|
||||||
|
|
|
@ -112,18 +112,14 @@ static void
|
||||||
python_inferior_exit (struct inferior *inf)
|
python_inferior_exit (struct inferior *inf)
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
LONGEST exit_code = -1;
|
const LONGEST *exit_code = NULL;
|
||||||
ptid_t ptidp;
|
|
||||||
struct target_waitstatus status;
|
|
||||||
|
|
||||||
cleanup = ensure_python_env (target_gdbarch, current_language);
|
cleanup = ensure_python_env (target_gdbarch, current_language);
|
||||||
|
|
||||||
get_last_target_status (&ptidp, &status);
|
if (inf->has_exit_code)
|
||||||
|
exit_code = &inf->exit_code;
|
||||||
|
|
||||||
exit_code = status.value.integer;
|
if (emit_exited_event (exit_code) < 0)
|
||||||
|
|
||||||
if (exit_code >= 0
|
|
||||||
&& emit_exited_event (exit_code) < 0)
|
|
||||||
gdbpy_print_stack ();
|
gdbpy_print_stack ();
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
|
|
Loading…
Reference in a new issue