From: Jeff Johnston Date: Fri, 12 Sep 2003 15:37:03 +0000 (+0000) Subject: 2003-09-12 Jeff Johnston X-Git-Tag: gdb_6_0-2003-10-04-release~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfc9f70c619cf1e02c2dc29c413cc6ada0a05aed;p=thirdparty%2Fbinutils-gdb.git 2003-09-12 Jeff Johnston * top.c (quit_target): New static helper function. (quit_force): Moved code to quit_target(). Call quit_target() via catch_errors() to catch errors during quit. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ea86ab5f52b..236bcdf9bf6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-09-12 Jeff Johnston + + * top.c (quit_target): New static helper function. + (quit_force): Moved code to quit_target(). Call quit_target() + via catch_errors() to catch errors during quit. + 2003-09-11 Daniel Jacobowitz * dwarf2loc.c (dwarf2_loc_desc_needs_frame): Variables in a diff --git a/gdb/top.c b/gdb/top.c index 3efebecb3ec..b174b33f362 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1693,28 +1693,25 @@ quit_confirm (void) return 1; } -/* Quit without asking for confirmation. */ +/* Helper routine for quit_force that requires error handling. */ -void -quit_force (char *args, int from_tty) +struct qt_args { - int exit_code = 0; - - /* An optional expression may be used to cause gdb to terminate with the - value of that expression. */ - if (args) - { - struct value *val = parse_and_eval (args); + char *args; + int from_tty; +}; - exit_code = (int) value_as_long (val); - } +static int +quit_target (void *arg) +{ + struct qt_args *qt = (struct qt_args *)arg; if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { if (attach_flag) - target_detach (args, from_tty); + target_detach (qt->args, qt->from_tty); else - target_kill (); + target_kill (); } /* UDI wants this, to kill the TIP. */ @@ -1726,6 +1723,29 @@ quit_force (char *args, int from_tty) do_final_cleanups (ALL_CLEANUPS); /* Do any final cleanups before exiting */ + return 0; +} + +/* Quit without asking for confirmation. */ + +void +quit_force (char *args, int from_tty) +{ + int exit_code = 0; + + /* An optional expression may be used to cause gdb to terminate with the + value of that expression. */ + if (args) + { + struct value *val = parse_and_eval (args); + + exit_code = (int) value_as_long (val); + } + + /* We want to handle any quit errors and exit regardless. */ + catch_errors (quit_target, args, + "Quitting: ", RETURN_MASK_ALL); + exit (exit_code); }