2009-02-05 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Thu, 5 Feb 2009 13:59:18 +0000 (13:59 +0000)
committerTristan Gingold <gingold@adacore.com>
Thu, 5 Feb 2009 13:59:18 +0000 (13:59 +0000)
* 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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/sigbpt.c
gdb/testsuite/gdb.base/sigbpt.exp
gdb/testsuite/gdb.base/signull.c
gdb/testsuite/gdb.base/signull.exp

index 7fce52081253f65500195f89afdbe1be0c1c6dde..28a268d98d7b473293ea0c09f9be24bbdd0dd5c9 100644 (file)
@@ -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>
 
index 1335372214917f9de22b85250cdf7c0b2d995627..62eef555397f5b6bb41a336f4acf9ad48cd9caaa 100644 (file)
@@ -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;
index 2806cf9b85d68ccfe7092903fe405488a2e1ce24..0a8cdd7ede63cadaa2a40dbcff4bcdc24bb2176b 100644 (file)
@@ -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
index c506a2b5d5dda2878e5ddb29fa5a73538b3a918d..e4eb6d82739c0e7aba4462dec2d5c2ebd03a7567 100644 (file)
@@ -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++)
     {
index 51e0a8ac644641716d4162341aa14485e7b43c6a..82c2f59ac7407d8185831032c169f8f84a1aec89 100644 (file)
@@ -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 \
This page took 0.061498 seconds and 4 git commands to generate.