This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] Add support for --start option in -exec-run GDB/MI command.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 1 Oct 2013 11:12:43 +0200
- Subject: [RFC] Add support for --start option in -exec-run GDB/MI command.
- Authentication-results: sourceware.org; auth=none
Hello,
We'd like to be able to do the equivalent of the "start" command
using the GDB/MI interpreter. For this, I propose the addition
of the --start command-line option to the -exec-run command.
Attached is first try at its implementation. This is just an RFC,
just in case another interface to this feature gets prefered.
Once we've settled on that, I'll finalize the implementation
as well as provide documentation + NEWS.
Thoughts?
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.
Tested on x86_64-linux.
Thanks,
--
Joel
---
gdb/mi/mi-main.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index e8c4744..73454e9 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;
+ 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,29 @@ 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;
+
+ for (i = 0; i < argc; i++)
+ {
+ if (strcmp (argv[i], "--start") == 0)
+ start_p = 1;
+ else
+ error (_("invalid option '%s'"), argv[i]);
+ }
+
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 (),
+ char *run_cmd = start_p ? "start" : "run";
+
+ mi_execute_cli_command (run_cmd, target_can_async_p (),
target_can_async_p () ? "&" : NULL);
}
}
--
1.8.1.2