]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/watch_thread_num.exp
2010-06-03 Michael Snyder <msnyder@vmware.com>
[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
4c38e0a4 3# Copyright 2007, 2008, 2009, 2010 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
22if $tracelevel then {
23 strace $tracelevel
24}
25
26set testfile watch_thread_num
27set srcfile ${testfile}.c
28set binfile ${objdir}/${subdir}/${testfile}
29
30# What compiler are we using?
31#
32if [get_compiler_info ${binfile}] {
33 return -1
34}
35
62172bb9
UW
36if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 return -1
37e4754d
LM
38}
39
40gdb_exit
41gdb_start
42gdb_reinitialize_dir $srcdir/$subdir
43gdb_load ${binfile}
44
45if { ![runto main] } then {
46 fail "run to main"
47 return
48}
49
2992cbe0
UW
50# Disable hardware watchpoints if necessary.
51if [target_info exists gdb,no_hardware_watchpoints] {
35ec993f 52 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
2992cbe0
UW
53}
54
37e4754d
LM
55gdb_test "watch shared_var thread 0" "Unknown thread 0\." "Watchpoint on invalid thread"
56gdb_test "watch shared_var thread" "A syntax error in expression, near `thread'\." "Invalid watch syntax"
57
27d3a1a2 58gdb_test "Next 5" ".*"
37e4754d 59
abc8a88d
PM
60gdb_test "break thread_function" "Breakpoint \[0-9\].*" \
61 "Set breakpoint at thread_function"
37e4754d 62
abc8a88d
PM
63gdb_test "continue" ".*Breakpoint 2.*" "Stopped in thread_function"
64
02746bbc
MS
65gdb_test_multiple "thread" "Thread command" {
66 -re ".*Current thread is (\[0-9\]*).*$gdb_prompt $" {
67 pass "Thread command"
68 }
abc8a88d
PM
69}
70
71set thread_num "$expect_out(1,string)"
72
27d3a1a2 73gdb_test_no_output "disable 2" "Disable breakpoint 2"
2992cbe0 74gdb_test "watch shared_var thread $thread_num" "atchpoint 3: shared_var" "Watchpoint on shared variable"
abc8a88d
PM
75gdb_test "info breakpoint 3" "stop only in thread $thread_num"
76
77for {set i 1} {$i <= 10} {incr i 1} {
ac0bb574
NF
78 set watchpoint "Watchpoint triggered iteration $i"
79 set check "Check thread that triggered iteration $i"
80
2992cbe0
UW
81 gdb_test "continue" "atchpoint 3: shared_var.*" $watchpoint
82 gdb_test "thread" ".*Current thread is $thread_num .*" $check
37e4754d
LM
83}
84