]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-watch.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-watch.exp
CommitLineData
0b302171
JB
1# Copyright 1999-2002, 2004-2005, 2007-2012 Free Software Foundation,
2# Inc.
fb40c209
AC
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
fb40c209 7# (at your option) any later version.
e22f8b7c 8#
fb40c209
AC
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
fb40c209 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
fb40c209 16
fb40c209
AC
17#
18# Test essential Machine interface (MI) operations
19#
20# Verify that, using the MI, we can run a simple program and perform basic
21# debugging activities like: insert breakpoints, run the program,
22# step, next, continue until it ends and, last but not least, quit.
23#
24# The goal is not to test gdb functionality, which is done by other tests,
25# but to verify the correct output response to MI operations.
26#
27
28load_lib mi-support.exp
b30bf9ee 29set MIFLAGS "-i=mi"
fb40c209
AC
30
31gdb_exit
32if [mi_gdb_start] {
33 continue
34}
35
298a9cf0
TT
36standard_testfile basics.c
37
9357e021 38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
39 untested mi-watch.exp
40 return -1
fb40c209
AC
41}
42
4a543daf 43proc test_watchpoint_creation_and_listing {type} {
fb40c209
AC
44 global mi_gdb_prompt
45 global srcfile
46 global hex
47
45f07fef
MC
48 set line_callee4_head [gdb_get_line_number "callee4 ("]
49 set line_callee4_body [expr $line_callee4_head + 2]
50
fb40c209
AC
51 # Insert a watchpoint and list
52 # Tests:
53 # -break-watch C
54 # -break-list
55
56 mi_gdb_test "111-break-watch C" \
57 "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \
58 "break-watch operation"
59
60 mi_gdb_test "222-break-list" \
8d3788bd 61 "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",what=\"C\",times=\"0\",original-location=\"C\"\}\\\]\}" \
fb40c209
AC
62 "list of watchpoints"
63
64}
65
66# UNUSED at the time
4a543daf 67proc test_awatch_creation_and_listing {type} {
fb40c209
AC
68 global mi_gdb_prompt
69 global srcfile
70 global hex
71
45f07fef
MC
72 set line_main_head [gdb_get_line_number "main ("]
73 set line_main_body [expr $line_main_head + 2]
74
fb40c209
AC
75 # Insert an access watchpoint and list it
76 # Tests:
77 # -break-watch -a A
78 # -break-list
79
80 mi_gdb_test "333-break-watch -a A" \
45f07fef 81 "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \
fb40c209
AC
82 "break-watch -a operation"
83
84 mi_gdb_test "444-break-list" \
45f07fef 85 "444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\]\}" \
fb40c209
AC
86 "list of watchpoints awatch"
87
88 mi_gdb_test "777-break-delete 3" \
89 "777\\^done" \
90 "delete access watchpoint"
91}
92
93# UNUSED at the time
4a543daf 94proc test_rwatch_creation_and_listing {type} {
fb40c209
AC
95 global mi_gdb_prompt
96 global srcfile
97 global hex
98
45f07fef
MC
99 set line_main_head [gdb_get_line_number "main ("]
100 set line_main_body [expr $line_main_head + 2]
101
fb40c209
AC
102 # Insert a read watchpoint and list it.
103 # Tests:
e714f336 104 # -break-watch -r B
fb40c209
AC
105 # -break-list
106
107 mi_gdb_test "200-break-watch -r C" \
45f07fef 108 "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \
e714f336 109 "break-watch -r operation"
fb40c209
AC
110
111 mi_gdb_test "300-break-list" \
45f07fef 112 "300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \
fb40c209
AC
113 "list of breakpoints"
114
115 mi_gdb_test "177-break-delete 4" \
116 "177\\^done" \
117 "delete read watchpoint"
118}
119
4a543daf 120proc test_watchpoint_triggering {type} {
fb40c209 121 global mi_gdb_prompt
76ff342d 122 global hex fullname_syntax srcfile
fb40c209 123
45f07fef
MC
124 set line_callee4_return_0 [gdb_get_line_number "return 0;"]
125 set line_callee3_head [gdb_get_line_number "callee3 ("]
126 set line_callee3_close_brace [expr $line_callee3_head + 3]
127
fb40c209
AC
128 # Continue execution until the watchpoint is reached, continue again,
129 # to see the watchpoint go out of scope.
130 # Does:
131 # -exec-continue (Here wp triggers)
132 # -exec-continue (Here wp goes out of scope)
133
bb378428
VP
134 mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
135 ".*basics.c" $line_callee4_return_0 \
136 {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
137 "watchpoint trigger"
fb40c209 138
4a543daf
MR
139 if { $type == "sw" } {
140 setup_xfail *-*-*
141 }
bb378428
VP
142 mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
143 ".*basics.c" $line_callee3_close_brace \
144 {"" "wpnum=\"2\""} \
145 "watchpoint trigger"
4a543daf 146 clear_xfail *-*-*
fb40c209
AC
147}
148
0f4d39d5 149proc test_watchpoint_all {type} { with_test_prefix "$type" {
5509918f
MR
150 upvar srcdir srcdir
151 upvar subdir subdir
152 upvar binfile binfile
153
5509918f
MR
154 mi_delete_breakpoints
155 mi_gdb_reinitialize_dir $srcdir/$subdir
156 mi_gdb_load ${binfile}
157
158 mi_runto callee4
4a543daf
MR
159 test_watchpoint_creation_and_listing $type
160 #test_rwatch_creation_and_listing $type
161 #test_awatch_creation_and_listing $type
162 test_watchpoint_triggering $type
6a5870ce 163}}
5509918f
MR
164
165# Run the tests twice, once using software watchpoints...
166mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \
167 "567\\^done" \
168 "hw watchpoints toggle (1)"
169test_watchpoint_all sw
170
171mi_gdb_exit
172
173# ... and unless requested otherwise...
3e347599 174if [target_info exists gdb,no_hardware_watchpoints] {
5509918f 175 return 0
3e347599
DJ
176}
177
5509918f
MR
178mi_gdb_start
179
180# ... once using hardware watchpoints (if available).
181mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \
182 "890\\^done" \
183 "hw watchpoints toggle (2)"
184test_watchpoint_all hw
fb40c209
AC
185
186mi_gdb_exit
187return 0