]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change 'require' to accept a list of predicates
authorTom Tromey <tom@tromey.com>
Tue, 13 Dec 2022 22:00:07 +0000 (15:00 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 13 Jan 2023 20:18:54 +0000 (13:18 -0700)
This changes 'require' to accept a list of simple predicates.  For
now, each predicate is just the name of a proc, optionally prefixed
with "!" to indicate that the result should be inverted.

It's possible to make this fancier, but so far I haven't done so.  One
idea I had is to allow a predicate to have associated text to display
on failure.  Another is to convert the predicates that need a running
gdb (e.g., skip_python_tests) to start their own gdb, and then
'require' could enforce the rule that gdb not be running when it is
called.

gdb/testsuite/gdb.base/valgrind-bt.exp
gdb/testsuite/gdb.base/valgrind-disp-step.exp
gdb/testsuite/gdb.base/valgrind-infcall-2.exp
gdb/testsuite/gdb.base/valgrind-infcall.exp
gdb/testsuite/gdb.dwarf2/dw2-lines.exp
gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
gdb/testsuite/gdb.mi/mi-async.exp
gdb/testsuite/gdb.reverse/insn-reverse.exp
gdb/testsuite/gdb.tui/tui-missing-src.exp
gdb/testsuite/lib/gdb.exp

index d139d374def4261dca5ed1d69fb723db87305342..049b42f9b1e8b7a9c9744762d526261a7fd95eef 100644 (file)
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
 
 load_lib valgrind.exp
 
index 99ba29b89299ccc8ecf75c40824a1c4656188ead..05d0d8d6951621d80c6006552c478c73ee7eefb8 100644 (file)
@@ -19,7 +19,7 @@
 # automatically instead of getting stuck or crashing.
 
 # Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
 
 load_lib valgrind.exp
 
index c85abd8d2721b387a2d3fb91d20cda480773b175..13d290079cc41c8b547eed0b40efb09c927f1a43 100644 (file)
@@ -30,7 +30,7 @@
 # Aborted (core dumped)
 
 # Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
 
 load_lib valgrind.exp
 
index 3f7f81d9c21553221ecf5a74db35a3d0eade4efe..48b3bb2c6c1f9c1255e1c1bcf9afdf7fb8ca7c27 100644 (file)
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
 
 load_lib valgrind.exp
 
index 198d752606ce9e228e31cb9a471f996466834161..658d1f69a1893c406e55540e8aba4814fd165a32 100644 (file)
@@ -18,7 +18,7 @@
 load_lib dwarf.exp
 
 # This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support 1
+require dwarf2_support
 
 standard_testfile .c
 
index 6ae2035b37c86fbd3ead97ff1bc549cda3190464..d870275c3c6e6d468fe7c2c063c2d29f036f132b 100644 (file)
@@ -40,7 +40,7 @@
 load_lib dwarf.exp
 
 # This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support 1
+require dwarf2_support
 
 standard_testfile main.c .S
 
index fbce42b1a25cbef8123f09c00cbdfedde8864b2d..0915ee4de130c98ee2523a3dcb4257cca343c003 100644 (file)
@@ -26,7 +26,7 @@
 # directives.
 
 # Check if starti command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
 
 load_lib dwarf.exp
 
index 0b8349913dde116edc530c7f8c71c59dbf12f646..880db6de68be5afa5da65b6bb4215ae3c45f9994 100644 (file)
@@ -26,7 +26,7 @@ if {!([isnative] && [istarget *-linux*])} {
 }
 
 # Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
 
 # The plan is for async mode to become the default but toggle for now.
 set saved_gdbflags $GDBFLAGS
index 9cefea931086696f2f583df59dc8b019e1fdc3dd..a73220679221e573756ffb33eb8aff2d255b8efb 100644 (file)
@@ -18,7 +18,7 @@ if ![supports_reverse] {
 }
 
 # Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
 
 standard_testfile
 
index b373aadadc3812f2bb098e11fed042d05c0ee61f..7dd8324f2770f0faeeeeeb28dd2d1a2b14897e1b 100644 (file)
@@ -26,7 +26,7 @@
 # 7. Going back to main() shall result in no contents again.
 
 # Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
 
 tuiterm_env
 
index 39dfa67c34405297f2641b12b2afbf5fc6701757..88dfdafb6545258f5d74c2384b56400ff5e0626d 100644 (file)
@@ -9061,41 +9061,30 @@ gdb_caching_proc have_avx {
     return $status
 }
 
-# Called as either:
-# - require EXPR VAL
-# - require EXPR OP VAL
-# In the first case, OP is ==.
-#
-# Require EXPR OP VAL, where EXPR is evaluated in caller context.  If not,
-# return in the caller's context.
-
-proc require { fn arg1 {arg2 ""} } {
-    if { $arg2 == "" } {
-       set op ==
-       set val $arg1
-    } else {
-       set op $arg1
-       set val $arg2
-    }
-    set res [uplevel 1 $fn]
-    if { [expr $res $op $val] } {
-       return
-    }
+# Called as
+# - require ARG...
+#
+# 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.
 
-    switch "$fn $op $val" {
-       "gdb_skip_xml_test == 0" { set msg "missing xml support" }
-       "ensure_gdb_index $binfile != -1" -
-       "ensure_gdb_index $binfile -dwarf-5 != -1" {
-           set msg "Couldn't ensure index in binfile"
+proc require { args } {
+    foreach arg $args {
+       if {[string index $arg 0] == "!"} {
+           set ok 0
+           set fn [string range $arg 1 end]
+       } else {
+           set ok 1
+           set fn $arg
        }
-       "use_gdb_stub == 0" {
-           set msg "Remote stub used"
+       if {$ok != !![uplevel 1 $fn]} {
+           untested "require failed: $arg"
+           return -code return 0
        }
-       default { set msg "$fn != $val" }
     }
-
-    untested $msg
-    return -code return 0
 }
 
 # Wait up to ::TIMEOUT seconds for file PATH to exist on the target system.