* 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:
Tom Tromey 2011-06-03 15:32:44 +00:00
parent 8ddd9a20a7
commit 8cf64490f2
10 changed files with 59 additions and 20 deletions

View file

@ -112,18 +112,14 @@ static void
python_inferior_exit (struct inferior *inf)
{
struct cleanup *cleanup;
LONGEST exit_code = -1;
ptid_t ptidp;
struct target_waitstatus status;
const LONGEST *exit_code = NULL;
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 (exit_code >= 0
&& emit_exited_event (exit_code) < 0)
if (emit_exited_event (exit_code) < 0)
gdbpy_print_stack ();
do_cleanups (cleanup);