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 ECE063857351 for ; Tue, 31 May 2022 16:00:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECE063857351 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-259-TksCmd6eOgCJ9VJlQLHPJA-1; Tue, 31 May 2022 12:00:43 -0400 X-MC-Unique: TksCmd6eOgCJ9VJlQLHPJA-1 Received: by mail-wr1-f71.google.com with SMTP id g22-20020adfa496000000b002101fcd7c86so1538518wrb.11 for ; Tue, 31 May 2022 09:00:43 -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=XZ+zwSN8nQ2Do7w9UsycJQiVW2Ok1sLVKEiQS4anjF8=; b=l1GH2mB8yCzRwaA2yJTFhk8irV/wUv5wW8UaiaQb8RzsaAjip9PtxqOQSL3rZdd7T6 ksKhA/TqXEtHntCjcxoCooD3JKU7+ul7RN/sNlQAIl2ei/gLsn9eYVYr4GSGhEJODDcL UVz+Nnfhdjw14m3YBjsmkUa5Zq+bFo1Z4AMVoAKZ5bdDZh0NoivcGUK/oSuUTWcO3l2+ YTvYyv7I2J6ZqdBExE8b2YSeAFKdnBt+8g+fDYF0cc185E0eTLpnDgzyFpIzwEbSaYrC KzPWzTKeIhx/OpMMgoQJ3uUIWiNKXwedwfs6YrweHtMF9fX2rsKKc0KflP+N0qeev3HH k61A== X-Gm-Message-State: AOAM530qByfexmJ07MS9Z/oMPAnqKyJpRmcOiBePBr5sUuVQ8dXBBkAA Rp/JyC9cdotzFLzsG0YjthMUjyN0jB1PB7QU8NAS0dUlytCH0XeU/hqH+WrCfXngASNqFJFPgW6 6oB0AHNwuV1Wo1jyWfCcadQ== X-Received: by 2002:a05:6000:1a88:b0:20e:6eb4:124e with SMTP id f8-20020a0560001a8800b0020e6eb4124emr50887454wry.8.1654012842081; Tue, 31 May 2022 09:00:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw146cjfYKbzxf1zcmWrJ0MKa6LyJnmKuLwYCWRColrvO60qsrra8eb0o5gfhjg8Se1tOkxOg== X-Received: by 2002:a05:6000:1a88:b0:20e:6eb4:124e with SMTP id f8-20020a0560001a8800b0020e6eb4124emr50887432wry.8.1654012841762; Tue, 31 May 2022 09:00:41 -0700 (PDT) Received: from localhost (host109-152-215-36.range109-152.btcentralplus.com. [109.152.215.36]) by smtp.gmail.com with ESMTPSA id c2-20020a056000184200b0020fc3e24041sm9076028wri.106.2022.05.31.09.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:00:41 -0700 (PDT) From: Andrew Burgess To: Nils-Christian Kempke , gdb-patches@sourceware.org Cc: JiniSusan.George@amd.com Subject: Re: [PATCH v2 04/16] gdb/testsuite: move getting_compiler_info to front of gdb_compile In-Reply-To: <20220531092423.2361679-3-nils-christian.kempke@intel.com> References: <20220531092423.2361679-1-nils-christian.kempke@intel.com> <20220531092423.2361679-3-nils-christian.kempke@intel.com> Date: Tue, 31 May 2022 17:00:39 +0100 Message-ID: <87tu95d74o.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: Tue, 31 May 2022 16:00:47 -0000 Nils-Christian Kempke via Gdb-patches writes: > The procedure gdb_compile queries 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 to > figure out the current compiler version via the 'getting_compiler_info' > option 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 there are checks for the > getting_compiler_info option needed. > > In the procedure, there was already a variable 'getting_compiler_info' > which was set to the result of the 'lsearch' query and used instead of > again and again looking for getting_compiler_info in the procedure > options. But, this variable was actually set 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. It is set to true > or false 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. LGTM. Thanks, Andrew > --- > gdb/testsuite/lib/gdb.exp | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 6fbf74442c..381367ee6c 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -4412,6 +4412,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 false > + } else { > + set getting_compiler_info true > + } > + > # Add platform-specific options if a shared library was specified using > # "shlib=librarypath" in OPTIONS. > set new_options {} > @@ -4428,7 +4435,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 > && [lsearch -exact $options rust] == -1 > && [lsearch -exact $options ada] == -1 > && [lsearch -exact $options f90] == -1 > @@ -4439,7 +4446,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 > && [lsearch -exact $options c++] != -1 > && [string match *.c $source] != 0 } { > > @@ -4460,7 +4467,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 && [lsearch -exact $options f90] != -1 } { > # Fortran compile. > set mod_path [standard_output_file ""] > if [test_compiler_info "gcc-*"] { > @@ -4473,7 +4480,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"} { > @@ -4505,8 +4511,9 @@ 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 handled earlier in this > + # procedure. Do not append it to new_options as this will cause > + # recursion. > } elseif {[regexp "^text_segment=(.*)" $opt dummy_var addr]} { > if { [linker_supports_Ttext_segment_flag] } { > # For GNU ld. > @@ -4529,7 +4536,7 @@ proc gdb_compile {source dest type options} { > # DWARF line numbering. > # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432 > # This option defaults to on for Debian/Ubuntu. > - if { $getting_compiler_info == 0 > + if { !$getting_compiler_info > && [test_compiler_info {gcc-*-*}] > && !([test_compiler_info {gcc-[0-3]-*}] > || [test_compiler_info {gcc-4-0-*}]) > -- > 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