summaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2013-10-04 08:35:29 +0000
committerJoel Brobecker <brobecker@gnat.com>2013-10-04 08:35:29 +0000
commit6957386a80c6432cf6fd3dec2b394a0dd836bac2 (patch)
tree058a541f9b4853e4cfa312bb92cc08f21da03458 /gdb/mi
parentd8de0472d930925e8a8bb8d8bfcd489f07c8a203 (diff)
downloadgdb-6957386a80c6432cf6fd3dec2b394a0dd836bac2.tar.gz
Add support for --start option in -exec-run GDB/MI command.
gdb/ChangeLog: * mi/mi-main.c (run_one_inferior): Add function description. Make ARG a pointer to an integer whose value determines whether we should "run" or "start" the program. (mi_cmd_exec_run): Add handling of the "--start" option. Reject all other command-line options. * NEWS: Add entry for "-exec-run"'s new "--start" option. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Program Execution): Document "-exec-run"'s new "--start" option. gdb/testsuite/ChangeLog: * gdb.mi/mi-start.c, gdb.mi/mi-start.exp: New files.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-main.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index ea31367a825..24ac1e0751b 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -364,9 +364,19 @@ mi_cmd_exec_interrupt (char *command, char **argv, int argc)
}
}
+/* Callback for iterate_over_inferiors which starts the execution
+ of the given inferior.
+
+ ARG is a pointer to an integer whose value, if non-zero, indicates
+ that the program should be stopped when reaching the main subprogram
+ (similar to what the CLI "start" command does). */
+
static int
run_one_inferior (struct inferior *inf, void *arg)
{
+ int start_p = *(int *) arg;
+ const char *run_cmd = start_p ? "start" : "run";
+
if (inf->pid != 0)
{
if (inf->pid != ptid_get_pid (inferior_ptid))
@@ -386,7 +396,7 @@ run_one_inferior (struct inferior *inf, void *arg)
switch_to_thread (null_ptid);
set_current_program_space (inf->pspace);
}
- mi_execute_cli_command ("run", target_can_async_p (),
+ mi_execute_cli_command (run_cmd, target_can_async_p (),
target_can_async_p () ? "&" : NULL);
return 0;
}
@@ -394,16 +404,54 @@ run_one_inferior (struct inferior *inf, void *arg)
void
mi_cmd_exec_run (char *command, char **argv, int argc)
{
+ int i;
+ int start_p = 0;
+
+ /* Parse the command options. */
+ enum opt
+ {
+ START_OPT,
+ };
+ static const struct mi_opt opts[] =
+ {
+ {"-start", START_OPT, 0},
+ {NULL, 0, 0},
+ };
+
+ int oind = 0;
+ char *oarg;
+
+ while (1)
+ {
+ int opt = mi_getopt ("-exec-run", argc, argv, opts, &oind, &oarg);
+
+ if (opt < 0)
+ break;
+ switch ((enum opt) opt)
+ {
+ case START_OPT:
+ start_p = 1;
+ break;
+ }
+ }
+
+ /* This command does not accept any argument. Make sure the user
+ did not provide any. */
+ if (oind != argc)
+ error (_("Invalid argument: %s"), argv[oind]);
+
if (current_context->all)
{
struct cleanup *back_to = save_current_space_and_thread ();
- iterate_over_inferiors (run_one_inferior, NULL);
+ iterate_over_inferiors (run_one_inferior, &start_p);
do_cleanups (back_to);
}
else
{
- mi_execute_cli_command ("run", target_can_async_p (),
+ const char *run_cmd = start_p ? "start" : "run";
+
+ mi_execute_cli_command (run_cmd, target_can_async_p (),
target_can_async_p () ? "&" : NULL);
}
}