--- gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c | 45 +++++++ .../gdb.base/watchpoint-hw-unreadable.exp | 127 ++++++++++++++++++++ 2 files changed, 172 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c create mode 100644 gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c new file mode 100644 index 0000000..887c293 --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c @@ -0,0 +1,45 @@ +/* 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 . */ + +#include + +static int dummy, *p, **pp; + +int +main (void) +{ + dummy = 1; + dummy = 2; + p = &dummy; + dummy = 3; + dummy = 4; + pp = &p; + dummy = 5; + pp = NULL; + dummy = 6; + p = NULL; + dummy = 7; + p = &dummy; + dummy = 8; + dummy = 9; + pp = &p; + dummy = 10; + p = *pp; + dummy = 11; + + return 0; +} diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp new file mode 100644 index 0000000..034972f --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp @@ -0,0 +1,127 @@ +# 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 . + +# Tests watchpoints. +# Input: Array of list containing the folowing elements: +# 1: W_NAME - watched var name +# 2: W_ID - watched var id +# 3: OLD_VAL - expected old val +# 4: NEW_VAL - expected new val +proc gdb_watch_test {arg_array} { + upvar $arg_array arg_arr + global test + global gdb_prompt + + set expect_output "\r\ninfrun: stopped by watchpoint\r\n.*" + foreach {k v} [array get arg_arr] { + set w_name [lindex $v 0] + set w_id [lindex $v 1] + set old_val [lindex $v 2] + set new_val [lindex $v 3] + + set expect_output "$expect_output\r\nHardware watchpoint $w_id: \\$w_name\[\r\n\]+Old value = $old_val\r\nNew value = $new_val" + } + + gdb_test_multiple "continue" $test { + -re "$expect_output.*$gdb_prompt $" { + #puts "PASS" + pass $test + } + default { + #puts "FAIL" + fail $test + return 0 + } + } + + return 1 +} + +# 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" +gdb_test "watch **pp" "ardware watchpoint 3: \\\*\\\*pp" +set test "catch *p" + +set c(0) [list *p 2 2] +gdb_watch_test c + +set c(0) [list *p 2 2 3] +gdb_watch_test c + +set c(0) [list *p 2 3 4] +gdb_watch_test c + +set c(0) [list **pp 3 4] +gdb_watch_test c + +set c(0) [list *p 2 4 5] +set c(1) [list **pp 3 4 5] +gdb_watch_test c +unset c + +set c(0) [list **pp 3 5 ] +gdb_watch_test c + +set c(0) [list *p 2 5 6] +gdb_watch_test c + +set c(0) [list *p 2 6 ] +gdb_watch_test c + +set c(0) [list *p 2 7] +gdb_watch_test c + +set c(0) [list *p 2 7 8] +gdb_watch_test c + +set c(0) [list *p 2 8 9] +gdb_watch_test c + +set c(0) [list **pp 3 9] +gdb_watch_test c + +set c(0) [list *p 2 9 10] +set c(1) [list **pp 3 9 10] +gdb_watch_test c +unset c + +set c(0) [list *p 2 10 11] +set c(1) [list **pp 3 10 11] +gdb_watch_test c +unset c -- 1.6.5.2