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 | |
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')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/NEWS | 5 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 10 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 54 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-start.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-start.exp | 47 |
8 files changed, 151 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 53359dd..1f88eb6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2013-10-04 Joel Brobecker <brobecker@adacore.com> + + * 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. + 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. @@ -137,6 +137,11 @@ show range-stepping -stack-list-variables now accept an option "--skip-unavailable". When used, only the available locals or arguments are displayed. + ** The -exec-run command now accepts an optional "--start" option. + When used, the command follows the same semantics as the "start" + command, stopping the program's execution at the start of its + main subprogram. + * New system-wide configuration scripts A GDB installation now provides scripts suitable for use as system-wide configuration scripts for the following systems: diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 705af69..04e291b 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2013-10-04 Joel Brobecker <brobecker@adacore.com> + + * gdb.texinfo (GDB/MI Program Execution): Document "-exec-run"'s + new "--start" option. + 2013-10-02 Pedro Alves <palves@redhat.com> * gdb.texinfo (Registers): Expand description of saved registers diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index cf6f7d3..a68556b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -31057,7 +31057,7 @@ fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@} @subsubheading Synopsis @smallexample - -exec-run [--all | --thread-group N] + -exec-run [ --all | --thread-group N ] [ --start ] @end smallexample Starts execution of the inferior from the beginning. The inferior @@ -31065,11 +31065,17 @@ executes until either a breakpoint is encountered or the program exits. In the latter case the output will include an exit code, if the program has exited exceptionally. -When no option is specified, the current inferior is started. If the +When neither the @samp{--all} nor the @samp{--thread-group} option +is specified, the current inferior is started. If the @samp{--thread-group} option is specified, it should refer to a thread group of type @samp{process}, and that thread group will be started. If the @samp{--all} option is specified, then all inferiors will be started. +Using the @samp{--start} option instructs the debugger to stop +the execution at the start of the inferior's main subprogram, +following the same behavior as the @code{start} command +(@pxref{Starting}). + @subsubheading @value{GDBN} Command The corresponding @value{GDBN} command is @samp{run}. 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); } } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 991e677..4f07777 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-10-04 Joel Brobecker <brobecker@adacore.com> + + * gdb.mi/mi-start.c, gdb.mi/mi-start.exp: New files. + 2013-10-02 Vidya Praveen <vidyapraveen@arm.com> * gdb.trace/entry-values.exp: Modify regular expression to scan for diff --git a/gdb/testsuite/gdb.mi/mi-start.c b/gdb/testsuite/gdb.mi/mi-start.c new file mode 100644 index 0000000..13d1ac2 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-start.c @@ -0,0 +1,22 @@ +/* Copyright 2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.mi/mi-start.exp b/gdb/testsuite/gdb.mi/mi-start.exp new file mode 100644 index 0000000..98dfef4 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-start.exp @@ -0,0 +1,47 @@ +# Copyright 2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +# The purpose of this testcase is to test the --start option of +# the -exec-run command. If we cannot use the -exec-run command, +# then there is no point in running this testcase... +if [target_info exists use_gdb_stub] { + untested "cannot use -exec-run command" + return -1 +} + +gdb_exit +if [mi_gdb_start] { + continue +} + +standard_testfile mi-start.c + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "could not build mi-start" + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_run_cmd "--start" +mi_expect_stop "breakpoint-hit" "main" "" ".*mi-start.c" "$decimal" \ +{ "" "disp=\"del\"" } "run to main" + |