mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 22:07:58 +08:00
gdb: use foreach_with_prefix in gdb.base/break-interp.exp
Use foreach_with_prefix, instead of foreach and with_test_prefix separately. Since allows removing some indentation levels, and formats the test names a bit nicer, in my opinion (or at least, it's more consistent with the rest of the testsuite): - PASS: gdb.base/break-interp.exp: LDprelinkNOdebugNO: BINprelinkNOdebugNOpieNO: INNER: core: set verbose on + PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: binprelink=NO: binsepdebug=NO: binpie=NO: INNER: set verbose on Note: this patch is better viewed with "git show -w" to ignore whitespace changes. gdb/testsuite/ChangeLog: * gdb.base/break-interp.exp: Use foreach_with_prefix.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
|
||||||
|
|
||||||
|
* gdb.base/break-interp.exp: Use foreach_with_prefix.
|
||||||
|
|
||||||
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
|
2020-03-12 Simon Marchi <simon.marchi@efficios.com>
|
||||||
|
|
||||||
* gdb.arch/amd64-disp-step-avx.S: Add nops after _start.
|
* gdb.arch/amd64-disp-step-avx.S: Add nops after _start.
|
||||||
|
@ -538,8 +538,8 @@ proc test_ld {file ifmain trynosym displacement} {
|
|||||||
# Create separate binaries for each testcase - to make the possible reported
|
# Create separate binaries for each testcase - to make the possible reported
|
||||||
# problem reproducible after the whole test run finishes.
|
# problem reproducible after the whole test run finishes.
|
||||||
|
|
||||||
foreach ldprelink {NO YES} {
|
foreach_with_prefix ldprelink {NO YES} {
|
||||||
foreach ldsepdebug {NO IN SEP} {
|
foreach_with_prefix ldsepdebug {NO IN SEP} {
|
||||||
# Skip running the ldsepdebug test if we do not have system separate
|
# Skip running the ldsepdebug test if we do not have system separate
|
||||||
# debug info available.
|
# debug info available.
|
||||||
if {$interp_system_debug == "" && $ldsepdebug == "SEP"} {
|
if {$interp_system_debug == "" && $ldsepdebug == "SEP"} {
|
||||||
@ -562,164 +562,160 @@ foreach ldprelink {NO YES} {
|
|||||||
# possibly unprelinked ld.so to test all the combinations for GDB.
|
# possibly unprelinked ld.so to test all the combinations for GDB.
|
||||||
set interp_saved ${interp}-saved
|
set interp_saved ${interp}-saved
|
||||||
|
|
||||||
with_test_prefix "$ldname" {
|
if {$ldsepdebug == "NO"} {
|
||||||
if {$ldsepdebug == "NO"} {
|
file_copy $interp_system $interp
|
||||||
file_copy $interp_system $interp
|
# Never call strip-debug before unprelink:
|
||||||
# Never call strip-debug before unprelink:
|
# prelink: ...: Section .note.gnu.build-id created after prelinking
|
||||||
# prelink: ...: Section .note.gnu.build-id created after prelinking
|
if ![prelinkNO $interp] {
|
||||||
if ![prelinkNO $interp] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
strip_debug $interp
|
|
||||||
} elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} {
|
|
||||||
file_copy $interp_system $interp
|
|
||||||
} elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} {
|
|
||||||
file_copy $interp_system $interp
|
|
||||||
file_copy $interp_system_debug "${interp}.debug"
|
|
||||||
# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
|
|
||||||
if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]"
|
|
||||||
set command "exec eu-unstrip -o $interp $interp ${interp}.debug"
|
|
||||||
verbose -log "command is $command"
|
|
||||||
if [catch $command] {
|
|
||||||
setup_xfail *-*-*
|
|
||||||
fail $test
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
pass $test
|
|
||||||
}
|
|
||||||
} elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
|
|
||||||
file_copy $interp_system $interp
|
|
||||||
# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
|
|
||||||
if ![prelinkNO $interp] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
gdb_gnu_strip_debug $interp
|
|
||||||
} elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} {
|
|
||||||
file_copy $interp_system $interp
|
|
||||||
file_copy $interp_system_debug "${interp}.debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$ldsepdebug == "SEP"} {
|
|
||||||
if ![prelinkNO "${interp}.debug"] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file delete "${interp}.debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
if ![prelink$ldprelink $interp "$interp, second time"] {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
strip_debug $interp
|
||||||
if {$ldprelink == "NO"} {
|
} elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} {
|
||||||
set displacement "NONZERO"
|
file_copy $interp_system $interp
|
||||||
} else {
|
} elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} {
|
||||||
# x86* kernel loads prelinked PIE binary at its
|
file_copy $interp_system $interp
|
||||||
# prelinked address but ppc* kernel loads it at a
|
file_copy $interp_system_debug "${interp}.debug"
|
||||||
# random address. prelink normally skips PIE binaries
|
# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
|
||||||
# during the system scan.
|
if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} {
|
||||||
set displacement "PRESENT"
|
|
||||||
}
|
|
||||||
test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
|
|
||||||
|
|
||||||
if ![file_copy $interp $interp_saved] {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]"
|
||||||
|
set command "exec eu-unstrip -o $interp $interp ${interp}.debug"
|
||||||
|
verbose -log "command is $command"
|
||||||
|
if [catch $command] {
|
||||||
|
setup_xfail *-*-*
|
||||||
|
fail $test
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
pass $test
|
||||||
|
}
|
||||||
|
} elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
|
||||||
|
file_copy $interp_system $interp
|
||||||
|
# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
|
||||||
|
if ![prelinkNO $interp] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
gdb_gnu_strip_debug $interp
|
||||||
|
} elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} {
|
||||||
|
file_copy $interp_system $interp
|
||||||
|
file_copy $interp_system_debug "${interp}.debug"
|
||||||
|
}
|
||||||
|
|
||||||
foreach binprelink {NO YES} {
|
if {$ldsepdebug == "SEP"} {
|
||||||
foreach binsepdebug {NO IN SEP} {
|
if ![prelinkNO "${interp}.debug"] {
|
||||||
# "ATTACH" is like "YES" but it is modified during
|
continue
|
||||||
# run. It cannot be used for problem
|
}
|
||||||
# reproducibility after the testcase ends.
|
} else {
|
||||||
foreach binpie {NO YES ATTACH} {
|
file delete "${interp}.debug"
|
||||||
# This combination is not possible, non-PIE (fixed address)
|
}
|
||||||
# binary cannot be prelinked to any (other) address.
|
|
||||||
if {$binprelink == "YES" && $binpie == "NO"} {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
|
if ![prelink$ldprelink $interp "$interp, second time"] {
|
||||||
set exec $binprefix-$binname
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
with_test_prefix "$binname" {
|
if {$ldprelink == "NO"} {
|
||||||
set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
|
set displacement "NONZERO"
|
||||||
if {$binsepdebug != "NO"} {
|
} else {
|
||||||
lappend opts {debug}
|
# x86* kernel loads prelinked PIE binary at its
|
||||||
}
|
# prelinked address but ppc* kernel loads it at a
|
||||||
if {$binpie != "NO"} {
|
# random address. prelink normally skips PIE binaries
|
||||||
lappend opts {pie}
|
# during the system scan.
|
||||||
|
set displacement "PRESENT"
|
||||||
|
}
|
||||||
|
test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
|
||||||
|
|
||||||
|
if ![file_copy $interp $interp_saved] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach_with_prefix binprelink {NO YES} {
|
||||||
|
foreach_with_prefix binsepdebug {NO IN SEP} {
|
||||||
|
# "ATTACH" is like "YES" but it is modified during
|
||||||
|
# run. It cannot be used for problem
|
||||||
|
# reproducibility after the testcase ends.
|
||||||
|
foreach_with_prefix binpie {NO YES ATTACH} {
|
||||||
|
# This combination is not possible, non-PIE (fixed address)
|
||||||
|
# binary cannot be prelinked to any (other) address.
|
||||||
|
if {$binprelink == "YES" && $binpie == "NO"} {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
|
||||||
|
set exec $binprefix-$binname
|
||||||
|
|
||||||
|
set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
|
||||||
|
if {$binsepdebug != "NO"} {
|
||||||
|
lappend opts {debug}
|
||||||
|
}
|
||||||
|
if {$binpie != "NO"} {
|
||||||
|
lappend opts {pie}
|
||||||
|
} else {
|
||||||
|
# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled.
|
||||||
|
lappend opts {nopie}
|
||||||
|
}
|
||||||
|
|
||||||
|
set dir ${exec}.d
|
||||||
|
set relink_args [build_executable_own_libs ${test}.exp [file tail $exec] $srcfile $opts $interp $dir]
|
||||||
|
if {$relink_args == ""} {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$binsepdebug == "SEP"} {
|
||||||
|
gdb_gnu_strip_debug $exec
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$binpie == "NO"} {
|
||||||
|
set displacement "NONE"
|
||||||
|
} elseif {$binprelink == "NO"} {
|
||||||
|
set displacement "NONZERO"
|
||||||
|
} else {
|
||||||
|
# x86* kernel loads prelinked PIE binary at its prelinked
|
||||||
|
# address but ppc* kernel loads it at a random address.
|
||||||
|
# prelink normally skips PIE binaries during the system scan.
|
||||||
|
set displacement "PRESENT"
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[prelink$binprelink $relink_args [file tail $exec]]
|
||||||
|
&& [file_copy $interp_saved $interp]} {
|
||||||
|
# In order to make test names unique wrap the core of this if block
|
||||||
|
# with a test prefix. Some of the tests performed in the if
|
||||||
|
# condition are repeated within this body.
|
||||||
|
with_test_prefix "INNER" {
|
||||||
|
if {$binpie != "ATTACH"} {
|
||||||
|
test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
|
||||||
} else {
|
} else {
|
||||||
# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled.
|
# If the file has been randomly prelinked it must be
|
||||||
lappend opts {nopie}
|
# "NONZERO". We could see "ZERO" only if it was unprelinked
|
||||||
}
|
# and it is now running at the same address - which is 0 but
|
||||||
|
# executable can never run at address 0.
|
||||||
|
|
||||||
set dir ${exec}.d
|
|
||||||
set relink_args [build_executable_own_libs ${test}.exp [file tail $exec] $srcfile $opts $interp $dir]
|
|
||||||
if {$relink_args == ""} {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$binsepdebug == "SEP"} {
|
|
||||||
gdb_gnu_strip_debug $exec
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$binpie == "NO"} {
|
|
||||||
set displacement "NONE"
|
|
||||||
} elseif {$binprelink == "NO"} {
|
|
||||||
set displacement "NONZERO"
|
set displacement "NONZERO"
|
||||||
} else {
|
test_attach $exec $displacement $relink_args
|
||||||
# x86* kernel loads prelinked PIE binary at its prelinked
|
|
||||||
# address but ppc* kernel loads it at a random address.
|
|
||||||
# prelink normally skips PIE binaries during the system scan.
|
|
||||||
set displacement "PRESENT"
|
|
||||||
}
|
|
||||||
|
|
||||||
if {[prelink$binprelink $relink_args [file tail $exec]]
|
# ATTACH means that executables and libraries have been
|
||||||
&& [file_copy $interp_saved $interp]} {
|
# modified after they have been run. They cannot be reused
|
||||||
# In order to make test names unique wrap the core of this if block
|
# for problem reproducibility after the testcase ends in
|
||||||
# with a test prefix. Some of the tests performed in the if
|
# the ATTACH case. Therefore they are rather deleted not
|
||||||
# condition are repeated within this body.
|
# to confuse after the run finishes.
|
||||||
with_test_prefix "INNER" {
|
set exec_debug [system_debug_get $exec]
|
||||||
if {$binpie != "ATTACH"} {
|
if {$exec_debug != ""} {
|
||||||
test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
|
# `file delete [glob "${exec_debug}*"]' does not work.
|
||||||
} else {
|
foreach f [glob "${exec_debug}*"] {
|
||||||
# If the file has been randomly prelinked it must be
|
file delete $f
|
||||||
# "NONZERO". We could see "ZERO" only if it was unprelinked
|
|
||||||
# and it is now running at the same address - which is 0 but
|
|
||||||
# executable can never run at address 0.
|
|
||||||
|
|
||||||
set displacement "NONZERO"
|
|
||||||
test_attach $exec $displacement $relink_args
|
|
||||||
|
|
||||||
# ATTACH means that executables and libraries have been
|
|
||||||
# modified after they have been run. They cannot be reused
|
|
||||||
# for problem reproducibility after the testcase ends in
|
|
||||||
# the ATTACH case. Therefore they are rather deleted not
|
|
||||||
# to confuse after the run finishes.
|
|
||||||
set exec_debug [system_debug_get $exec]
|
|
||||||
if {$exec_debug != ""} {
|
|
||||||
# `file delete [glob "${exec_debug}*"]' does not work.
|
|
||||||
foreach f [glob "${exec_debug}*"] {
|
|
||||||
file delete $f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file delete -force $dir
|
|
||||||
# `file delete [glob "${exec}*"]' does not work.
|
|
||||||
foreach f [glob "${exec}*"] {
|
|
||||||
file delete $f
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file delete -force $dir
|
||||||
|
# `file delete [glob "${exec}*"]' does not work.
|
||||||
|
foreach f [glob "${exec}*"] {
|
||||||
|
file delete $f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file delete $interp_saved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file delete $interp_saved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user