Merge branch 'master' into merge-job
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.rocm / devicecode_breakpoint_test.exp
1 # Copyright (C) 2019-2020 Free Software Foundation, Inc.
2 # Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
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
18 set testfile "bit_extract_compile"
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"
97 gdb_expect -re "\\s+(\\d+)\\s+ROCm Thread\\s+(\\d+\.\\d+)\\s+(\\(\\d+,\\d+,\\d+\\)/\\d+).*$gdb_prompt $" {
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
167
168
169 gdb_exit
170
171
172
173
174
175
This page took 0.034382 seconds and 4 git commands to generate.