From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wKjULryLe2IDnQUAWB0awg (envelope-from ) for ; Wed, 11 May 2022 06:11:08 -0400 Received: by simark.ca (Postfix, from userid 112) id B21F81E21F; Wed, 11 May 2022 06:11:08 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=yJOo3mnD; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 350481E00D for ; Wed, 11 May 2022 06:11:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3CE33838006 for ; Wed, 11 May 2022 10:11:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3CE33838006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652263864; bh=Sgp3hHdikOwGlxIdqAbIbltFQoB7NNNOsxOZszq7erk=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=yJOo3mnDgS2HOEPy73BxuwYBjfihrFmqsL/0MaxzcGDug/mvw78ZiS53+4wYXThFU 0bGL0b5wJiE72BdGxoeDipo/XKRb2Lkn4LWgmbJkDfeLxBFK84rs0iwWIl+An4omwF wHH7SWA0BZaN86BfrBm2z1xSyLkMLH4/60A/OxLA= 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 CB8E738485A6 for ; Wed, 11 May 2022 10:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB8E738485A6 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-DKaqUU-JO5uBaKfWUdD6xg-1; Wed, 11 May 2022 06:10:40 -0400 X-MC-Unique: DKaqUU-JO5uBaKfWUdD6xg-1 Received: by mail-wm1-f70.google.com with SMTP id u3-20020a05600c210300b0039430c7665eso565167wml.2 for ; Wed, 11 May 2022 03:10:40 -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:in-reply-to:references:date :message-id:mime-version; bh=Sgp3hHdikOwGlxIdqAbIbltFQoB7NNNOsxOZszq7erk=; b=63o1ZAU4NtkIlpA+vWMR+AuBBIr8V3kOdmLBe3kXShjduPGX+ww+6JXmINUjeVKF3D 15/hKnXv6t0jf5ktifoujYjkn9GLyaYbSpfI3GGNyGUec5OecwRvpDJ3vOW7ioaUXjvp fFiI+htMB1eGnkiU0yK1p+L4dFdJCZK55YrVfvohcscPcY+O39twFUyt3Y7BJoRxPq0h lGW6WbzoBQ99IBruH/k9UH6PlAUCECULTHnFGmBXQtFQ7syHJaKyckbF2PrTZfT/xBHe NVIFAXIdpvkvCF+dxsTNCMsnJNtcOpuIisSe4ZFWqwdNxdJOqiHzV2qwbz7/d13B/6sf XfpA== X-Gm-Message-State: AOAM5334NNmhCHW7DRNXhOklH/brk63hI/9GDl5/uke0GLAmUhQkzsMj 7BcCQHyXJwzcRxdlmjWN8id53Xp7QUJNW9df9ibFPB9Fhzo4S/7/p1RGBzFy21q5kkEmlPLdAko Yjxmp0df+gIYy/VCv5I9YrA== X-Received: by 2002:a05:6000:1acd:b0:20c:726a:3840 with SMTP id i13-20020a0560001acd00b0020c726a3840mr21672811wry.507.1652263839670; Wed, 11 May 2022 03:10:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7YYmqDYCxpmIppKLGeQy0kiWr20ikxcVCOf2dBUowGfE5S5NeCLhgW+qFE0hqywdj0j0pSw== X-Received: by 2002:a05:6000:1acd:b0:20c:726a:3840 with SMTP id i13-20020a0560001acd00b0020c726a3840mr21672787wry.507.1652263839401; Wed, 11 May 2022 03:10:39 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id d8-20020a1c7308000000b003942a244f50sm5073604wmb.41.2022.05.11.03.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 03:10:38 -0700 (PDT) To: Nils-Christian Kempke , gdb-patches@sourceware.org Subject: Re: [PATCH 04/18] gdb/testsuite: add local variable for passing 'getting_compiler_info' to gdb_compile In-Reply-To: <20220510142437.1397399-5-nils-christian.kempke@intel.com> References: <20220510142437.1397399-1-nils-christian.kempke@intel.com> <20220510142437.1397399-5-nils-christian.kempke@intel.com> Date: Wed, 11 May 2022 11:10:37 +0100 Message-ID: <87czgkl6qq.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: JiniSusan.George@amd.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" I think the subject would be better as 'move local variable ....etc...' Nils-Christian Kempke via Gdb-patches writes: > The procedure gdb_compile used to query its options via > > [lsearch -exact $options getting_compiler_info] > > to check whether or not it was called in with the option > getting_compiler_info. If it was called with this option it would > preprocess some test input to try and figure out the actual compiler > version of the compiler used. While doing this we cannot again try > figure out the current compiler version via the 'getting_compiler_info' > options as this would cause infinite recursion. As some parts of the > procedure do recursively test for the compiler version to e.g. set > certain flags, at several places gdb_compile queried its options for > this setting. > > In the procedure, there was already a variable 'getting_compiler_info'. > It was set to the result of the above lsearch, but too late within > the code. This lead to a mixture of querying 'getting_compiler_info' or > doing an lserach on the options passed to the procedure. > > I found this inconsistent and instead moved the variable getting_compiler_info > to the front of the procedure. Am I correct that this is just a clean up? And doesn't fix an actual bug? That's not a problem, and I think this is a good cleanup, I just wasn't 100% sure after reading the above. > It is set to 0 or 1 depending on whether or > not the argument is found in the procedure's options (just as before) > and queried instead of doing an lsearch on the procedure options in the > rest of the procedure. You can actually use 'true' and 'false' in tcl, and just treat the variable as a boolean, so.... > --- > gdb/testsuite/lib/gdb.exp | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index a6f2d847a5..639a0cd1be 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -4378,6 +4378,13 @@ proc gdb_compile {source dest type options} { > > set outdir [file dirname $dest] > > + # If this is set, calling test_compiler_info will cause recursion. > + if { [lsearch -exact $options getting_compiler_info] == -1 } { > + set getting_compiler_info 0 set getting_compiler_info false > + } else { > + set getting_compiler_info 1 set getting_compiler_info true > + } > + > # Add platform-specific options if a shared library was specified using > # "shlib=librarypath" in OPTIONS. > set new_options {} > @@ -4394,7 +4401,7 @@ proc gdb_compile {source dest type options} { > # default, unless you pass -Wno-unknown-warning-option as well. > # We do that here, so that individual testcases don't have to > # worry about it. > - if {[lsearch -exact $options getting_compiler_info] == -1 > + if {$getting_compiler_info == 0 if {!$getting_compiler_info && .... etc .... Which I think makes it clearer that this is a boolean flag. > && [lsearch -exact $options rust] == -1 > && [lsearch -exact $options ada] == -1 > && [lsearch -exact $options f90] == -1 > @@ -4405,7 +4412,7 @@ proc gdb_compile {source dest type options} { > > # Treating .c input files as C++ is deprecated in Clang, so > # explicitly force C++ language. > - if { [lsearch -exact $options getting_compiler_info] == -1 > + if { $getting_compiler_info == 0 > && [lsearch -exact $options c++] != -1 > && [string match *.c $source] != 0 } { > > @@ -4426,7 +4433,7 @@ proc gdb_compile {source dest type options} { > # Place (and look for) Fortran `.mod` files in the output > # directory for this specific test. For Intel compilers the -J > # option is not supported so instead use the -module flag. > - if { [lsearch -exact $options f90] != -1 } { > + if { $getting_compiler_info == 0 && [lsearch -exact $options f90] != -1 } { > # Fortran compile. > set mod_path [standard_output_file ""] > if [test_compiler_info "gcc-*"] { > @@ -4439,7 +4446,6 @@ proc gdb_compile {source dest type options} { > > set shlib_found 0 > set shlib_load 0 > - set getting_compiler_info 0 > foreach opt $options { > if {[regexp {^shlib=(.*)} $opt dummy_var shlib_name] > && $type == "executable"} { > @@ -4471,8 +4477,8 @@ proc gdb_compile {source dest type options} { > } elseif { $opt == "shlib_load" && $type == "executable" } { > set shlib_load 1 > } elseif { $opt == "getting_compiler_info" } { > - # If this is set, calling test_compiler_info will cause recursion. > - set getting_compiler_info 1 > + # Ignore this setting here as it has been treated in the very > + # beginning of this procedure. Do not append it to new_options. I think this comment should be reworded as: # Ignore this setting here as it has been handled earlier in # this procedure. Do not append it to new_options as this # will cause recursion. Thanks, Andrew > } elseif {[regexp "^text_segment=(.*)" $opt dummy_var addr]} { > if { [linker_supports_Ttext_segment_flag] } { > # For GNU ld. > -- > 2.25.1 > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928