From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 481D738493FF; Fri, 13 Jan 2023 20:34:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 481D738493FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673642041; bh=LslnFuDcX/itySi+a8ev7WWtK0OjmQZJi1AaegBpfsw=; h=From:To:Subject:Date:From; b=AON0qCe5cv5diAzys3fuErufi/GN1lEvWWd9gdjwBD9nMMXKybycgTGtWQpzporXL HRGylo/e3WehyWCrJl9F7UHQE3B8RSy+HzLC8sCixlJLYGNOkPsl/I+2lDpNwXx4B1 XIxAB/C8SKfdYDb5qao3EbS+sSZVNTauVkUBa1Oc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Change 'require' to accept a list of predicates X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 15bdcf4ca1514b89c242eccd3a74599bdd00e3e0 X-Git-Newrev: 793862d2f427bdc7b80da5bb917acccb06c4ba61 Message-Id: <20230113203401.481D738493FF@sourceware.org> Date: Fri, 13 Jan 2023 20:34:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D793862d2f427= bdc7b80da5bb917acccb06c4ba61 commit 793862d2f427bdc7b80da5bb917acccb06c4ba61 Author: Tom Tromey Date: Tue Dec 13 15:00:07 2022 -0700 Change 'require' to accept a list of predicates =20 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. =20 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. Diff: --- gdb/testsuite/gdb.base/valgrind-bt.exp | 2 +- gdb/testsuite/gdb.base/valgrind-disp-step.exp | 2 +- gdb/testsuite/gdb.base/valgrind-infcall-2.exp | 2 +- gdb/testsuite/gdb.base/valgrind-infcall.exp | 2 +- gdb/testsuite/gdb.dwarf2/dw2-lines.exp | 2 +- .../gdb.dwarf2/dw2-symtab-includes-lookup.exp | 2 +- .../gdb.dwarf2/frame-inlined-in-outer-frame.exp | 2 +- gdb/testsuite/gdb.mi/mi-async.exp | 2 +- gdb/testsuite/gdb.reverse/insn-reverse.exp | 2 +- gdb/testsuite/gdb.tui/tui-missing-src.exp | 2 +- gdb/testsuite/lib/gdb.exp | 51 +++++++++---------= ---- 11 files changed, 30 insertions(+), 41 deletions(-) diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.bas= e/valgrind-bt.exp index d139d374def..049b42f9b1e 100644 --- a/gdb/testsuite/gdb.base/valgrind-bt.exp +++ b/gdb/testsuite/gdb.base/valgrind-bt.exp @@ -14,7 +14,7 @@ # along with this program. If not, see . =20 # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test =20 load_lib valgrind.exp =20 diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.exp b/gdb/testsuite/= gdb.base/valgrind-disp-step.exp index 99ba29b8929..05d0d8d6951 100644 --- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp +++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp @@ -19,7 +19,7 @@ # automatically instead of getting stuck or crashing. =20 # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test =20 load_lib valgrind.exp =20 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp b/gdb/testsuite/= gdb.base/valgrind-infcall-2.exp index c85abd8d272..13d290079cc 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp +++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp @@ -30,7 +30,7 @@ # Aborted (core dumped) =20 # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test =20 load_lib valgrind.exp =20 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gd= b.base/valgrind-infcall.exp index 3f7f81d9c21..48b3bb2c6c1 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall.exp +++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp @@ -14,7 +14,7 @@ # along with this program. If not, see . =20 # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test =20 load_lib valgrind.exp =20 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwa= rf2/dw2-lines.exp index 198d752606c..658d1f69a18 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp @@ -18,7 +18,7 @@ load_lib dwarf.exp =20 # This test can only be run on targets which support DWARF-2 and use gas. -require dwarf2_support 1 +require dwarf2_support =20 standard_testfile .c =20 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp b/gdb/= testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp index 6ae2035b37c..d870275c3c6 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp @@ -40,7 +40,7 @@ load_lib dwarf.exp =20 # This test can only be run on targets which support DWARF-2 and use gas. -require dwarf2_support 1 +require dwarf2_support =20 standard_testfile main.c .S =20 diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gd= b/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp index fbce42b1a25..0915ee4de13 100644 --- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp +++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp @@ -26,7 +26,7 @@ # directives. =20 # Check if starti command is supported. -require use_gdb_stub 0 +require !use_gdb_stub =20 load_lib dwarf.exp =20 diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-as= ync.exp index 0b8349913dd..880db6de68b 100644 --- a/gdb/testsuite/gdb.mi/mi-async.exp +++ b/gdb/testsuite/gdb.mi/mi-async.exp @@ -26,7 +26,7 @@ if {!([isnative] && [istarget *-linux*])} { } =20 # Check if start command is supported. -require use_gdb_stub 0 +require !use_gdb_stub =20 # The plan is for async mode to become the default but toggle for now. set saved_gdbflags $GDBFLAGS diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb= .reverse/insn-reverse.exp index 9cefea93108..a7322067922 100644 --- a/gdb/testsuite/gdb.reverse/insn-reverse.exp +++ b/gdb/testsuite/gdb.reverse/insn-reverse.exp @@ -18,7 +18,7 @@ if ![supports_reverse] { } =20 # Check if start command is supported. -require use_gdb_stub 0 +require !use_gdb_stub =20 standard_testfile =20 diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.= tui/tui-missing-src.exp index b373aadadc3..7dd8324f277 100644 --- a/gdb/testsuite/gdb.tui/tui-missing-src.exp +++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp @@ -26,7 +26,7 @@ # 7. Going back to main() shall result in no contents again. =20 # Check if start command is supported. -require use_gdb_stub 0 +require !use_gdb_stub =20 tuiterm_env =20 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 39dfa67c344..88dfdafb654 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9061,41 +9061,30 @@ gdb_caching_proc have_avx { return $status } =20 -# Called as either: -# - require EXPR VAL -# - require EXPR OP VAL -# In the first case, OP is =3D=3D. -# -# 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 =3D=3D "" } { - set op =3D=3D - 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. =20 - switch "$fn $op $val" { - "gdb_skip_xml_test =3D=3D 0" { set msg "missing xml support" } - "ensure_gdb_index $binfile !=3D -1" - - "ensure_gdb_index $binfile -dwarf-5 !=3D -1" { - set msg "Couldn't ensure index in binfile" +proc require { args } { + foreach arg $args { + if {[string index $arg 0] =3D=3D "!"} { + set ok 0 + set fn [string range $arg 1 end] + } else { + set ok 1 + set fn $arg } - "use_gdb_stub =3D=3D 0" { - set msg "Remote stub used" + if {$ok !=3D !![uplevel 1 $fn]} { + untested "require failed: $arg" + return -code return 0 } - default { set msg "$fn !=3D $val" } } - - untested $msg - return -code return 0 } =20 # Wait up to ::TIMEOUT seconds for file PATH to exist on the target system.