Skip to content

Commit

Permalink
create command
Browse files Browse the repository at this point in the history
  • Loading branch information
palves committed Apr 10, 2012
1 parent 014d62f commit be1bc6c
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions gdb/infcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,19 @@ Start it from the beginning? ")))
}
}

enum run_cmd
{
run_mode,
start_mode,
create_mode
};

/* 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_1 (char *args, int from_tty, int tbreak_at_main)
run_command_1 (char *args, int from_tty, enum run_cmd mode)
{
char *exec_file;
struct cleanup *old_chain;
Expand Down Expand Up @@ -525,15 +532,15 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
reopen_exec_file ();
reread_symbols ();

if (non_stop && !target_supports_non_stop ())
error (_("The target does not support running in non-stop mode."));

/* Insert the temporary breakpoint if a location was specified. */
if (tbreak_at_main)
if (mode == start_mode)
tbreak_command (main_name (), 0);

exec_file = (char *) get_exec_file (0);

if (non_stop && !target_supports_non_stop ())
error (_("The target does not support running in non-stop mode."));

/* We keep symbols from add-symbol-file, on the grounds that the
user might want to add some symbols before running the program
(right?). But sometimes (dynamic loading where the user manually
Expand Down Expand Up @@ -605,6 +612,13 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
has done its thing; now we are setting up the running program. */
post_create_inferior (&current_target, 0);

if (mode == create_mode)
{
do_cleanups (old_chain);
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
return;
}

/* Start the target running. Do not use -1 continuation as it would skip
breakpoint right at the entry point. */
proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
Expand All @@ -617,7 +631,7 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
static void
run_command (char *args, int from_tty)
{
run_command_1 (args, from_tty, 0);
run_command_1 (args, from_tty, run_mode);
}

static void
Expand All @@ -640,9 +654,15 @@ start_command (char *args, int from_tty)
error (_("No symbol table loaded. Use the \"file\" command."));

/* Run the program until reaching the main procedure... */
run_command_1 (args, from_tty, 1);
run_command_1 (args, from_tty, start_mode);
}

static void
create_command (char *args, int from_tty)
{
run_command_1 (args, from_tty, create_mode);
}

static int
proceed_thread_callback (struct thread_info *thread, void *arg)
{
Expand Down Expand Up @@ -3089,6 +3109,12 @@ You may specify arguments to give to your program, just as with the\n\
\"run\" command."));
set_cmd_completer (c, filename_completer);

c = add_com ("create", class_run, create_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.\n\
If non-stop mode is enabled, interrupt only the current thread,\n\
Expand Down

0 comments on commit be1bc6c

Please sign in to comment.