From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UILKMD52emIAdAUAWB0awg (envelope-from ) for ; Tue, 10 May 2022 10:27:10 -0400 Received: by simark.ca (Postfix, from userid 112) id C4DF81E21F; Tue, 10 May 2022 10:27:10 -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=Bt9ryEWj; 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=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.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 30DDA1E01D for ; Tue, 10 May 2022 10:27:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D456B3954422 for ; Tue, 10 May 2022 14:27:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D456B3954422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652192829; bh=PoQq/vJ1uJWdWBPkdmSdJjRZNH2akKQC4KDfv/83bu4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Bt9ryEWjp163sP8S3vEPGZoxJVPRGCPBIkSlr7o3kOoJwKIkW6Sm0gKK3fytE5xmn lNwUSZDFy8Yhu77Vq1QyHAU2YjgSuL88H74HrE7A5+I29TrmK67KumgnHuxy+sqkAj SOvGVN9zsd5nbZHD7yjW7VYJKVaFKRIj/3O01oa0= Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 5D68D3953833 for ; Tue, 10 May 2022 14:25:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D68D3953833 X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="256926036" X-IronPort-AV: E=Sophos;i="5.91,214,1647327600"; d="scan'208";a="256926036" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 07:25:08 -0700 X-IronPort-AV: E=Sophos;i="5.91,214,1647327600"; d="scan'208";a="570694771" Received: from labpcdell3650-003.iul.intel.com (HELO localhost) ([172.28.49.87]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 07:25:07 -0700 To: gdb-patches@sourceware.org Subject: [PATCH 04/18] gdb/testsuite: add local variable for passing 'getting_compiler_info' to gdb_compile Date: Tue, 10 May 2022 16:24:23 +0200 Message-Id: <20220510142437.1397399-5-nils-christian.kempke@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220510142437.1397399-1-nils-christian.kempke@intel.com> References: <20220510142437.1397399-1-nils-christian.kempke@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: Nils-Christian Kempke via Gdb-patches Reply-To: Nils-Christian Kempke Cc: JiniSusan.George@amd.com, aburgess@redhat.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. 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. --- 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 + } else { + set getting_compiler_info 1 + } + # 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 && [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. } 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