-# 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
# 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
# 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
# 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
}
}
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)"
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"
}
}
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" \
# 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] {
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
test_wide_location_1
test_wide_location_2
+
+ test_watch_register_location
}
# On targets that can do hardware watchpoints, run the tests twice: