2012-02-21 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break-interp.exp
index 904fbcf948e16482494f67bf686a27f0d3ca676f..59e5753426eab1b6de8569e74ae01cd8a968aa63 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2012 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
@@ -14,7 +14,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This test only works on GNU/Linux.
-if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_tests]} {
+if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
+     || ![istarget *-linux*] || [skip_shlib_tests]} {
     continue
 }
 
@@ -35,7 +36,7 @@ if [get_compiler_info ${binfile_lib}] {
 
 # Use -soname so that the new library gets copied by build_executable_own_libs.
 
-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-Wl,-soname,${test}.so]] != ""} {
+if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug ldflags=-Wl,-soname,${test}.so]] != ""} {
     return -1
 }
 
@@ -140,21 +141,21 @@ proc reach_1 {func command displacement} {
            }
            exp_continue
        }
-       -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
+       -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$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 \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" {
            if {$func == "_dl_debug_state"} {
                fail $test
            } else {
                pass $test
            }
        }
-       -re "Stopped due to shared library event\r\n$gdb_prompt $" {
+       -re "Stopped due to (spurious )?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
@@ -184,16 +185,12 @@ proc reach_1 {func command displacement} {
 # 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
+    with_test_prefix "reach-$func" {
+       reach_1 $func $command $displacement
+    }
 }
 
-proc test_core {file displacement} {
+proc test_core {file displacement} { with_test_prefix "core" {
     global srcdir subdir gdb_prompt expect_out
 
     set corefile [core_find $file {} "segv"]
@@ -201,10 +198,6 @@ proc test_core {file displacement} {
        return
     }
 
-    global pf_prefix
-    set old_ldprefix $pf_prefix
-    lappend pf_prefix "core:"
-
     gdb_exit
     gdb_start
     # Clear it to never find any separate debug infos in $debug_root.
@@ -244,26 +237,18 @@ proc test_core {file displacement} {
     }
 
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
+}}
 
-    set pf_prefix $old_ldprefix
-}
-
-proc test_attach_gdb {file pid displacement prefix} {
+proc test_attach_gdb {file pid displacement prefix} { with_test_prefix "$prefix" {
     global gdb_prompt expect_out
 
-    global pf_prefix
-    set old_ldprefix $pf_prefix
-    lappend pf_prefix "$prefix:"
-
     gdb_exit
     gdb_start
 
     # Print the "PIE (Position Independent Executable) displacement" message.
     gdb_test_no_output "set verbose on"
 
-    if {$file != ""} {
-       gdb_test "file $file" "Reading symbols from .*done\\." "file"
-    }
+    gdb_test "file $file" "Reading symbols from .*done\\." "file"
 
     set test "attach"
     gdb_test_multiple "attach $pid" $test {
@@ -301,12 +286,11 @@ proc test_attach_gdb {file pid displacement prefix} {
 
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
     gdb_exit
-
-    set pf_prefix $old_ldprefix
-}
+}}
 
 proc test_attach {file displacement {relink_args ""}} {
     global board_info
+    global exec
 
     gdb_exit
 
@@ -335,10 +319,10 @@ proc test_attach {file displacement {relink_args ""}} {
     }
 
     if {$relink_args == ""} {
-       test_attach_gdb "" $pid $displacement "attach"
+       test_attach_gdb $exec $pid $displacement "attach"
     } else {
        # These could be rather passed as arguments.
-       global exec interp_saved interp
+       global interp_saved interp
 
        foreach relink {YES NO} {
            # Formerly this test was testing only prelinking of $EXEC.  As the
@@ -352,6 +336,14 @@ proc test_attach {file displacement {relink_args ""}} {
            # test simplicity, we merged this test and the test above by not
            # restoring $INTERP after $EXEC prelink.  $INTERP gets restored
            # later below.
+           #
+           # `(wrong library or version mismatch?)' messages are printed for
+           # $binfile_lib on platforms converting REL->RELA relocations by
+           # prelink (such as on i386).  There is no reliable way to verify
+           # the library file matches the running library in such case but
+           # GDB at least attempts to set the right displacement.  We test
+           # `libfunc' is present in the backtrace and therefore the
+           # displacement has been guessed right.
 
            if [prelink$relink $relink_args [file tail $exec]] {
                # /proc/PID/exe cannot be loaded as it is "EXECNAME (deleted)".
@@ -365,7 +357,7 @@ proc test_attach {file displacement {relink_args ""}} {
 }
 
 proc test_ld {file ifmain trynosym displacement} {
-    global srcdir subdir gdb_prompt expect_out
+    global srcdir subdir gdb_prompt expect_out inferior_exited_re
 
     # First test normal `file'-command loaded $FILE with symbols.
 
@@ -390,12 +382,12 @@ proc test_ld {file ifmain trynosym displacement} {
        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"
+       gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test"
     }
 
     reach "_dl_debug_state" "run" $displacement
 
-    gdb_test "bt" "#0 +\[^\r\n\]*\\m_dl_debug_state\\M.*" "dl bt"
+    gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt"
 
     if $ifmain {
        reach "main" continue "NONE"
@@ -421,7 +413,7 @@ proc test_ld {file ifmain trynosym displacement} {
 
     global pf_prefix
     set old_ldprefix $pf_prefix
-    lappend pf_prefix "symbol-less:"
+    append pf_prefix " symbol-less:"
 
     # Test also `exec-file'-command loaded $FILE - therefore without symbols.
     # SYMBOL_OBJFILE is not available and only EXEC_BFD must be used.
@@ -442,21 +434,19 @@ proc test_ld {file ifmain trynosym displacement} {
     if $ifmain {
        reach "_dl_debug_state" run $displacement
 
-       # Use two separate gdb_expect statements to avoid timeouts due to
-       # slow processing of wildcard capturing long output
+       # Use two separate gdb_test_multiple statements to avoid timeouts due
+       # to slow processing of wildcard capturing long output
        set test "info files"
        set entrynohex ""
-       send_gdb "$test\n"
-       gdb_expect  {
+       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_expect {
-                   -re "$gdb_prompt $" { pass $test }
-                   timeout { fail "$test (timeout)" }
+               gdb_test_multiple "" $test {
+                   -re "\r\n$gdb_prompt $" {
+                       pass $test
+                   }
                }
            }
-           -re ".*$gdb_prompt $"  { fail $test }
-           timeout         { fail "$test (timeout)" }
        }
 
        # `info sym' cannot be tested for .opd as the binary may not have
@@ -496,7 +486,7 @@ proc test_ld {file ifmain trynosym displacement} {
                }
                exp_continue
            }
-           -re "Program exited (normally|with code \[0-9\]+)\\.\r\n$gdb_prompt $" {
+           -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
            }
@@ -538,7 +528,7 @@ foreach ldprelink {NO YES} {
        set interp_saved ${interp}-saved
 
        set pf_prefix $old_ldprefix
-       lappend pf_prefix "$ldname:"
+       append pf_prefix " $ldname:"
 
        if {$ldsepdebug == "NO"} {
            file_copy $interp_system $interp
@@ -620,9 +610,9 @@ foreach ldprelink {NO YES} {
                    set exec $binprefix-$binname
 
                    set pf_prefix $old_binprefix
-                   lappend pf_prefix "$binname:"
+                   append pf_prefix " $binname:"
 
-                   set opts "additional_flags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
+                   set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
                    if {$binsepdebug != "NO"} {
                        lappend opts {debug}
                    }
This page took 0.034943 seconds and 4 git commands to generate.