aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-03-28 08:23:05 -0400
committerSimon Marchi <simon.marchi@efficios.com>2023-03-28 11:53:40 -0400
commit7cd38c3c566502906ba3a6c214cc30cc5aadbda4 (patch)
tree59fc3b5f7e5bbb15a6028b2f5745509d28caceac /gdb
parent4516ff910bb256b629c72cc5cf3535607296e42d (diff)
downloadbinutils-7cd38c3c566502906ba3a6c214cc30cc5aadbda4.zip
binutils-7cd38c3c566502906ba3a6c214cc30cc5aadbda4.tar.gz
binutils-7cd38c3c566502906ba3a6c214cc30cc5aadbda4.tar.bz2
gdb/testsuite: allow "require" callbacks to provide a reason
When an allow_* proc returns false, it can be a bit difficult what check failed exactly, if the procedure does multiple checks. To make investigation easier, I propose to allow the "require" callbacks to be able to return a list of two elements: the zero/non-zero value, and a reason string. Use the new feature in allow_hipcc_tests to demonstrate it (it's also where I hit actually hit this inconvenience). On my computer (where GDB is built with amd-dbgapi support but where I don't have a suitable GPU target), I get: UNSUPPORTED: gdb.rocm/simple.exp: require failed: allow_hipcc_tests (no suitable amdgpu targets found) vs before: UNSUPPORTED: gdb.rocm/simple.exp: require failed: allow_hipcc_tests Change-Id: Id1966535b87acfcbe9eac99f49dc1196398c6578 Approved-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/lib/gdb.exp37
-rw-r--r--gdb/testsuite/lib/rocm.exp8
2 files changed, 33 insertions, 12 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 46aa1441..7fb4f1c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9251,22 +9251,43 @@ gdb_caching_proc have_avx {} {
#
# ARG can either be a name, or of the form !NAME.
#
-# Each name is a proc to evaluate in the caller's context. It returns
-# a boolean, and a "!" means to invert the result. If this is
-# nonzero, all is well. If it is zero, an "untested" is emitted and
-# this proc causes the caller to return.
+# Each name is a proc to evaluate in the caller's context. It can return a
+# boolean or a two element list with a boolean and a reason string.
+# A "!" means to invert the result. If this is true, all is well. If it is
+# false, an "unsupported" is emitted and this proc causes the caller to return.
+#
+# The reason string is used to provide some context about a require failure,
+# and is included in the "unsupported" message.
proc require { args } {
foreach arg $args {
if {[string index $arg 0] == "!"} {
- set ok 0
+ set required_val 0
set fn [string range $arg 1 end]
} else {
- set ok 1
+ set required_val 1
set fn $arg
}
- if {$ok != !![uplevel 1 $fn]} {
- unsupported "require failed: $arg"
+
+ set result [uplevel 1 $fn]
+ set len [llength $result]
+ if { $len == 2 } {
+ set actual_val [lindex $result 0]
+ set msg [lindex $result 1]
+ } elseif { $len == 1 } {
+ set actual_val $result
+ set msg ""
+ } else {
+ error "proc $fn returned a list of unexpected length $len"
+ }
+
+ if {$required_val != !!$actual_val} {
+ if { [string length $msg] > 0 } {
+ unsupported "require failed: $arg ($msg)"
+ } else {
+ unsupported "require failed: $arg"
+ }
+
return -code return 0
}
}
diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp
index b3e4353..389d73b 100644
--- a/gdb/testsuite/lib/rocm.exp
+++ b/gdb/testsuite/lib/rocm.exp
@@ -64,19 +64,19 @@ gdb_caching_proc allow_hipcc_tests {} {
# testing against GDBserver, there's no point in running the ROCm
# tests.
if {[target_info gdb_protocol] != ""} {
- return 0
+ return {0 "remote debugging"}
}
# Ensure that GDB is built with amd-dbgapi support.
set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
if { [string first "--with-amd-dbgapi" $output] == -1 } {
- return 0
+ return {0 "amd-dbgapi not supported"}
}
# Check we have a working hipcc compiler available.
set targets [hcc_amdgpu_targets]
if { [llength $targets] == 0} {
- return 0
+ return {0 "no suitable amdgpu targets found"}
}
set flags [list hip additional_flags=--offload-arch=[join $targets ","]]
@@ -93,7 +93,7 @@ gdb_caching_proc allow_hipcc_tests {} {
return 0;
}
} executable $flags]} {
- return 0
+ return {0 "failed to compile hip program"}
}
return 1