From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23233 invoked by alias); 8 Mar 2005 21:28:36 -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 23048 invoked from network); 8 Mar 2005 21:28:23 -0000 Received: from unknown (HELO priv-edtnes57.telusplanet.net) (199.185.220.220) by sourceware.org with SMTP; 8 Mar 2005 21:28:23 -0000 Received: from takamaka.act-europe.fr ([154.20.104.226]) by priv-edtnes57.telusplanet.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050308212822.YWIZ22106.priv-edtnes57.telusplanet.net@takamaka.act-europe.fr> for ; Tue, 8 Mar 2005 14:28:22 -0700 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id BC96047DC0; Tue, 8 Mar 2005 13:28:16 -0800 (PST) Date: Tue, 08 Mar 2005 21:28:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFA] re-read symbols before "start"-ing... Message-ID: <20050308212816.GF1113@adacore.com> References: <20050308064529.GB18053@adacore.com> <20050308134809.GE7417@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" Content-Disposition: inline In-Reply-To: <20050308134809.GE7417@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2005-03/txt/msg00125.txt.bz2 --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2232 > > 2005-03-07 Joel Brobecker > > > > * infcmd.c (start_command): Make sure the symbols are up to date > > before setting the temporary breakpoint. > > Just my two cents, but I think you may want to add an argument to > run_command, instead, and create the breakpoint there. For instance > there's probably a case where you'll need reopen_exec_file (). And > reread_symbols is passably expensive - lots of stat(). I wasn't too concerned about the expensiveness of reread_symbols, because I think the "start" command is used only once in a while, so the performance hit should be only occasional. I was also hoping, but this is only guessing game on my part, that the system would cache theses operations so that the next stat operations are made from memory, and hence be very fast. However, I see your point with reopen_exec_file(), though. How about the following patch? Because run_command is used as a callback for the "run" command, I couldn't change its profile, so instead I extracted its body into run_command_1, and added the extra parameter there. On my first try, I was a bit silly, because I made this parameter a char * containing the location of the temporary breakpoint. I then called this procedure like this (in start_command()): run_command_1 (args, from_tty, main_name()); Which doesn't work, since we still end up calling main_main() before we have verified whether symbols should be reread or not. So instead, I settled for a flag. And we get to simplify start_command() a bit, by removing some code that is no longer needed (the call to kill_if_already_running()). 2005-03-08 Joel Brobecker * infcmd.c (run_command_1): New function, extracted from run_command. (run_command): Replace implementation by call to run_command_1. (start_command): Use run_command_1 to insert the temporary breakpoint and run the program. Remove code that's no longer needed, as already done at the proper time by run_command_1. Tested on x86-linux, no regression. I have a testcase that I will submit shortly that used to fail before the change, and passes after. OK to apply? Thanks, -- Joel --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="restart.diff" Content-length: 1976 Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.134 diff -u -p -r1.134 infcmd.c --- infcmd.c 21 Feb 2005 03:25:56 -0000 1.134 +++ infcmd.c 8 Mar 2005 21:13:23 -0000 @@ -400,8 +400,12 @@ Start it from the beginning? ")) } } +/* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert + a temporary breakpoint at the begining of the main program before + running the program. */ + static void -run_command (char *args, int from_tty) +run_command_1 (char *args, int from_tty, int tbreak_at_main) { char *exec_file; @@ -425,6 +429,10 @@ run_command (char *args, int from_tty) reopen_exec_file (); reread_symbols (); + /* Insert the temporary breakpoint if a location was specified. */ + if (tbreak_at_main) + tbreak_command (main_name (), 0); + exec_file = (char *) get_exec_file (0); /* We keep symbols from add-symbol-file, on the grounds that the @@ -487,6 +495,12 @@ run_command (char *args, int from_tty) static void +run_command (char *args, int from_tty) +{ + run_command_1 (args, from_tty, 0); +} + +static void run_no_args_command (char *args, int from_tty) { char *old_args = set_inferior_args (xstrdup ("")); @@ -506,15 +520,8 @@ start_command (char *args, int from_tty) if (!have_minimal_symbols ()) error (_("No symbol table loaded. Use the \"file\" command.")); - /* If the inferior is already running, we want to ask the user if we - should restart it or not before we insert the temporary breakpoint. - This makes sure that this command doesn't have any side effect if - the user changes its mind. */ - kill_if_already_running (from_tty); - - /* Insert the temporary breakpoint, and run... */ - tbreak_command (main_name (), 0); - run_command (args, from_tty); + /* Run the program until reaching the main procedure... */ + run_command_1 (args, from_tty, 1); } void --wac7ysb48OaltWcw--