From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13512 invoked by alias); 2 Aug 2013 17:22:54 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 13479 invoked by uid 306); 2 Aug 2013 17:22:54 -0000 Date: Fri, 02 Aug 2013 17:22:00 -0000 Message-ID: <20130802172254.13451.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/catch-exit: set $_exitcode when exiting X-Git-Refname: refs/heads/tromey/catch-exit X-Git-Reftype: branch X-Git-Oldrev: 385be8429c1bce524f7b2fcb284e92ed396eb472 X-Git-Newrev: 921b251ae9c48ae12273bfe3f742d190c0514fc6 X-SW-Source: 2013-q3/txt/msg00017.txt.bz2 List-Id: The branch, tromey/catch-exit has been updated via 921b251ae9c48ae12273bfe3f742d190c0514fc6 (commit) from 385be8429c1bce524f7b2fcb284e92ed396eb472 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 921b251ae9c48ae12273bfe3f742d190c0514fc6 Author: Tom Tromey Date: Fri Aug 2 11:19:02 2013 -0600 set $_exitcode when exiting this sets $_exitcode when TARGET_WAITKIND_EXITING is handled note that this will have to be redone when the $_exitcode change goes in ----------------------------------------------------------------------- Summary of changes: gdb/inferior.c | 14 ++++++++++++++ gdb/inferior.h | 3 +++ gdb/infrun.c | 11 ++--------- 3 files changed, 19 insertions(+), 9 deletions(-) First 500 lines of diff: diff --git a/gdb/inferior.c b/gdb/inferior.c index b9e9a8d..eef22ba 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -237,6 +237,20 @@ delete_inferior_silent (int pid) delete_inferior_1 (inf, 1); } +/* Set the inferior's exit code and $_exitcode as well. Note that it + is ok to set it more than once. For example we might see a "catch + exit" event and then a real exit. */ + +void +set_inferior_exit_code (struct inferior *inf, LONGEST code) +{ + /* Record the exit code in the convenience variable $_exitcode, so + that the user can inspect this again later. */ + set_internalvar_integer (lookup_internalvar ("_exitcode"), code); + + inf->has_exit_code = 1; + inf->exit_code = code; +} /* If SILENT then be quiet -- don't announce a inferior exit, or the exit of its threads. */ diff --git a/gdb/inferior.h b/gdb/inferior.h index 2a5770d..e312494 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -526,6 +526,9 @@ DECLARE_REGISTRY (inferior); /* Create an empty inferior list, or empty the existing one. */ extern void init_inferior_list (void); +/* Set inferior's exit code. */ +extern void set_inferior_exit_code (struct inferior *inf, LONGEST code); + /* Add an inferior to the inferior list, print a message that a new inferior is found, and return the pointer to the new inferior. Caller may use this pointer to initialize the private inferior diff --git a/gdb/infrun.c b/gdb/infrun.c index 31bd51f..f72a04b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3423,15 +3423,7 @@ handle_inferior_event (struct execution_control_state *ecs) if (ecs->ws.kind == TARGET_WAITKIND_EXITED) { - /* Record the exit code in the convenience variable $_exitcode, so - that the user can inspect this again later. */ - set_internalvar_integer (lookup_internalvar ("_exitcode"), - (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; - + set_inferior_exit_code (current_inferior (), ecs->ws.value.integer); print_exited_reason (ecs->ws.value.integer); } else @@ -3690,6 +3682,7 @@ handle_inferior_event (struct execution_control_state *ecs) goto process_event_stop_test; case TARGET_WAITKIND_EXITING: + set_inferior_exit_code (current_inferior (), ecs->ws.value.integer); if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_EXITING\n"); ecs->event_thread->control.stop_bpstat hooks/post-receive -- Repository for Project Archer.