Fix some duplicate test names
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / sigbpt.exp
index 0e69e3989ea906b3819f5a2ce3e93d8eba8112c1..bd7e1d8db94a1fcb8d9ce3466225710f652b8b6b 100644 (file)
@@ -1,10 +1,10 @@
 # This testcase is part of GDB, the GNU debugger.
 
-# Copyright 2004, 2005 Free Software Foundation, Inc.
+# Copyright 2004-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
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that GDB can and only executes single instructions when
 # stepping through a sequence of breakpoints interleaved by a signal
 # software single-step this is KFAILed rather than XFAILed.
 
 if [target_info exists gdb,nosignals] {
-    verbose "Skipping signals.exp because of nosignals."
+    verbose "Skipping sigbpt.exp because of nosignals."
     continue
 }
 
-if $tracelevel {
-    strace $tracelevel
-}
 
-set prms_id 0
-set bug_id 0
+standard_testfile
 
-set testfile "sigbpt"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 #
 # Run to `main' where we begin our tests.
 #
 
 if ![runto_main] then {
-    gdb_suppress_tests
+    fail "can't run to main"
+    return 0
 }
 
 # If we can examine what's at memory address 0, it is possible that we
@@ -67,14 +55,9 @@ if ![runto_main] then {
 # especially on targets without an MMU.  Don't run the tests in that
 # case.
 
-send_gdb "x 0\n"
-gdb_expect {
-    -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
-    -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
-    -re ".*$gdb_prompt $" {
-       untested "Memory at address 0 is possibly executable"
-       return
-    }
+if { [is_address_zero_readable] } {
+    untested "memory at address 0 is possibly executable"
+    return
 }
 
 gdb_test "break keeper"
@@ -83,18 +66,23 @@ gdb_test "break keeper"
 # the address of each single-step instruction (up to and including the
 # instruction that causes the SIGSEGV) in bowler_addrs, and the address
 # of the actual SIGSEGV in segv_addr.
+# Note: this test detects which signal is received.  Usually it is SIGSEGV
+# (and we use SIGSEGV in comments) but on Darwin it is SIGBUS.
 
 set bowler_addrs bowler
+set segv_addr none
 gdb_test {display/i $pc}
-gdb_test "advance *bowler" "bowler.*" "advance to the bowler"
-set test "stepping to SIGSEGV"
+gdb_test "advance bowler" "bowler.*" "advance to the bowler"
+set test "stepping to fault"
+set signame "SIGSEGV"
 gdb_test_multiple "stepi" "$test" {
-    -re "Program received signal SIGSEGV.*pc *(0x\[0-9a-f\]*).*$gdb_prompt $" {
-       set segv_addr $expect_out(1,string)
+    -re "Program received signal (SIGBUS|SIGSEGV).*pc(\r\n| *) *=> (0x\[0-9a-f\]*).*$gdb_prompt $" {
+       set signame $expect_out(1,string)
+       set segv_addr $expect_out(3,string)
        pass "$test"
     }
-    -re " .*pc *(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
-       set bowler_addrs [concat $expect_out(1,string) $bowler_addrs]
+    -re " .*pc(\r\n| *)=> (0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
+       set bowler_addrs [concat $expect_out(2,string) $bowler_addrs]
        send_gdb "stepi\n"
        exp_continue
     }
@@ -105,7 +93,7 @@ gdb_test_multiple "stepi" "$test" {
 
 set test "get insn after fault"
 gdb_test_multiple {x/2i $pc} "$test" {
-    -re "(0x\[0-9a-f\]*).*bowler.*(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
+    -re "=> (0x\[0-9a-f\]*).*bowler.*(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
        set bowler_addrs [concat $expect_out(2,string) $bowler_addrs]
        pass "$test"
     }
@@ -131,7 +119,7 @@ proc after_segv { } {
 
 # Check that the address table and SIGSEGV correspond.
 
-set test "Verify that SIGSEGV occurs at the last STEPI insn"
+set test "verify that ${signame} occurs at the last STEPI insn"
 if {[string compare $segv_addr [at_segv]] == 0} {
     pass "$test"
 } else {
@@ -143,16 +131,19 @@ if {[string compare $segv_addr [at_segv]] == 0} {
 
 proc stepi_out { name args } {
     global gdb_prompt
+    global signame
 
     # Set SIGSEGV to pass+nostop and then run the inferior all the way
     # through to the signal handler.  With the handler is reached,
     # disable SIGSEGV, ensuring that further signals stop the
     # inferior.  Stops a SIGSEGV infinite loop when a broke system
     # keeps re-executing the faulting instruction.
-    rerun_to_main
-    gdb_test "handle SIGSEGV nostop print pass" "" "${name}; pass SIGSEGV"
+    with_test_prefix $name {
+       rerun_to_main
+    }
+    gdb_test "handle ${signame} nostop print pass" ".*" "${name}; pass ${signame}"
     gdb_test "continue" "keeper.*" "${name}; continue to keeper"
-    gdb_test "handle SIGSEGV stop print nopass" "" "${name}; nopass SIGSEGV"
+    gdb_test "handle ${signame} stop print nopass" ".*" "${name}; nopass ${signame}"
 
     # Insert all the breakpoints.  To avoid the need to step over
     # these instructions, this is delayed until after the keeper has
@@ -167,7 +158,11 @@ proc stepi_out { name args } {
     set test "${name}; stepi out of handler"
     gdb_test_multiple "stepi" "$test" {
        -re "Could not insert single-step breakpoint.*$gdb_prompt $" {
-           setup_kfail "sparc*-*-openbsd*" gdb/1736
+           setup_kfail gdb/8841 "sparc*-*-openbsd*"
+           fail "$test (could not insert single-step breakpoint)"
+       }
+       -re "Cannot insert breakpoint.*Cannot access memory.*$gdb_prompt $" {
+           setup_kfail gdb/8841 "nios2*-*-linux*"
            fail "$test (could not insert single-step breakpoint)"
        }
        -re "keeper.*$gdb_prompt $" {
@@ -179,22 +174,22 @@ proc stepi_out { name args } {
            exp_continue
        }
        -re "Program received signal SIGSEGV.*$gdb_prompt $" {
-           kfail gdb/1702 "$test (executed fault insn)"
+           kfail gdb/8807 "$test (executed fault insn)"
        }
-       -re "Breakpoint.*pc *[at_segv] .*bowler.*$gdb_prompt $" {
+       -re "Breakpoint.*pc(\r\n| *)[at_segv] .*bowler.*$gdb_prompt $" {
            pass "$test (at breakpoint)"
        }
-       -re "Breakpoint.*pc *[after_segv] .*bowler.*$gdb_prompt $" {
-           kfail gdb/1702 "$test (executed breakpoint)"
+       -re "Breakpoint.*pc(\r\n| *)[after_segv] .*bowler.*$gdb_prompt $" {
+           kfail gdb/8807 "$test (executed breakpoint)"
        }
-       -re "pc *[at_segv] .*bowler.*$gdb_prompt $" {
+       -re "pc(\r\n| *)[at_segv] .*bowler.*$gdb_prompt $" {
            pass "$test"
        }
-       -re "pc *[after_segv] .*bowler.*$gdb_prompt $" {
-           kfail gdb/1702 "$test (skipped fault insn)"
+       -re "pc(\r\n| *)[after_segv] .*bowler.*$gdb_prompt $" {
+           kfail gdb/8807 "$test (skipped fault insn)"
        }
-       -re "pc *0x\[a-z0-9\]* .*bowler.*$gdb_prompt $" {
-           kfail gdb/1702 "$test (corrupt pc)"
+       -re "pc(\r\n| *)=> 0x\[a-z0-9\]* .*bowler.*$gdb_prompt $" {
+           kfail gdb/8807 "$test (corrupt pc)"
        }
     }
 
@@ -212,16 +207,19 @@ proc stepi_out { name args } {
 
 proc cont_out { name args } {
     global gdb_prompt
+    global signame
 
     # Set SIGSEGV to pass+nostop and then run the inferior all the way
     # through to the signal handler.  With the handler is reached,
     # disable SIGSEGV, ensuring that further signals stop the
     # inferior.  Stops a SIGSEGV infinite loop when a broke system
     # keeps re-executing the faulting instruction.
-    rerun_to_main
-    gdb_test "handle SIGSEGV nostop print pass" "" "${name}; pass SIGSEGV"
+    with_test_prefix $name {
+       rerun_to_main
+    }
+    gdb_test "handle ${signame} nostop print pass" ".*" "${name}; pass ${signame}"
     gdb_test "continue" "keeper.*" "${name}; continue to keeper"
-    gdb_test "handle SIGSEGV stop print nopass" "" "${name}; nopass SIGSEGV"
+    gdb_test "handle ${signame} stop print nopass" ".*" "${name}; nopass ${signame}"
 
     # Insert all the breakpoints.  To avoid the need to step over
     # these instructions, this is delayed until after the keeper has
@@ -237,12 +235,12 @@ proc cont_out { name args } {
     # inserted at the faulting instruction.  Note that the breakpoint
     # instruction wasn't executed, rather the inferior was SIGTRAPed
     # with the PC at the breakpoint.
-    gdb_test "continue" "Breakpoint.*pc *[at_segv] .*" \
+    gdb_test "continue" "Breakpoint.*pc(\r\n| *)=> [at_segv] .*" \
        "${name}; continue to breakpoint at fault"
 
     # Now single step the faulted instrction at that breakpoint.
     gdb_test "stepi" \
-       "Program received signal SIGSEGV.*pc *[at_segv] .*" \
+       "Program received signal ${signame}.*pc(\r\n| *)=> [at_segv] .*" \
        "${name}; stepi fault"    
 
     # Clear any breakpoints
This page took 0.02835 seconds and 4 git commands to generate.