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