Clean up "Reading symbols" output
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break-interp.exp
index 1e47b34664d860b1c31d1597f6e9e64d3cfa695c..50d0c23a279f7f174b02fb0ee99d8bf94f85cb0a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Free Software Foundation, Inc.
+# Copyright 2010-2018 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,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This test only works on GNU/Linux.
-if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
+if { ![isnative] || [is_remote host] || [use_gdb_stub]
      || ![istarget *-linux*] || [skip_shlib_tests]} {
     continue
 }
@@ -22,15 +22,15 @@ if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
 load_lib prelink-support.exp
 
 set test "break-interp"
-set binprefix ${objdir}/${subdir}/${test}
+set binprefix [standard_output_file ${test}]
 # Only to get the $interp_system name.
 set srcfile_test "start.c"
 set binfile_test ${test}-test
-set binfile_lib ${objdir}/${subdir}/${test}.so
+set binfile_lib ${binprefix}.so
 set srcfile "${test}-main.c"
 set srcfile_lib "${test}-lib.c"
 
-if [get_compiler_info ${binfile_lib}] {
+if [get_compiler_info] {
     return -1
 }
 
@@ -83,7 +83,7 @@ gdb_test_multiple $test $test {
     }
 }
 
-set interp_system [section_get ${objdir}/${subdir}/$binfile_test .interp]
+set interp_system [section_get [standard_output_file $binfile_test] .interp]
 set interp_system_debug [system_debug_get $interp_system]
 verbose -log "$interp_system has debug $interp_system_debug"
 
@@ -109,12 +109,19 @@ proc strip_debug {dest} {
     }
 }
 
+# The marker function for the standard runtime linker interface is
+# _dl_debug_state.  The probes-based interface has no specific marker
+# function; the probe we will stop on (init_start) is in dl_main so we
+# check for that.
+
+set solib_bp {(_dl_debug_state|dl_main)}
+
 # Implementation of reach.
 
 proc reach_1 {func command displacement} {
-    global gdb_prompt expect_out
+    global gdb_prompt expect_out solib_bp
 
-    if {$func == "_dl_debug_state"} {
+    if {$func == $solib_bp} {
        # 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"
@@ -142,21 +149,21 @@ proc reach_1 {func command displacement} {
            exp_continue
        }
        -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
-           if {$func == "_dl_debug_state"} {
+           if {$func == $solib_bp} {
                fail $test
            } else {
                pass $test
            }
        }
        -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" {
-           if {$func == "_dl_debug_state"} {
+           if {$func == $solib_bp} {
                fail $test
            } else {
                pass $test
            }
        }
        -re "Stopped due to (spurious )?shared library event.*\r\n$gdb_prompt $" {
-           if {$func == "_dl_debug_state"} {
+           if {$func == $solib_bp} {
                if {$debug_state_count == 0} {
                    # First stop does not yet relocate the _start function
                    # descriptor on ppc64.
@@ -175,7 +182,7 @@ proc reach_1 {func command displacement} {
        fail $test_displacement
     }
 
-    if {$func == "_dl_debug_state"} {
+    if {$func == $solib_bp} {
        gdb_test_no_output "set stop-on-solib-events 0"
     }
 }
@@ -190,103 +197,107 @@ proc reach {func command displacement} {
     }
 }
 
-proc test_core {file displacement} { with_test_prefix "core" {
-    global srcdir subdir gdb_prompt expect_out
+proc test_core {file displacement} {
+    with_test_prefix "core" {
+       global srcdir subdir gdb_prompt expect_out
 
-    set corefile [core_find $file {} "segv"]
-    if {$corefile == ""} {
-       return
-    }
+       set corefile [core_find $file {} "segv"]
+       if {$corefile == ""} {
+           return
+       }
 
-    gdb_exit
-    gdb_start
-    # Clear it to never find any separate debug infos in $debug_root.
-    gdb_test_no_output "set debug-file-directory" \
-       "set debug-file-directory for core"
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $file
+       gdb_exit
+       gdb_start
+       # Clear it to never find any separate debug infos in $debug_root.
+       gdb_test_no_output "set debug-file-directory" \
+           "set debug-file-directory for core"
+       gdb_reinitialize_dir $srcdir/$subdir
+       gdb_load $file
 
-    # Print the "PIE (Position Independent Executable) displacement" message.
-    gdb_test_no_output "set verbose on"
+       # Print the "PIE (Position Independent Executable) displacement" message.
+       gdb_test_no_output "set verbose on"
 
-    set test "core loaded"
-    set test_displacement "seen displacement message as $displacement"
-    gdb_test_multiple "core-file $corefile" $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"
+       set test "core loaded"
+       set test_displacement "seen displacement message as $displacement"
+       gdb_test_multiple "core-file $corefile" $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
            }
-           if {$displacement == $case || $displacement == "PRESENT"} {
-               pass $test_displacement
-               set displacement "FOUND-$displacement"
-           } else {
-               fail $test_displacement
+           -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
+               # Do not check the binary filename as it may be truncated.
+               pass $test
            }
-           exp_continue
        }
-       -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
-           # Do not check the binary filename as it may be truncated.
-           pass $test
+       if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+           fail $test_displacement
        }
-    }
-    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
-       fail $test_displacement
-    }
 
-    gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
-}}
+       gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
+    }
+}
 
-proc test_attach_gdb {file pid displacement prefix} { with_test_prefix "$prefix" {
-    global gdb_prompt expect_out
+proc test_attach_gdb {file pid displacement prefix} {
+    with_test_prefix "$prefix" {
+       global gdb_prompt expect_out
 
-    gdb_exit
-    gdb_start
+       gdb_exit
+       gdb_start
 
-    # Print the "PIE (Position Independent Executable) displacement" message.
-    gdb_test_no_output "set verbose on"
+       # Print the "PIE (Position Independent Executable) displacement" message.
+       gdb_test_no_output "set verbose on"
 
-    gdb_test "file $file" "Reading symbols from .*done\\." "file"
+       gdb_test "file $file" "Reading symbols from .*" "file"
 
-    set test "attach"
-    gdb_test_multiple "attach $pid" $test {
-       -re "Attaching to (program: .*, )?process $pid\r\n" {
-           # Missing "$gdb_prompt $" is intentional.
-           pass $test
+       set test "attach"
+       gdb_test_multiple "attach $pid" $test {
+           -re "Attaching to (program: .*, )?process $pid\r\n" {
+               # Missing "$gdb_prompt $" is intentional.
+               pass $test
+           }
        }
-    }
 
-    set test "attach final prompt"
-    set test_displacement "seen displacement message as $displacement"
-    gdb_test_multiple "" $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"
+       set test "attach final prompt"
+       set test_displacement "seen displacement message as $displacement"
+       gdb_test_multiple "" $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
            }
-           if {$displacement == $case || $displacement == "PRESENT"} {
-               pass $test_displacement
-               set displacement "FOUND-$displacement"
-           } else {
-               fail $test_displacement
+           -re "$gdb_prompt $" {
+               pass $test
            }
-           exp_continue
        }
-       -re "$gdb_prompt $" {
-           pass $test
+       if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+           fail $test_displacement
        }
-    }
-    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
-       fail $test_displacement
-    }
 
-    gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
-    gdb_exit
-}}
+       gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
+       gdb_exit
+    }
+}
 
 proc test_attach {file displacement {relink_args ""}} {
     global board_info
@@ -297,23 +308,25 @@ proc test_attach {file displacement {relink_args ""}} {
     set test "sleep function started"
 
     set command "${file} sleep"
-    set res [remote_spawn host $command];
-    if { $res < 0 || $res == "" } {
+    set test_spawn_id [remote_spawn host $command]
+    if { $test_spawn_id < 0 || $test_spawn_id == "" } {
        perror "Spawning $command failed."
        fail $test
        return
     }
-    set pid [exp_pid -i $res]
+    set pid [spawn_id_get_pid $test_spawn_id]
     gdb_expect {
        -re "sleeping\r\n" {
            pass $test
        }
        eof {
            fail "$test (eof)"
+           wait -i $test_spawn_id
            return
        }
        timeout {
            fail "$test (timeout)"
+           kill_wait_spawned_process $test_spawn_id
            return
        }
     }
@@ -353,11 +366,11 @@ proc test_attach {file displacement {relink_args ""}} {
        file_copy $interp_saved $interp
     }
 
-    remote_exec host "kill -9 $pid"
+    kill_wait_spawned_process $test_spawn_id
 }
 
 proc test_ld {file ifmain trynosym displacement} {
-    global srcdir subdir gdb_prompt expect_out inferior_exited_re
+    global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp
 
     # First test normal `file'-command loaded $FILE with symbols.
 
@@ -379,15 +392,16 @@ proc test_ld {file ifmain trynosym displacement} {
     if $ifmain {
        gdb_test_no_output "set args segv"
     } else {
-       global objdir binfile_test
+       global binfile_test
 
        # ld.so needs some executable to run to reach _dl_debug_state.
-       gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test"
+       gdb_test_no_output "set args [standard_output_file $binfile_test]" \
+           "set args OBJDIR/${subdir}/$binfile_test"
     }
 
-    reach "_dl_debug_state" "run" $displacement
+    reach $solib_bp "run" $displacement
 
-    gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt"
+    gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
 
     if $ifmain {
        reach "main" continue "NONE"
@@ -399,7 +413,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_debug_state" "run" $displacement
+    reach $solib_bp "run" $displacement
 
     if $ifmain {
        test_core $file $displacement
@@ -431,7 +445,7 @@ proc test_ld {file ifmain trynosym displacement} {
        gdb_test "exec-file $file" "exec-file $escapedfile" "load"
 
        if $ifmain {
-           reach "_dl_debug_state" run $displacement
+           reach $solib_bp run $displacement
 
            # Use two separate gdb_test_multiple statements to avoid timeouts due
            # to slow processing of wildcard capturing long output
@@ -536,7 +550,7 @@ foreach ldprelink {NO YES} {
            } 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 $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"]} {
@@ -611,13 +625,14 @@ foreach ldprelink {NO YES} {
                                lappend opts {debug}
                            }
                            if {$binpie != "NO"} {
-                               lappend opts {additional_flags=-fPIE -pie}
+                               lappend opts {additional_flags=-fPIE}
+                               lappend opts {ldflags=-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;
+                               continue
                            }
 
                            if {$binsepdebug == "SEP"} {
This page took 0.047416 seconds and 4 git commands to generate.