2012-02-24 Pedro Alves <palves@redhat.com>

* gdb.base/break-interp.exp (test_ld): Use with_test_prefix.
	(top level): Use with_test_prefix.
This commit is contained in:
Pedro Alves 2012-02-24 14:09:08 +00:00
parent 13fc3e3cf9
commit 11337c2fed
2 changed files with 204 additions and 207 deletions

View File

@ -1,3 +1,8 @@
2012-02-24 Pedro Alves <palves@redhat.com>
* gdb.base/break-interp.exp (test_ld): Use with_test_prefix.
(top level): Use with_test_prefix.
2012-02-24 Pedro Alves <palves@redhat.com> 2012-02-24 Pedro Alves <palves@redhat.com>
* gdb.threads/attach-into-signal.exp (corefunc): Use * gdb.threads/attach-into-signal.exp (corefunc): Use

View File

@ -411,98 +411,95 @@ proc test_ld {file ifmain trynosym displacement} {
return return
} }
global pf_prefix with_test_prefix "symbol-less" {
set old_ldprefix $pf_prefix # Test also `exec-file'-command loaded $FILE - therefore
append pf_prefix " symbol-less:" # without symbols. SYMBOL_OBJFILE is not available and only
# EXEC_BFD must be used.
# Test also `exec-file'-command loaded $FILE - therefore without symbols. gdb_exit
# SYMBOL_OBJFILE is not available and only EXEC_BFD must be used. gdb_start
# Clear it to never find any separate debug infos in $debug_root.
gdb_test_no_output "set debug-file-directory"
gdb_reinitialize_dir $srcdir/$subdir
gdb_exit # Print the "PIE (Position Independent Executable)
gdb_start # displacement" message.
# Clear it to never find any separate debug infos in $debug_root. gdb_test_no_output "set verbose on"
gdb_test_no_output "set debug-file-directory"
gdb_reinitialize_dir $srcdir/$subdir
# Print the "PIE (Position Independent Executable) displacement" message. # Test no (error) message has been printed by `exec-file'.
gdb_test_no_output "set verbose on" set escapedfile [string_to_regexp $file]
gdb_test "exec-file $file" "exec-file $escapedfile" "load"
# Test no (error) message has been printed by `exec-file'. if $ifmain {
set escapedfile [string_to_regexp $file] reach "_dl_debug_state" run $displacement
gdb_test "exec-file $file" "exec-file $escapedfile" "load"
if $ifmain { # Use two separate gdb_test_multiple statements to avoid timeouts due
reach "_dl_debug_state" run $displacement # to slow processing of wildcard capturing long output
set test "info files"
set entrynohex ""
gdb_test_multiple $test $test {
-re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n" {
set entrynohex $expect_out(1,string)
gdb_test_multiple "" $test {
-re "\r\n$gdb_prompt $" {
pass $test
}
}
}
}
# Use two separate gdb_test_multiple statements to avoid timeouts due # `info sym' cannot be tested for .opd as the binary may not have
# to slow processing of wildcard capturing long output # symbols.
set test "info files" if {[istarget powerpc64-*] && [is_lp64_target]} {
set entrynohex "" set test "convert entry point"
gdb_test_multiple $test $test { gdb_test_multiple "p *(void(*)(void) *) 0x$entrynohex" $test {
-re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n" { -re " =( \\(\[^0-9\]*\\))? 0x(\[0-9a-f\]+)( < \[^\r\n\]*)?\r\n$gdb_prompt $" {
set entrynohex $expect_out(1,string) set entrynohex $expect_out(2,string)
gdb_test_multiple "" $test {
-re "\r\n$gdb_prompt $" {
pass $test pass $test
} }
} }
} }
} if {$entrynohex != ""} {
gdb_test "break *0x$entrynohex" "" "break at entry point"
gdb_test "continue" "\r\nBreakpoint \[0-9\]+, 0x0*$entrynohex in .*" "entry point reached"
}
} else {
# There is no symbol to break at ld.so. Moreover it can
# exit with an error code.
# `info sym' cannot be tested for .opd as the binary may not have set test "ld.so exit"
# symbols. set test_displacement "seen displacement message as $displacement"
if {[istarget powerpc64-*] && [is_lp64_target]} { gdb_test_multiple "run" $test {
set test "convert entry point" -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
gdb_test_multiple "p *(void(*)(void) *) 0x$entrynohex" $test { # Missing "$gdb_prompt $" is intentional.
-re " =( \\(\[^0-9\]*\\))? 0x(\[0-9a-f\]+)( < \[^\r\n\]*)?\r\n$gdb_prompt $" { if {$expect_out(1,string) == "0x0"} {
set entrynohex $expect_out(2,string) set case "ZERO"
} else {
set case "NONZERO"
}
if {$displacement == $case || $displacement == "PRESENT"} {
pass $test_displacement
set displacement "FOUND-$displacement"
} else {
fail $test_displacement
}
exp_continue
}
-re "$inferior_exited_re (normally|with code \[0-9\]+).\r\n$gdb_prompt $" {
# Do not check the binary filename as it may be truncated.
pass $test pass $test
} }
} }
} if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
if {$entrynohex != ""} { fail $test_displacement
gdb_test "break *0x$entrynohex" "" "break at entry point"
gdb_test "continue" "\r\nBreakpoint \[0-9\]+, 0x0*$entrynohex in .*" "entry point reached"
}
} else {
# There is no symbol to break at ld.so. Moreover it can exit with an
# error code.
set test "ld.so exit"
set test_displacement "seen displacement message as $displacement"
gdb_test_multiple "run" $test {
-re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
# Missing "$gdb_prompt $" is intentional.
if {$expect_out(1,string) == "0x0"} {
set case "ZERO"
} else {
set case "NONZERO"
}
if {$displacement == $case || $displacement == "PRESENT"} {
pass $test_displacement
set displacement "FOUND-$displacement"
} else {
fail $test_displacement
}
exp_continue
} }
-re "$inferior_exited_re (normally|with code \[0-9\]+).\r\n$gdb_prompt $" {
# Do not check the binary filename as it may be truncated.
pass $test
}
}
if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
fail $test_displacement
} }
} }
set pf_prefix $old_ldprefix
} }
# 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.
set old_ldprefix $pf_prefix
foreach ldprelink {NO YES} { foreach ldprelink {NO YES} {
foreach ldsepdebug {NO IN SEP} { foreach 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
@ -527,160 +524,155 @@ 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
set pf_prefix $old_ldprefix with_test_prefix "$ldname" {
append pf_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 == "NO"} { if {$ldsepdebug == "SEP"} {
file_copy $interp_system $interp if ![prelinkNO "${interp}.debug"] {
# Never call strip-debug before unprelink: continue
# 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 { } else {
pass $test file delete "${interp}.debug"
} }
} elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
file_copy $interp_system $interp if ![prelink$ldprelink $interp] {
# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
if ![prelinkNO $interp] {
continue continue
} }
gdb_gnu_strip_debug $interp if {$ldprelink == "NO"} {
} elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} { set displacement "NONZERO"
file_copy $interp_system $interp } else {
file_copy $interp_system_debug "${interp}.debug" # 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 {$ldsepdebug == "SEP"} { if ![file_copy $interp $interp_saved] {
if ![prelinkNO "${interp}.debug"] {
continue continue
} }
} else {
file delete "${interp}.debug"
}
if ![prelink$ldprelink $interp] { foreach binprelink {NO YES} {
continue foreach binsepdebug {NO IN SEP} {
} # "ATTACH" is like "YES" but it is modified during
if {$ldprelink == "NO"} { # run. It cannot be used for problem
set displacement "NONZERO" # reproducibility after the testcase ends.
} else { foreach binpie {NO YES ATTACH} {
# x86* kernel loads prelinked PIE binary at its prelinked address # This combination is not possible, non-PIE (fixed address)
# but ppc* kernel loads it at a random address. prelink normally # binary cannot be prelinked to any (other) address.
# skips PIE binaries during the system scan. if {$binprelink == "YES" && $binpie == "NO"} {
set displacement "PRESENT" continue
} }
test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
if ![file_copy $interp $interp_saved] { set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
continue set exec $binprefix-$binname
}
set old_binprefix $pf_prefix
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
}
set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}" with_test_prefix "$binname" {
set exec $binprefix-$binname set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
if {$binsepdebug != "NO"} {
set pf_prefix $old_binprefix lappend opts {debug}
append pf_prefix " $binname:"
set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
if {$binsepdebug != "NO"} {
lappend opts {debug}
}
if {$binpie != "NO"} {
lappend opts {additional_flags=-fPIE -pie}
}
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]} {
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 if {$binpie != "NO"} {
# `file delete [glob "${exec}*"]' does not work. lappend opts {additional_flags=-fPIE -pie}
foreach f [glob "${exec}*"] { }
file delete $f
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]} {
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
}
}
} }
} }
} }
} }
} }
}
file delete $interp_saved file delete $interp_saved
}
} }
} }
set pf_prefix $old_ldprefix