aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-01-23 11:12:39 +0000
committerPedro Alves <palves@redhat.com>2015-01-23 11:12:39 +0000
commit198297aafb4f7a9717be8370581b048ae9107c14 (patch)
tree8570ebf1a6777d3baac44cef0087494bf8288e57 /gdb/linux-nat.c
parentbbbbffbbfc3fca35649896d6626ab02581df8037 (diff)
downloadgdb-198297aafb4f7a9717be8370581b048ae9107c14.zip
gdb-198297aafb4f7a9717be8370581b048ae9107c14.tar.gz
gdb-198297aafb4f7a9717be8370581b048ae9107c14.tar.bz2
Linux: make target_is_async_p return false when async is off
linux_nat_is_async_p currently always returns true, even when the target is _not_ async. That confuses gdb_readline_wrapper/gdb_readline_wrapper_cleanup, which force-disables target-async while the secondary prompt is active. As a result, when gdb_readline_wrapper returns, the target is left async, even through it was sync to begin with. That can result in weird bugs, like the one the test added by this commit exposes. Ref: https://sourceware.org/ml/gdb-patches/2015-01/msg00592.html gdb/ChangeLog: 2015-01-23 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_is_async_p): New macro. (linux_nat_is_async_p): (linux_nat_terminal_inferior): Check whether the target can async instead of whether it is already async. (linux_nat_terminal_ours): Don't check whether the target is async. (linux_async_pipe): Use linux_is_async_p. gdb/testsuite/ChangeLog: 2015-01-23 Pedro Alves <palves@redhat.com> * gdb.threads/continue-pending-after-query.c: New file. * gdb.threads/continue-pending-after-query.exp: New file.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index be52470..b49cd57 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -219,6 +219,9 @@ struct simple_pid_list *stopped_pids;
event loop. */
static int linux_nat_event_pipe[2] = { -1, -1 };
+/* True if we're currently in async mode. */
+#define linux_is_async_p() (linux_nat_event_pipe[0] != -1)
+
/* Flush the event pipe. */
static void
@@ -4302,10 +4305,7 @@ linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int))
static int
linux_nat_is_async_p (struct target_ops *ops)
{
- /* NOTE: palves 2008-03-21: We're only async when the user requests
- it explicitly with the "set target-async" command.
- Someday, linux will always be async. */
- return target_async_permitted;
+ return linux_is_async_p ();
}
/* target_can_async_p implementation. */
@@ -4355,7 +4355,11 @@ static int async_terminal_is_ours = 1;
static void
linux_nat_terminal_inferior (struct target_ops *self)
{
- if (!target_is_async_p ())
+ /* Like target_terminal_inferior, use target_can_async_p, not
+ target_is_async_p, since at this point the target is not async
+ yet. If it can async, then we know it will become async prior to
+ resume. */
+ if (!target_can_async_p ())
{
/* Async mode is disabled. */
child_terminal_inferior (self);
@@ -4385,13 +4389,6 @@ linux_nat_terminal_inferior (struct target_ops *self)
static void
linux_nat_terminal_ours (struct target_ops *self)
{
- if (!target_is_async_p ())
- {
- /* Async mode is disabled. */
- child_terminal_ours (self);
- return;
- }
-
/* GDB should never give the terminal to the inferior if the
inferior is running in the background (run&, continue&, etc.),
but claiming it sure should. */
@@ -4444,7 +4441,7 @@ handle_target_event (int error, gdb_client_data client_data)
static int
linux_async_pipe (int enable)
{
- int previous = (linux_nat_event_pipe[0] != -1);
+ int previous = linux_is_async_p ();
if (previous != enable)
{