diff options
author | Pedro Alves <palves@redhat.com> | 2015-03-19 12:20:25 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-03-19 12:26:49 +0000 |
commit | eb54c8bf087f434b0cb91b35e7cde68a69ac9193 (patch) | |
tree | 341eb32253fad30cfc3a81e678ba4fb59ccfc56c /gdb/testsuite/gdb.threads/continue-pending-status.c | |
parent | b90fc18880972f0c2ed280df20604d89f1d4ec38 (diff) | |
download | binutils-eb54c8bf087f434b0cb91b35e7cde68a69ac9193.zip binutils-eb54c8bf087f434b0cb91b35e7cde68a69ac9193.tar.gz binutils-eb54c8bf087f434b0cb91b35e7cde68a69ac9193.tar.bz2 |
native/Linux: internal error if resume is short-circuited
If the linux_nat_resume's short-circuits the resume because the
current thread has a pending status, and, a thread with a higher
number was previously stopped for a breakpoint, GDB internal errors,
like:
/home/pedro/gdb/mygit/src/gdb/linux-nat.c:2590: internal-error: status_callback: Assertion `lp->status != 0' failed.
Fix this by make status_callback bail out earlier. GDBserver is
already doing the same.
New test added that exercises this.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (status_callback): Return early if the LWP has no
status pending.
gdb/testsuite/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* gdb.threads/continue-pending-status.c: New file.
* gdb.threads/continue-pending-status.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.threads/continue-pending-status.c')
-rw-r--r-- | gdb/testsuite/gdb.threads/continue-pending-status.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.c b/gdb/testsuite/gdb.threads/continue-pending-status.c new file mode 100644 index 0000000..eea0c7e --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-pending-status.c @@ -0,0 +1,58 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <pthread.h> +#include <assert.h> + +pthread_barrier_t barrier; + +#define NUM_THREADS 2 + +void * +thread_function (void *arg) +{ + /* This ensures that the breakpoint is only hit after both threads + are created, so the test can always switch to the non-event + thread when the breakpoint triggers. */ + pthread_barrier_wait (&barrier); + + while (1); /* break here */ +} + +int +main (void) +{ + int i; + + pthread_barrier_init (&barrier, NULL, NUM_THREADS); + + for (i = 0; i < NUM_THREADS; i++) + { + pthread_t thread; + int res; + + res = pthread_create (&thread, NULL, + thread_function, NULL); + assert (res == 0); + } + + sleep (300); + return 0; +} |