From patchwork Wed Mar 1 20:25:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65863 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 DED043858422 for ; Wed, 1 Mar 2023 20:26:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DED043858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677702370; bh=KTV6LPfkPLFLO5xHXpsTqyCBrw7bc6wN5xtnK7nW/Lk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=E5IyaZsiiViMgoQaX1iGY8zeVr2NCtemsdABzHllIV2C/97B8zvRytzfThoqKmGYb Mr1PraNhSjXLyLfq8v44/ZFic+TcZDceCcKEyerhI1kDu1+0Zlm1NEy9qcv/+QgHd5 TUwKs1a8+BwnTdvY+q62w6pma6aSHgWNroxJmR7U= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id EDBCF3858D3C for ; Wed, 1 Mar 2023 20:25:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDBCF3858D3C Received: by mail-il1-x12d.google.com with SMTP id g9so1529560ila.8 for ; Wed, 01 Mar 2023 12:25:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677702346; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KTV6LPfkPLFLO5xHXpsTqyCBrw7bc6wN5xtnK7nW/Lk=; b=aPta0rKLrKqqCPFRWsQ1u0c20xSDDmRLatrcr5SsUpS7dAjrMFlCvcCsb0K4tCRrzS Xpg/zqNKqpMu3vIbojf1c5oedYF86mCoyKE5KktF3wsqifrCrwVA+K3dO0YSAX4Ni+4y zH4WeG8KMF80YIO8C32yQfqynHqcOIA7NlOVkhvGAsR7y1TQH0HP9ccMtGPwjkpfMJAj 1nfds/PrQHId8sKdZ06NEBIOlJbfMxsMzXntvhQWv3ZDEwkqUGI3W2WqY6ikXBS/s6JN uEAZxLSW/2z8wqVLeRlNL1PjW1vPvQo9uCTVPOpMhYsEsjZu+uN+ITgZGHuH8NqEqc/d fFdg== X-Gm-Message-State: AO0yUKWzEthma0maramg1tcLydGVGZCK5SeGV/W92LzNfN8aERlFMpkl MKouocDdnML/rpVJR0yKr1IreyKhekKQ0SqL X-Google-Smtp-Source: AK7set+bm4dC4Ja/MF+de1zF5PM0HIYwiXqCw8WamHTiUBTQ85CDECUS1zNQQfwusxrM2bxrXhm0fQ== X-Received: by 2002:a05:6e02:1542:b0:315:5141:339a with SMTP id j2-20020a056e02154200b003155141339amr6944156ilu.7.1677702346163; Wed, 01 Mar 2023 12:25:46 -0800 (PST) Received: from localhost.localdomain (75-166-130-93.hlrn.qwest.net. [75.166.130.93]) by smtp.gmail.com with ESMTPSA id v8-20020a927a08000000b0031578323bc5sm424633ilc.56.2023.03.01.12.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 12:25:45 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Introduce rust_at_least helper proc Date: Wed, 1 Mar 2023 13:25:38 -0700 Message-Id: <20230301202538.3291371-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This adds a 'rust_at_least' helper proc, for checking the version of the Rust compiler in use. It then changes various tests to use this with 'require'. --- gdb/testsuite/gdb.rust/rawids.exp | 8 +------- gdb/testsuite/gdb.rust/unicode.exp | 8 +------- gdb/testsuite/gdb.rust/unsized.exp | 5 +---- gdb/testsuite/lib/rust-support.exp | 11 +++++++++++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp index 976b723833e..8b7db877328 100644 --- a/gdb/testsuite/gdb.rust/rawids.exp +++ b/gdb/testsuite/gdb.rust/rawids.exp @@ -16,13 +16,7 @@ # Test raw identifiers. load_lib rust-support.exp -require allow_rust_tests - -set v [split [rust_compiler_version] .] -if {[lindex $v 0] == 1 && [lindex $v 1] < 30} { - untested "raw identifiers require rust 1.30 or greater" - return -1 -} +require allow_rust_tests {rust_at_least 1 30} standard_testfile .rs if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} { diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp index 2b4766b5553..c2bc0ef960f 100644 --- a/gdb/testsuite/gdb.rust/unicode.exp +++ b/gdb/testsuite/gdb.rust/unicode.exp @@ -16,14 +16,8 @@ # Test raw identifiers. load_lib rust-support.exp -require allow_rust_tests - # Non-ASCII identifiers were allowed starting in 1.53. -set v [split [rust_compiler_version] .] -if {[lindex $v 0] == 1 && [lindex $v 1] < 53} { - untested "this test requires rust 1.53 or greater" - return -1 -} +require allow_rust_tests {rust_at_least 1 53} # Enable basic use of UTF-8. LC_ALL gets reset for each testfile. setenv LC_ALL C.UTF-8 diff --git a/gdb/testsuite/gdb.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp index f81be8a3078..b3bd2d7d1c5 100644 --- a/gdb/testsuite/gdb.rust/unsized.exp +++ b/gdb/testsuite/gdb.rust/unsized.exp @@ -31,10 +31,7 @@ if {![runto ${srcfile}:$line]} { gdb_test "ptype us" " = .*V<\\\[u8\\\]>.*" -set v [split [rust_compiler_version] .] -# The necessary debuginfo generation landed in 1.60, but had a bug -# that was fixed in 1.61. -if {[lindex $v 0] > 1 || [lindex $v 1] >= 61} { +if {[rust_at_least 1 61]} { gdb_test "print us2" " = .*Box<.*> \\\[1, 2, 3\\\]" gdb_test "ptype us2" "type = .*" } diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index df517647ce9..c4a403732dc 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -112,3 +112,14 @@ gdb_caching_proc rust_compiler_version { } return 0.0 } + +# A helper that checks that the rust compiler is at least MAJOR.MINOR. +# This is handy for use with 'require'. +proc rust_at_least {major minor} { + set v [split [rust_compiler_version] .] + if {[lindex $v 0] < $major + || ([lindex $v 0] == $major && [lindex $v 1] < $minor)} { + return 0 + } + return 1 +}