PR gdb/17471: Repeating a background command makes it foreground
authorPedro Alves <palves@redhat.com>
Fri, 17 Oct 2014 12:31:26 +0000 (13:31 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 17 Oct 2014 12:34:16 +0000 (13:34 +0100)
commit6c4486e63f7583ed85a0c72841f6ccceebbf858e
tree02307265129b92c560eea444a06f25d409959bf7
parent0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
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.
gdb/ChangeLog
gdb/infcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/bg-execution-repeat.c [new file with mode: 0644]
gdb/testsuite/gdb.base/bg-execution-repeat.exp [new file with mode: 0644]