From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id D719E3834F00; Thu, 9 Jun 2022 13:41:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D719E3834F00 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: make 'c' default language for get/test compiler info X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 1562f64fec2ce6a31bc534be73e9e4180edbb600 X-Git-Newrev: 08b326ee0a6384508703f9187905bb00bfe3d5d9 Message-Id: <20220609134125.D719E3834F00@sourceware.org> Date: Thu, 9 Jun 2022 13:41:25 +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: Thu, 09 Jun 2022 13:41:25 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D08b326ee0a63= 84508703f9187905bb00bfe3d5d9 commit 08b326ee0a6384508703f9187905bb00bfe3d5d9 Author: Andrew Burgess Date: Wed Jun 8 13:35:29 2022 +0100 gdb/testsuite: make 'c' default language for get/test compiler info =20 This commit is a minor cleanup for the two functions (in gdb.exp) get_compiler_info and test_compiler_info. =20 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. =20 This is a good thing, now that the API appears to take a language, if somebody does: =20 test_compiler_info "xxxx" "rust" =20 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. =20 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. =20 There should be no changes to the test results after this commit. Diff: --- 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 c9a30d88b2f..e530ba05a61 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 =20 -proc get_compiler_info {{arg ""}} { +proc get_compiler_info {{language "c"}} { # For compiler.c, compiler.cc and compiler.F90. global srcdir =20 @@ -4117,11 +4117,15 @@ proc get_compiler_info {{arg ""}} { } =20 # Choose which file to preprocess. - set ifile "${srcdir}/lib/compiler.c" - if { $arg =3D=3D "c++" } { + if { $language =3D=3D "c++" } { set ifile "${srcdir}/lib/compiler.cc" - } elseif { $arg =3D=3D "f90" } { + } elseif { $language =3D=3D "f90" } { set ifile "${srcdir}/lib/compiler.F90" + } elseif { $language =3D=3D "c" } { + set ifile "${srcdir}/lib/compiler.c" + } else { + perror "Unable to fetch compiler version for language: $language" + return -1 } =20 # 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_com= piler_info] + gdb_compile "${ifile}" "$ppout" preprocess [list "$language" quiet gettin= g_compiler_info] set file [open $ppout r] set cppout [read $file] close $file } else { - set cppout [ gdb_compile "${ifile}" "" preprocess [list "$arg" quiet gett= ing_compiler_info] ] + set cppout [ gdb_compile "${ifile}" "" preprocess [list "$language" quiet= getting_compiler_info] ] } eval log_file $saved_log =20 @@ -4193,7 +4197,7 @@ proc get_compiler_info {{arg ""}} { # Otherwise the argument is a glob-style expression to match against # compiler_info. =20 -proc test_compiler_info { {compiler ""} {language ""} } { +proc test_compiler_info { {compiler ""} {language "c"} } { global compiler_info get_compiler_info $language =20 @@ -4767,11 +4771,12 @@ proc gdb_compile_shlib_1 {sources dest options} { set ada 1 } =20 - set info_options "" if { [lsearch -exact $options "c++"] >=3D 0 } { set info_options "c++" } elseif { [lsearch -exact $options "f90"] >=3D 0 } { set info_options "f90" + } else { + set info_options "c" } =20 switch -glob [test_compiler_info "" ${info_options}] {