From patchwork Thu Jan 12 02:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63001 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D79D38493EB for ; Thu, 12 Jan 2023 03:01:37 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id E39C93858C66 for ; Thu, 12 Jan 2023 03:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E39C93858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 340831003FA96 for ; Thu, 12 Jan 2023 03:01:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id Fnpzp34cWFxgHFnpzpCGU0; Thu, 12 Jan 2023 03:01:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ePfWMFl1 c=1 sm=1 tr=0 ts=63bf77f3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=mDV3o1hIAAAA:8 a=0LbjRSOGAATxGzLodCMA:9 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fHdpRxvr4w766zcyA67MmUKCCxg3gbivgOekJu17xOc=; b=iX3ZpCTzyice5ap8NFxOc4N4Yt nDdVm6nG1j082qG8jx79ddRwNzNHDaPepTYCg8Antel65Gz05vJkWIE9KrM8L+BmoOLFQrNCjN11P c5uj72iFJPftCnvIvA8NUcAGe; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:53100 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pFnpy-000lEr-V6; Wed, 11 Jan 2023 20:01:07 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 02/79] Change 'require' to accept a list of predicates Date: Wed, 11 Jan 2023 19:59:35 -0700 Message-Id: <20230112030052.3306113-3-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112030052.3306113-1-tom@tromey.com> References: <20230112030052.3306113-1-tom@tromey.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.76.186 X-Source-L: No X-Exim-ID: 1pFnpy-000lEr-V6 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:53100 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 | 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 +- .../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.base/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 . # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test load_lib valgrind.exp 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. # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test load_lib valgrind.exp 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) # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test load_lib valgrind.exp diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.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 . # Valgrind gdbserver requires gdb with xml support. -require gdb_skip_xml_test 0 +require !gdb_skip_xml_test load_lib valgrind.exp diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwarf2/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 # 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 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 # 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 diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gdb/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. # Check if starti command is supported. -require use_gdb_stub 0 +require !use_gdb_stub load_lib dwarf.exp diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.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*])} { } # 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 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] { } # Check if start command is supported. -require use_gdb_stub 0 +require !use_gdb_stub standard_testfile 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. # Check if start command is supported. -require use_gdb_stub 0 +require !use_gdb_stub tuiterm_env 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 } -# 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.