# 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"
+set test "stepping to fault"
+set signame "SIGSEGV"
gdb_test_multiple "stepi" "$test" {
- -re "Program received signal SIGSEGV.*pc(\r\n| *) *(0x\[0-9a-f\]*).*$gdb_prompt $" {
- set segv_addr $expect_out(2,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(\r\n| *)(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
# 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 {
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,
# 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"
+ 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
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,
# 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"
+ 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
# Now single step the faulted instrction at that breakpoint.
gdb_test "stepi" \
- "Program received signal SIGSEGV.*pc(\r\n| *)[at_segv] .*" \
+ "Program received signal ${signame}.*pc(\r\n| *)[at_segv] .*" \
"${name}; stepi fault"
# Clear any breakpoints
gdb_test "set test = code_entry_point" "" "set for function pointer probe"
set test "probe function pointer"
set function_pointer code_entry_point
+set signame "SIGSEGV"
gdb_test_multiple "continue" "$test" {
-re "Program received signal SIGSEGV.*bowler .*$gdb_prompt $" {
set function_pointer code_descriptor
-re "Program received signal SIGSEGV.*0.*$gdb_prompt $" {
pass "$test (function entry-point)"
}
+ -re "Program received signal SIGBUS.*0.*$gdb_prompt $" {
+ set signame SIGBUS
+ pass "$test (function entry-point)"
+ }
}
# Re-start from scratch, breakpoint the bowler so that control is
gdb_test "break keeper"
# By default Stop:Yes Print:Yes Pass:Yes
gdb_test "handle SIGSEGV" "SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault"
+gdb_test "handle SIGBUS" "SIGBUS.*Yes.*Yes.*Yes.*Bus error"
# For the given signal type, check that: the SIGSEGV occures; a
# backtrace from the SEGV works; the sigsegv is delivered; a backtrace
# through the SEGV works.
proc test_segv { name tag bt_from_segv bt_from_keeper } {
+ global signame
gdb_test continue "Breakpoint.* bowler.*" "${name}; start with the bowler"
# NB: Don't use $tag in the testname - changes across systems.
gdb_test "set test = $tag" "" "${name}; select the pointer type"
- gdb_test continue "Program received signal SIGSEGV.*" \
- "${name}; take the SIGSEGV"
- gdb_test backtrace $bt_from_segv "${name}; backtrace from SIGSEGV"
+ gdb_test continue "Program received signal ${signame}.*" \
+ "${name}; take the ${signame}"
+ gdb_test backtrace $bt_from_segv "${name}; backtrace from ${signame}"
gdb_test continue "Breakpoint.* keeper.*" "${name}; continue to the keeper"
- gdb_test backtrace $bt_from_keeper "${name}; backtrace from keeper through SIGSEGV"
+ gdb_test backtrace $bt_from_keeper "${name}; backtrace from keeper through ${signame}"
}
test_segv "data read" data_read \