Added delete breakpoint tests for device code
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.rocm / devicecode-breakpoint.exp
CommitLineData
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
16load_lib rocm.exp
17
83bd8cbb 18set testfile "devicecode-breakpoint"
abeeff98
LM
19set srcfile ${srcdir}/${subdir}/${testfile}.cpp
20set objfile [standard_output_file ${testfile}.o]
21set binfile [standard_output_file ${testfile}]
22
23set breakpoint_loc 35
24set wave_id {(0,0,0)/2}
25set rocm_threadno {1.3}
26set threadid {7}
27
28# Check if skip hip tests
29if [skip_hipcc_tests] {
30 verbose "Skipping hip test: ${testfile}."
31 return 0
32}
33
34# Compile the hip program
35if {[prepare_for_testing "failed to prepare ${testfile}" $testfile $srcfile {debug hip}]} {
36 return -1
37}
38
39gdb_start
40
41# Load the hip program
42if {[gdb_load ${binfile}] == -1} {
43 verbose "failed to load program ${testfile}."
44 return -1
45}
46
47# Run to main and break
48if ![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
57gdb_breakpoint "bit_extract_kernel" "allow-pending"
58
59# Do continue to check the breakpoint is created at device
60gdb_test "c" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
61
62clean_restart ${binfile}
63
64
65#TEST2
66#tbreak <device_function_name>
67#tbreak bit_extract_kernel
68gdb_breakpoint "bit_extract_kernel" "allow-pending" "temporary"
69gdb_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
71set timeout 30
72gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
73
74clean_restart ${binfile}
75
76#TEST3
77#break <file>:<lineNO>
78#e.g. break bit_extract_compile:35
79gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
80gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
81
82clean_restart ${binfile}
83
84#TEST4
85#break <lineNo>
86#e.g break 35
87gdb_test "break $breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
88gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
89
90clean_restart ${binfile}
91
92#Code to fetch threadno and corresponding wave_id
93#Set breakpoing in device code
94gdb_breakpoint "bit_extract_kernel" "allow-pending"
95gdb_test "run" {.+hit\sBreakpoint\s\d+.+\sbit_extract_kernel\s\(.*\)\sat.*}
96send_gdb "info threads\n"
2cc9b6f3 97gdb_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
103verbose $rocm_threadno
104verbose $threadid
105verbose $wave_id
106regsub -all {[]*+.|()^$\[\\]} $wave_id {\\&} wave_id_re
107verbose $wave_id_re
108
109clean_restart ${binfile}
110
111set timeout 40
112#TEST5
113#break <file>:<lineNO> <device thread condition>
114#e.g. break bit_extract_compile:35 if $_thread==<threadno>
115gdb_test "break $srcfile:$breakpoint_loc if \$_thread==$threadid" "Breakpoint .* at .*${testfile}.*"
116gdb_test "run" ".+Thread.+$threadid.+hit.+Breakpoint.+${testfile}.cpp:$breakpoint_loc.*"
117gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
118
119
120clean_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)
124gdb_test "break $srcfile:$breakpoint_loc if \$_streq(\$_wave_id,\"$wave_id\")" "Breakpoint .* at .*${testfile}.*"
125gdb_test "run" ".+$wave_id_re.+Thread.+hit.+Breakpoint.+${testfile}.cpp:$breakpoint_loc.*"
126gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
127
128
129
130clean_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
144gdb_breakpoint "bit_extract_kernel" "allow-pending"
145
146# Do continue to check the breakpoint is created at device
147gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
148gdb_test "disable 1"
149gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
150gdb_test "run" {.+Inferior\s[\d].+\sexited\snormally.+}
151gdb_test "enable 1"
152gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
153
154clean_restart ${binfile}
155
156#TEST8
157#clear the breakpoint in device thread
158#break <file>:<lineNO>
159#e.g. break bit_extract_compile:35
160gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
161gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
162gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
163gdb_test "clear $breakpoint_loc"
164gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
165
166
01e49a5d 167clean_restart ${binfile}
168#TEST9
169#delete all the breakpoints in device thread
170#break <file>:<lineNO>
171#e.g. break bit_extract_compile:35
172gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
173gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
174gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
175#gdb_test "delete 1"
176delete_breakpoints
177gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
178
179clean_restart ${binfile}
180#TEST10
181#delete single breakpoint in device thread
182#break <file>:<lineNO>
183#e.g. break bit_extract_compile:35
184gdb_test "break $srcfile:$breakpoint_loc" "Breakpoint .* at .*${testfile}.*"
185gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
186gdb_test "continue" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
187gdb_test "delete 1"
188gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
189
190clean_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
202gdb_breakpoint "bit_extract_kernel" "allow-pending"
203
204# Do continue to check the breakpoint is created at device
205gdb_test "run" {.+hit\sBreakpoint\s[\d].+\sbit_extract_kernel\s\(.*\)\sat.*}
206gdb_test "disable 1"
207gdb_test "continue" {.+Inferior\s[\d].+\sexited\snormally.+}
208delete_breakpoints
209gdb_test "run" {.+Inferior\s[\d].+\sexited\snormally.+}
abeeff98
LM
210
211
212gdb_exit
213
214
215
216
217
218
This page took 0.032473 seconds and 4 git commands to generate.