aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/bg-execution-repeat.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-10-17 13:31:26 +0100
committerPedro Alves <palves@redhat.com>2014-10-17 13:34:16 +0100
commit6c4486e63f7583ed85a0c72841f6ccceebbf858e (patch)
tree02307265129b92c560eea444a06f25d409959bf7 /gdb/testsuite/gdb.base/bg-execution-repeat.c
parent0ff33695eeedf3c2e8cdec8690ae4a10a66b3389 (diff)
downloadgdb-6c4486e63f7583ed85a0c72841f6ccceebbf858e.zip
gdb-6c4486e63f7583ed85a0c72841f6ccceebbf858e.tar.gz
gdb-6c4486e63f7583ed85a0c72841f6ccceebbf858e.tar.bz2
PR gdb/17471: Repeating a background command makes it foreground
When we repeat a command, by just pressing <ret>, the input from the previous command is reused for the new command invocation. When an execution command strips the "&" out of its incoming argument string, to detect background execution, we poke a '\0' directly to the incoming argument string. Combine both, and a repeat of a background command loses the "&". This is actually only visible if args other than "&" are specified (e.g., "c 1&" or "next 2&" or "c -a&"), as in the special case of "&" alone (e.g. "c&") doesn't actually clobber the incoming string. Fix this by making strip_bg_char return a new string instead of poking a hole in the input string. New test included. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2014-10-17 Pedro Alves <palves@redhat.com> PR gdb/17471 * infcmd.c (strip_bg_char): Change prototype and rewrite. Now returns a copy of the input. (run_command_1, continue_command, step_1, jump_command) (signal_command, until_command, advance_command, finish_command) (attach_command): Adjust and install a cleanup to free the stripped args. gdb/testsuite/ 2014-10-17 Pedro Alves <palves@redhat.com> PR gdb/17471 * gdb.base/bg-execution-repeat.c: New file. * gdb.base/bg-execution-repeat.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.base/bg-execution-repeat.c')
-rw-r--r--gdb/testsuite/gdb.base/bg-execution-repeat.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c
new file mode 100644
index 0000000..26ab997
--- /dev/null
+++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014 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/>. */
+
+#include <unistd.h>
+
+int
+foo (void)
+{
+ return 0; /* set break here */
+}
+
+int
+main (void)
+{
+ foo ();
+ sleep (5);
+ foo ();
+ return 0;
+}