Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint.exp
index a69271b0affa09e2030c36f891dc397ba686ebff..7de577bb39ff826f2dd787cb7cead33a987e8293 100644 (file)
@@ -1,22 +1,18 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-# Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2007, 2008, 2009,
+# 2010 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,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # 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.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
@@ -38,7 +34,8 @@ if [get_compiler_info ${binfile}] {
 }
 
 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."
+     untested watchpoint.exp
+     return -1
 }
 
 # Prepare for watchpoint tests by setting up two breakpoints and one
@@ -606,7 +603,7 @@ proc test_complex_watchpoint {} {
         # local to a recursing function should be bound only to that
         # one invocation, and should not trigger for other invocations.
         #
-        gdb_test "tbreak recurser" ".*Breakpoint.*"
+        gdb_test "tbreak recurser" ".*breakpoint.*"
         gdb_test "cont" "Continuing.*recurser.*"
         gdb_test "watch local_x" ".*\[Ww\]atchpoint \[0-9\]*: local_x" \
                  "set local watch in recursive call"
@@ -645,6 +642,49 @@ proc test_watchpoint_and_breakpoint {} {
     }
 }
     
+proc test_inaccessible_watchpoint {} {
+    global gdb_prompt
+
+    # This is a test for watchpoints on currently inaccessible (but later
+    # valid) memory.
+
+    if [runto func4] then {
+       # Make sure we only allow memory access errors.
+       set msg "watchpoint refused to insert on nonexistent struct member"
+       gdb_test_multiple "watch struct1.nosuchmember" $msg {
+           -re ".*atchpoint \[0-9\]+: struct1.nosuchmember.*$gdb_prompt $" {
+               # PR breakpoints/9681
+               fail $msg
+           }
+           -re "There is no member named nosuchmember\\..*$gdb_prompt $" {
+               pass $msg
+           }
+       }
+
+       gdb_test "watch *global_ptr" ".*atchpoint \[0-9\]+: \\*global_ptr"
+       gdb_test "next" ".*global_ptr = buf.*"
+       gdb_test_multiple "next" "next over ptr init" {
+           -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = .*\r\nNew value = 3 .*\r\n.*$gdb_prompt $" {
+               # We can not test for <unknown> here because NULL may be readable.
+               # This test does rely on *NULL != 3.
+               pass "next over ptr init"
+           }
+       }
+       gdb_test_multiple "next" "next over buffer set" {
+           -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = 3 .*\r\nNew value = 7 .*\r\n.*$gdb_prompt $" {
+               pass "next over buffer set"
+           }
+       }
+    }
+}
+    
+proc test_watchpoint_in_big_blob {} {
+    global gdb_prompt
+
+    gdb_test "watch buf" ".*atchpoint \[0-9\]+: buf"
+    gdb_test "cont" "Continuing.*atchpoint \[0-9\]+: buf\r\n\r\nOld value = .*testte\".*" "watchpoint on buf hit"
+}
+
 # Start with a fresh gdb.
 
 gdb_exit
@@ -757,7 +797,7 @@ if [initialize] then {
     }
 
     # We've explicitly disabled hardware watches.  Verify that GDB
-    # 
+    # refrains from using them.
     #
     send_gdb "rwatch ival3\n"
     gdb_expect {
@@ -797,6 +837,8 @@ if [initialize] then {
       }
     }
 
+    test_inaccessible_watchpoint
+
     # See above.
     if [istarget "mips-idt-*"] then {
        gdb_exit
@@ -807,6 +849,8 @@ if [initialize] then {
     }
 
     test_watchpoint_and_breakpoint
+
+    test_watchpoint_in_big_blob
 }
 
 # Restore old timeout
This page took 0.0262520000000001 seconds and 4 git commands to generate.