gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break-interp.exp
index 50d0c23a279f7f174b02fb0ee99d8bf94f85cb0a..6b03c59c8175c43989ed6bf962288a711e64b558 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010-2018 Free Software Foundation, Inc.
+# Copyright 2010-2020 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
@@ -191,8 +191,16 @@ proc reach_1 {func command displacement} {
 # 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} {
-    with_test_prefix "reach-$func" {
+#
+# The optional ITERATION parameter is used in order to make unique
+# test prefixes, when calling this proc with the same FUNC name
+# provide a unique ITERATION value for each call.
+proc reach {func command displacement {iteration 1}} {
+    set prefix "reach-$func"
+    if { $iteration > 1 } {
+       set prefix "$prefix-$iteration"
+    }
+    with_test_prefix $prefix {
        reach_1 $func $command $displacement
     }
 }
@@ -243,6 +251,7 @@ proc test_core {file displacement} {
        if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
            fail $test_displacement
        }
+       gdb_test_no_output "set verbose off"
 
        gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
     }
@@ -293,6 +302,7 @@ proc test_attach_gdb {file pid displacement prefix} {
        if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
            fail $test_displacement
        }
+       gdb_test_no_output "set verbose off"
 
        gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
        gdb_exit
@@ -399,21 +409,30 @@ proc test_ld {file ifmain trynosym displacement} {
            "set args OBJDIR/${subdir}/$binfile_test"
     }
 
-    reach $solib_bp "run" $displacement
+    reach $solib_bp "run" $displacement 1
 
-    gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
+    with_test_prefix "first backtrace" {
+       gdb_test_no_output "set verbose off"
+       gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
+       gdb_test_no_output "set verbose on"
+    }
 
     if $ifmain {
        reach "main" continue "NONE"
 
        reach "libfunc" continue "NONE"
 
-       gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
+       with_test_prefix "second backtrace" {
+           gdb_test_no_output "set verbose off"
+           gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
+           gdb_test_no_output "set verbose on"
+       }
     }
 
     # Try re-run if the new PIE displacement takes effect.
     gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
-    reach $solib_bp "run" $displacement
+    reach $solib_bp "run" $displacement 2
+    gdb_test_no_output "set verbose off"
 
     if $ifmain {
        test_core $file $displacement
@@ -445,12 +464,16 @@ proc test_ld {file ifmain trynosym displacement} {
        gdb_test "exec-file $file" "exec-file $escapedfile" "load"
 
        if $ifmain {
-           reach $solib_bp run $displacement
+           reach $solib_bp run $displacement 3
 
            # 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 ""
+           set info_line [join [list \
+                                    "\r\n" "\[\t\]" "0x\[0-9af\]+" " - " \
+                                    "0x\[0-9af\]+" " @ " "0x\[0-9af\]+"  \
+                                    " is " "\[^\r\n\]+"] ""]
            gdb_test_multiple $test $test {
                -re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n" {
                    set entrynohex $expect_out(1,string)
@@ -458,6 +481,10 @@ proc test_ld {file ifmain trynosym displacement} {
                        -re "\r\n$gdb_prompt $" {
                            pass $test
                        }
+                       -re $info_line {
+                           # Avoid timeout with check-read1
+                           exp_continue
+                       }
                    }
                }
            }
@@ -508,14 +535,15 @@ proc test_ld {file ifmain trynosym displacement} {
                fail $test_displacement
            }
        }
+       gdb_test_no_output "set verbose off"
     }
 }
 
 # 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"} {
@@ -538,156 +566,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 {$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 ![prelink$ldprelink $interp] {
+           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
            }
-           if {$ldprelink == "NO"} {
-               set displacement "NONZERO"
+           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 {
-               # 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"
+               pass $test
            }
-           test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
+       } 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 ![file_copy $interp $interp_saved] {
+       if {$ldsepdebug == "SEP"} {
+           if ![prelinkNO "${interp}.debug"] {
                continue
            }
+       } else {
+           file delete "${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 ![prelink$ldprelink $interp "[file tail $interp], second time"] {
+           continue
+       }
 
-                       set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
-                       set exec $binprefix-$binname
+       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
 
-                       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 {additional_flags=-fPIE}
-                               lappend opts {ldflags=-pie}
-                           }
+       if ![file_copy $interp $interp_saved] {
+           continue
+       }
 
-                           set dir ${exec}.d
-                           set relink_args [build_executable_own_libs ${test}.exp [file tail $exec] $srcfile $opts $interp $dir]
-                           if {$relink_args == ""} {
-                               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
+                   }
 
-                           if {$binsepdebug == "SEP"} {
-                               gdb_gnu_strip_debug $exec
-                           }
+                   set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
+                   set exec $binprefix-$binname
 
-                           if {$binpie == "NO"} {
-                               set displacement "NONE"
-                           } elseif {$binprelink == "NO"} {
-                               set displacement "NONZERO"
+                   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 {
-                               # 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 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.
 
-                           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}*"] {
+                               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
     }
 }
This page took 0.035998 seconds and 4 git commands to generate.