testsuite: i386 regression for funcargs.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint.exp
index 502742cb2ebb806b3cc435ffbac8c4710bc1a607..e4eab3da19b7a6d9a1c8f37633f60c25becd7985 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright 1992-2016 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
@@ -16,9 +16,7 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "watchpoint"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if [get_compiler_info] {
     return -1
@@ -344,7 +342,7 @@ proc test_watchpoint_triggered_in_syscall {} {
 
     # These tests won't work without printf support.
     if [gdb_skip_stdio_test "watchpoints triggered in syscall"] {
-       return;
+       return
     }
     # Run until we get to the first marker function.
     set x 0
@@ -364,13 +362,13 @@ proc test_watchpoint_triggered_in_syscall {} {
        # to gdb, not the inferior, and we lose.  So that is why we have
        # watchpoint.c prompt us, so we can wait for that prompt.
 
-       send_gdb "continue\n";
+       send_gdb "continue\n"
        gdb_expect {
            -re "Continuing\\.\r\ntype stuff for buf now:" {
                pass "continue to read"
            }
            default {
-               fail "continue to read";
+               fail "continue to read"
                return
            }
        }
@@ -466,12 +464,11 @@ proc test_complex_watchpoint {} {
                pass $test
            }
            -re "can't compute CFA for this frame.*\r\n$gdb_prompt $" {
-               global compiler_info no_hw
+               global no_hw
 
                # GCC < 4.5.0 does not get LOCATIONS_VALID set by dwarf2read.c.
                # Therefore epilogue unwinder gets applied which is
                # incompatible with dwarf2_frame_cfa.
-               verbose -log "compiler_info: $compiler_info"
                if {$no_hw && ([test_compiler_info {gcc-[0-3]-*}]
                               || [test_compiler_info {gcc-4-[0-4]-*}])} {
                    xfail "$test (old GCC has broken watchpoints in epilogues)"
@@ -552,21 +549,16 @@ proc test_complex_watchpoint {} {
 proc test_watchpoint_and_breakpoint {} {
     global gdb_prompt
 
-    # This is a test for PR gdb/38, which involves setting a
+    # This is a test for PR breakpoints/7143, 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"
-           }
-       }
+       gdb_test "next" \
+           ".*atchpoint \[0-9\]+: x\r\n\r\nOld value = 0\r\nNew value = 1\r\n.*" \
+           "next after watch x"
 
        gdb_test_no_output "delete \$bpnum" "delete watch x"
     }
@@ -602,9 +594,22 @@ proc test_disable_enable_software_watchpoint {} {
 }
 
 proc test_watch_location {} {
+    global gdb_prompt
+
     gdb_breakpoint [gdb_get_line_number "func5 breakpoint here"]
     gdb_continue_to_breakpoint "func5 breakpoint here"
 
+    # Check first if a null pointer can be dereferenced on the target.
+    gdb_test_multiple "p *nullptr" "" {
+       -re "Cannot access memory at address 0x0.*$gdb_prompt $" {
+           gdb_test "watch -location nullptr->p->x" \
+               "Cannot access memory at address 0x0"
+       }
+       -re ".*$gdb_prompt $" {
+           # Null pointer dereference is legitimate.
+       }
+    }
+
     gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x"
 
     gdb_test "continue" \
@@ -824,8 +829,12 @@ proc test_no_hw_watchpoints {} {
     # refrains from using them.
     #
     gdb_test "rwatch ival3" \
-       "Expression cannot be implemented with read/access watchpoint..*" \
+       "Can't set read/access watchpoint when hardware watchpoints are disabled." \
        "rwatch disallowed when can-set-hw-watchpoints cleared"
+    gdb_test "awatch ival3" \
+       "Can't set read/access watchpoint when hardware watchpoints are disabled." \
+       "awatch disallowed when can-set-hw-watchpoints cleared"
+
 
     # Re-enable hardware watchpoints if necessary.
     if ![target_info exists gdb,no_hardware_watchpoints] {
@@ -878,6 +887,22 @@ proc test_watchpoint_in_big_blob {} {
     gdb_test_no_output "delete \$bpnum" "delete watch buf"
 }
 
+proc test_watch_register_location {} {
+    global no_hw
+
+    if {!$no_hw && ![target_info exists gdb,no_hardware_watchpoints]} {
+       # Non-memory read/access watchpoints are not supported, they would
+       # require software read/access watchpoint support (which is not
+       # currently available).
+       gdb_test "rwatch \$pc" \
+           "Expression cannot be implemented with read/access watchpoint..*" \
+           "rwatch disallowed for register based expression"
+       gdb_test "awatch \$pc" \
+           "Expression cannot be implemented with read/access watchpoint..*" \
+           "awatch disallowed for register based expression"
+    }
+}
+
 # Start with a fresh gdb.
 
 set prev_timeout $timeout
@@ -939,6 +964,8 @@ proc do_tests {} {
 
     test_wide_location_1
     test_wide_location_2
+
+    test_watch_register_location
 }
 
 # On targets that can do hardware watchpoints, run the tests twice:
This page took 0.027569 seconds and 4 git commands to generate.