From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13174 invoked by alias); 11 Sep 2003 20:11:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 13161 invoked from network); 11 Sep 2003 20:11:45 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 11 Sep 2003 20:11:45 -0000 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 6200180034C; Thu, 11 Sep 2003 16:11:45 -0400 (EDT) Message-ID: <3F60D701.8060200@redhat.com> Date: Thu, 11 Sep 2003 20:11:00 -0000 From: "J. Johnston" Organization: Red Hat Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Cagney Cc: Daniel Jacobowitz , gdb-patches@sources.redhat.com Subject: Re: RFC: fix problems with errors during quitting (killed.exp) References: <3F58B193.5090400@redhat.com> <20030905155833.GA27258@nevyn.them.org> <3F5F6F2C.2030403@redhat.com> In-Reply-To: <3F5F6F2C.2030403@redhat.com> Content-Type: multipart/mixed; boundary="------------010109080001020405070209" X-SW-Source: 2003-09/txt/msg00246.txt.bz2 This is a multi-part message in MIME format. --------------010109080001020405070209 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2622 Andrew Cagney wrote: >>> My new strategy is to intercept error() calls during quitting. >>> Basically, >>> a simple get/set function is set up to denote when we the user has >>> confirmed >>> a quit. >> >> >> >> My immediate concern is, does killed.exp leave a stopped binary around? >> >> Other than that I like it. > > > I feel ill. > I'm sorry to hear that. > The first bug is in quit_force, so modifying throw_exeption to work > around it is a hack. quit_force needs to catch any errors thrown by the > target vector. > > Looking at the function's body. I think the first part: > >> /* 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); >> } > > > should still be allowed to error out. Otherwize something like: > > (gdb) exit bogus operand > > will quit gdb denying the user of an oportunity to enter the correct > command. The target calls and (I guess) the write_history should be > captured: > >> if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) >> { >> if (attach_flag) >> target_detach (args, from_tty); >> else >> target_kill (); >> } >> >> /* UDI wants this, to kill the TIP. */ >> target_close (1); >> >> /* Save the history information if it is appropriate to do so. */ >> if (write_history_p && history_filename) >> write_history (history_filename); > > > Also putting the do_final_cleanups inside the safety net would also > probably be for the best. > >> do_final_cleanups (ALL_CLEANUPS); /* Do any final cleanups >> before exiting > > Ok, your idea is much better. I have reworked the patch to use catch_errors(). I prepended the message "Quitting: " so users will know that even though there is an error message appended, it is still quitting. I could optionally have put "Error quitting: " but I thought the former was a better choice. New patch attached. 2003-09-11 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. Ok to commit? -- Jeff J. > > > > The second less urgent bug is in the target code. The target code > should catch the error and then force itself to be popped (then > rethrowing the error I guess). That would have ensured that forward > progress was made and that second quit attemt worked. > > Andrew > > --------------010109080001020405070209 Content-Type: text/plain; name="killed-patch2" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="killed-patch2" Content-length: 1834 Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.75 diff -u -r1.75 top.c --- top.c 16 Aug 2003 18:38:46 -0000 1.75 +++ top.c 11 Sep 2003 19:42:03 -0000 @@ -1439,28 +1439,25 @@ 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. */ @@ -1471,6 +1468,29 @@ write_history (history_filename); 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); } --------------010109080001020405070209--