1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2007, 2008 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 # watch-thread_num.exp Test thread <thread_num> parameter for
26 set testfile watch_thread_num
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
30 # What compiler are we using?
32 if [get_compiler_info ${binfile}] {
36 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
42 gdb_reinitialize_dir $srcdir/$subdir
45 if { ![runto main] } then {
50 gdb_test "watch shared_var thread 0" "Unknown thread 0\." "Watchpoint on invalid thread"
51 gdb_test "watch shared_var thread" "A syntax error in expression, near `thread'\." "Invalid watch syntax"
55 gdb_test "break thread_function" "Breakpoint \[0-9\].*" \
56 "Set breakpoint at thread_function"
58 gdb_test "continue" ".*Breakpoint 2.*" "Stopped in thread_function"
62 -re ".*Current thread is (\[0-9\]*).*$gdb_prompt $" { pass "Thread command" }
63 -re ".*$gdb_prompt $" { fail "Thread command" }
64 timeout { fail "(timeout) Thread command" }
67 set thread_num "$expect_out(1,string)"
69 gdb_test "disable 2" "" "Disable breakpoint 2"
70 gdb_test "watch shared_var thread $thread_num" "Hardware watchpoint 3: shared_var" "Watchpoint on shared variable"
71 gdb_test "info breakpoint 3" "stop only in thread $thread_num"
73 for {set i 1} {$i <= 10} {incr i 1} {
74 set watchpoint "Watchpoint triggered iteration $i"
75 set check "Check thread that triggered iteration $i"
77 if {[target_info exists gdb,no_hardware_watchpoints]} {
78 unsupported $watchpoint
81 gdb_test "continue" "Hardware watchpoint 3: shared_var.*" $watchpoint
82 gdb_test "thread" ".*Current thread is $thread_num .*" $check