diff options
author | Pedro Alves <palves@redhat.com> | 2015-01-23 11:12:39 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-01-23 11:12:39 +0000 |
commit | 198297aafb4f7a9717be8370581b048ae9107c14 (patch) | |
tree | 8570ebf1a6777d3baac44cef0087494bf8288e57 /gdb/testsuite/gdb.threads/continue-pending-after-query.c | |
parent | bbbbffbbfc3fca35649896d6626ab02581df8037 (diff) | |
download | binutils-198297aafb4f7a9717be8370581b048ae9107c14.zip binutils-198297aafb4f7a9717be8370581b048ae9107c14.tar.gz binutils-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/testsuite/gdb.threads/continue-pending-after-query.c')
-rw-r--r-- | gdb/testsuite/gdb.threads/continue-pending-after-query.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.c b/gdb/testsuite/gdb.threads/continue-pending-after-query.c new file mode 100644 index 0000000..9510ce8 --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.c @@ -0,0 +1,48 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013-2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <pthread.h> + +static int global; + +static void +break_function (void) +{ + global = 42; /* set break here */ +} + +static void * +thread_function (void *arg) +{ + break_function (); + + return arg; +} + +int +main (void) +{ + pthread_t th; + + pthread_create (&th, NULL, thread_function, NULL); + + break_function (); + + pthread_join (th, NULL); + + return 0; +} |