b05b120205
[This reapplies a change that was accidentally reverted with c0ecb95f3d.] Before: (gdb) info threads Id Target Id Frame 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 After: (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 gdb/doc/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.texinfo (Inferiors and Programs): Adjust "maint info program-spaces" example to ascending order listing. (Threads): Adjust "info threads" example to ascending order listing. (Forks): Adjust "info inferiors" example to ascending order listing. gdb/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * inferior.c (add_inferior_silent): Append the new inferior to the end of the list. * progspace.c (add_program_space): Append the new pspace to the end of the list. * thread.c (new_thread): Append the new thread to the end of the list. gdb/testsuite/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and threads in ascending order. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.multi/base.exp: Likewise. * gdb.multi/multi-arch.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.threads/break-while-running.exp: Likewise. * gdb.threads/execl.exp: Likewise. * gdb.threads/gcore-thread.exp: Likewise. * gdb.threads/info-threads-cur-sal.exp: Likewise. * gdb.threads/kill.exp: Likewise. * gdb.threads/linux-dp.exp: Likewise. * gdb.threads/multiple-step-overs.exp: Likewise. * gdb.threads/next-bp-other-thread.exp: Likewise. * gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise. * gdb.threads/step-over-lands-on-breakpoint.exp: Likewise. * gdb.threads/step-over-trips-on-watchpoint.exp: Likewise. * gdb.threads/thread-find.exp: Likewise. * gdb.threads/tls.exp: Likewise. * lib/mi-support.exp (mi_reverse_list): Delete. (mi_check_thread_states): No longer reverse list.
162 lines
5.3 KiB
Text
162 lines
5.3 KiB
Text
# Copyright (C) 2014-2016 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/>.
|
|
|
|
# Test that:
|
|
#
|
|
# - setting a breakpoint while a thread is running results in the
|
|
# breakpoint being inserted immediately.
|
|
#
|
|
# - if breakpoint always-inserted mode is off, GDB doesn't remove
|
|
# breakpoints from the target when a thread stops, if there are
|
|
# still threads running.
|
|
|
|
standard_testfile
|
|
|
|
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
|
|
return -1
|
|
}
|
|
|
|
# The test proper. UPDATE_THREAD_LIST indicates whether we should do
|
|
# an "info threads" to sync the thread list after the first stop.
|
|
# ALWAYS_INSERTED indicates whether testing in "breakpoint
|
|
# always-inserted" mode. NON_STOP indicates whether we're testing in
|
|
# non-stop, or all-stop mode.
|
|
|
|
proc test { update_thread_list always_inserted non_stop } {
|
|
global srcfile binfile
|
|
global gdb_prompt
|
|
global decimal
|
|
|
|
clean_restart $binfile
|
|
|
|
gdb_test_no_output "set non-stop $non_stop"
|
|
gdb_test_no_output "set breakpoint always-inserted $always_inserted"
|
|
|
|
if ![runto_main] {
|
|
return -1
|
|
}
|
|
|
|
# In all-stop, check whether we're testing with the remote or
|
|
# extended-remote targets. If so, skip the tests, as with the
|
|
# RSP, we can't issue commands until the target replies to vCont.
|
|
# Not an issue with the non-stop RSP variant, which has a
|
|
# non-blocking vCont.
|
|
if {$non_stop=="off" && [gdb_is_target_remote]} {
|
|
return -1
|
|
}
|
|
|
|
gdb_breakpoint [gdb_get_line_number "set wait-thread breakpoint here"]
|
|
gdb_continue_to_breakpoint "run to wait-thread breakpoint"
|
|
|
|
delete_breakpoints
|
|
|
|
# Leave the main thread stopped, so GDB can poke at memory freely.
|
|
if {$non_stop == "off"} {
|
|
gdb_test_no_output "set scheduler-locking on"
|
|
gdb_test "thread 2" "Switching to .*"
|
|
gdb_test "continue &" "Continuing\." "continuing thread 2"
|
|
gdb_test "thread 3" "Switching to .*"
|
|
gdb_test "continue &" "Continuing\." "continuing thread 3"
|
|
gdb_test "thread 1" "Switching to .*" "switch back to main thread"
|
|
}
|
|
|
|
# Test with and without pulling the thread list explicitly with
|
|
# "info threads". GDB should be able to figure out itself whether
|
|
# the target is running and thus breakpoints should be inserted,
|
|
# without the user explicitly fetching the thread list.
|
|
if {$update_thread_list} {
|
|
gdb_test "info threads" \
|
|
"main .*\\\(running\\\).*\\\(running\\\).*" \
|
|
"only main stopped"
|
|
}
|
|
|
|
# Don't use gdb_test as it's racy in this case -- gdb_test matches
|
|
# the prompt with an end anchor. Sometimes expect will manage to
|
|
# read the breakpoint hit output while still processing this test,
|
|
# defeating the anchor.
|
|
set test "set breakpoint while a thread is running"
|
|
gdb_test_multiple "break breakpoint_function" $test {
|
|
-re "Breakpoint $decimal at .*: file .*$srcfile.*\r\n$gdb_prompt " {
|
|
pass $test
|
|
}
|
|
-re "$gdb_prompt " {
|
|
fail $test
|
|
}
|
|
}
|
|
|
|
# Check that the breakpoint is hit. Can't use gdb_test here, as
|
|
# no prompt is expected to come out.
|
|
set test "breakpoint is hit"
|
|
gdb_test_multiple "" $test {
|
|
-re "Breakpoint .*, breakpoint_function \[^\r\n\]+" {
|
|
pass $test
|
|
}
|
|
}
|
|
|
|
if {$non_stop == "on"} {
|
|
gdb_test "info threads" \
|
|
"main .* breakpoint_function .*\\\(running\\\)" \
|
|
"one thread running"
|
|
|
|
# Unblock the other thread, which should then trip on the same
|
|
# breakpoint, unless GDB removed it by mistake. Can't use
|
|
# gdb_test here for the same reasons as above.
|
|
set test "unblock second thread"
|
|
gdb_test_multiple "print second_child = 1" $test {
|
|
-re " = 1\r\n$gdb_prompt " {
|
|
pass $test
|
|
}
|
|
-re "$gdb_prompt " {
|
|
fail $test
|
|
}
|
|
}
|
|
|
|
set test "breakpoint on second child is hit"
|
|
gdb_test_multiple "" $test {
|
|
-re "Breakpoint .*, breakpoint_function \[^\r\n\]+" {
|
|
pass $test
|
|
}
|
|
}
|
|
|
|
gdb_test "info threads" \
|
|
" main .* breakpoint_function .* breakpoint_function .*" \
|
|
"all threads stopped"
|
|
} else {
|
|
# This test is not merged with the non-stop one because in
|
|
# all-stop we don't know where the other thread stops (inside
|
|
# usleep, for example).
|
|
set test "all threads stopped"
|
|
gdb_test_multiple "info threads" "$test" {
|
|
-re "\\\(running\\\).*$gdb_prompt $" {
|
|
fail $test
|
|
}
|
|
-re "main .* breakpoint_function .*$gdb_prompt $" {
|
|
pass $test
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach update_thread_list { true false } {
|
|
foreach always_inserted { "off" "on" } {
|
|
foreach non_stop { "off" "on" } {
|
|
set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"]
|
|
set update_list_mode [expr ($update_thread_list)?"w/ithr":"wo/ithr"]
|
|
with_test_prefix "$update_list_mode: always-inserted $always_inserted: $stop_mode" {
|
|
test $update_thread_list $always_inserted $non_stop
|
|
}
|
|
}
|
|
}
|
|
}
|