mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
ef7a6b977b
After this commit the gcc_compiled global is no longer exported from lib/gdb.exp. In theory we could switch over all uses of gcc_compiled to instead call test_compiler_info directly, however, I have instead added a new proc to gdb.exp: 'is_c_compiler_gcc'. I've then updated the testsuite to call this proc instead of using the global. Having a new proc specifically for this task means that we have a single consistent pattern for detecting gcc. By wrapping this logic within a proc that calls test_compiler_info, rather than using the global, means that test scripts don't need to call get_compiler_info before they read the global, simply calling the new proc does everything in one go. As a result I've been able to remove the get_compiler_info calls from all the test scripts that I've touched in this commit. In some of the tests e.g. gdb.dwarf2/*.exp, the $gcc_compiled flag was being checked at the top of the script to decide if the whole script should be skipped or not. In these cases I've called the new proc directly and removed all uses of gcc_compiled. In other cases, e.g. most of the gdb.base scripts, there were many uses of gcc_compiled. In these cases I set a new global gcc_compiled near the top of the script, and leave the rest of the script unchanged. There should be no changes in what is tested after this commit.
128 lines
4.2 KiB
Plaintext
128 lines
4.2 KiB
Plaintext
# Copyright (C) 1997-2022 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
standard_testfile langs0.c langs1.c langs2.c
|
|
|
|
if [is_remote host] {
|
|
remote_download host ${srcdir}/${subdir}/langs1.f
|
|
remote_download host ${srcdir}/${subdir}/langs2.cxx
|
|
}
|
|
|
|
|
|
if {[prepare_for_testing "failed to prepare" ${testfile} \
|
|
[list $srcfile $srcfile2 $srcfile3] {debug}]} {
|
|
return -1
|
|
}
|
|
|
|
set oldtimeout $timeout
|
|
set timeout 10
|
|
|
|
# Some tests require GCC.
|
|
set gcc_compiled [is_c_compiler_gcc]
|
|
|
|
gdb_test_multiple "b -qualified langs0" "break on nonexistent function in langs.exp" {
|
|
-re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
|
|
|
|
gdb_test "n" "" "break on nonexistent function in langs.exp"
|
|
}
|
|
-re "Breakpoint .* (deferred).*$gdb_prompt $" {
|
|
pass "break on nonexistent function in langs.exp"
|
|
}
|
|
}
|
|
|
|
# TODO: Since there variables are now constants, we can cleanup the test,
|
|
# remove some dead code.
|
|
set isfixed 0
|
|
set foo_func foo__Fi
|
|
set do_func langs0__2do
|
|
|
|
if [runto csub] then {
|
|
|
|
if { !$isfixed } { set lang c }
|
|
gdb_test "show language" "currently $lang\".*" \
|
|
"show language at csub in langs.exp"
|
|
|
|
gdb_test "bt" "#0.*csub.*#1.*(foo|$foo_func) \\(.*#2.*cppsub_ .*#3.*fsub.*#4.*$do_func \\(.*#5 \[0-9a-fx\]* in main.*" "backtrace in langs.exp"
|
|
|
|
if { !$isfixed } { set lang c\\+\\+; set ext cxx }
|
|
if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
|
|
gdb_test "up" ".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*" \
|
|
"up to foo in langs.exp"
|
|
gdb_test "show language" "currently $lang.*" \
|
|
"show language at foo in langs.exp"
|
|
|
|
if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
|
|
gdb_test "up" ".* in cppsub_ .* at .*langs2\\.$ext.*return foo \\(.*" \
|
|
"up to cppsub_ in langs.exp"
|
|
gdb_test "show language" "currently $lang.*" \
|
|
"show language at cppsub_ in langs.exp"
|
|
|
|
if { !$isfixed } { set lang fortran }
|
|
if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
|
|
gdb_test "up" ".* in fsub.* at .*langs1\\.f.*" \
|
|
"up to fsub in langs.exp"
|
|
gdb_test "show language" "currently $lang.*" \
|
|
"show language at fsub in langs.exp"
|
|
|
|
if { !$isfixed } { set lang c }
|
|
gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \
|
|
"up to langs0__2do in langs.exp"
|
|
gdb_test "show language" "currently $lang\".*" \
|
|
"show language at langs0__2do in langs.exp"
|
|
|
|
gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \
|
|
"up to main in langs.exp"
|
|
gdb_test "show language" "currently $lang\".*" \
|
|
"show language at main in langs.exp"
|
|
|
|
if [target_info exists gdb,noresults] { return }
|
|
|
|
gdb_continue_to_end "langs.exp"
|
|
}
|
|
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
gdb_load $binfile
|
|
|
|
# Try exercising the "minimal" language a bit...
|
|
|
|
if [runto csub] then {
|
|
gdb_test "set lang minimal" \
|
|
"Warning: the current language does not match this frame." \
|
|
"set lang to minimal"
|
|
|
|
gdb_test "print x" " = 5000" "print parameter value"
|
|
|
|
# Ensure this at least does not crash.
|
|
gdb_test_no_output "set language unknown"
|
|
gdb_test "print x" \
|
|
"expression parsing not implemented for language .Unknown." \
|
|
"expression parsing does not crash for unknown"
|
|
|
|
gdb_test_no_output "set lang auto" \
|
|
"set lang back to auto for verbose test"
|
|
gdb_test_no_output "set verbose on"
|
|
if { !$isfixed } { set lang c\\+\\+; set ext cxx }
|
|
if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
|
|
gdb_test "up" \
|
|
".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*Current language: auto.*" \
|
|
"up to foo in langs.exp when verbose"
|
|
}
|
|
|
|
set timeout $oldtimeout
|
|
return 0
|