]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/watch_thread_num.exp
Fix test names starting with uppercase using gdb_test on a single line.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / watch_thread_num.exp
CommitLineData
37e4754d
LM
1# This testcase is part of GDB, the GNU debugger.
2
618f726f 3# Copyright 2007-2016 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
8e6a5956
UW
22# This test verifies that a watchpoint is detected in the proper thread
23# so the test is only meaningful on a system with hardware watchpoints.
63fc80ce
AA
24# More specifically, the implementation of this test uses access
25# watchpoints, so skip it when those are not available.
26if {[skip_hw_watchpoint_access_tests]} {
b800ec70 27 return 0
8e6a5956
UW
28}
29
62cef515 30standard_testfile .c
37e4754d
LM
31
32# What compiler are we using?
33#
4c93b1db 34if [get_compiler_info] {
37e4754d
LM
35 return -1
36}
37
62172bb9
UW
38if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 return -1
37e4754d
LM
40}
41
62cef515 42clean_restart ${binfile}
37e4754d
LM
43
44if { ![runto main] } then {
45 fail "run to main"
46 return
47}
48
cdc7edd7
LM
49gdb_test "watch shared_var thread 0" "Invalid thread ID: 0" "watchpoint on invalid thread"
50gdb_test "watch shared_var thread" "A syntax error in expression, near `thread'\." "invalid watch syntax"
37e4754d 51
a7b796db
PA
52set bpexitline [gdb_get_line_number "all threads started"]
53gdb_breakpoint "$bpexitline"
54gdb_continue_to_breakpoint "all threads started"
37e4754d 55
a7b796db
PA
56gdb_test "break loop" "Breakpoint \[0-9\].*" \
57 "Set breakpoint at loop"
37e4754d 58
cdc7edd7 59gdb_test "continue" ".*Breakpoint .*loop.*" "stopped in loop"
abc8a88d 60
02746bbc
MS
61gdb_test_multiple "thread" "Thread command" {
62 -re ".*Current thread is (\[0-9\]*).*$gdb_prompt $" {
bc6c7af4 63 pass "thread command"
02746bbc 64 }
abc8a88d
PM
65}
66
67set thread_num "$expect_out(1,string)"
68
a7b796db 69delete_breakpoints
abc8a88d 70
a7b796db
PA
71# We use an access watchpoint rather than a write watchpoint, because
72# GDB can drop the latter when multiple threads trigger events
73# simultaneously, on targets with continuable watchpoints, such as
74# x86. See PR breakpoints/10116.
75
76gdb_test "awatch shared_var thread $thread_num" \
77 "Hardware access \\(read/write\\) watchpoint .*: shared_var.*" \
78 "Watchpoint on shared variable"
79
80gdb_test "info breakpoint \$bpnum" \
81 "stop only in thread $thread_num" \
82 "info breakpoint shows watchpoint is thread-specific"
83
84for {set i 1} {$i <= 5} {incr i} {
ac0bb574
NF
85 set watchpoint "Watchpoint triggered iteration $i"
86 set check "Check thread that triggered iteration $i"
87
a7b796db
PA
88 set test $watchpoint
89 gdb_test_multiple "continue" $test {
90 -re "infrun:" {
91 # Avoid timeouts when debugging GDB.
92 exp_continue
93 }
94 -re "Hardware access \\(read/write\\) watchpoint .*: shared_var.*$gdb_prompt $" {
95 pass $test
96 }
97 }
2992cbe0 98 gdb_test "thread" ".*Current thread is $thread_num .*" $check
37e4754d
LM
99}
100