From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7876) id 9E268395A027; Tue, 31 May 2022 14:45:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E268395A027 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nils-Christian Kempke To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: move getting_compiler_info to front of gdb_compile X-Act-Checkin: binutils-gdb X-Git-Author: Nils-Christian Kempke X-Git-Refname: refs/heads/master X-Git-Oldrev: c8df10fc707ec1f30767d96f508a99b8c0f901aa X-Git-Newrev: 7ce4a6d1846fae44b25c1733164451a316f22567 Message-Id: <20220531144528.9E268395A027@sourceware.org> Date: Tue, 31 May 2022 14:45:28 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2022 14:45:28 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7ce4a6d1846f= ae44b25c1733164451a316f22567 commit 7ce4a6d1846fae44b25c1733164451a316f22567 Author: Nils-Christian Kempke Date: Tue May 31 16:43:43 2022 +0200 gdb/testsuite: move getting_compiler_info to front of gdb_compile =20 The procedure gdb_compile queries its options via =20 [lsearch -exact $options getting_compiler_info] =20 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. =20 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. =20 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. Diff: --- 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 6fbf74442c9..381367ee6c4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4412,6 +4412,13 @@ proc gdb_compile {source dest type options} { =20 set outdir [file dirname $dest] =20 + # If this is set, calling test_compiler_info will cause recursion. + if { [lsearch -exact $options getting_compiler_info] =3D=3D -1 } { + set getting_compiler_info false + } else { + set getting_compiler_info true + } + # Add platform-specific options if a shared library was specified using # "shlib=3Dlibrarypath" 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] =3D=3D -1 + if {!$getting_compiler_info && [lsearch -exact $options rust] =3D=3D -1 && [lsearch -exact $options ada] =3D=3D -1 && [lsearch -exact $options f90] =3D=3D -1 @@ -4439,7 +4446,7 @@ proc gdb_compile {source dest type options} { =20 # Treating .c input files as C++ is deprecated in Clang, so # explicitly force C++ language. - if { [lsearch -exact $options getting_compiler_info] =3D=3D -1 + if { !$getting_compiler_info && [lsearch -exact $options c++] !=3D -1 && [string match *.c $source] !=3D 0 } { =20 @@ -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] !=3D -1 } { + if { !$getting_compiler_info && [lsearch -exact $options f90] !=3D -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} { =20 set shlib_found 0 set shlib_load 0 - set getting_compiler_info 0 foreach opt $options { if {[regexp {^shlib=3D(.*)} $opt dummy_var shlib_name] && $type =3D=3D "executable"} { @@ -4505,8 +4511,9 @@ proc gdb_compile {source dest type options} { } elseif { $opt =3D=3D "shlib_load" && $type =3D=3D "executable" } { set shlib_load 1 } elseif { $opt =3D=3D "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=3D(.*)" $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=3D88432 # This option defaults to on for Debian/Ubuntu. - if { $getting_compiler_info =3D=3D 0 + if { !$getting_compiler_info && [test_compiler_info {gcc-*-*}] && !([test_compiler_info {gcc-[0-3]-*}] || [test_compiler_info {gcc-4-0-*}])