Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010 |
76ff342d | 2 | # Free Software Foundation, 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 | ||
28 | load_lib mi-support.exp | |
b30bf9ee | 29 | set MIFLAGS "-i=mi" |
fb40c209 AC |
30 | |
31 | gdb_exit | |
32 | if [mi_gdb_start] { | |
33 | continue | |
34 | } | |
35 | ||
36 | set testfile "basics" | |
37 | set srcfile ${testfile}.c | |
3788363d | 38 | set binfile ${objdir}/${subdir}/mi-watch |
fb40c209 | 39 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
40 | untested mi-watch.exp |
41 | return -1 | |
fb40c209 AC |
42 | } |
43 | ||
4a543daf | 44 | proc test_watchpoint_creation_and_listing {type} { |
fb40c209 AC |
45 | global mi_gdb_prompt |
46 | global srcfile | |
47 | global hex | |
48 | ||
45f07fef MC |
49 | set line_callee4_head [gdb_get_line_number "callee4 ("] |
50 | set line_callee4_body [expr $line_callee4_head + 2] | |
51 | ||
fb40c209 AC |
52 | # Insert a watchpoint and list |
53 | # Tests: | |
54 | # -break-watch C | |
55 | # -break-list | |
56 | ||
57 | mi_gdb_test "111-break-watch C" \ | |
58 | "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \ | |
59 | "break-watch operation" | |
60 | ||
61 | mi_gdb_test "222-break-list" \ | |
d24317b4 | 62 | "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\",addr=\"\",what=\"C\",times=\"0\",original-location=\"C\"\}\\\]\}" \ |
fb40c209 AC |
63 | "list of watchpoints" |
64 | ||
65 | } | |
66 | ||
67 | # UNUSED at the time | |
4a543daf | 68 | proc test_awatch_creation_and_listing {type} { |
fb40c209 AC |
69 | global mi_gdb_prompt |
70 | global srcfile | |
71 | global hex | |
72 | ||
45f07fef MC |
73 | set line_main_head [gdb_get_line_number "main ("] |
74 | set line_main_body [expr $line_main_head + 2] | |
75 | ||
fb40c209 AC |
76 | # Insert an access watchpoint and list it |
77 | # Tests: | |
78 | # -break-watch -a A | |
79 | # -break-list | |
80 | ||
81 | mi_gdb_test "333-break-watch -a A" \ | |
45f07fef | 82 | "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \ |
fb40c209 AC |
83 | "break-watch -a operation" |
84 | ||
85 | mi_gdb_test "444-break-list" \ | |
45f07fef | 86 | "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 |
87 | "list of watchpoints awatch" |
88 | ||
89 | mi_gdb_test "777-break-delete 3" \ | |
90 | "777\\^done" \ | |
91 | "delete access watchpoint" | |
92 | } | |
93 | ||
94 | # UNUSED at the time | |
4a543daf | 95 | proc test_rwatch_creation_and_listing {type} { |
fb40c209 AC |
96 | global mi_gdb_prompt |
97 | global srcfile | |
98 | global hex | |
99 | ||
45f07fef MC |
100 | set line_main_head [gdb_get_line_number "main ("] |
101 | set line_main_body [expr $line_main_head + 2] | |
102 | ||
fb40c209 AC |
103 | # Insert a read watchpoint and list it. |
104 | # Tests: | |
105 | # -break-insert -r B | |
106 | # -break-list | |
107 | ||
108 | mi_gdb_test "200-break-watch -r C" \ | |
45f07fef | 109 | "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \ |
fb40c209 AC |
110 | "break-insert -r operation" |
111 | ||
112 | mi_gdb_test "300-break-list" \ | |
45f07fef | 113 | "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 |
114 | "list of breakpoints" |
115 | ||
116 | mi_gdb_test "177-break-delete 4" \ | |
117 | "177\\^done" \ | |
118 | "delete read watchpoint" | |
119 | } | |
120 | ||
4a543daf | 121 | proc test_watchpoint_triggering {type} { |
fb40c209 | 122 | global mi_gdb_prompt |
76ff342d | 123 | global hex fullname_syntax srcfile |
fb40c209 | 124 | |
45f07fef MC |
125 | set line_callee4_return_0 [gdb_get_line_number "return 0;"] |
126 | set line_callee3_head [gdb_get_line_number "callee3 ("] | |
127 | set line_callee3_close_brace [expr $line_callee3_head + 3] | |
128 | ||
fb40c209 AC |
129 | # Continue execution until the watchpoint is reached, continue again, |
130 | # to see the watchpoint go out of scope. | |
131 | # Does: | |
132 | # -exec-continue (Here wp triggers) | |
133 | # -exec-continue (Here wp goes out of scope) | |
134 | ||
bb378428 VP |
135 | mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \ |
136 | ".*basics.c" $line_callee4_return_0 \ | |
137 | {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \ | |
138 | "watchpoint trigger" | |
fb40c209 | 139 | |
4a543daf MR |
140 | if { $type == "sw" } { |
141 | setup_xfail *-*-* | |
142 | } | |
bb378428 VP |
143 | mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \ |
144 | ".*basics.c" $line_callee3_close_brace \ | |
145 | {"" "wpnum=\"2\""} \ | |
146 | "watchpoint trigger" | |
4a543daf | 147 | clear_xfail *-*-* |
fb40c209 AC |
148 | } |
149 | ||
5509918f MR |
150 | proc test_watchpoint_all {type} { |
151 | global pf_prefix | |
152 | upvar srcdir srcdir | |
153 | upvar subdir subdir | |
154 | upvar binfile binfile | |
155 | ||
156 | set old_prefix $pf_prefix | |
157 | lappend pf_prefix "$type:" | |
158 | ||
159 | mi_delete_breakpoints | |
160 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
161 | mi_gdb_load ${binfile} | |
162 | ||
163 | mi_runto callee4 | |
4a543daf MR |
164 | test_watchpoint_creation_and_listing $type |
165 | #test_rwatch_creation_and_listing $type | |
166 | #test_awatch_creation_and_listing $type | |
167 | test_watchpoint_triggering $type | |
5509918f MR |
168 | |
169 | set pf_prefix $old_prefix | |
170 | } | |
171 | ||
172 | # Run the tests twice, once using software watchpoints... | |
173 | mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \ | |
174 | "567\\^done" \ | |
175 | "hw watchpoints toggle (1)" | |
176 | test_watchpoint_all sw | |
177 | ||
178 | mi_gdb_exit | |
179 | ||
180 | # ... and unless requested otherwise... | |
3e347599 | 181 | if [target_info exists gdb,no_hardware_watchpoints] { |
5509918f | 182 | return 0 |
3e347599 DJ |
183 | } |
184 | ||
5509918f MR |
185 | mi_gdb_start |
186 | ||
187 | # ... once using hardware watchpoints (if available). | |
188 | mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \ | |
189 | "890\\^done" \ | |
190 | "hw watchpoints toggle (2)" | |
191 | test_watchpoint_all hw | |
fb40c209 AC |
192 | |
193 | mi_gdb_exit | |
194 | return 0 |