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.129.124]) by sourceware.org (Postfix) with ESMTPS id A85F4392AC25 for ; Wed, 8 Jun 2022 14:22:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A85F4392AC25 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-369-2tKxsWPpNseozBPT6374kQ-1; Wed, 08 Jun 2022 10:22:28 -0400 X-MC-Unique: 2tKxsWPpNseozBPT6374kQ-1 Received: by mail-wr1-f70.google.com with SMTP id q14-20020a5d61ce000000b00210353e32b0so4860493wrv.12 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=WTdHkmTmEcyJhBaJTUedIrdJcLUdpCWdbbPBUIIa5tQ=; b=IWLg9BYJXDcQxnFz5Z8k6K0GgZ8WRBW+/cTkNEKchxA3/cCijbpLwkhcsgaB9Rv2jb C5Zy1MaefaT9wALGH+h9WRp+JntUS2GzreAsflGGTQAEmPoQY29PEFU4omuSOHk9GXnz 7ow/U4MAhX/etzEaKyl4VTExlAEcGSDSPG1/q4dfhB1DCrSfk5o4uimSTi2PwBFOTU+N beibV2PC+41LKmAHzpfeEYvsfk73fDNtIHxq7bEH1X38E/vWwByx4gPpFxe8GNSn+ANC cLVfpCO5yZ4gzUElU1jov16kMC3ldNmGvqmQsPMZL4IXnLZtmxBfi/gMhEJ93YkQqm3N GiYQ== X-Gm-Message-State: AOAM532Cxx2WrlXB4J2r3bKlhiAn6tg2eGpCgc0/WKfw4kifB6qFWUmx /IOMemKpeViHVs1MW16ZNV7XLLXX2Srh75oSe0FXyu433c9yDbljtOtPXRW7eUmmePBds+2Xt9n /2X2Dx/WrMDKCfNT9ofiqRKnLpajKCwSQmPdYyWwyZx/BaW87KPiCNDx8khY+6d3NyYZw8oSedw == X-Received: by 2002:a05:600c:2312:b0:397:7647:2ac4 with SMTP id 18-20020a05600c231200b0039776472ac4mr34499439wmo.125.1654698146569; Wed, 08 Jun 2022 07:22:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx526dnTdfiO4Q9GJp9JoHMqB5hweK/nMFRYJfX2OSgsLk8WFVYqiR/X/bijSeecjMOD846cg== X-Received: by 2002:a05:600c:2312:b0:397:7647:2ac4 with SMTP id 18-20020a05600c231200b0039776472ac4mr34499407wmo.125.1654698146257; Wed, 08 Jun 2022 07:22:26 -0700 (PDT) Received: from localhost (host109-152-215-36.range109-152.btcentralplus.com. [109.152.215.36]) by smtp.gmail.com with ESMTPSA id s6-20020adfbc06000000b0020fe4c5e94csm21991477wrg.19.2022.06.08.07.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:22:25 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/5] gdb/testsuite: make 'c' default language for get/test compiler info Date: Wed, 8 Jun 2022 15:22:15 +0100 Message-Id: <950a3ff84295fa8f3daacb08c489e874712ca194.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 This commit is a minor cleanup for the two functions (in gdb.exp) get_compiler_info and test_compiler_info. Instead of using the empty string as the default language, and just "knowing" that this means the C language. Make this explicit. The language argument now defaults to "c" if not specified, and the if chain in get_compiler_info that checks the language not explicitly handles "c" and gives an error for unknown languages. This is a good thing, now that the API appears to take a language, if somebody does: test_compiler_info "xxxx" "rust" to check the version of the rust compiler then we will now give an error rather than just using the C compiler and leaving the user having to figure out why they are not getting the results they expect. After a little grepping, I think the only place we were explicitly passing the empty string to either get_compiler_info or test_compiler_info was in gdb_compile_shlib_1, this is now changed to pass "c" as the default language. There should be no changes to the test results after this commit. --- gdb/testsuite/lib/gdb.exp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index b779bff81e6..140da05b35e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4097,7 +4097,7 @@ set gcc_compiled 0 # # -- chastain 2004-01-06 -proc get_compiler_info {{arg ""}} { +proc get_compiler_info {{language "c"}} { # For compiler.c, compiler.cc and compiler.F90. global srcdir @@ -4117,11 +4117,15 @@ proc get_compiler_info {{arg ""}} { } # Choose which file to preprocess. - set ifile "${srcdir}/lib/compiler.c" - if { $arg == "c++" } { + if { $language == "c++" } { set ifile "${srcdir}/lib/compiler.cc" - } elseif { $arg == "f90" } { + } elseif { $language == "f90" } { set ifile "${srcdir}/lib/compiler.F90" + } elseif { $language == "c" } { + set ifile "${srcdir}/lib/compiler.c" + } else { + perror "Unable to fetch compiler version for language: $language" + return -1 } # Run $ifile through the right preprocessor. @@ -4132,12 +4136,12 @@ proc get_compiler_info {{arg ""}} { # We have to use -E and -o together, despite the comments # above, because of how DejaGnu handles remote host testing. set ppout "$outdir/compiler.i" - gdb_compile "${ifile}" "$ppout" preprocess [list "$arg" quiet getting_compiler_info] + gdb_compile "${ifile}" "$ppout" preprocess [list "$language" quiet getting_compiler_info] set file [open $ppout r] set cppout [read $file] close $file } else { - set cppout [ gdb_compile "${ifile}" "" preprocess [list "$arg" quiet getting_compiler_info] ] + set cppout [ gdb_compile "${ifile}" "" preprocess [list "$language" quiet getting_compiler_info] ] } eval log_file $saved_log @@ -4193,7 +4197,7 @@ proc get_compiler_info {{arg ""}} { # Otherwise the argument is a glob-style expression to match against # compiler_info. -proc test_compiler_info { {compiler ""} {language ""} } { +proc test_compiler_info { {compiler ""} {language "c"} } { global compiler_info get_compiler_info $language @@ -4767,11 +4771,12 @@ proc gdb_compile_shlib_1 {sources dest options} { set ada 1 } - set info_options "" if { [lsearch -exact $options "c++"] >= 0 } { set info_options "c++" } elseif { [lsearch -exact $options "f90"] >= 0 } { set info_options "f90" + } else { + set info_options "c" } switch -glob [test_compiler_info ${info_options}] { -- 2.25.4