View | Details | Raw Unified | Return to bug 10645 | Differences between
and this patch

Collapse All | Expand All

(-)a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c (+45 lines)
Line 0 Link Here
1
/* This testcase is part of GDB, the GNU debugger.
2
3
   Copyright 2009 Free Software Foundation, Inc.
4
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18
#include <stdio.h>
19
20
static int dummy, *p, **pp;
21
22
int
23
main (void)
24
{
25
  dummy = 1;
26
  dummy = 2;
27
  p = &dummy;
28
  dummy = 3;
29
  dummy = 4;
30
  pp = &p;
31
  dummy = 5;
32
  pp = NULL;
33
  dummy = 6;
34
  p = NULL;
35
  dummy = 7;
36
  p = &dummy; 
37
  dummy = 8;
38
  dummy = 9;
39
  pp = &p;
40
  dummy = 10;
41
  p = *pp;
42
  dummy = 11;
43
44
  return 0;
45
}
(-)a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp (-1 / +127 lines)
Line 0 Link Here
0
- 
1
# Copyright 2009 Free Software Foundation, Inc.
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16
# Tests watchpoints.
17
# Input: Array of list containing the folowing elements:
18
# 1: W_NAME - watched var name
19
# 2: W_ID - watched var id
20
# 3: OLD_VAL - expected old val
21
# 4: NEW_VAL - expected new val
22
proc gdb_watch_test {arg_array} {
23
    upvar $arg_array arg_arr
24
    global test
25
    global gdb_prompt
26
27
    set expect_output "\r\ninfrun: stopped by watchpoint\r\n.*"
28
    foreach {k v} [array get arg_arr] {
29
        set w_name [lindex $v 0]
30
        set w_id [lindex $v 1]
31
        set old_val [lindex $v 2]
32
        set new_val [lindex $v 3]
33
        
34
        set expect_output "$expect_output\r\nHardware watchpoint $w_id: \\$w_name\[\r\n\]+Old value = $old_val\r\nNew value = $new_val"
35
    }
36
37
    gdb_test_multiple "continue" $test {
38
        -re "$expect_output.*$gdb_prompt $" {
39
            #puts "PASS"
40
            pass $test
41
        }
42
        default {
43
            #puts "FAIL"
44
            fail $test
45
            return 0
46
        }
47
   }
48
49
   return 1
50
}
51
52
# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set.
53
if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]
54
     && ![istarget "ia64-*-*"] && ![istarget "s390*-*-*"])
55
    || [target_info exists gdb,no_hardware_watchpoints]} then {
56
    verbose "Skipping watchpoint-hw test."
57
    return
58
}
59
60
set testfile watchpoint-hw-unreadable
61
if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
62
    return -1
63
}
64
65
if ![runto_main] {
66
    return -1
67
}
68
69
# The test below would get false FAIL as the first breakpoint left by
70
# runto_main must be singlestepped over while this testfile tries to ensure no
71
# singlestepping occurs for the watchpoints.
72
delete_breakpoints
73
74
gdb_test "set debug infrun 1"
75
gdb_test "show debug infrun" "Inferior debugging is 1\\."
76
77
gdb_test "watch *p" "ardware watchpoint 2: \\\*p"
78
gdb_test "watch **pp" "ardware watchpoint 3: \\\*\\\*pp"
79
set test "catch *p"
80
81
set c(0) [list *p 2 <unreadable> 2]
82
gdb_watch_test c
83
84
set c(0) [list *p 2 2 3]
85
gdb_watch_test c
86
87
set c(0) [list *p 2 3 4]
88
gdb_watch_test c
89
90
set c(0) [list **pp 3 <unreadable> 4]
91
gdb_watch_test c
92
93
set c(0) [list *p 2 4 5]
94
set c(1) [list **pp 3 4 5]
95
gdb_watch_test c
96
unset c
97
98
set c(0) [list **pp 3 5 <unreadable>]
99
gdb_watch_test c
100
101
set c(0) [list *p 2 5 6]
102
gdb_watch_test c
103
104
set c(0) [list *p 2 6 <unreadable>]
105
gdb_watch_test c
106
107
set c(0) [list *p 2 <unreadable> 7]
108
gdb_watch_test c
109
110
set c(0) [list *p 2 7 8]
111
gdb_watch_test c
112
113
set c(0) [list *p 2 8 9]
114
gdb_watch_test c
115
116
set c(0) [list **pp 3 <unreadable> 9]
117
gdb_watch_test c
118
119
set c(0) [list *p 2 9 10]
120
set c(1) [list **pp 3 9 10]
121
gdb_watch_test c
122
unset c
123
124
set c(0) [list *p 2 10 11]
125
set c(1) [list **pp 3 10 11]
126
gdb_watch_test c
127
unset c

Return to bug 10645