[PATCH v2 42/47] testsuite, sycl: add tests for stepping and accessing data elements

Tankut Baris Aktemur
2024-12-13T16:38:05Z

Add SYCL test cases for
- stepping inside the kernel
- reading data elements and locals
- modifying data elements and locals
---
gdb/testsuite/gdb.sycl/step-into-function.exp | 47 ++++++++++++++++++++++++
gdb/testsuite/gdb.sycl/step.exp | 51 +++++++++++++++++++++++++++
2 files changed, 98 insertions(+)

diff --git a/gdb/testsuite/gdb.sycl/step-into-function.exp b/gdb/testsuite/gdb.sycl/step-into-function.exp
new file mode 100644
index 0000000000000000000000000000000000000000..06d0046f46f1be92a997343be6d718c9d702caeb
--- /dev/null
+++ b/gdb/testsuite/gdb.sycl/step-into-function.exp
@@ -0,0 +1,47 @@
+# 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 stepping into a kernel function.
+
+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 inside [gdb_get_line_number "ordinary-outer-loc"]
+ gdb_breakpoint $inside
+ gdb_continue_to_breakpoint "inside" ".*$srcfile:$inside.*"
+
+ gdb_test "step" "first .* at .*" "step into function"
+ }
+}
diff --git a/gdb/testsuite/gdb.sycl/step.exp b/gdb/testsuite/gdb.sycl/step.exp
new file mode 100644
index 0000000000000000000000000000000000000000..b16679f8704869cf7c0df061c40dde66b08b8b81
--- /dev/null
+++ b/gdb/testsuite/gdb.sycl/step.exp
@@ -0,0 +1,51 @@
+# 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; in particular, single-stepping the
+# source and printing values of local vars and data elements.
+
+load_lib sycl.exp
+
+standard_testfile single-task.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
+ }
+
+ # Break at the first line of the kernel, then make steps.
+ set first_line [gdb_get_line_number "kernel-line-1"]
+ gdb_breakpoint $first_line
+ gdb_continue_to_breakpoint "first line" ".*$srcfile:$first_line.*"
+
+ gdb_test "next" "int four = .*" "next 1"
+ gdb_test "next" "int fourteen = .*" "next 2"
+ gdb_test "next" "numbers.0. = .*" "next 3"
+ }
+}