2009-02-05 Tristan Gingold <gingold@adacore.com>
* gdb.base/sigbpt.exp: Detect which signal is received when a NULL pointer is dereferenced and use this signal name in regexp. * gdb.base/signull.exp: Ditto. * gdb.base/sigbpt.c (main): Catch SIGBUS too. * gdb.base/signull.c (main): Ditto.
This commit is contained in:
parent
ae6a3a4c2a
commit
aacd552b10
5 changed files with 36 additions and 13 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-02-05 Tristan Gingold <gingold@adacore.com>
|
||||
|
||||
* gdb.base/sigbpt.exp: Detect which signal is received when a NULL
|
||||
pointer is dereferenced and use this signal name in regexp.
|
||||
* gdb.base/signull.exp: Ditto.
|
||||
* gdb.base/sigbpt.c (main): Catch SIGBUS too.
|
||||
* gdb.base/signull.c (main): Ditto.
|
||||
|
||||
2009-02-04 Tom Tromey <tromey@redhat.com>
|
||||
Thiago Jung Bauermann <bauerman@br.ibm.com>
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ main ()
|
|||
memset (&act, 0, sizeof act);
|
||||
act.sa_handler = keeper;
|
||||
sigaction (SIGSEGV, &act, NULL);
|
||||
sigaction (SIGBUS, &act, NULL);
|
||||
|
||||
bowler ();
|
||||
return 0;
|
||||
|
|
|
@ -83,15 +83,19 @@ 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"
|
||||
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 $" {
|
||||
|
@ -132,7 +136,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 {
|
||||
|
@ -144,6 +148,7 @@ 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,
|
||||
|
@ -151,9 +156,9 @@ proc stepi_out { name args } {
|
|||
# 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
|
||||
|
@ -213,6 +218,7 @@ 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,
|
||||
|
@ -220,9 +226,9 @@ proc cont_out { name args } {
|
|||
# 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
|
||||
|
@ -243,7 +249,7 @@ proc cont_out { name args } {
|
|||
|
||||
# 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
|
||||
|
|
|
@ -78,6 +78,7 @@ main ()
|
|||
memset (&act, 0, sizeof act);
|
||||
act.sa_handler = keeper;
|
||||
sigaction (SIGSEGV, &act, NULL);
|
||||
sigaction (SIGBUS, &act, NULL);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ gdb_expect {
|
|||
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
|
||||
|
@ -91,6 +92,10 @@ gdb_test_multiple "continue" "$test" {
|
|||
-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
|
||||
|
@ -100,20 +105,22 @@ gdb_test "break bowler"
|
|||
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 \
|
||||
|
|
Loading…
Add table
Reference in a new issue