From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id 19D7C3858D39 for ; Tue, 14 Mar 2023 14:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19D7C3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2c.google.com with SMTP id bf15so6435634iob.7 for ; Tue, 14 Mar 2023 07:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1678802579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rlA6lBD79EYuqluM88nyin2JRW3eyUM0X4jau0GJs1Q=; b=X5Bqy/Ka+D9ksbZyeGhZwP9Z0SoBByKFZiHHUBQnhI5dTxBVD5neFIbRJSavHOSbuL fgronbPcdLuGmjfF5un+k/XQqSaskh7gEAvHIOuvpmHeh0XlVp3kQAT7H+ZYEZfVyaUt Q7amOx41W4hXTxLdFbHuSQ0XxvEWe/x2I4ctqz9XD8hwcbJ9Rf5o+KAUwtnDyFfqigiA aSZuMNN+efKw4Hdwu8mDww6k9+CGItSaJcDlYvTp5Q8Soei4JLM4xttJ/6Y3NH5lI2RD ymlFeHpbWIF+lMDq5k5SgdriuIbjsFc+KHzXOblPrNNvyvpQxxOh601r3y2qofZ17h/S IoOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678802579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rlA6lBD79EYuqluM88nyin2JRW3eyUM0X4jau0GJs1Q=; b=lHKOPSWqrXnSpYU9APzB45hhNHF7NlzVUGIKkh+q6jZdJz9ktmWQQKi7lRiNZWiF50 s7fuE6mEylrglknqaRwrzTx7ZlZ41BlnxD0I7gS0rFLnMEsrpiKQ2XCZ2W3CzryZUVbr YlVsl0Uhpv7BVCUEMcfecq8xeKF+iJXjRTyBzSeJPY+J8hDNo/vXzYWRf4+gXt7eUCqP x0Q9dHNc7sd3tI3pxvnAuCzciB5lp1Ha0crjDeMhFZCyJNXtTRH98xX/L9sQzglGPKqH c+SDwsQVSPumqYeEFXRwROb7LFES+KjJDtwsN9GbWKFNWeY93EXqAxERLh2+udufi0jb mapQ== X-Gm-Message-State: AO0yUKUUUYYwC9zFsvHDnfcC1bYcYRvNjGdNsKgC048WGx71IglJXvRQ cP4/B/dyb86huA+/Kp+d9AocvIeOSVhL3MWK2Dc= X-Google-Smtp-Source: AK7set9kQ7GGkgnxS2OgcNO9ecdKJ8SpKODWyKUUrkgjKN+aVorgfV81qG+fJLwoM+Oe3kD7GC/R+Q== X-Received: by 2002:a6b:a07:0:b0:6e5:25a2:c63d with SMTP id z7-20020a6b0a07000000b006e525a2c63dmr22243442ioi.21.1678802578890; Tue, 14 Mar 2023 07:02:58 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id q3-20020a02a303000000b003a971c488cesm778356jai.173.2023.03.14.07.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:02:58 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 1/3] Introduce rust_at_least helper proc Date: Tue, 14 Mar 2023 08:02:49 -0600 Message-Id: <20230314140251.1081243-2-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230314140251.1081243-1-tromey@adacore.com> References: <20230314140251.1081243-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.5 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 List-Id: 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 | 25 +++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp index 976b723833e..3c65efb30c0 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..3de8fefdcc0 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..c81a93a9303 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 f3739e2ce02..381871e22f4 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -112,3 +112,28 @@ gdb_caching_proc rust_compiler_version {} { } return 0.0 } + +# A helper that checks that the rust compiler is at least the given +# version. This is handy for use with 'require'. +proc rust_at_least {atleast} { + foreach n1 [split [rust_compiler_version] .] n2 [split $atleast .] { + if {$n1 == ""} { + # Have 1.2, wanted 1.2.1. + return 0 + } + if {$n2 == ""} { + # Have 1.2.1, wanted 1.2. + return 1 + } + if {$n1 > $n2} { + # Have 1.3, wanted 1.2. + return 1 + } + if {$n1 < $n2} { + # Have 1.1, wanted 1.2. + return 0 + } + } + # Completely equal. + return 1 +} -- 2.39.1