Commit | Line | Data |
---|---|---|
37e4754d LM |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
7b6bb8da | 3 | # Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
37e4754d LM |
4 | |
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. | |
9 | # | |
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. | |
14 | # | |
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/>. */ | |
17 | ||
18 | # watch-thread_num.exp Test thread <thread_num> parameter for | |
19 | # watch commands. | |
20 | # | |
21 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
8e6a5956 UW |
26 | # This test verifies that a watchpoint is detected in the proper thread |
27 | # so the test is only meaningful on a system with hardware watchpoints. | |
b800ec70 UW |
28 | if {[skip_hw_watchpoint_tests]} { |
29 | return 0 | |
8e6a5956 UW |
30 | } |
31 | ||
37e4754d LM |
32 | set testfile watch_thread_num |
33 | set srcfile ${testfile}.c | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | ||
36 | # What compiler are we using? | |
37 | # | |
38 | if [get_compiler_info ${binfile}] { | |
39 | return -1 | |
40 | } | |
41 | ||
62172bb9 UW |
42 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
43 | return -1 | |
37e4754d LM |
44 | } |
45 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | gdb_load ${binfile} | |
50 | ||
51 | if { ![runto main] } then { | |
52 | fail "run to main" | |
53 | return | |
54 | } | |
55 | ||
56 | gdb_test "watch shared_var thread 0" "Unknown thread 0\." "Watchpoint on invalid thread" | |
57 | gdb_test "watch shared_var thread" "A syntax error in expression, near `thread'\." "Invalid watch syntax" | |
58 | ||
27d3a1a2 | 59 | gdb_test "Next 5" ".*" |
37e4754d | 60 | |
abc8a88d PM |
61 | gdb_test "break thread_function" "Breakpoint \[0-9\].*" \ |
62 | "Set breakpoint at thread_function" | |
37e4754d | 63 | |
abc8a88d PM |
64 | gdb_test "continue" ".*Breakpoint 2.*" "Stopped in thread_function" |
65 | ||
02746bbc MS |
66 | gdb_test_multiple "thread" "Thread command" { |
67 | -re ".*Current thread is (\[0-9\]*).*$gdb_prompt $" { | |
68 | pass "Thread command" | |
69 | } | |
abc8a88d PM |
70 | } |
71 | ||
72 | set thread_num "$expect_out(1,string)" | |
73 | ||
27d3a1a2 | 74 | gdb_test_no_output "disable 2" "Disable breakpoint 2" |
8e6a5956 | 75 | gdb_test "watch shared_var thread $thread_num" "Hardware watchpoint 3: shared_var" "Watchpoint on shared variable" |
abc8a88d PM |
76 | gdb_test "info breakpoint 3" "stop only in thread $thread_num" |
77 | ||
78 | for {set i 1} {$i <= 10} {incr i 1} { | |
ac0bb574 NF |
79 | set watchpoint "Watchpoint triggered iteration $i" |
80 | set check "Check thread that triggered iteration $i" | |
81 | ||
8e6a5956 | 82 | gdb_test "continue" "Hardware watchpoint 3: shared_var.*" $watchpoint |
2992cbe0 | 83 | gdb_test "thread" ".*Current thread is $thread_num .*" $check |
37e4754d LM |
84 | } |
85 |