diff options
author | Joel Brobecker <brobecker@gnat.com> | 2013-10-04 08:35:31 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2013-10-04 08:35:31 +0000 |
commit | 5713b9b5c1cb873d65caba98616e3f9d92db11f6 (patch) | |
tree | d799d2878722ee6901a9fa3e86f181542ebc54d9 /gdb/mi | |
parent | f48ff2a7d3f69653dbf164e03d3397de8f6ba7c0 (diff) | |
download | gdb-5713b9b5c1cb873d65caba98616e3f9d92db11f6.zip gdb-5713b9b5c1cb873d65caba98616e3f9d92db11f6.tar.gz gdb-5713b9b5c1cb873d65caba98616e3f9d92db11f6.tar.bz2 |
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.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index ea31367..24ac1e0 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); } } |