From patchwork Fri May 26 17:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 70171 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 85B9238498E0 for ; Fri, 26 May 2023 17:58:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id C55E23858289 for ; Fri, 26 May 2023 17:57:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C55E23858289 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id EAC031A84C5E for ; Fri, 26 May 2023 13:57:57 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 3/4] Add a have_native_target helper function for use with require. Date: Fri, 26 May 2023 10:57:41 -0700 Message-Id: <20230526175742.66885-4-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230526175742.66885-1-jhb@FreeBSD.org> References: <20230526175742.66885-1-jhb@FreeBSD.org> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Fri, 26 May 2023 13:57:58 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE 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" Move logic from auto-connect-native-target.exp into this helper. --- .../gdb.base/auto-connect-native-target.exp | 18 +----------------- gdb/testsuite/lib/gdb.exp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/auto-connect-native-target.exp b/gdb/testsuite/gdb.base/auto-connect-native-target.exp index 002a6d61126..0586cd4baf4 100644 --- a/gdb/testsuite/gdb.base/auto-connect-native-target.exp +++ b/gdb/testsuite/gdb.base/auto-connect-native-target.exp @@ -22,23 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -# Whether this GDB is configured with a "native" target. -set have_native 0 - -set test "help target native" -gdb_test_multiple $test $test { - -re "Undefined target command.*$gdb_prompt $" { - set have_native 0 - } - -re "Native process.*$gdb_prompt $" { - set have_native 1 - } -} - -if { !$have_native } { - unsupported "no \"target native\" support." - return -} +require have_native_target # Returns the topmost target pushed on the target stack. TEST is used # as test message. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 133d914aff8..128c0779b69 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9739,6 +9739,23 @@ gdb_caching_proc have_compile_and_link_flag { flag } { additional_flags=$flag] } +# Return 1 if this GDB is configured with a "native" target. + +gdb_caching_proc have_native_target {} { + global gdb_prompt + + set test "help target native" + gdb_test_multiple $test $test { + -re "Undefined target command.*$gdb_prompt $" { + return 0 + } + -re "Native process.*$gdb_prompt $" { + return 1 + } + } + return 0 +} + # Handle include file $srcdir/$subdir/FILE. proc include_file { file } {