1 # Copyright (C) 2013-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Verify that a thread-specific breakpoint is deleted when the
17 # corresponding thread is gone.
21 if {[gdb_compile_pthreads \
22 "${srcdir}/${subdir}/${srcfile}" \
23 "${binfile}" executable {debug} ] != "" } {
27 # Extract and return the thread ID of the thread stopped at function
30 proc get_thread_id {func} {
35 set test "get $func thread id"
36 gdb_test_multiple "info threads" $test {
37 -re "(\[0-9\]+)\[^\n\r\]*${tdlabel_re}\[^\n\r\]*$func.*$gdb_prompt $" {
38 # Get the thread's id.
39 set thre $expect_out(1,string)
47 proc check_thread_specific_breakpoint {non_stop} {
50 if { ![runto_main] } {
54 set main_thre [get_thread_id "main"]
55 if { $main_thre < 0 } {
59 gdb_breakpoint "start"
60 gdb_continue_to_breakpoint "start"
62 set start_thre [get_thread_id "start"]
63 if { $start_thre < 0 } {
67 # Check that multiple uses of 'thread' keyword give an error.
68 gdb_test "break main thread $start_thre thread $main_thre" \
69 "You can specify only one thread\\."
71 # Set a thread-specific breakpoint at "main". This can't ever
72 # be hit, but that's OK.
73 gdb_breakpoint "main thread $start_thre"
74 gdb_test "info break" ".*breakpoint.*thread $start_thre" "breakpoint set"
76 # Set breakpoint at a place only reachable after the "start"
80 # Switch back to the main thread, and resume all threads. The
81 # "start" thread exits, and the main thread reaches "end".
82 gdb_test "thread $main_thre" \
83 "Switching to thread $main_thre.*" \
84 "thread $main_thre selected"
94 "Thread-specific breakpoint 3 deleted" \
96 "thread 2 no longer in the thread list\\."]]
98 gdb_test_multiple "$cmd" "continue to end" {
99 -re "$\r\n${gdb_prompt} .*${msg_re}\r\n" {
102 -re "\r\n${msg_re}\r\n.*$gdb_prompt " {
107 set test "thread-specific breakpoint was deleted"
108 gdb_test_multiple "info breakpoint" $test {
109 -re "thread $start_thre\n$gdb_prompt $" {
112 -re "$gdb_prompt $" {
118 foreach_with_prefix non_stop {on off} {
119 save_vars { GDBFLAGS } {
120 append GDBFLAGS " -ex \"set non-stop $non_stop\""
121 clean_restart $binfile
124 check_thread_specific_breakpoint $non_stop