From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6A5EA38BE6AF for ; Wed, 8 Jun 2022 14:22:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A5EA38BE6AF Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-oqcPB4hDNvmrX2S0awlT-A-1; Wed, 08 Jun 2022 10:22:29 -0400 X-MC-Unique: oqcPB4hDNvmrX2S0awlT-A-1 Received: by mail-wr1-f70.google.com with SMTP id v14-20020a5d610e000000b00213b51a0234so4228555wrt.11 for ; Wed, 08 Jun 2022 07:22:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5q05uHHK2GUniRNtriLCkkZ/K2gjjYr7yN6lDsjSfk=; b=rnGmszr5sbZnaGwp2JJx3GmkVrlRz1tRfvOgqI3RXRb1vS4Byyc0IGghJhkwaMbsMB b5AwPLafxSLK84J96FYlr8YQL8VuziPa5/E4x9hlQNO2v8CZLk3PilFa793HpUUbJJoL zDeq4HFR4chwD+39EgfAIySyMj/w5OwcOMOPb/U1sZ1nUphlNewGhSI3uwhAY+ilLVFw RcgKWyO0AjFEuJKZjuBIPQAJg+Rhhbn+8MUjWsknq9M+1olF7lYe3pRyVTYxAQ58XdJz 5g/yvaIpwFhZ2LcLfVwKbOc7AHqocJbNc5NLbDgubinkHnpQ6LYuuwUgUCDJHRG0OyT8 K9Ww== X-Gm-Message-State: AOAM531XuGPPxU+fySyH9Ra2Grmr6v3tGhe38Gt7ruCW/5mnyOtyzYbG 5KLTmwEwdFwCA7Vijng596icCczWDodbhaREpPlOPRZeuwKrNjcSgy5HgqtXMUXg20PhZlrh17H 05X1ouUxvMBeN1VtnKn9WowZL9ASR5iwHTjclt7zTlURSyQ+IfxcDZ9HFjwKP3mSZvpkB06BwbQ == X-Received: by 2002:adf:ea87:0:b0:211:68d:7c93 with SMTP id s7-20020adfea87000000b00211068d7c93mr33059742wrm.412.1654698147865; Wed, 08 Jun 2022 07:22:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZxhUE/2rVfTUt2B17Zxra9349LSRsf5IqcFYw1RCsJYsbZQavPcAtB136ojz9yiax1DLNbQ== X-Received: by 2002:adf:ea87:0:b0:211:68d:7c93 with SMTP id s7-20020adfea87000000b00211068d7c93mr33059721wrm.412.1654698147615; Wed, 08 Jun 2022 07:22:27 -0700 (PDT) Received: from localhost (host109-152-215-36.range109-152.btcentralplus.com. [109.152.215.36]) by smtp.gmail.com with ESMTPSA id j22-20020a5d4536000000b0021108003596sm20830096wra.10.2022.06.08.07.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:22:27 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/5] gdb/testsuite: handle errors better in test_compiler_info Date: Wed, 8 Jun 2022 15:22:16 +0100 Message-Id: <34f4b3846b1d3d9011a0babba7dbde8f320cf4ea.1654697966.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <871qvzgrwd.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: , X-List-Received-Date: Wed, 08 Jun 2022 14:22:31 -0000 Now that get_compiler_info might actually fail (if the language is not handled), then we should try to handle this failure better in test_compiler_info. After this commit, if get_compiler_info fails then we will return a suitable result depending on how the user called test_compiler_info. If the user does something like: set version [test_compiler_info "" "unknown-language"] Then test_compiler_info will return an empty string. My assumption is that the user will be trying to match 'version' against something, and the empty string hopefully will not match. If the user does something like: if { [test_compiler_info "some_pattern" "unknown-language"] } { .... } Then test_compiler_info will return false which seems the obvious choice. There should be no change in the test results after this commit. --- gdb/testsuite/lib/gdb.exp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 140da05b35e..9b4f3a180ef 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4199,7 +4199,17 @@ proc get_compiler_info {{language "c"}} { proc test_compiler_info { {compiler ""} {language "c"} } { global compiler_info - get_compiler_info $language + + if [get_compiler_info $language] { + # An error will already have been printed in this case. Just + # return a suitable result depending on how the user called + # this function. + if [string match "" $compiler] { + return "" + } else { + return false + } + } # If no arg, return the compiler_info string. if [string match "" $compiler] { -- 2.25.4