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:
Simon Marchi 2020-03-12 14:34:22 -04:00
parent 40310f30a5
commit 3f512721a8
2 changed files with 142 additions and 142 deletions

View File

@ -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>
* gdb.arch/amd64-disp-step-avx.S: Add nops after _start.

View File

@ -538,8 +538,8 @@ proc test_ld {file ifmain trynosym displacement} {
# Create separate binaries for each testcase - to make the possible reported
# problem reproducible after the whole test run finishes.
foreach ldprelink {NO YES} {
foreach ldsepdebug {NO IN SEP} {
foreach_with_prefix ldprelink {NO YES} {
foreach_with_prefix ldsepdebug {NO IN SEP} {
# Skip running the ldsepdebug test if we do not have system separate
# debug info available.
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.
set interp_saved ${interp}-saved
with_test_prefix "$ldname" {
if {$ldsepdebug == "NO"} {
file_copy $interp_system $interp
# Never call strip-debug before unprelink:
# prelink: ...: Section .note.gnu.build-id created after prelinking
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"] {
if {$ldsepdebug == "NO"} {
file_copy $interp_system $interp
# Never call strip-debug before unprelink:
# prelink: ...: Section .note.gnu.build-id created after prelinking
if ![prelinkNO $interp] {
continue
}
if {$ldprelink == "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"
}
test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
if ![file_copy $interp $interp_saved] {
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"
}
foreach binprelink {NO YES} {
foreach 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 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
}
if {$ldsepdebug == "SEP"} {
if ![prelinkNO "${interp}.debug"] {
continue
}
} else {
file delete "${interp}.debug"
}
set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
set exec $binprefix-$binname
if ![prelink$ldprelink $interp "$interp, second time"] {
continue
}
with_test_prefix "$binname" {
set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
if {$binsepdebug != "NO"} {
lappend opts {debug}
}
if {$binpie != "NO"} {
lappend opts {pie}
if {$ldprelink == "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"
}
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 {
# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled.
lappend opts {nopie}
}
# If the file has been randomly prelinked it must be
# "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"
} 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"
}
test_attach $exec $displacement $relink_args
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 {
# If the file has been randomly prelinked it must be
# "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
}
# 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 $interp_saved
}
file delete $interp_saved
}
}