[PATCH v2 41/47] testsuite, sycl: add test for 'info locals' and 'info args'

Tankut Baris Aktemur
2024-12-13T16:19:29Z

Test that local variables and arguments inside a SYCL kernel can be
displayed correctly.
---
gdb/testsuite/gdb.sycl/info-locals-and-args.exp | 78 +++++++++++++++++++++++++
1 file changed, 78 insertions(+)

diff --git a/gdb/testsuite/gdb.sycl/info-locals-and-args.exp b/gdb/testsuite/gdb.sycl/info-locals-and-args.exp
new file mode 100644
index 0000000000000000000000000000000000000000..289d3656afdddc9921c9c38487c5c7cf92996993
--- /dev/null
+++ b/gdb/testsuite/gdb.sycl/info-locals-and-args.exp
@@ -0,0 +1,78 @@
+# Copyright 2019-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Tests GDBs support for SYCL for the "info locals" and "info args"
+# commands inside a kernel.
+
+load_lib sycl.exp
+
+standard_testfile call-stack.cpp
+
+set sycl_device_list [init_sycl_devices_list]
+if {[llength $sycl_device_list] == 0} {
+ unsupported "target does not support SYCL"
+ return 0
+}
+
+if {[build_executable "failed to compile $srcfile" \
+ "${binfile}" $srcfile {sycl debug}]} {
+ return -1
+}
+
+foreach device $sycl_device_list {
+ sycl_with_intelgt_lock $device {
+ clean_restart "${binfile}"
+
+ if {![sycl_start $device]} {
+ continue
+ }
+
+ set outer_loc [gdb_get_line_number "ordinary-outer-loc"]
+ set inner_loc [gdb_get_line_number "kernel-function-return"]
+ gdb_breakpoint "$outer_loc"
+ gdb_breakpoint "$inner_loc"
+
+ gdb_continue_to_breakpoint "bp 1" ".*$srcfile:$outer_loc.*"
+
+ set fill "\[^\r\n\]+"
+ set ten 0
+ set four 0
+ set fourteen 0
+ gdb_test_multiple "info locals" "info locals 1" -lbl {
+ -re "\r\nten = $fill" {
+ set ten 1
+ exp_continue
+ }
+ -re "\r\nfour = $fill" {
+ set four 1
+ exp_continue
+ }
+ -re "\r\nfourteen = $fill" {
+ set fourteen 1
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { $ten == 1 && $four == 1 && $fourteen == 1 } \
+ $gdb_test_name
+ }
+ }
+
+ gdb_continue_to_breakpoint "bp 2" ".*$srcfile:$inner_loc.*"
+ gdb_test "info locals" "result = $fill.*" "info locals 2"
+ gdb_test "info args" [multi_line \
+ "x1 = $fill" \
+ "y1 = $fill"]
+ }
+}