From d3d7896de378a9d127f355af1187cb47357f4f2a Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 11 Oct 2010 08:47:47 +0000 Subject: [PATCH] gdb/testsuite/ Fix missing _start PIE relocation on ppc64 due to stop on dl_main. * break-interp.exp (reach): Move the core body ... (reach_1): ... here. Use stop-on-solib-events for _dl_debug_state. (test_ld): Provide always real argument, even to the linker. Replace dl_main by _dl_debug_state. --- gdb/testsuite/ChangeLog | 8 ++ gdb/testsuite/gdb.base/break-interp.exp | 117 +++++++++++++++++------- 2 files changed, 91 insertions(+), 34 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e01dd40ddfc..865568c1d1f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2010-10-11 Jan Kratochvil + + Fix missing _start PIE relocation on ppc64 due to stop on dl_main. + * break-interp.exp (reach): Move the core body ... + (reach_1): ... here. Use stop-on-solib-events for _dl_debug_state. + (test_ld): Provide always real argument, even to the linker. Replace + dl_main by _dl_debug_state. + 2010-10-11 Jan Kratochvil Fix results of prelinked PIEs on ppc*. diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp index c00db6377fb..4025083e715 100644 --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -108,47 +108,87 @@ proc strip_debug {dest} { } } -# `runto' does not check we stopped really at the function we specified. -# DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for -# displacement of 0 bytes to be present, "NONZERO" for displacement of non-0 -# bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid. -proc reach {func command displacement} { +# Implementation of reach. + +proc reach_1 {func command displacement} { global gdb_prompt expect_out - global pf_prefix - set old_ldprefix $pf_prefix - lappend pf_prefix "reach-$func:" + if {$func == "_dl_debug_state"} { + # Breakpoint on _dl_debug_state can have problems due to its overlap + # with the existing internal breakpoint from GDB. + gdb_test_no_output "set stop-on-solib-events 1" + } elseif {! [gdb_breakpoint $func allow-pending]} { + return + } - if [gdb_breakpoint $func allow-pending] { - set test "reach" - set test_displacement "seen displacement message as $displacement" - gdb_test_multiple $command $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 + set test "reach" + set test_displacement "seen displacement message as $displacement" + set debug_state_count 0 + gdb_test_multiple $command $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" } - -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { + if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { + fail $test_displacement + } + exp_continue + } + -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { + if {$func == "_dl_debug_state"} { + fail $test + } else { pass $test } - -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?$func \\(\\).*\r\n$gdb_prompt $" { + } + -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?$func \\(\\).*\r\n$gdb_prompt $" { + if {$func == "_dl_debug_state"} { + fail $test + } else { pass $test } } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { - fail $test_displacement + -re "Stopped due to shared library event\r\n$gdb_prompt $" { + if {$func == "_dl_debug_state"} { + if {$debug_state_count == 0} { + # First stop does not yet relocate the _start function + # descriptor on ppc64. + set debug_state_count 1 + send_gdb "continue\n" + exp_continue + } else { + pass $test + } + } else { + fail $test + } } } + if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + fail $test_displacement + } + + if {$func == "_dl_debug_state"} { + gdb_test_no_output "set stop-on-solib-events 0" + } +} + +# `runto' does not check we stopped really at the function we specified. +# DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for +# displacement of 0 bytes to be present, "NONZERO" for displacement of non-0 +# bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid. +proc reach {func command displacement} { + global pf_prefix + set old_ldprefix $pf_prefix + lappend pf_prefix "reach-$func:" + + reach_1 $func $command $displacement set pf_prefix $old_ldprefix } @@ -344,9 +384,18 @@ proc test_ld {file ifmain trynosym displacement} { # prevents that from happening. So turn it off. gdb_test "set disable-randomization off" - reach "dl_main" "run segv" $displacement + if $ifmain { + gdb_test_no_output "set args segv" + } else { + global objdir binfile_test + + # ld.so needs some executable to run to reach _dl_debug_state. + gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" + } + + reach "_dl_debug_state" "run" $displacement - gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt" + gdb_test "bt" "#0 +\[^\r\n\]*\\m_dl_debug_state\\M.*" "dl bt" if $ifmain { reach "main" continue "NONE" @@ -358,7 +407,7 @@ proc test_ld {file ifmain trynosym displacement} { # Try re-run if the new PIE displacement takes effect. gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" - reach "dl_main" "run segv" $displacement + reach "_dl_debug_state" "run" $displacement if $ifmain { test_core $file $displacement @@ -391,7 +440,7 @@ proc test_ld {file ifmain trynosym displacement} { gdb_test "exec-file $file" "exec-file $escapedfile" "load" if $ifmain { - reach "dl_main" run $displacement + reach "_dl_debug_state" run $displacement set test "info files" set entrynohex "" -- 2.30.2