[PATCH v2 45/47] testsuite, arch, intelgt: add a disassembly test

Tankut Baris Aktemur
2024-12-13T16:33:25Z

From: Albertano Caruso <albertano.caruso@intel.com>

Test the disassemble command on the Intel GT target.
---
gdb/testsuite/gdb.arch/intelgt-disassemble.exp | 82 ++++++++++++++++++++++++++
gdb/testsuite/gdb.arch/sycl-simple.cpp | 42 +++++++++++++
2 files changed, 124 insertions(+)

diff --git a/gdb/testsuite/gdb.arch/intelgt-disassemble.exp b/gdb/testsuite/gdb.arch/intelgt-disassemble.exp
new file mode 100644
index 0000000000000000000000000000000000000000..8269d2ba2ccf3166b7d03a4f47724b7e0cc8b3bc
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/intelgt-disassemble.exp
@@ -0,0 +1,82 @@
+# 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 disassembly support for Intel(R) Graphics Technology.
+
+load_lib sycl.exp
+
+standard_testfile sycl-simple.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 {
+ if {![require_sycl_device "$device" "gpu" "Intel*"]} {
+ unsupported "test is aimed at Intel GPUs only"
+ continue
+ }
+
+ sycl_with_intelgt_lock $device {
+ clean_restart "${binfile}"
+
+ if {![sycl_start $device]} {
+ continue
+ }
+
+ # Set breakpoint inside the kernel.
+ set bp_location [gdb_get_line_number "inside-kernel"]
+ gdb_breakpoint "$srcfile:$bp_location"
+
+ # Hit the breakpoint.
+ gdb_continue_to_breakpoint "kernel" ".*$srcfile:$bp_location.*"
+
+ # Check if IGA is supposed to exist.
+ set has_iga 0
+ gdb_test_multiple "show configuration" "check iga" {
+ -re -wrap "with-libiga64.*" {
+ set has_iga 1
+ }
+ -re -wrap "without-libiga64.*" {
+ set has_iga 0
+ }
+ }
+
+ if {$has_iga} {
+ gdb_test "disassemble \$pc, \$pc+64" \
+ [multi_line "Dump of assembler code from $hex to $hex:" \
+ "=> $hex .*" \
+ "End of assembler dump."] \
+ "disassemble"
+ } else {
+ unsupported "disassemble"
+
+ gdb_test "disassemble \$pc, \$pc+64" \
+ [multi_line "Dump of assembler code from $hex to $hex:" \
+ "=> $hex \[^\r\n\]+" \
+ "Disassemble feature not available: libiga64 is missing." \
+ "" \
+ "unknown disassembler error.*"] \
+ "disassembly is unavailable without iga"
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/sycl-simple.cpp b/gdb/testsuite/gdb.arch/sycl-simple.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a51fd1ac3fda687879fddf909f246059a54c796f
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/sycl-simple.cpp
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+#include <sycl/sycl.hpp>
+#include "../lib/sycl-util.cpp"
+
+int
+main (int argc, char *argv[])
+{
+ int data = 42;
+
+ { /* Extra scope enforces waiting on the kernel. */
+ sycl::queue deviceQueue {get_sycl_queue (argc, argv)};
+ sycl::buffer<int, 1> buf {&data, sycl::range<1> {1}};
+
+ deviceQueue.submit ([&] (sycl::handler& cgh)
+ {
+ auto accessor = buf.get_access<sycl::access::mode::write> (cgh);
+
+ cgh.single_task<class simple_kernel> ([=] ()
+ {
+ accessor[0] = 99; /* inside-kernel */
+ });
+ });
+ }
+
+ return 0;
+}