Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint.exp
index df796baf29c6122bd31af7e42eaa54366dd6b9c1..7de577bb39ff826f2dd787cb7cead33a987e8293 100644 (file)
@@ -1,21 +1,18 @@
-# Copyright (C) 1992, 1994, 1997, 1998 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)
 
@@ -37,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
@@ -63,6 +61,11 @@ proc initialize {} {
     global srcfile
     global wp_set
 
+    # Disable hardware watchpoints if necessary.
+    if [target_info exists gdb,no_hardware_watchpoints] {
+       gdb_test "set can-use-hw-watchpoints 0" "" ""
+    }
+
     if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] { 
       return 0; 
     }
@@ -368,31 +371,8 @@ proc test_stepping {} {
        gdb_test "break func2 if 0" "Breakpoint.*at.*"
        gdb_test "p \$func2_breakpoint_number = \$bpnum" " = .*"
 
-       # The problem is that GDB confuses stepping through the call
-       # dummy with hitting the breakpoint at the end of the call dummy.
-       # Will be fixed once all architectures define 
-       # CALL_DUMMY_BREAKPOINT_OFFSET.
-       setup_xfail "*-*-*"
-       # This doesn't occur if the call dummy starts with a call,
-       # because we are out of the dummy by the first time the inferior
-       # stops.
-       clear_xfail "arm*-*-*"
-       clear_xfail "d10v*-*-*"
-       clear_xfail "m68*-*-*"
-       clear_xfail "i*86*-*-*"
-       clear_xfail "vax-*-*"
-       # The following architectures define CALL_DUMMY_BREAKPOINT_OFFSET.
-       clear_xfail "alpha-*-*"
-       clear_xfail "mips*-*-*"
-       clear_xfail "sparc-*-*"
-       clear_xfail "hppa*-*-*bsd*"
-       # It works with the generic inferior function calling code too.
-       clear_xfail "mn10200*-*-*"
-       clear_xfail "mn10300*-*-*"
-       # The following architectures define CALL_DUMMY_HAS_COMPLETED.
-       clear_xfail "hppa*-*-*hpux*"
        gdb_test "p func1 ()" "= 73" \
-       "calling function with watchpoint enabled"
+           "calling function with watchpoint enabled"
 
        # 
        # "finish" brings us back to main.
@@ -460,9 +440,9 @@ proc test_stepping {} {
 proc test_watchpoint_triggered_in_syscall {} {
     global gdb_prompt
 
-    if [target_info exists gdb,noinferiorio] {
-       verbose "Skipping test_watchpoint_triggered_in_syscall due to noinferiorio"
-       return
+    # These tests won't work without printf support.
+    if [gdb_skip_stdio_test "watchpoints triggered in syscall"] {
+       return;
     }
     # Run until we get to the first marker function.
     set x 0
@@ -623,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"
@@ -641,12 +621,77 @@ proc test_complex_watchpoint {} {
     }
 }
 
+proc test_watchpoint_and_breakpoint {} {
+    global gdb_prompt
+
+    # This is a test for PR gdb/38, which involves setting a
+    # watchpoint right after you've reached a breakpoint.
+
+    if [runto func3] then {
+       gdb_breakpoint [gdb_get_line_number "second x assignment"]
+       gdb_continue_to_breakpoint "second x assignment"
+       gdb_test "watch x" ".*atchpoint \[0-9\]+: x"
+       gdb_test_multiple "next" "next after watch x" {
+           -re ".*atchpoint \[0-9\]+: x\r\n\r\nOld value = 0\r\nNew value = 1\r\n.*$gdb_prompt $" {
+               pass "next after watch x"
+           }
+           -re "\[0-9\]+\[\t \]+y = 1;\r\n$gdb_prompt $" {
+               kfail "gdb/38" "next after watch x"
+           }
+       }
+    }
+}
+    
+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
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load $binfile
+set prev_timeout $timeout
 set timeout 600        
 verbose "Timeout now 600 sec.\n"
 
@@ -752,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 {
@@ -791,4 +836,23 @@ if [initialize] then {
         timeout {fail "(timeout) access watches disallowed"}
       }
     }
+
+    test_inaccessible_watchpoint
+
+    # See above.
+    if [istarget "mips-idt-*"] then {
+       gdb_exit
+       gdb_start
+       gdb_reinitialize_dir $srcdir/$subdir
+       gdb_load $binfile
+       initialize
+    }
+
+    test_watchpoint_and_breakpoint
+
+    test_watchpoint_in_big_blob
 }
+
+# Restore old timeout
+set timeout $prev_timeout
+verbose "Timeout now $timeout sec.\n"
This page took 0.02678 seconds and 4 git commands to generate.