diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-06-08 13:35:29 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-06-09 14:40:48 +0100 |
commit | 08b326ee0a6384508703f9187905bb00bfe3d5d9 (patch) | |
tree | a83e7de6f0981827208b9237500975dccfe0db49 | |
parent | 1562f64fec2ce6a31bc534be73e9e4180edbb600 (diff) | |
download | gdb-08b326ee0a6384508703f9187905bb00bfe3d5d9.zip gdb-08b326ee0a6384508703f9187905bb00bfe3d5d9.tar.gz gdb-08b326ee0a6384508703f9187905bb00bfe3d5d9.tar.bz2 |
gdb/testsuite: make 'c' default language for get/test compiler info
This commit is a minor cleanup for the two functions (in gdb.exp)
get_compiler_info and test_compiler_info.
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.
This is a good thing, now that the API appears to take a language, if
somebody does:
test_compiler_info "xxxx" "rust"
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.
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.
There should be no changes to the test results after this commit.
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c9a30d8..e530ba0 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 -proc get_compiler_info {{arg ""}} { +proc get_compiler_info {{language "c"}} { # For compiler.c, compiler.cc and compiler.F90. global srcdir @@ -4117,11 +4117,15 @@ proc get_compiler_info {{arg ""}} { } # Choose which file to preprocess. - set ifile "${srcdir}/lib/compiler.c" - if { $arg == "c++" } { + if { $language == "c++" } { set ifile "${srcdir}/lib/compiler.cc" - } elseif { $arg == "f90" } { + } elseif { $language == "f90" } { set ifile "${srcdir}/lib/compiler.F90" + } elseif { $language == "c" } { + set ifile "${srcdir}/lib/compiler.c" + } else { + perror "Unable to fetch compiler version for language: $language" + return -1 } # 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_compiler_info] + gdb_compile "${ifile}" "$ppout" preprocess [list "$language" quiet getting_compiler_info] set file [open $ppout r] set cppout [read $file] close $file } else { - set cppout [ gdb_compile "${ifile}" "" preprocess [list "$arg" quiet getting_compiler_info] ] + set cppout [ gdb_compile "${ifile}" "" preprocess [list "$language" quiet getting_compiler_info] ] } eval log_file $saved_log @@ -4193,7 +4197,7 @@ proc get_compiler_info {{arg ""}} { # Otherwise the argument is a glob-style expression to match against # compiler_info. -proc test_compiler_info { {compiler ""} {language ""} } { +proc test_compiler_info { {compiler ""} {language "c"} } { global compiler_info get_compiler_info $language @@ -4767,11 +4771,12 @@ proc gdb_compile_shlib_1 {sources dest options} { set ada 1 } - set info_options "" if { [lsearch -exact $options "c++"] >= 0 } { set info_options "c++" } elseif { [lsearch -exact $options "f90"] >= 0 } { set info_options "f90" + } else { + set info_options "c" } switch -glob [test_compiler_info "" ${info_options}] { |