Update copyright and license
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.rocm / devicecode-breakpoint.exp
1 # Copyright (C) 2019-2020 Free Software Foundation, Inc.
2 # Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
3
4 # This file is part of GDB.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 load_lib rocm.exp
20
21 set testfile "devicecode-breakpoint"
22 set srcfile ${srcdir}/${subdir}/${testfile}.cpp
23 set objfile [standard_output_file ${testfile}.o]
24 set binfile [standard_output_file ${testfile}]
25
26 set breakpoint_loc 35
27 set wave_id {(0,0,0)/2}
28 set rocm_threadno {1.3}
29 set threadid {7}
30
31 # Check if skip hip tests
32 if [skip_hipcc_tests] {
33 verbose "Skipping hip test: ${testfile}."
34 return 0
35 }
36
37 # Compile the hip program
38 if {[prepare_for_testing "failed to prepare ${testfile}" $testfile $srcfile {debug hip}]} {
39 return -1
40 }
41
42 gdb_start
43
44 # Load the hip program
45 if {[gdb_load ${binfile}] == -1} {
46 verbose "failed to load program ${testfile}."
47 return -1
48 }
49
50 # Run to main and break
51 if ![runto_main] {
52 fail "can't run to main and break in program ${testfile}."
53 return -1
54 }
55
56 #TEST1
57 #break <device_function_name>
58 #break bit_extract_kernel
59 # Set breakpoing in device code
60 gdb_breakpoint "bit_extract_kernel" "allow-pending"
61
62 # Do continue to check the breakpoint is created at device
63 gdb_test "c" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
64
65 clean_restart ${binfile}
66
67
68 #TEST2
69 #tbreak <device_function_name>
70 #tbreak bit_extract_kernel
71 gdb_breakpoint "bit_extract_kernel" "allow-pending" "temporary"
72 gdb_test "run" {.+hit\sTemporary\sbreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
73 #controlling the timeout of the test as continue on device thread taking around 20-30s
74 set timeout 30
75 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
76
77 clean_restart ${binfile}
78
79 #TEST3
80 #break <file>:<lineNO>
81 #e.g. break bit_extract_compile:35
82 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
83 gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
84 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
85
86 clean_restart ${binfile}
87
88 #TEST4
89 #break <lineNo>
90 #e.g break 35
91 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
92 gdb_test "break $breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
93 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
94
95 clean_restart ${binfile}
96
97 #Code to fetch threadno and corresponding wave_id
98 #Set breakpoing in device code
99 gdb_breakpoint "bit_extract_kernel" "allow-pending"
100 gdb_test "run" {.+hit\sBreakpoint\s\d+.+\sbit_extract_kernel\s\(.*\)\sat.*}
101 send_gdb "info threads\n"
102 gdb_expect -re "\\s+(\\d+)\\s+AMDGPU Thread\\s+(\\d+\.\\d+)\\s+(\\(\\d+,\\d+,\\d+\\)/\\d+).*$gdb_prompt $" {
103 set threadid "$expect_out(1,string)"
104 set rocm_threadno "$expect_out(2,string)"
105 set wave_id "$expect_out(3,string)"
106 }
107
108 verbose $rocm_threadno
109 verbose $threadid
110 verbose $wave_id
111 regsub -all {[]*+.|()^$\[\\]} $wave_id {\\&} wave_id_re
112 verbose $wave_id_re
113
114 clean_restart ${binfile}
115
116 set timeout 40
117 #TEST5
118 #break <file>:<lineNO> <device thread condition>
119 #e.g. break bit_extract_compile:35 if $_thread==<threadno>
120 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
121 gdb_test "break $srcfile:$breakpoint_loc if \$_thread==$threadid" "Breakpoint .* at .*${testfile}.*"
122 gdb_test "run" ".+Thread.+$threadid.+hit.+Breakpoint.+${testfile}.cpp:$breakpoint_loc.*"
123 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
124
125
126 clean_restart ${binfile}
127 #TEST6
128 #break <file>:<lineNO> <device thread condition>
129 #e.g. break bit_extract_compile:35 if $_streq($_wave_id,(0,0,1)/2)
130 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
131 gdb_test "break $srcfile:$breakpoint_loc if \$_streq(\$_wave_id,\"$wave_id\")" "Breakpoint .* at .*${testfile}.*"
132 gdb_test "run" ".+$wave_id_re.+Thread.+hit.+Breakpoint.+${testfile}.cpp:$breakpoint_loc.*"
133 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
134
135
136
137 clean_restart ${binfile}
138
139 #TEST7
140 #enable\disable the breakpoint in device thread
141 #break <device_function_name>
142 #break bit_extract_kernel
143 #run //to hit the breakpoint in device thread
144 #disable <breakpoint no>
145 #continue //to exit inferior normally
146 #run //to check that test running without hitting any breakpoint as it disabled
147 #enable <breakpoint no>
148 ##run //to hit the breakpoint in device thread after enabling the breakpoint
149
150 # Set breakpoing in device code
151 gdb_breakpoint "bit_extract_kernel" "allow-pending"
152
153 # Do continue to check the breakpoint is created at device
154 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
155 gdb_test "disable 1"
156 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
157 gdb_test "run" {.+Inferior\s[\d].+\sexited\snormally.+}
158 gdb_test "enable 1"
159 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
160
161 clean_restart ${binfile}
162
163 #TEST8
164 #clear the breakpoint in device thread
165 #break <file>:<lineNO>
166 #e.g. break bit_extract_compile:35
167 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
168 gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
169 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
170 gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
171 gdb_test "clear $breakpoint_loc"
172 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
173
174
175 clean_restart ${binfile}
176 #TEST9
177 #delete all the breakpoints in device thread
178 #break <file>:<lineNO>
179 #e.g. break bit_extract_compile:35
180 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
181 gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
182 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
183 gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
184 #gdb_test "delete 1"
185 delete_breakpoints
186 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
187
188 clean_restart ${binfile}
189 #TEST10
190 #delete single breakpoint in device thread
191 #break <file>:<lineNO>
192 #e.g. break bit_extract_compile:35
193 gdb_test_no_output "set environment HIP_ENABLE_DEFERRED_LOADING=0"
194 gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
195 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
196 gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
197 gdb_test "delete 1"
198 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
199
200 clean_restart ${binfile}
201 #TEST11
202 #disable the breakpoint in device thread and then delete_breakpoints
203 #break <device_function_name>
204 #break bit_extract_kernel
205 #run //to hit the breakpoint in device thread
206 #disable <breakpoint no>
207 #continue //to exit inferior normally
208 #delete breakpoints
209 ##run //to hit the breakpoint in device thread after enabling the breakpoint
210
211 # Set breakpoing in device code
212 gdb_breakpoint "bit_extract_kernel" "allow-pending"
213
214 # Do continue to check the breakpoint is created at device
215 gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
216 gdb_test "disable 1"
217 gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
218 delete_breakpoints
219 gdb_test "run" {.+Inferior\s[\d].+\sexited\snormally.+}
220
221
222 gdb_exit
223
224
225
226
227
228
This page took 0.033861 seconds and 4 git commands to generate.