OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [watchthreads.exp] - Blame information for rev 842

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
 
3
# Copyright 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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 .
17
 
18
# Check that GDB can support multiple watchpoints across threads.
19
 
20
if $tracelevel {
21
    strace $tracelevel
22
}
23
 
24
set prms_id 0
25
set bug_id 0
26
 
27
# This test verifies that a watchpoint is detected in the proper thread
28
# so the test is only meaningful on a system with hardware watchpoints.
29
if [target_info exists gdb,no_hardware_watchpoints] {
30
    return 0;
31
}
32
 
33
proc target_no_stopped_data { } {
34
    return [istarget s390*-*-*]
35
}
36
 
37
set testfile "watchthreads"
38
set srcfile ${testfile}.c
39
set binfile ${objdir}/${subdir}/${testfile}
40
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
41
    return -1
42
}
43
 
44
gdb_exit
45
gdb_start
46
gdb_reinitialize_dir $srcdir/$subdir
47
gdb_load ${binfile}
48
 
49
gdb_test "set can-use-hw-watchpoints 1" "" ""
50
 
51
#
52
# Run to `main' where we begin our tests.
53
#
54
 
55
if ![runto_main] then {
56
    gdb_suppress_tests
57
}
58
 
59
set args_0 0
60
set args_1 0
61
 
62
# Watch values that will be modified by distinct threads.
63
gdb_test "watch args\[0\]" "Hardware watchpoint 2: args\\\[0\\\]"
64
gdb_test "watch args\[1\]" "Hardware watchpoint 3: args\\\[1\\\]"
65
set hwwp_2_enabled 1
66
set hwwp_3_enabled 1
67
 
68
set init_line [gdb_get_line_number "Init value"]
69
set inc_line [gdb_get_line_number "Loop increment"]
70
set main_loc "main \\\(\\\) at .*watchthreads.c:$init_line"
71
set thread0_loc "thread_function \\\(arg=0x0\\\) at .*watchthreads.c:$inc_line"
72
set thread1_loc "thread_function \\\(arg=0x1\\\) at .*watchthreads.c:$inc_line"
73
 
74
# Loop and continue to allow both watchpoints to be triggered.
75
for {set i 0} {$i < 30} {incr i} {
76
  set test_flag_0 0
77
  set test_flag_1 0
78
  set test_flag 0
79
  gdb_test_multiple "continue" "threaded watch loop" {
80
    -re "(.*Hardware watchpoint.*)$gdb_prompt $" {
81
        # At least one hardware watchpoint was hit.  Check if both were.
82
        set string $expect_out(1,string)
83
 
84
        if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr $args_0+1]\r" $string] {
85
            incr args_0
86
            incr test_flag_0
87
        }
88
        if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr $args_1+1]\r" $string] {
89
            incr args_1
90
            incr test_flag_1
91
        }
92
 
93
        set expected_loc "bogus location"
94
        if { $test_flag_0 == 1 && $test_flag_1 == 0 && $args_0 == 1 } {
95
            set expected_loc $main_loc
96
        } elseif { $test_flag_0 == 0 && $test_flag_1 == 1 && $args_1 == 1 } {
97
            set expected_loc $main_loc
98
        } elseif { $test_flag_0 == 1 && $test_flag_1 == 0 } {
99
            set expected_loc $thread0_loc
100
        } elseif { $test_flag_0 == 0 && $test_flag_1 == 1 } {
101
            set expected_loc $thread1_loc
102
        } elseif { $test_flag_0 + $test_flag_1 == 2 } {
103
            # On S/390, or any other system which can not report the
104
            # stopped data address, it is OK to report two watchpoints
105
            # at once in this test.  Make sure the reported location
106
            # corresponds to at least one of the watchpoints (and not,
107
            # e.g., __nptl_create_event).  On other systems, we should
108
            # report the two watchpoints serially.
109
            if { [target_no_stopped_data] } {
110
                set expected_loc "($main_loc|$thread0_loc|$thread1_loc)"
111
            }
112
        }
113
 
114
        if [ regexp "$expected_loc" $string ] {
115
            set test_flag 1
116
        } else {
117
            fail "threaded watch loop"
118
        }
119
 
120
        # If one of the watchpoints is disabled, we'd better not stop there.
121
        if { !$hwwp_2_enabled && $test_flag_0 } {
122
            fail "disabled hw watchpoint 2 triggered"
123
        }
124
        if { !$hwwp_3_enabled && $test_flag_1 } {
125
            fail "disabled hw watchpoint 3 triggered"
126
        }
127
 
128
        # If we get to 10 in one of the watched locations disable it so we
129
        # see some of the other watched location.
130
        # 10 is chosen so we're guaranteed to come through here.
131
        if { $hwwp_2_enabled && $hwwp_3_enabled } {
132
            if { $args_0 >= 10 && $hwwp_2_enabled } {
133
                gdb_test "disable 2" ""
134
                set hwwp_2_enabled 0
135
            } elseif { $args_1 >= 10 && $hwwp_3_enabled } {
136
                gdb_test "disable 3" ""
137
                set hwwp_3_enabled 0
138
            }
139
        }
140
    }
141
  }
142
 
143
  # If we fail above, don't bother continuing loop
144
  if { $test_flag == 0 } {
145
    set i 30;
146
  }
147
}
148
 
149
# Print success message if loop succeeded.
150
if { $test_flag == 1 } {
151
  pass "threaded watch loop"
152
}
153
 
154
# Verify that we hit first watchpoint in main thread.
155
set message "first watchpoint on args\[0\] hit"
156
if { $args_0 > 0 } {
157
  pass $message
158
} else {
159
  fail $message
160
}
161
 
162
# Verify that we hit second watchpoint in main thread.
163
set message "first watchpoint on args\[1\] hit"
164
if { $args_1 > 0 } {
165
  pass $message
166
} else {
167
  fail $message
168
}
169
 
170
# Verify that we hit first watchpoint in child thread.
171
set message "watchpoint on args\[0\] hit in thread"
172
if { $args_0 > 1 } {
173
  pass $message
174
} else {
175
  fail $message
176
}
177
 
178
# Verify that we hit second watchpoint in child thread.
179
set message "watchpoint on args\[1\] hit in thread"
180
if { $args_1 > 1 } {
181
  pass $message
182
} else {
183
  fail $message
184
}
185
 
186
# Verify that all watchpoint hits are accounted for.
187
set message "combination of threaded watchpoints = 30"
188
if { [target_no_stopped_data] } {
189
    # See above.  If we allow two watchpoints to be hit at once, we
190
    # may have more than 30 hits total.
191
    set result [expr $args_0 + $args_1 >= 30]
192
} else {
193
    set result [expr $args_0 + $args_1 == 30]
194
}
195
if { $result } {
196
  pass $message
197
} else {
198
  fail $message
199
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.