diff options
author | Joel Brobecker <brobecker@gnat.com> | 2004-05-24 23:48:25 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2004-05-24 23:48:25 +0000 |
commit | a4d5f2e026acb7ad8bc82b3fa659edb60b51b100 (patch) | |
tree | f4eba63f5c364f6ca994ade743ec3355857b09f9 /gdb | |
parent | d34436e841271678f30b83e20f1521242a8572c7 (diff) | |
download | gdb-a4d5f2e026acb7ad8bc82b3fa659edb60b51b100.zip gdb-a4d5f2e026acb7ad8bc82b3fa659edb60b51b100.tar.gz gdb-a4d5f2e026acb7ad8bc82b3fa659edb60b51b100.tar.bz2 |
* infcmd.c (kill_if_already_running): New function, extracted
from run_command().
(run_command): Replace extracted code by call to
kill_if_already_running().
(start_command): New function.
(_initialize_infcmd): Add "start" command.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/infcmd.c | 52 |
2 files changed, 55 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 022b359..d04cd66 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2004-05-24 Joel Brobecker <brobecker@gnat.com> + + * infcmd.c (kill_if_already_running): New function, extracted + from run_command(). + (run_command): Replace extracted code by call to + kill_if_already_running(). + (start_command): New function. + (_initialize_infcmd): Add "start" command. + 2004-05-24 Mark Kettenis <kettenis@gnu.org> Add OpenBSD/m88k support. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a1a8ac3..d1a4af1 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -375,13 +375,14 @@ tty_command (char *file, int from_tty) inferior_io_terminal = savestring (file, strlen (file)); } -static void -run_command (char *args, int from_tty) -{ - char *exec_file; - - dont_repeat (); +/* Kill the inferior if already running. This function is designed + to be called when we are about to start the execution of the program + from the beginning. Ask the user to confirm that he wants to restart + the program being debugged when FROM_TTY is non-null. */ +void +kill_if_already_running (int from_tty) +{ if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { if (from_tty @@ -394,7 +395,16 @@ Start it from the beginning? ")) #endif init_wait_for_inferior (); } +} + +static void +run_command (char *args, int from_tty) +{ + char *exec_file; + dont_repeat (); + + kill_if_already_running (from_tty); clear_breakpoint_hit_counts (); /* Purge old solib objfiles. */ @@ -481,6 +491,29 @@ run_no_args_command (char *args, int from_tty) } +/* Start the execution of the program up until the beginning of the main + program. */ + +static void +start_command (char *args, int from_tty) +{ + /* Some languages such as Ada need to search inside the program + minimal symbols for the location where to put the temporary + breakpoint before starting. */ + 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); +} + void continue_command (char *proc_count_exp, int from_tty) { @@ -2144,6 +2177,13 @@ use \"set args\" without arguments."); add_com ("R", class_run, run_no_args_command, "Start debugged program with no arguments."); + c = add_com ("start", class_run, start_command, + "\ +Run the debugged program until the beginning of the main procedure.\n\ +You may specify arguments to give to your program, just as with the\n\ +\"run\" command."); + set_cmd_completer (c, filename_completer); + add_com ("interrupt", class_run, interrupt_target_command, "Interrupt the execution of the debugged program."); |