aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.multi
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-12-17 14:20:52 +0000
committerPedro Alves <palves@redhat.com>2015-12-17 14:23:28 +0000
commita6904d5a6aa63e4bef7207407250d8b76b56f8a9 (patch)
treee4651001446dda94d8b8f04382b7b916028cb5ff /gdb/testsuite/gdb.multi
parent4a6ed09b0f70c79b11bc1e0973a7333d9316a287 (diff)
downloadgdb-a6904d5a6aa63e4bef7207407250d8b76b56f8a9.zip
gdb-a6904d5a6aa63e4bef7207407250d8b76b56f8a9.tar.gz
gdb-a6904d5a6aa63e4bef7207407250d8b76b56f8a9.tar.bz2
Fix PR threads/19354: "info threads" error with multiple inferiors
Note: this applies on top of: [PATCH] Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL https://sourceware.org/ml/gdb-patches/2015-12/msg00214.html We try to avoid using libthread_db.so to list threads in the inferior when debugging live processes, but the code that decides whether to use it decides incorrectly if you have more than one inferior, and the current inferior doesn't have execution yet. The result is visible as: (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 15397 /home/pedro/gdb/tests/threads * 2 <null> (gdb) info threads Cannot find new threads: generic error (gdb) Fix this by checking whether each inferior has execution rather than just the current inferior. By moving the core updating to linux-nat.c's update_thread_list implementation, this also ends up fixing the lwp-last-seen-running-on-core updating in the case we're debugging a program that uses raw clone rather than pthreads, as linux-thread-db.c isn't pushed in the target stack in that scenario. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-12-17 Pedro Alves <palves@redhat.com> PR threads/19354 * linux-nat.c (linux_nat_update_thread_list): Update process cores each lwp was last seen running on here. * linux-thread-db.c (update_thread_core): Delete. (thread_db_update_thread_list_td_ta_thr_iter): Rename to ... (thread_db_update_thread_list): ... this. Skip inferiors with execution. Also call the target beneath. (thread_db_update_thread_list): Delete. gdb/testsuite/ChangeLog: 2015-12-17 Pedro Alves <palves@redhat.com> PR threads/19354 * gdb.multi/info-threads.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.multi')
-rw-r--r--gdb/testsuite/gdb.multi/info-threads.exp39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.multi/info-threads.exp b/gdb/testsuite/gdb.multi/info-threads.exp
new file mode 100644
index 0000000..c00b8d7
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/info-threads.exp
@@ -0,0 +1,39 @@
+# Copyright 2009-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/>.
+
+# Regression test for PR threads/19354. If you have a threaded
+# inferior running (thread_db must be loaded), switch to another
+# inferior, one that is NOT running yet, and do "info threads", you
+# would get back an error.
+
+standard_testfile hello.c
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {pthreads debug}] } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+if { ![runto_main] } then {
+ return -1
+}
+
+# Add another inferior.
+gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
+gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2"
+
+# "info threads" while inferior 1 has execution and inferior 2 is not
+# running yet should show inferior 1's thread, and give no error.
+gdb_test "info threads" "1 .* main .* at .*$srcfile:.*No selected thread.*"