--- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c @@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009 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 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, see . */ + +static int dummy, *p, **pp; + +int +main (void) +{ + dummy = 1; + dummy = 2; + p = &dummy; + dummy = 3; + dummy = 4; + pp = &p; + dummy = 5; + return 0; +} --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp @@ -0,0 +1,50 @@ +# Copyright 2009 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 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, see . + +# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set. +if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] + && ![istarget "ia64-*-*"] && ![istarget "s390*-*-*"]) + || [target_info exists gdb,no_hardware_watchpoints]} then { + verbose "Skipping watchpoint-hw test." + return +} + +set testfile watchpoint-hw-unreadable +if { [prepare_for_testing ${testfile}.exp ${testfile}] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +# The test below would get false FAIL as the first breakpoint left by +# runto_main must be singlestepped over while this testfile tries to ensure no +# singlestepping occurs for the watchpoints. +delete_breakpoints + +gdb_test "set debug infrun 1" +gdb_test "show debug infrun" "Inferior debugging is 1\\." + +gdb_test "watch *p" "ardware watchpoint 2: \\\*p" +set test "catch *p" +gdb_test_multiple "continue" $test { + -re "\r\ninfrun: no stepping, continue\r\n.*$gdb_prompt $" { + fail $test + } + -re "\r\ninfrun: stopped by watchpoint\r\n.*\r\nHardware watchpoint 2: \\\*p\[\r\n\]+Old value = \r\nNew value = 2\r\n.*$gdb_prompt $" { + pass $test + } +}