]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-watch.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-watch.exp
CommitLineData
ecd75fc8 1# Copyright 1999-2014 Free Software Foundation, Inc.
fb40c209
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
fb40c209 6# (at your option) any later version.
e22f8b7c 7#
fb40c209
AC
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.
e22f8b7c 12#
fb40c209 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
fb40c209 15
17282693 16# Test Machine interface (MI) operations
fb40c209 17#
17282693 18# Test MI watchpoint commands.
fb40c209 19#
17282693
PA
20# The goal is not to test gdb functionality, which is done by other
21# tests, but to verify the correct output response to MI operations.
fb40c209
AC
22
23load_lib mi-support.exp
b30bf9ee 24set MIFLAGS "-i=mi"
fb40c209
AC
25
26gdb_exit
27if [mi_gdb_start] {
28 continue
29}
30
298a9cf0
TT
31standard_testfile basics.c
32
9357e021 33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
34 untested mi-watch.exp
35 return -1
fb40c209
AC
36}
37
4a543daf 38proc test_watchpoint_creation_and_listing {type} {
fb40c209
AC
39 global mi_gdb_prompt
40 global srcfile
41 global hex
42
45f07fef
MC
43 set line_callee4_head [gdb_get_line_number "callee4 ("]
44 set line_callee4_body [expr $line_callee4_head + 2]
45
fb40c209
AC
46 # Insert a watchpoint and list
47 # Tests:
48 # -break-watch C
49 # -break-list
50
51 mi_gdb_test "111-break-watch C" \
52 "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \
53 "break-watch operation"
54
55 mi_gdb_test "222-break-list" \
998580f1 56 "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\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\"C\"\}\\\]\}" \
fb40c209
AC
57 "list of watchpoints"
58
59}
60
61# UNUSED at the time
4a543daf 62proc test_awatch_creation_and_listing {type} {
fb40c209
AC
63 global mi_gdb_prompt
64 global srcfile
65 global hex
66
45f07fef
MC
67 set line_main_head [gdb_get_line_number "main ("]
68 set line_main_body [expr $line_main_head + 2]
69
fb40c209
AC
70 # Insert an access watchpoint and list it
71 # Tests:
72 # -break-watch -a A
73 # -break-list
74
75 mi_gdb_test "333-break-watch -a A" \
45f07fef 76 "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \
fb40c209
AC
77 "break-watch -a operation"
78
79 mi_gdb_test "444-break-list" \
998580f1 80 "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\",thread-groups=\\\[\"i1\"\\\],times=\"0\"\},.*\}\\\]\}" \
fb40c209
AC
81 "list of watchpoints awatch"
82
83 mi_gdb_test "777-break-delete 3" \
84 "777\\^done" \
85 "delete access watchpoint"
86}
87
88# UNUSED at the time
4a543daf 89proc test_rwatch_creation_and_listing {type} {
fb40c209
AC
90 global mi_gdb_prompt
91 global srcfile
92 global hex
93
45f07fef
MC
94 set line_main_head [gdb_get_line_number "main ("]
95 set line_main_body [expr $line_main_head + 2]
96
fb40c209
AC
97 # Insert a read watchpoint and list it.
98 # Tests:
e714f336 99 # -break-watch -r B
fb40c209
AC
100 # -break-list
101
102 mi_gdb_test "200-break-watch -r C" \
45f07fef 103 "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 104 "break-watch -r operation"
fb40c209
AC
105
106 mi_gdb_test "300-break-list" \
998580f1 107 "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\",thread-groups=\\\[\"i1\"\\\],times=\"0\"\},.*\}\\\}\}" \
fb40c209
AC
108 "list of breakpoints"
109
110 mi_gdb_test "177-break-delete 4" \
111 "177\\^done" \
112 "delete read watchpoint"
113}
114
4a543daf 115proc test_watchpoint_triggering {type} {
fb40c209 116 global mi_gdb_prompt
76ff342d 117 global hex fullname_syntax srcfile
fb40c209 118
45f07fef
MC
119 set line_callee4_return_0 [gdb_get_line_number "return 0;"]
120 set line_callee3_head [gdb_get_line_number "callee3 ("]
121 set line_callee3_close_brace [expr $line_callee3_head + 3]
122
fb40c209
AC
123 # Continue execution until the watchpoint is reached, continue again,
124 # to see the watchpoint go out of scope.
125 # Does:
126 # -exec-continue (Here wp triggers)
127 # -exec-continue (Here wp goes out of scope)
128
bb378428
VP
129 mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
130 ".*basics.c" $line_callee4_return_0 \
131 {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
132 "watchpoint trigger"
fb40c209 133
4a543daf
MR
134 if { $type == "sw" } {
135 setup_xfail *-*-*
136 }
bb378428
VP
137 mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
138 ".*basics.c" $line_callee3_close_brace \
139 {"" "wpnum=\"2\""} \
140 "watchpoint trigger"
4a543daf 141 clear_xfail *-*-*
fb40c209
AC
142}
143
0a251e08
YQ
144proc test_watchpoint_all {type} {
145 with_test_prefix "$type" {
146 upvar srcdir srcdir
147 upvar subdir subdir
148 upvar binfile binfile
149
150 mi_delete_breakpoints
151 mi_gdb_reinitialize_dir $srcdir/$subdir
152 mi_gdb_load ${binfile}
153
154 mi_runto callee4
155 test_watchpoint_creation_and_listing $type
156 #test_rwatch_creation_and_listing $type
157 #test_awatch_creation_and_listing $type
158 test_watchpoint_triggering $type
159 }
160}
5509918f
MR
161
162# Run the tests twice, once using software watchpoints...
163mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \
164 "567\\^done" \
165 "hw watchpoints toggle (1)"
166test_watchpoint_all sw
167
168mi_gdb_exit
169
170# ... and unless requested otherwise...
3e347599 171if [target_info exists gdb,no_hardware_watchpoints] {
5509918f 172 return 0
3e347599
DJ
173}
174
5509918f
MR
175mi_gdb_start
176
177# ... once using hardware watchpoints (if available).
178mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \
179 "890\\^done" \
180 "hw watchpoints toggle (2)"
181test_watchpoint_all hw
fb40c209
AC
182
183mi_gdb_exit
184return 0