mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +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.
101 lines
2.3 KiB
Plaintext
101 lines
2.3 KiB
Plaintext
# Copyright 2021-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/>.
|
|
|
|
# Check that an out-of-range DW_LNE_end_sequence is removed from the
|
|
# line table.
|
|
|
|
load_lib dwarf.exp
|
|
|
|
# This test can only be run on targets which support DWARF-2 and use gas.
|
|
if {![dwarf2_support]} {
|
|
verbose "Skipping $gdb_test_file_name."
|
|
return 0
|
|
}
|
|
|
|
# The .c files use __attribute__.
|
|
if ![is_c_compiler_gcc] {
|
|
verbose "Skipping $gdb_test_file_name."
|
|
return 0
|
|
}
|
|
|
|
standard_testfile main.c -dw.S
|
|
|
|
set func_info_vars [get_func_info main]
|
|
|
|
set asm_file [standard_output_file $srcfile2]
|
|
Dwarf::assemble $asm_file {
|
|
declare_labels Llines
|
|
global srcdir subdir srcfile
|
|
global func_info_vars
|
|
foreach var $func_info_vars {
|
|
global $var
|
|
}
|
|
|
|
cu {} {
|
|
compile_unit {
|
|
{language @DW_LANG_C}
|
|
{name $srcfile}
|
|
{stmt_list $Llines DW_FORM_sec_offset}
|
|
} {
|
|
subprogram {
|
|
{external 1 flag}
|
|
{name main}
|
|
{low_pc $main_start}
|
|
{high_pc $main_end addr}
|
|
}
|
|
}
|
|
}
|
|
|
|
lines {version 2} Llines {
|
|
include_dir "${srcdir}/${subdir}"
|
|
file_name "$srcfile" 1
|
|
|
|
program {
|
|
DW_LNE_set_address $main_start
|
|
line 1
|
|
DW_LNS_copy
|
|
|
|
DW_LNE_set_address $main_end
|
|
DW_LNE_end_sequence
|
|
|
|
DW_LNE_set_address 0
|
|
line 2
|
|
DW_LNS_copy
|
|
|
|
DW_LNS_advance_pc 1
|
|
DW_LNE_end_sequence
|
|
}
|
|
}
|
|
}
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile} \
|
|
[list $srcfile $asm_file] {nodebug}] } {
|
|
return -1
|
|
}
|
|
|
|
if ![runto_main] {
|
|
return -1
|
|
}
|
|
|
|
set test "END with address 1 eliminated"
|
|
gdb_test_multiple "maint info line-table $srcfile$" $test {
|
|
-re -wrap "END *0x0*1 *Y *\r\n.*" {
|
|
fail $gdb_test_name
|
|
}
|
|
-re -wrap "END *$hex *Y *" {
|
|
pass $gdb_test_name
|
|
}
|
|
}
|