* [Bug cli/17300] crash in non-stop mode with continue -a & (readline_callback_read_char() called with no handler!)
2014-08-22 4:11 [Bug cli/17300] New: crash in non-stop mode with continue -a & (readline_callback_read_char() called with no handler!) dilyan.palauzov at aegee dot org
` (7 preceding siblings ...)
2014-10-09 15:51 ` palves at redhat dot com
@ 2014-10-17 12:47 ` cvs-commit at gcc dot gnu.org
2014-10-17 13:30 ` palves at redhat dot com
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-10-17 12:47 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=17300
--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, master has been updated
via 6c4486e63f7583ed85a0c72841f6ccceebbf858e (commit)
via 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389 (commit)
via 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b (commit)
via 5842f62aad5c20dbb3511208efbc40a8d638b6d3 (commit)
from 3f7308212cefe5cd958b29e0b9e92d92c4dbe941 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c4486e63f7583ed85a0c72841f6ccceebbf858e
commit 6c4486e63f7583ed85a0c72841f6ccceebbf858e
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
commit 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
commit 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5842f62aad5c20dbb3511208efbc40a8d638b6d3
commit 5842f62aad5c20dbb3511208efbc40a8d638b6d3
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16840-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 12:47:50 2014
Return-Path: <gdb-prs-return-16840-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 30566 invoked by alias); 17 Oct 2014 12:47:49 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 30524 invoked by uid 55); 17 Oct 2014 12:47:47 -0000
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17471] repeating a background command makes it foreground
Date: Fri, 17 Oct 2014 12:47:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cvs-commit at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-17471-4717-q8W9UjJXbk@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17471-4717@http.sourceware.org/bugzilla/>
References: <bug-17471-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00083.txt.bz2
Content-length: 15605
https://sourceware.org/bugzilla/show_bug.cgi?id=17471
--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, master has been updated
via 6c4486e63f7583ed85a0c72841f6ccceebbf858e (commit)
via 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389 (commit)
via 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b (commit)
via 5842f62aad5c20dbb3511208efbc40a8d638b6d3 (commit)
from 3f7308212cefe5cd958b29e0b9e92d92c4dbe941 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c4486e63f7583ed85a0c72841f6ccceebbf858e
commit 6c4486e63f7583ed85a0c72841f6ccceebbf858e
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
commit 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
commit 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5842f62aad5c20dbb3511208efbc40a8d638b6d3
commit 5842f62aad5c20dbb3511208efbc40a8d638b6d3
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16842-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 12:47:50 2014
Return-Path: <gdb-prs-return-16842-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 30682 invoked by alias); 17 Oct 2014 12:47:50 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 30539 invoked by uid 55); 17 Oct 2014 12:47:49 -0000
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17472] with annotations, input while executing in the
foreground crashes readline/gdb
Date: Fri, 17 Oct 2014 12:47:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cvs-commit at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-17472-4717-bQ4vWsSTn5@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17472-4717@http.sourceware.org/bugzilla/>
References: <bug-17472-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00084.txt.bz2
Content-length: 15605
https://sourceware.org/bugzilla/show_bug.cgi?id=17472
--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, master has been updated
via 6c4486e63f7583ed85a0c72841f6ccceebbf858e (commit)
via 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389 (commit)
via 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b (commit)
via 5842f62aad5c20dbb3511208efbc40a8d638b6d3 (commit)
from 3f7308212cefe5cd958b29e0b9e92d92c4dbe941 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c4486e63f7583ed85a0c72841f6ccceebbf858e
commit 6c4486e63f7583ed85a0c72841f6ccceebbf858e
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
commit 0ff33695eeedf3c2e8cdec8690ae4a10a66b3389
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
commit 6fdebc3d1c54d2202f7637e7345fe6d25c7ed93b
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5842f62aad5c20dbb3511208efbc40a8d638b6d3
commit 5842f62aad5c20dbb3511208efbc40a8d638b6d3
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16845-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 13:00:35 2014
Return-Path: <gdb-prs-return-16845-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 12222 invoked by alias); 17 Oct 2014 13:00:35 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 12093 invoked by uid 55); 17 Oct 2014 13:00:33 -0000
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17472] with annotations, input while executing in the
foreground crashes readline/gdb
Date: Fri, 17 Oct 2014 13:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cvs-commit at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-17472-4717-PaSZsNWqgf@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17472-4717@http.sourceware.org/bugzilla/>
References: <bug-17472-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00088.txt.bz2
Content-length: 15613
https://sourceware.org/bugzilla/show_bug.cgi?id=17472
--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, gdb-7.8-branch has been updated
via 36c57a3ceeb2260913f7d2d349e994dd844cbcae (commit)
via e37951dc10da6940ef354f062fc43ee03687c571 (commit)
via 04f0515702a6e5711d71203fcc0ea488161ba086 (commit)
via 92e08c0d191908b7315603558226c7ca0bfa86a5 (commit)
from e7366593996e36a8ac452fc4577725fe9c3556ca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=36c57a3ceeb2260913f7d2d349e994dd844cbcae
commit 36c57a3ceeb2260913f7d2d349e994dd844cbcae
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e37951dc10da6940ef354f062fc43ee03687c571
commit e37951dc10da6940ef354f062fc43ee03687c571
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04f0515702a6e5711d71203fcc0ea488161ba086
commit 04f0515702a6e5711d71203fcc0ea488161ba086
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=92e08c0d191908b7315603558226c7ca0bfa86a5
commit 92e08c0d191908b7315603558226c7ca0bfa86a5
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:49:28 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16843-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 13:00:33 2014
Return-Path: <gdb-prs-return-16843-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 12090 invoked by alias); 17 Oct 2014 13:00:33 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 12054 invoked by uid 55); 17 Oct 2014 13:00:31 -0000
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17471] repeating a background command makes it foreground
Date: Fri, 17 Oct 2014 13:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cvs-commit at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-17471-4717-2lsoD7P3TN@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17471-4717@http.sourceware.org/bugzilla/>
References: <bug-17471-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00086.txt.bz2
Content-length: 15613
https://sourceware.org/bugzilla/show_bug.cgi?id=17471
--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, gdb-7.8-branch has been updated
via 36c57a3ceeb2260913f7d2d349e994dd844cbcae (commit)
via e37951dc10da6940ef354f062fc43ee03687c571 (commit)
via 04f0515702a6e5711d71203fcc0ea488161ba086 (commit)
via 92e08c0d191908b7315603558226c7ca0bfa86a5 (commit)
from e7366593996e36a8ac452fc4577725fe9c3556ca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=36c57a3ceeb2260913f7d2d349e994dd844cbcae
commit 36c57a3ceeb2260913f7d2d349e994dd844cbcae
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e37951dc10da6940ef354f062fc43ee03687c571
commit e37951dc10da6940ef354f062fc43ee03687c571
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04f0515702a6e5711d71203fcc0ea488161ba086
commit 04f0515702a6e5711d71203fcc0ea488161ba086
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=92e08c0d191908b7315603558226c7ca0bfa86a5
commit 92e08c0d191908b7315603558226c7ca0bfa86a5
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:49:28 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16844-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 13:00:35 2014
Return-Path: <gdb-prs-return-16844-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 12146 invoked by alias); 17 Oct 2014 13:00:33 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 12088 invoked by uid 55); 17 Oct 2014 13:00:33 -0000
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug cli/17300] crash in non-stop mode with continue -a &
(readline_callback_read_char() called with no handler!)
Date: Fri, 17 Oct 2014 13:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: cli
X-Bugzilla-Version: 7.8
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cvs-commit at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-17300-4717-8eFDbncjHV@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17300-4717@http.sourceware.org/bugzilla/>
References: <bug-17300-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00087.txt.bz2
Content-length: 15614
https://sourceware.org/bugzilla/show_bug.cgi?id=17300
--- Comment #10 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".
The branch, gdb-7.8-branch has been updated
via 36c57a3ceeb2260913f7d2d349e994dd844cbcae (commit)
via e37951dc10da6940ef354f062fc43ee03687c571 (commit)
via 04f0515702a6e5711d71203fcc0ea488161ba086 (commit)
via 92e08c0d191908b7315603558226c7ca0bfa86a5 (commit)
from e7366593996e36a8ac452fc4577725fe9c3556ca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=36c57a3ceeb2260913f7d2d349e994dd844cbcae
commit 36c57a3ceeb2260913f7d2d349e994dd844cbcae
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:26 2014 +0100
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.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e37951dc10da6940ef354f062fc43ee03687c571
commit e37951dc10da6940ef354f062fc43ee03687c571
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17300: Input after "c -a" crashes readline/GDB
If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command. The result is that user input afterwards crashes
readline/gdb:
(gdb) start
Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c,
line 23.
Starting program: continue-all-already-running
Temporary breakpoint 1, main () at continue-all-already-running.c:23
23 sleep (10);
(gdb) c -a&
Continuing.
(gdb) c -a
Continuing.
p 1
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
Backtrace:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) p 1
$1 = 1
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
#2 0x0000000000784aa9 in rl_callback_read_char () at
readline/callback.c:116
#3 0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0)
at gdb/event-top.c:167
#4 0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0)
at gdb/event-top.c:373
#5 0x000000000061814a in handle_file_event (data=...) at
gdb/event-loop.c:763
#6 0x0000000000617631 in process_event () at gdb/event-loop.c:340
#7 0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
#8 0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
#9 0x00000000006191b3 in cli_command_loop (data=0x0) at
gdb/event-top.c:182
#10 0x000000000060f538 in current_interp_command_loop () at
gdb/interps.c:318
#11 0x0000000000610701 in captured_command_loop (data=0x0) at
gdb/main.c:323
#12 0x000000000060c3f5 in catch_errors (func=0x6106e6
<captured_command_loop>, func_args=0x0, errstring=0x9002c1 "",
mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at
gdb/main.c:1151
#14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>,
func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
at gdb/exceptions.c:237
#15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at
gdb/main.c:1159
#16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at
gdb/gdb.c:32
(top-gdb)
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04f0515702a6e5711d71203fcc0ea488161ba086
commit 04f0515702a6e5711d71203fcc0ea488161ba086
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:31:25 2014 +0100
PR gdb/17472: With annotations, input while executing in the foreground
crashes readline/GDB
Jan caught an intermittent GDB crash with the annota1.exp test:
Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
[...]
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
[...]
readline: readline_callback_read_char() called with no handler!^M
ERROR: Process no longer exists
All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running. E.g.:
(gdb) set annotate 2
▒▒pre-prompt
(gdb)
▒▒prompt
c
▒▒post-prompt
Continuing.
▒▒starting
▒▒frames-invalid
*inferior is running now*
p 1<ret>
readline: readline_callback_read_char() called with no handler!
Aborted (core dumped)
$
When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect. Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too. When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.
However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:
(top-gdb) bt
#0 0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
#1 0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
#2 0x0000000000594bb9 in registers_changed_ptid (ptid=...) at
gdb/regcache.c:612
#3 0x000000000064cca1 in target_resume (ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/target.c:2136
#4 0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at
gdb/infrun.c:2263
#5 0x00000000005f6051 in proceed (addr=18446744073709551615,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613
And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state. We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop. Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:
Program received signal SIGABRT, Aborted.
0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(top-gdb) bt
#0 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x0000003b36a36f68 in __GI_abort () at abort.c:89
During symbol reading, debug info gives source 9 included from file at
zero line 0.
During symbol reading, debug info gives command-line macro definition with
non-zero line 19: _STDC_PREDEF_H 1.
#2 0x0000000000784a25 in rl_callback_read_char () at
src/readline/callback.c:116
#3 0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0)
at src/gdb/event-top.c:167
#4 0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0)
at src/gdb/event-top.c:373
#5 0x00000000006180da in handle_file_event (data=...) at
src/gdb/event-loop.c:763
#6 0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
#7 0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
#8 0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
#9 0x0000000000619143 in cli_command_loop (data=0x0) at
src/gdb/event-top.c:182
#10 0x000000000060f4c8 in current_interp_command_loop () at
src/gdb/interps.c:318
#11 0x0000000000610691 in captured_command_loop (data=0x0) at
src/gdb/main.c:323
#12 0x000000000060c385 in catch_errors (func=0x610676
<captured_command_loop>, func_args=0x0, errstring=0x900241 "",
mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at
src/gdb/main.c:1151
#14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>,
func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
at src/gdb/exceptions.c:237
#15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at
src/gdb/main.c:1159
#16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at
src/gdb/gdb.c:32
The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.
While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.
New test included.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=92e08c0d191908b7315603558226c7ca0bfa86a5
commit 92e08c0d191908b7315603558226c7ca0bfa86a5
Author: Pedro Alves <palves@redhat.com>
Date: Fri Oct 17 13:49:28 2014 +0100
Make common code handle target_terminal_* idempotency
I found a place that should be giving back the terminal to the target,
but only if the target was already owning it. So I need to add a
getter for who owns the terminal.
The trouble is that several places/target have their own globals to
track this state:
- inflow.c:terminal_is_ours
- remote.c:remote_async_terminal_ours_p
- linux-nat.c:async_terminal_is_ours
- go32-nat.c:terminal_is_ours
While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal. There's only one GDB
(or rather, only one top level interpreter).
So what this comment does is add a new global that is tracked by the
core instead. A subsequent pass may later remove the other globals.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 42 +++++
gdb/annotate.c | 22 +++-
gdb/infcmd.c | 160 +++++++++++++-------
gdb/target.c | 64 ++++++++
gdb/target.h | 25 ++--
gdb/testsuite/ChangeLog | 18 +++
.../gdb.base/annota-input-while-running.c | 25 +++
.../gdb.base/annota-input-while-running.exp | 130 ++++++++++++++++
gdb/testsuite/gdb.base/bg-execution-repeat.c | 33 ++++
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 86 +++++++++++
.../gdb.base/continue-all-already-running.c | 25 +++
.../gdb.base/continue-all-already-running.exp | 79 ++++++++++
gdb/windows-nat.c | 2 +-
13 files changed, 642 insertions(+), 69 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.c
create mode 100644 gdb/testsuite/gdb.base/annota-input-while-running.exp
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.c
create mode 100644 gdb/testsuite/gdb.base/bg-execution-repeat.exp
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.c
create mode 100644 gdb/testsuite/gdb.base/continue-all-already-running.exp
--
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-16846-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri Oct 17 13:29:53 2014
Return-Path: <gdb-prs-return-16846-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 6655 invoked by alias); 17 Oct 2014 13:29:52 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 6632 invoked by uid 48); 17 Oct 2014 13:29:52 -0000
From: "palves at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17472] with annotations, input while executing in the
foreground crashes readline/gdb
Date: Fri, 17 Oct 2014 13:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: palves at redhat dot com
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: palves at redhat dot com
X-Bugzilla-Target-Milestone: 7.9
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: target_milestone
Message-ID: <bug-17472-4717-1N7VgkRAg4@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17472-4717@http.sourceware.org/bugzilla/>
References: <bug-17472-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-q4/txt/msg00089.txt.bz2
Content-length: 459
https://sourceware.org/bugzilla/show_bug.cgi?id\x17472
Pedro Alves <palves at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |7.9
--- Comment #5 from Pedro Alves <palves at redhat dot com> ---
Fixed, mainline and 7.8.1.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread