Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: gdb/testsuite/lib/mi-support.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/lib/java.exp ('k') | gdb/testsuite/lib/objc.exp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 1999-2000, 2002-2005, 2007-2012 Free Software Foundation, 1 # Copyright 1999-2013 Free Software Foundation, Inc.
2 # Inc.
3 2
4 # This program is free software; you can redistribute it and/or modify 3 # 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 4 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or 5 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version. 6 # (at your option) any later version.
8 # 7 #
9 # This program is distributed in the hope that it will be useful, 8 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details. 11 # GNU General Public License for more details.
(...skipping 26 matching lines...) Expand all
39 # mi_gdb_exit -- exit the GDB, killing the target program if necessary 38 # mi_gdb_exit -- exit the GDB, killing the target program if necessary
40 # 39 #
41 proc mi_gdb_exit {} { 40 proc mi_gdb_exit {} {
42 catch mi_uncatched_gdb_exit 41 catch mi_uncatched_gdb_exit
43 } 42 }
44 43
45 proc mi_uncatched_gdb_exit {} { 44 proc mi_uncatched_gdb_exit {} {
46 global GDB 45 global GDB
47 global INTERNAL_GDBFLAGS GDBFLAGS 46 global INTERNAL_GDBFLAGS GDBFLAGS
48 global verbose 47 global verbose
49 global gdb_spawn_id; 48 global gdb_spawn_id
50 global gdb_prompt 49 global gdb_prompt
51 global mi_gdb_prompt 50 global mi_gdb_prompt
52 global MIFLAGS 51 global MIFLAGS
53 52
54 gdb_stop_suppressing_tests; 53 gdb_stop_suppressing_tests
55 54
56 if { [info procs sid_exit] != "" } { 55 if { [info procs sid_exit] != "" } {
57 sid_exit 56 sid_exit
58 } 57 }
59 58
60 if ![info exists gdb_spawn_id] { 59 if ![info exists gdb_spawn_id] {
61 » return; 60 » return
62 } 61 }
63 62
64 verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS" 63 verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS"
65 64
66 if { [is_remote host] && [board_info host exists fileid] } { 65 if { [is_remote host] && [board_info host exists fileid] } {
67 » send_gdb "999-gdb-exit\n"; 66 » send_gdb "999-gdb-exit\n"
68 gdb_expect 10 { 67 gdb_expect 10 {
69 -re "y or n" { 68 -re "y or n" {
70 » » send_gdb "y\n"; 69 » » send_gdb "y\n"
71 » » exp_continue; 70 » » exp_continue
72 } 71 }
73 -re "Undefined command.*$gdb_prompt $" { 72 » -re "Undefined command.*$gdb_prompt $" {
74 send_gdb "quit\n" 73 » » send_gdb "quit\n"
75 » » exp_continue; 74 » » exp_continue
76 } 75 » }
77 -re "DOSEXIT code" { } 76 -re "DOSEXIT code" { }
78 default { } 77 default { }
79 } 78 }
80 } 79 }
81 80
82 if ![is_remote host] { 81 if ![is_remote host] {
83 » remote_close host; 82 » remote_close host
84 } 83 }
85 unset gdb_spawn_id 84 unset gdb_spawn_id
86 } 85 }
87 86
88 # 87 #
89 # default_mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure 88 # default_mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure
90 # 89 #
91 # INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work 90 # INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work
92 # with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY. 91 # with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY.
93 # The default value is same-inferior-tty. 92 # The default value is same-inferior-tty.
94 # 93 #
95 # When running over NFS, particularly if running many simultaneous 94 # When running over NFS, particularly if running many simultaneous
96 # tests on different hosts all using the same server, things can 95 # tests on different hosts all using the same server, things can
97 # get really slow. Give gdb at least 3 minutes to start up. 96 # get really slow. Give gdb at least 3 minutes to start up.
98 # 97 #
99 proc default_mi_gdb_start { args } { 98 proc default_mi_gdb_start { args } {
100 global verbose use_gdb_stub 99 global verbose use_gdb_stub
101 global GDB 100 global GDB
102 global INTERNAL_GDBFLAGS GDBFLAGS 101 global INTERNAL_GDBFLAGS GDBFLAGS
103 global gdb_prompt 102 global gdb_prompt
104 global mi_gdb_prompt 103 global mi_gdb_prompt
105 global timeout 104 global timeout
106 global gdb_spawn_id; 105 global gdb_spawn_id
107 global MIFLAGS 106 global MIFLAGS
108 107
109 gdb_stop_suppressing_tests; 108 gdb_stop_suppressing_tests
110 set inferior_pty no-tty 109 set inferior_pty no-tty
111 110
112 # Set the default value, it may be overriden later by specific testfile. 111 # Set the default value, it may be overriden later by specific testfile.
113 set use_gdb_stub [target_info exists use_gdb_stub] 112 set use_gdb_stub [target_info exists use_gdb_stub]
114 113
115 if { [llength $args] == 1} { 114 if { [llength $args] == 1} {
116 set inferior_pty [lindex $args 0] 115 set inferior_pty [lindex $args 0]
117 } 116 }
118 117
119 set separate_inferior_pty [string match $inferior_pty separate-inferior-tty] 118 set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
120 119
121 # Start SID. 120 # Start SID.
122 if { [info procs sid_start] != "" } { 121 if { [info procs sid_start] != "" } {
123 verbose "Spawning SID" 122 verbose "Spawning SID"
124 sid_start 123 sid_start
125 } 124 }
126 125
127 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS" 126 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS"
128 127
129 if [info exists gdb_spawn_id] { 128 if [info exists gdb_spawn_id] {
130 » return 0; 129 » return 0
131 } 130 }
132 131
133 if ![is_remote host] { 132 if ![is_remote host] {
134 if { [which $GDB] == 0 } then { 133 if { [which $GDB] == 0 } then {
135 perror "$GDB does not exist." 134 perror "$GDB does not exist."
136 exit 1 135 exit 1
137 } 136 }
138 } 137 }
139 138
140 # Create the new PTY for the inferior process. 139 # Create the new PTY for the inferior process.
141 if { $separate_inferior_pty } { 140 if { $separate_inferior_pty } {
142 spawn -pty 141 spawn -pty
143 global mi_inferior_spawn_id 142 global mi_inferior_spawn_id
144 global mi_inferior_tty_name 143 global mi_inferior_tty_name
145 set mi_inferior_spawn_id $spawn_id 144 set mi_inferior_spawn_id $spawn_id
146 set mi_inferior_tty_name $spawn_out(slave,name) 145 set mi_inferior_tty_name $spawn_out(slave,name)
147 } 146 }
148 147
149 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host _info gdb_opts]"]; 148 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host _info gdb_opts]"]
150 if { $res < 0 || $res == "" } { 149 if { $res < 0 || $res == "" } {
151 perror "Spawning $GDB failed." 150 perror "Spawning $GDB failed."
152 » return 1; 151 » return 1
153 } 152 }
154 gdb_expect { 153 gdb_expect {
155 -re "~\"GNU.*\r\n~\".*$mi_gdb_prompt$" { 154 -re "~\"GNU.*\r\n~\".*$mi_gdb_prompt$" {
156 # We have a new format mi startup prompt. If we are 155 # We have a new format mi startup prompt. If we are
157 # running mi1, then this is an error as we should be 156 # running mi1, then this is an error as we should be
158 # using the old-style prompt. 157 # using the old-style prompt.
159 if { $MIFLAGS == "-i=mi1" } { 158 if { $MIFLAGS == "-i=mi1" } {
160 » perror "(mi startup) Got unexpected new mi prompt." 159 » » perror "(mi startup) Got unexpected new mi prompt."
161 » remote_close host; 160 » » remote_close host
162 » return -1; 161 » » return -1
163 } 162 }
164 verbose "GDB initialized." 163 verbose "GDB initialized."
165 } 164 }
166 -re "\[^~\].*$mi_gdb_prompt$" { 165 -re "\[^~\].*$mi_gdb_prompt$" {
167 # We have an old format mi startup prompt. If we are 166 # We have an old format mi startup prompt. If we are
168 # not running mi1, then this is an error as we should be 167 # not running mi1, then this is an error as we should be
169 # using the new-style prompt. 168 # using the new-style prompt.
170 if { $MIFLAGS != "-i=mi1" } { 169 if { $MIFLAGS != "-i=mi1" } {
171 » perror "(mi startup) Got unexpected old mi prompt." 170 » » perror "(mi startup) Got unexpected old mi prompt."
172 » remote_close host; 171 » » remote_close host
173 » return -1; 172 » » return -1
174 } 173 }
175 verbose "GDB initialized." 174 verbose "GDB initialized."
176 } 175 }
177 -re ".*unrecognized option.*for a complete list of options." { 176 -re ".*unrecognized option.*for a complete list of options." {
178 untested "Skip mi tests (not compiled with mi support)." 177 untested "Skip mi tests (not compiled with mi support)."
179 » remote_close host; 178 » remote_close host
180 » return -1; 179 » return -1
181 } 180 }
182 -re ".*Interpreter `mi' unrecognized." { 181 -re ".*Interpreter `mi' unrecognized." {
183 untested "Skip mi tests (not compiled with mi support)." 182 untested "Skip mi tests (not compiled with mi support)."
184 » remote_close host; 183 » remote_close host
185 » return -1; 184 » return -1
186 } 185 }
187 timeout { 186 timeout {
188 perror "(timeout) GDB never initialized after 10 seconds." 187 perror "(timeout) GDB never initialized after 10 seconds."
189 » remote_close host; 188 » remote_close host
190 return -1 189 return -1
191 } 190 }
192 } 191 }
193 set gdb_spawn_id -1; 192 set gdb_spawn_id -1
194 193
195 # FIXME: mi output does not go through pagers, so these can be removed. 194 # FIXME: mi output does not go through pagers, so these can be removed.
196 # force the height to "unlimited", so no pagers get used 195 # force the height to "unlimited", so no pagers get used
197 send_gdb "100-gdb-set height 0\n" 196 send_gdb "100-gdb-set height 0\n"
198 gdb_expect 10 { 197 gdb_expect 10 {
199 » -re ".*100-gdb-set height 0\r\n100\\\^done\r\n$mi_gdb_prompt$" { 198 » -re ".*100-gdb-set height 0\r\n100\\\^done\r\n$mi_gdb_prompt$" {
200 verbose "Setting height to 0." 2 199 verbose "Setting height to 0." 2
201 } 200 }
202 timeout { 201 timeout {
203 warning "Couldn't set the height to 0" 202 warning "Couldn't set the height to 0"
204 } 203 }
205 } 204 }
206 # force the width to "unlimited", so no wraparound occurs 205 # force the width to "unlimited", so no wraparound occurs
207 send_gdb "101-gdb-set width 0\n" 206 send_gdb "101-gdb-set width 0\n"
208 gdb_expect 10 { 207 gdb_expect 10 {
209 -re ".*101-gdb-set width 0\r\n101\\\^done\r\n$mi_gdb_prompt$" { 208 -re ".*101-gdb-set width 0\r\n101\\\^done\r\n$mi_gdb_prompt$" {
210 verbose "Setting width to 0." 2 209 verbose "Setting width to 0." 2
211 } 210 }
212 timeout { 211 timeout {
213 warning "Couldn't set the width to 0." 212 warning "Couldn't set the width to 0."
214 } 213 }
215 } 214 }
216 # If allowing the inferior to have its own PTY then assign the inferior 215 # If allowing the inferior to have its own PTY then assign the inferior
217 # its own terminal device here. 216 # its own terminal device here.
218 if { $separate_inferior_pty } { 217 if { $separate_inferior_pty } {
219 send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n" 218 send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
220 gdb_expect 10 { 219 gdb_expect 10 {
221 -re ".*102\\\^done\r\n$mi_gdb_prompt$" { 220 -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
222 verbose "redirect inferior output to new terminal device." 221 verbose "redirect inferior output to new terminal device."
223 } 222 }
224 timeout { 223 timeout {
225 » » warning "Couldn't redirect inferior output." 2 224 » » warning "Couldn't redirect inferior output." 2
226 } 225 }
227 » } 226 » }
228 } 227 }
229 228
230 mi_detect_async 229 mi_detect_async
231 230
232 return 0; 231 return 0
233 } 232 }
234 233
235 # 234 #
236 # Overridable function. You can override this function in your 235 # Overridable function. You can override this function in your
237 # baseboard file. 236 # baseboard file.
238 # 237 #
239 proc mi_gdb_start { args } { 238 proc mi_gdb_start { args } {
240 return [default_mi_gdb_start $args] 239 return [default_mi_gdb_start $args]
241 } 240 }
242 241
243 # Many of the tests depend on setting breakpoints at various places and 242 # Many of the tests depend on setting breakpoints at various places and
244 # running until that breakpoint is reached. At times, we want to start 243 # running until that breakpoint is reached. At times, we want to start
245 # with a clean-slate with respect to breakpoints, so this utility proc 244 # with a clean-slate with respect to breakpoints, so this utility proc
246 # lets us do this without duplicating this code everywhere. 245 # lets us do this without duplicating this code everywhere.
247 # 246 #
248 247
249 proc mi_delete_breakpoints {} { 248 proc mi_delete_breakpoints {} {
250 global mi_gdb_prompt 249 global mi_gdb_prompt
251 250
252 # FIXME: The mi operation won't accept a prompt back and will use the 'all' arg 251 # FIXME: The mi operation won't accept a prompt back and will use the 'all' arg
253 send_gdb "102-break-delete\n" 252 send_gdb "102-break-delete\n"
254 gdb_expect 30 { 253 gdb_expect 30 {
255 -re "Delete all breakpoints.*y or n.*$" { 254 -re "Delete all breakpoints.*y or n.*$" {
256 » send_gdb "y\n"; 255 » send_gdb "y\n"
257 exp_continue 256 exp_continue
258 } 257 » }
259 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" { 258 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
260 # This happens if there were no breakpoints 259 » # This happens if there were no breakpoints
261 } 260 }
262 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (time out)" ; return } 261 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (time out)" ; return }
263 } 262 }
264 263
265 # The correct output is not "No breakpoints or watchpoints." but an 264 # The correct output is not "No breakpoints or watchpoints." but an
266 # empty BreakpointTable. Also, a query is not acceptable with mi. 265 # empty BreakpointTable. Also, a query is not acceptable with mi.
267 send_gdb "103-break-list\n" 266 send_gdb "103-break-list\n"
268 gdb_expect 30 { 267 gdb_expect 30 {
269 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prom pt$" {} 268 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prom pt$" {}
270 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_c ols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"N um\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*co lhdr=\"What\".*\\\],body=\\\[\\\]\}\r\n$mi_gdb_prompt$" {} 269 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_c ols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"N um\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*co lhdr=\"What\".*\\\],body=\\\[\\\]\}\r\n$mi_gdb_prompt$" {}
271 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\ n$mi_gdb_prompt$" {warning "Unexpected console text received"} 270 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\ n$mi_gdb_prompt$" {warning "Unexpected console text received"}
272 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return } 271 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
273 -re "Delete all breakpoints.*or n.*$" { 272 -re "Delete all breakpoints.*or n.*$" {
274 » warning "Unexpected prompt for breakpoints deletion"; 273 » warning "Unexpected prompt for breakpoints deletion"
275 » send_gdb "y\n"; 274 » send_gdb "y\n"
276 exp_continue 275 exp_continue
277 } 276 }
278 timeout { perror "-break-list (timeout)" ; return } 277 timeout { perror "-break-list (timeout)" ; return }
279 } 278 }
280 } 279 }
281 280
282 proc mi_gdb_reinitialize_dir { subdir } { 281 proc mi_gdb_reinitialize_dir { subdir } {
283 global mi_gdb_prompt 282 global mi_gdb_prompt
284 global MIFLAGS 283 global MIFLAGS
285 284
286 global suppress_flag 285 global suppress_flag
287 if { $suppress_flag } { 286 if { $suppress_flag } {
288 return 287 return
289 } 288 }
290 289
291 if [is_remote host] { 290 if [is_remote host] {
292 » return ""; 291 » return ""
293 } 292 }
294 293
295 if { $MIFLAGS == "-i=mi1" } { 294 if { $MIFLAGS == "-i=mi1" } {
296 send_gdb "104-environment-directory\n" 295 send_gdb "104-environment-directory\n"
297 gdb_expect 60 { 296 gdb_expect 60 {
298 -re ".*Reinitialize source path to empty.*y or n. " { 297 -re ".*Reinitialize source path to empty.*y or n. " {
299 warning "Got confirmation prompt for dir reinitialization." 298 » warning "Got confirmation prompt for dir reinitialization."
300 send_gdb "y\n" 299 send_gdb "y\n"
301 gdb_expect 60 { 300 gdb_expect 60 {
302 -re "$mi_gdb_prompt$" {} 301 -re "$mi_gdb_prompt$" {}
303 timeout {error "Dir reinitialization failed (timeout)"} 302 » » timeout {error "Dir reinitialization failed (timeout)"}
304 } 303 }
305 } 304 }
306 -re "$mi_gdb_prompt$" {} 305 -re "$mi_gdb_prompt$" {}
307 timeout {error "Dir reinitialization failed (timeout)"} 306 » timeout {error "Dir reinitialization failed (timeout)"}
308 } 307 }
309 } else { 308 } else {
310 send_gdb "104-environment-directory -r\n" 309 » send_gdb "104-environment-directory -r\n"
311 gdb_expect 60 { 310 » gdb_expect 60 {
312 » -re "104\\\^done,source-path=.*\r\n$mi_gdb_prompt$" {} 311 » -re "104\\\^done,source-path=.*\r\n$mi_gdb_prompt$" {}
313 » -re "$mi_gdb_prompt$" {} 312 » -re "$mi_gdb_prompt$" {}
314 timeout {error "Dir reinitialization failed (timeout)"} 313 » timeout {error "Dir reinitialization failed (timeout)"}
315 } 314 }
316 } 315 }
317 316
318 send_gdb "105-environment-directory $subdir\n" 317 send_gdb "105-environment-directory $subdir\n"
319 gdb_expect 60 { 318 gdb_expect 60 {
320 -re "Source directories searched.*$mi_gdb_prompt$" { 319 -re "Source directories searched.*$mi_gdb_prompt$" {
321 verbose "Dir set to $subdir" 320 verbose "Dir set to $subdir"
322 } 321 }
323 -re "105\\\^done.*\r\n$mi_gdb_prompt$" { 322 -re "105\\\^done.*\r\n$mi_gdb_prompt$" {
324 # FIXME: We return just the prompt for now. 323 » # FIXME: We return just the prompt for now.
325 verbose "Dir set to $subdir" 324 verbose "Dir set to $subdir"
326 # perror "Dir \"$subdir\" failed." 325 # perror "Dir \"$subdir\" failed."
327 } 326 }
328 } 327 }
329 } 328 }
330 329
331 # Send GDB the "target" command. 330 # Send GDB the "target" command.
332 # FIXME: Some of these patterns are not appropriate for MI. Based on 331 # FIXME: Some of these patterns are not appropriate for MI. Based on
333 # config/monitor.exp:gdb_target_command. 332 # config/monitor.exp:gdb_target_command.
334 proc mi_gdb_target_cmd { targetname serialport } { 333 proc mi_gdb_target_cmd { targetname serialport } {
335 global mi_gdb_prompt 334 global mi_gdb_prompt
336 335
337 set serialport_re [string_to_regexp $serialport] 336 set serialport_re [string_to_regexp $serialport]
338 for {set i 1} {$i <= 3} {incr i} { 337 for {set i 1} {$i <= 3} {incr i} {
339 send_gdb "47-target-select $targetname $serialport\n" 338 send_gdb "47-target-select $targetname $serialport\n"
340 gdb_expect 60 { 339 gdb_expect 60 {
341 -re "47\\^connected.*$mi_gdb_prompt" { 340 -re "47\\^connected.*$mi_gdb_prompt" {
342 » » verbose "Set target to $targetname"; 341 » » verbose "Set target to $targetname"
343 » » return 0; 342 » » return 0
344 } 343 }
345 -re "unknown host.*$mi_gdb_prompt" { 344 -re "unknown host.*$mi_gdb_prompt" {
346 » verbose "Couldn't look up $serialport" 345 » » verbose "Couldn't look up $serialport"
347 } 346 }
348 -re "Couldn't establish connection to remote.*$mi_gdb_prompt$" { 347 -re "Couldn't establish connection to remote.*$mi_gdb_prompt$" {
349 » » verbose "Connection failed"; 348 » » verbose "Connection failed"
350 } 349 }
351 -re "Remote MIPS debugging.*$mi_gdb_prompt$" { 350 -re "Remote MIPS debugging.*$mi_gdb_prompt$" {
352 » » verbose "Set target to $targetname"; 351 » » verbose "Set target to $targetname"
353 » » return 0; 352 » » return 0
354 } 353 }
355 -re "Remote debugging using .*$serialport_re.*$mi_gdb_prompt$" { 354 -re "Remote debugging using .*$serialport_re.*$mi_gdb_prompt$" {
356 » » verbose "Set target to $targetname"; 355 » » verbose "Set target to $targetname"
357 » » return 0; 356 » » return 0
358 } 357 }
359 -re "Remote target $targetname connected to.*$mi_gdb_prompt$" { 358 -re "Remote target $targetname connected to.*$mi_gdb_prompt$" {
360 » » verbose "Set target to $targetname"; 359 » » verbose "Set target to $targetname"
361 » » return 0; 360 » » return 0
362 } 361 }
363 » -re "Connected to.*$mi_gdb_prompt$" { 362 » -re "Connected to.*$mi_gdb_prompt$" {
364 » » verbose "Set target to $targetname"; 363 » » verbose "Set target to $targetname"
365 » » return 0; 364 » » return 0
366 } 365 }
367 -re "Ending remote.*$mi_gdb_prompt$" { } 366 -re "Ending remote.*$mi_gdb_prompt$" { }
368 -re "Connection refused.*$mi_gdb_prompt$" { 367 -re "Connection refused.*$mi_gdb_prompt$" {
369 verbose "Connection refused by remote target. Pausing, and tryi ng again." 368 verbose "Connection refused by remote target. Pausing, and tryi ng again."
370 sleep 5 369 sleep 5
371 continue 370 continue
372 } 371 }
373 -re "Non-stop mode requested, but remote does not support non-stop.* $mi_gdb_prompt" { 372 -re "Non-stop mode requested, but remote does not support non-stop.* $mi_gdb_prompt" {
374 unsupported "Non-stop mode not supported" 373 unsupported "Non-stop mode not supported"
375 return 1 374 return 1
376 } 375 }
377 -re "Timeout reading from remote system.*$mi_gdb_prompt$" { 376 -re "Timeout reading from remote system.*$mi_gdb_prompt$" {
378 » » verbose "Got timeout error from gdb."; 377 » » verbose "Got timeout error from gdb."
379 } 378 }
380 timeout { 379 timeout {
381 » » send_gdb ""; 380 » » send_gdb ""
382 break 381 break
383 } 382 }
384 } 383 }
385 } 384 }
386 return 1 385 return 1
387 } 386 }
388 387
389 # 388 #
390 # load a file into the debugger (file command only). 389 # load a file into the debugger (file command only).
391 # return a -1 if anything goes wrong. 390 # return a -1 if anything goes wrong.
392 # 391 #
393 proc mi_gdb_file_cmd { arg } { 392 proc mi_gdb_file_cmd { arg } {
394 global verbose 393 global verbose
395 global loadpath 394 global loadpath
396 global loadfile 395 global loadfile
397 global GDB 396 global GDB
398 global mi_gdb_prompt 397 global mi_gdb_prompt
399 global last_loaded_file 398 global last_loaded_file
400 upvar timeout timeout 399 upvar timeout timeout
401 400
402 set last_loaded_file $arg 401 set last_loaded_file $arg
403 402
404 if [is_remote host] { 403 if [is_remote host] {
405 » set arg [remote_download host $arg]; 404 » set arg [remote_download host $arg]
406 if { $arg == "" } { 405 if { $arg == "" } {
407 error "download failed" 406 error "download failed"
408 » return -1; 407 » return -1
409 } 408 }
410 } 409 }
411 410
412 # FIXME: Several of these patterns are only acceptable for console 411 # FIXME: Several of these patterns are only acceptable for console
413 # output. Queries are an error for mi. 412 # output. Queries are an error for mi.
414 send_gdb "105-file-exec-and-symbols $arg\n" 413 send_gdb "105-file-exec-and-symbols $arg\n"
415 gdb_expect 120 { 414 gdb_expect 120 {
416 -re "Reading symbols from.*done.*$mi_gdb_prompt$" { 415 » -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
417 verbose "\t\tLoaded $arg into the $GDB" 416 » verbose "\t\tLoaded $arg into the $GDB"
418 return 0 417 » return 0
419 }
420 -re "has no symbol-table.*$mi_gdb_prompt$" {
421 perror "$arg wasn't compiled with \"-g\""
422 return -1
423 }
424 -re "Load new symbol table from \".*\".*y or n. $" {
425 send_gdb "y\n"
426 gdb_expect 120 {
427 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
428 verbose "\t\tLoaded $arg with new symbol table into $GDB"
429 # All OK
430 }
431 timeout {
432 perror "(timeout) Couldn't load $arg, other program already loaded."
433 return -1
434 }
435 }
436 } 418 }
437 -re "No such file or directory.*$mi_gdb_prompt$" { 419 » -re "has no symbol-table.*$mi_gdb_prompt$" {
438 perror "($arg) No such file or directory\n" 420 » perror "$arg wasn't compiled with \"-g\""
439 return -1 421 » return -1
440 } 422 » }
441 -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" { 423 » -re "Load new symbol table from \".*\".*y or n. $" {
442 # We (MI) are just giving the prompt back for now, instead of giving 424 » send_gdb "y\n"
425 » gdb_expect 120 {
426 » » -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
427 » » verbose "\t\tLoaded $arg with new symbol table into $GDB"
428 » » # All OK
429 » » }
430 » » timeout {
431 » » perror "(timeout) Couldn't load $arg, other program already loaded."
432 » » return -1
433 » » }
434 » }
435 » }
436 » -re "No such file or directory.*$mi_gdb_prompt$" {
437 » perror "($arg) No such file or directory\n"
438 » return -1
439 » }
440 » -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
441 » # We (MI) are just giving the prompt back for now, instead of giving
443 # some acknowledgement. 442 # some acknowledgement.
444 return 0 443 return 0
445 } 444 }
446 timeout { 445 » timeout {
447 perror "couldn't load $arg into $GDB (timed out)." 446 » perror "couldn't load $arg into $GDB (timed out)."
448 return -1 447 » return -1
449 } 448 » }
450 eof { 449 eof {
451 # This is an attempt to detect a core dump, but seems not to 450 » # This is an attempt to detect a core dump, but seems not to
452 # work. Perhaps we need to match .* followed by eof, in which 451 » # work. Perhaps we need to match .* followed by eof, in which
453 # gdb_expect does not seem to have a way to do that. 452 » # gdb_expect does not seem to have a way to do that.
454 perror "couldn't load $arg into $GDB (end of file)." 453 » perror "couldn't load $arg into $GDB (end of file)."
455 return -1 454 » return -1
456 } 455 » }
457 } 456 }
458 } 457 }
459 458
460 # 459 #
461 # connect to the target and download a file, if necessary. 460 # connect to the target and download a file, if necessary.
462 # return a -1 if anything goes wrong. 461 # return a -1 if anything goes wrong.
463 # 462 #
464 proc mi_gdb_target_load { } { 463 proc mi_gdb_target_load { } {
465 global verbose 464 global verbose
466 global loadpath 465 global loadpath
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return 0 556 return 0
558 } 557 }
559 558
560 # mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb; 559 # mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb;
561 # test the result. 560 # test the result.
562 # 561 #
563 # COMMAND is the command to execute, send to GDB with send_gdb. If 562 # COMMAND is the command to execute, send to GDB with send_gdb. If
564 # this is the null string no command is sent. 563 # this is the null string no command is sent.
565 # PATTERN is the pattern to match for a PASS, and must NOT include 564 # PATTERN is the pattern to match for a PASS, and must NOT include
566 # the \r\n sequence immediately before the gdb prompt. 565 # the \r\n sequence immediately before the gdb prompt.
567 # MESSAGE is the message to be printed. (If this is the empty string, 566 # MESSAGE is the message to be printed. (If this is the empty string,
568 # then sometimes we don't call pass or fail at all; I don't 567 # then sometimes we don't call pass or fail at all; I don't
569 # understand this at all.) 568 # understand this at all.)
570 # IPATTERN is the pattern to match for the inferior's output. This parameter 569 # IPATTERN is the pattern to match for the inferior's output. This parameter
571 # is optional. If present, it will produce a PASS if the match is 570 # is optional. If present, it will produce a PASS if the match is
572 # successful, and a FAIL if unsuccessful. 571 # successful, and a FAIL if unsuccessful.
573 # 572 #
574 # Returns: 573 # Returns:
575 # 1 if the test failed, 574 # 1 if the test failed,
576 # 0 if the test passes, 575 # 0 if the test passes,
577 # -1 if there was an internal error. 576 # -1 if there was an internal error.
578 # 577 #
579 proc mi_gdb_test { args } { 578 proc mi_gdb_test { args } {
580 global verbose 579 global verbose
581 global mi_gdb_prompt 580 global mi_gdb_prompt
582 global GDB expect_out 581 global GDB expect_out
583 global inferior_exited_re async 582 global inferior_exited_re async
584 upvar timeout timeout 583 upvar timeout timeout
585 584
586 set command [lindex $args 0] 585 set command [lindex $args 0]
587 set pattern [lindex $args 1] 586 set pattern [lindex $args 1]
588 set message [lindex $args 2] 587 set message [lindex $args 2]
589 588
590 if [llength $args]==4 { 589 if [llength $args]==4 {
591 set ipattern [lindex $args 3] 590 set ipattern [lindex $args 3]
592 } 591 }
593 592
594 if [llength $args]==5 { 593 if [llength $args]==5 {
595 » set question_string [lindex $args 3]; 594 » set question_string [lindex $args 3]
596 » set response_string [lindex $args 4]; 595 » set response_string [lindex $args 4]
597 } else { 596 } else {
598 set question_string "^FOOBAR$" 597 set question_string "^FOOBAR$"
599 } 598 }
600 599
601 if $verbose>2 then { 600 if $verbose>2 then {
602 send_user "Sending \"$command\" to gdb\n" 601 send_user "Sending \"$command\" to gdb\n"
603 send_user "Looking to match \"$pattern\"\n" 602 send_user "Looking to match \"$pattern\"\n"
604 send_user "Message is \"$message\"\n" 603 send_user "Message is \"$message\"\n"
605 } 604 }
606 605
607 set result -1 606 set result -1
608 set string "${command}\n"; 607 set string "${command}\n"
609 set string_regex [string_to_regexp $command] 608 set string_regex [string_to_regexp $command]
610 609
611 if { $command != "" } { 610 if { $command != "" } {
612 while { "$string" != "" } { 611 while { "$string" != "" } {
613 » set foo [string first "\n" "$string"]; 612 » set foo [string first "\n" "$string"]
614 » set len [string length "$string"]; 613 » set len [string length "$string"]
615 if { $foo < [expr $len - 1] } { 614 if { $foo < [expr $len - 1] } {
616 » » set str [string range "$string" 0 $foo]; 615 » » set str [string range "$string" 0 $foo]
617 if { [send_gdb "$str"] != "" } { 616 if { [send_gdb "$str"] != "" } {
618 » » global suppress_flag; 617 » » global suppress_flag
619 618
620 if { ! $suppress_flag } { 619 if { ! $suppress_flag } {
621 » » » perror "Couldn't send $command to GDB."; 620 » » » perror "Couldn't send $command to GDB."
622 } 621 }
623 » » fail "$message"; 622 » » fail "$message"
624 » » return $result; 623 » » return $result
625 } 624 }
626 gdb_expect 2 { 625 gdb_expect 2 {
627 -re "\[\r\n\]" { } 626 -re "\[\r\n\]" { }
628 timeout { } 627 timeout { }
629 } 628 }
630 » » set string [string range "$string" [expr $foo + 1] end]; 629 » » set string [string range "$string" [expr $foo + 1] end]
631 } else { 630 } else {
632 » » break; 631 » » break
633 } 632 }
634 } 633 }
635 if { "$string" != "" } { 634 if { "$string" != "" } {
636 if { [send_gdb "$string"] != "" } { 635 if { [send_gdb "$string"] != "" } {
637 » » global suppress_flag; 636 » » global suppress_flag
638 637
639 if { ! $suppress_flag } { 638 if { ! $suppress_flag } {
640 » » perror "Couldn't send $command to GDB."; 639 » » perror "Couldn't send $command to GDB."
641 } 640 }
642 » » fail "$message"; 641 » » fail "$message"
643 » » return $result; 642 » » return $result
644 } 643 }
645 } 644 }
646 } 645 }
647 646
648 if [info exists timeout] { 647 if [info exists timeout] {
649 » set tmt $timeout; 648 » set tmt $timeout
650 } else { 649 } else {
651 » global timeout; 650 » global timeout
652 if [info exists timeout] { 651 if [info exists timeout] {
653 » set tmt $timeout; 652 » set tmt $timeout
654 } else { 653 } else {
655 » set tmt 60; 654 » set tmt 60
656 } 655 }
657 } 656 }
658 if {$async} { 657 if {$async} {
659 # With $prompt_re "" there may come arbitrary asynchronous response 658 # With $prompt_re "" there may come arbitrary asynchronous response
660 # from the previous command, before or after $string_regex. 659 # from the previous command, before or after $string_regex.
661 set string_regex ".*" 660 set string_regex ".*"
662 } 661 }
663 verbose -log "Expecting: ^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb _prompt\[ \]*)" 662 verbose -log "Expecting: ^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb _prompt\[ \]*)"
664 gdb_expect $tmt { 663 gdb_expect $tmt {
665 -re "\\*\\*\\* DOSEXIT code.*" { 664 -re "\\*\\*\\* DOSEXIT code.*" {
666 if { $message != "" } { 665 if { $message != "" } {
667 » » fail "$message"; 666 » » fail "$message"
668 } 667 }
669 » gdb_suppress_entire_file "GDB died"; 668 » gdb_suppress_entire_file "GDB died"
670 » return -1; 669 » return -1
671 } 670 }
672 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" { 671 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
673 if ![isnative] then { 672 if ![isnative] then {
674 warning "Can`t communicate to remote target." 673 warning "Can`t communicate to remote target."
675 } 674 }
676 gdb_exit 675 gdb_exit
677 gdb_start 676 gdb_start
678 set result -1 677 set result -1
679 } 678 }
680 -re "^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)" { 679 -re "^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)" {
681 # At this point, $expect_out(1,string) is the MI input command. 680 # At this point, $expect_out(1,string) is the MI input command.
682 # and $expect_out(2,string) is the MI output command. 681 # and $expect_out(2,string) is the MI output command.
683 # If $expect_out(1,string) is "", then there was no MI input command here. 682 # If $expect_out(1,string) is "", then there was no MI input command here.
684 683
685 # NOTE, there is no trailing anchor because with GDB/MI, 684 # NOTE, there is no trailing anchor because with GDB/MI,
686 # asynchronous responses can happen at any point, causing more 685 # asynchronous responses can happen at any point, causing more
687 # data to be available. Normally an anchor is used to make 686 # data to be available. Normally an anchor is used to make
688 # sure the end of the output is matched, however, $mi_gdb_prompt 687 # sure the end of the output is matched, however, $mi_gdb_prompt
689 # is just as good of an anchor since mi_gdb_test is meant to 688 # is just as good of an anchor since mi_gdb_test is meant to
690 # match a single mi output command. If a second GDB/MI output 689 # match a single mi output command. If a second GDB/MI output
691 # response is sent, it will be in the buffer for the next 690 # response is sent, it will be in the buffer for the next
692 # time mi_gdb_test is called. 691 # time mi_gdb_test is called.
693 if ![string match "" $message] then { 692 if ![string match "" $message] then {
694 pass "$message" 693 pass "$message"
695 } 694 }
696 set result 0 695 set result 0
697 } 696 }
698 -re "(${question_string})$" { 697 -re "(${question_string})$" {
699 » send_gdb "$response_string\n"; 698 » send_gdb "$response_string\n"
700 » exp_continue; 699 » exp_continue
701 } 700 }
702 -re "Undefined.* command:.*$mi_gdb_prompt\[ \]*$" { 701 -re "Undefined.* command:.*$mi_gdb_prompt\[ \]*$" {
703 perror "Undefined command \"$command\"." 702 perror "Undefined command \"$command\"."
704 fail "$message" 703 » fail "$message"
705 set result 1 704 set result 1
706 } 705 }
707 -re "Ambiguous command.*$mi_gdb_prompt\[ \]*$" { 706 -re "Ambiguous command.*$mi_gdb_prompt\[ \]*$" {
708 perror "\"$command\" is not a unique command name." 707 perror "\"$command\" is not a unique command name."
709 fail "$message" 708 » fail "$message"
710 set result 1 709 set result 1
711 } 710 }
712 -re "$inferior_exited_re with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" { 711 -re "$inferior_exited_re with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
713 if ![string match "" $message] then { 712 if ![string match "" $message] then {
714 set errmsg "$message (the program exited)" 713 set errmsg "$message (the program exited)"
715 } else { 714 } else {
716 set errmsg "$command (the program exited)" 715 set errmsg "$command (the program exited)"
717 } 716 }
718 fail "$errmsg" 717 fail "$errmsg"
719 return -1 718 return -1
720 } 719 }
721 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" { 720 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
722 if ![string match "" $message] then { 721 if ![string match "" $message] then {
723 set errmsg "$message (the program is no longer running)" 722 set errmsg "$message (the program is no longer running)"
724 } else { 723 } else {
725 set errmsg "$command (the program is no longer running)" 724 set errmsg "$command (the program is no longer running)"
726 } 725 }
727 fail "$errmsg" 726 fail "$errmsg"
728 return -1 727 return -1
729 } 728 }
730 -re ".*$mi_gdb_prompt\[ \]*$" { 729 -re ".*$mi_gdb_prompt\[ \]*$" {
731 if ![string match "" $message] then { 730 if ![string match "" $message] then {
732 fail "$message" 731 fail "$message"
733 } 732 }
734 set result 1 733 set result 1
735 } 734 }
736 "<return>" { 735 "<return>" {
737 send_gdb "\n" 736 send_gdb "\n"
738 perror "Window too small." 737 perror "Window too small."
739 fail "$message" 738 » fail "$message"
740 } 739 }
741 -re "\\(y or n\\) " { 740 -re "\\(y or n\\) " {
742 send_gdb "n\n" 741 send_gdb "n\n"
743 perror "Got interactive prompt." 742 perror "Got interactive prompt."
744 fail "$message" 743 » fail "$message"
745 } 744 }
746 eof { 745 eof {
747 perror "Process no longer exists" 746 perror "Process no longer exists"
748 if { $message != "" } { 747 if { $message != "" } {
749 fail "$message" 748 fail "$message"
750 } 749 }
751 return -1 750 return -1
752 } 751 }
753 full_buffer { 752 full_buffer {
754 perror "internal buffer is full." 753 perror "internal buffer is full."
755 fail "$message" 754 » fail "$message"
756 } 755 }
757 timeout { 756 timeout {
758 if ![string match "" $message] then { 757 if ![string match "" $message] then {
759 fail "$message (timeout)" 758 fail "$message (timeout)"
760 } 759 }
761 set result 1 760 set result 1
762 } 761 }
763 } 762 }
764 763
765 # If the GDB output matched, compare the inferior output. 764 # If the GDB output matched, compare the inferior output.
766 if { $result == 0 } { 765 if { $result == 0 } {
767 if [ info exists ipattern ] { 766 if [ info exists ipattern ] {
768 if { ![target_info exists gdb,noinferiorio] } { 767 if { ![target_info exists gdb,noinferiorio] } {
769 » » global mi_inferior_spawn_id 768 » » if { [target_info gdb_protocol] == "remote"
770 » » expect { 769 » » || [target_info gdb_protocol] == "extended-remote"
771 » » -i $mi_inferior_spawn_id -re "$ipattern" { 770 » » || [target_info protocol] == "sim"} {
772 » » » pass "$message inferior output" 771
772 » » gdb_expect {
773 » » » -re "$ipattern" {
774 » » » pass "$message inferior output"
775 » » » }
776 » » » timeout {
777 » » » fail "$message inferior output (timeout)"
778 » » » set result 1
779 » » » }
773 } 780 }
774 » » timeout { 781 » » } else {
775 » » » fail "$message inferior output (timeout)" 782 » » global mi_inferior_spawn_id
776 » » » set result 1 783 » » expect {
784 » » » -i $mi_inferior_spawn_id -re "$ipattern" {
785 » » » pass "$message inferior output"
786 » » » }
787 » » » timeout {
788 » » » fail "$message inferior output (timeout)"
789 » » » set result 1
790 » » » }
777 } 791 }
778 } 792 }
779 } else { 793 } else {
780 unsupported "$message inferior output" 794 unsupported "$message inferior output"
781 } 795 }
782 } 796 » }
783 } 797 }
784 798
785 return $result 799 return $result
786 } 800 }
787 801
788 # 802 #
789 # MI run command. (A modified version of gdb_run_cmd) 803 # MI run command. (A modified version of gdb_run_cmd)
790 # 804 #
791 805
792 # In patterns, the newline sequence ``\r\n'' is matched explicitly as 806 # In patterns, the newline sequence ``\r\n'' is matched explicitly as
(...skipping 10 matching lines...) Expand all
803 817
804 if {$use_mi_command} { 818 if {$use_mi_command} {
805 set run_prefix "220-exec-" 819 set run_prefix "220-exec-"
806 set run_match "220" 820 set run_match "220"
807 } else { 821 } else {
808 set run_prefix "" 822 set run_prefix ""
809 set run_match "" 823 set run_match ""
810 } 824 }
811 825
812 if [target_info exists gdb_init_command] { 826 if [target_info exists gdb_init_command] {
813 » send_gdb "[target_info gdb_init_command]\n"; 827 » send_gdb "[target_info gdb_init_command]\n"
814 gdb_expect 30 { 828 gdb_expect 30 {
815 -re "$mi_gdb_prompt$" { } 829 -re "$mi_gdb_prompt$" { }
816 default { 830 default {
817 » » perror "gdb_init_command for target failed"; 831 » » perror "gdb_init_command for target failed"
818 » » return -1; 832 » » return -1
819 } 833 }
820 } 834 }
821 } 835 }
822 836
823 if { [mi_gdb_target_load] < 0 } { 837 if { [mi_gdb_target_load] < 0 } {
824 return -1 838 return -1
825 } 839 }
826 840
827 if $use_gdb_stub { 841 if $use_gdb_stub {
828 if [target_info exists gdb,do_reload_on_run] { 842 if [target_info exists gdb,do_reload_on_run] {
829 » send_gdb "${run_prefix}continue\n"; 843 » send_gdb "${run_prefix}continue\n"
830 gdb_expect 60 { 844 gdb_expect 60 {
831 -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\" \]+\"\r\n$mi_gdb_prompt" {} 845 -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\" \]+\"\r\n$mi_gdb_prompt" {}
832 default {} 846 default {}
833 } 847 }
834 » return 0; 848 » return 0
835 } 849 }
836 850
837 if [target_info exists gdb,start_symbol] { 851 if [target_info exists gdb,start_symbol] {
838 » set start [target_info gdb,start_symbol]; 852 » set start [target_info gdb,start_symbol]
839 } else { 853 } else {
840 » set start "start"; 854 » set start "start"
841 } 855 }
842 856
843 # HACK: Should either use 000-jump or fix the target code 857 # HACK: Should either use 000-jump or fix the target code
844 # to better handle RUN. 858 # to better handle RUN.
845 send_gdb "jump *$start\n" 859 send_gdb "jump *$start\n"
846 warning "Using CLI jump command, expect run-to-main FAIL" 860 warning "Using CLI jump command, expect run-to-main FAIL"
847 return 0 861 return 0
848 } 862 }
849 863
850 send_gdb "${run_prefix}run $args\n" 864 send_gdb "${run_prefix}run $args\n"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 global suppress_flag 930 global suppress_flag
917 if { $suppress_flag } { 931 if { $suppress_flag } {
918 return -1 932 return -1
919 } 933 }
920 934
921 global mi_gdb_prompt expect_out 935 global mi_gdb_prompt expect_out
922 global hex decimal fullname_syntax 936 global hex decimal fullname_syntax
923 937
924 set test "mi runto $func" 938 set test "mi runto $func"
925 mi_gdb_test "200-break-insert -t $func" \ 939 mi_gdb_test "200-break-insert -t $func" \
926 "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enab led=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\] *\",times=\"0\",original-location=\".*\"\}" \ 940 "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enab led=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\] *\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".*\"\}" \
927 "breakpoint at $func" 941 "breakpoint at $func"
928 942
929 if {![regexp {number="[0-9]+"} $expect_out(buffer) str] 943 if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
930 || ![scan $str {number="%d"} bkptno]} { 944 || ![scan $str {number="%d"} bkptno]} {
931 set bkptno {[0-9]+} 945 set bkptno {[0-9]+}
932 } 946 }
933 947
934 if {$run_or_continue == "run"} { 948 if {$run_or_continue == "run"} {
935 if { [mi_run_cmd] < 0 } { 949 if { [mi_run_cmd] < 0 } {
936 return -1 950 return -1
(...skipping 24 matching lines...) Expand all
961 return [mi_step_to {.*} {.*} {.*} {.*} $test] 975 return [mi_step_to {.*} {.*} {.*} {.*} $test]
962 } 976 }
963 977
964 set async "unknown" 978 set async "unknown"
965 979
966 proc mi_detect_async {} { 980 proc mi_detect_async {} {
967 global async 981 global async
968 global mi_gdb_prompt 982 global mi_gdb_prompt
969 983
970 send_gdb "show target-async\n" 984 send_gdb "show target-async\n"
971 985
972 gdb_expect { 986 gdb_expect {
973 -re ".*Controlling the inferior in asynchronous mode is on...*$mi_gdb_pr ompt$" { 987 » -re ".*Controlling the inferior in asynchronous mode is on...*$mi_gdb_pr ompt$" {
974 set async 1 988 » set async 1
975 } 989 » }
976 -re ".*$mi_gdb_prompt$" { 990 » -re ".*$mi_gdb_prompt$" {
977 set async 0 991 » set async 0
978 } 992 » }
979 timeout { 993 » timeout {
980 set async 0 994 » set async 0
981 } 995 » }
982 } 996 }
983 return $async 997 return $async
984 } 998 }
985 999
986 # Wait for MI *stopped notification to appear. 1000 # Wait for MI *stopped notification to appear.
987 # The REASON, FUNC, ARGS, FILE and LINE are regular expressions 1001 # The REASON, FUNC, ARGS, FILE and LINE are regular expressions
988 # to match against whatever is output in *stopped. FILE may also match 1002 # to match against whatever is output in *stopped. FILE may also match
989 # filename of a file without debug info. ARGS should not include [] the 1003 # filename of a file without debug info. ARGS should not include [] the
990 # list of argument is enclosed in, and other regular expressions should 1004 # list of argument is enclosed in, and other regular expressions should
991 # not include quotes. 1005 # not include quotes.
992 # If EXTRA is a list of one element, it's the regular expression 1006 # If EXTRA is a list of one element, it's the regular expression
993 # for output expected right after *stopped, and before GDB prompt. 1007 # for output expected right after *stopped, and before GDB prompt.
994 # If EXTRA is a list of two elements, the first element is for 1008 # If EXTRA is a list of two elements, the first element is for
995 # output right after *stopped, and the second element is output 1009 # output right after *stopped, and the second element is output
996 # right after reason field. The regex after reason should not include 1010 # right after reason field. The regex after reason should not include
997 # the comma separating it from the following fields. 1011 # the comma separating it from the following fields.
998 # 1012 #
999 # When we fail to match output at all, -1 is returned. If FILE does 1013 # When we fail to match output at all, -1 is returned. If FILE does
1000 # match and the target system has no debug info for FILE return 0. 1014 # match and the target system has no debug info for FILE return 0.
1001 # Otherwise, the line at which we stop is returned. This is useful when 1015 # Otherwise, the line at which we stop is returned. This is useful when
1002 # exact line is not possible to specify for some reason -- one can pass 1016 # exact line is not possible to specify for some reason -- one can pass
1003 # the .* or "\[0-9\]*" regexps for line, and then check the line 1017 # the .* or "\[0-9\]*" regexps for line, and then check the line
1004 # programmatically. 1018 # programmatically.
1005 # 1019 #
1006 # Do not pass .* for any argument if you are expecting more than one stop. 1020 # Do not pass .* for any argument if you are expecting more than one stop.
1007 proc mi_expect_stop { reason func args file line extra test } { 1021 proc mi_expect_stop { reason func args file line extra test } {
1008 1022
1009 global mi_gdb_prompt 1023 global mi_gdb_prompt
1010 global hex 1024 global hex
1011 global decimal 1025 global decimal
1012 global fullname_syntax 1026 global fullname_syntax
1013 global async 1027 global async
1014 global thread_selected_re 1028 global thread_selected_re
1015 global breakpoint_re 1029 global breakpoint_re
1016 1030
1017 set after_stopped "" 1031 set after_stopped ""
1018 set after_reason "" 1032 set after_reason ""
1019 if { [llength $extra] == 2 } { 1033 if { [llength $extra] == 2 } {
1020 set after_stopped [lindex $extra 0] 1034 » set after_stopped [lindex $extra 0]
1021 set after_reason [lindex $extra 1] 1035 » set after_reason [lindex $extra 1]
1022 set after_reason "${after_reason}," 1036 » set after_reason "${after_reason},"
1023 } elseif { [llength $extra] == 1 } { 1037 } elseif { [llength $extra] == 1 } {
1024 set after_stopped [lindex $extra 0] 1038 » set after_stopped [lindex $extra 0]
1025 } 1039 }
1026 1040
1027 if {$async} { 1041 if {$async} {
1028 set prompt_re "" 1042 » set prompt_re ""
1029 } else { 1043 } else {
1030 set prompt_re "$mi_gdb_prompt$" 1044 » set prompt_re "$mi_gdb_prompt$"
1031 } 1045 }
1032 1046
1033 if { $reason == "really-no-reason" } { 1047 if { $reason == "really-no-reason" } {
1034 gdb_expect { 1048 » gdb_expect {
1035 -re "\\*stopped\r\n$prompt_re" { 1049 » -re "\\*stopped\r\n$prompt_re" {
1036 pass "$test" 1050 » » pass "$test"
1037 } 1051 » }
1038 timeout { 1052 » timeout {
1039 fail "$test (unknown output after running)" 1053 » » fail "$test (unknown output after running)"
1040 } 1054 » }
1041 } 1055 » }
1042 return 1056 » return
1043 } 1057 }
1044 1058
1045 if { $reason == "exited-normally" } { 1059 if { $reason == "exited-normally" } {
1046 1060
1047 gdb_expect { 1061 » gdb_expect {
1048 -re "\\*stopped,reason=\"exited-normally\"\r\n$prompt_re" { 1062 » -re "\\*stopped,reason=\"exited-normally\"\r\n$prompt_re" {
1049 pass "$test" 1063 » » pass "$test"
1050 } 1064 » }
1051 -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"} 1065 » -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
1052 timeout { 1066 » timeout {
1053 fail "$test (unknown output after running)" 1067 » » fail "$test (unknown output after running)"
1054 } 1068 » }
1055 } 1069 » }
1056 return 1070 » return
1057 } 1071 }
1058 1072
1059 set args "\\\[$args\\\]" 1073 set args "\\\[$args\\\]"
1060 1074
1061 set bn "" 1075 set bn ""
1062 if { $reason == "breakpoint-hit" } { 1076 if { $reason == "breakpoint-hit" } {
1063 set bn {bkptno="[0-9]+",} 1077 » set bn {bkptno="[0-9]+",}
1064 } elseif { $reason == "solib-event" } { 1078 } elseif { $reason == "solib-event" } {
1065 set bn ".*" 1079 set bn ".*"
1066 } 1080 }
1067 1081
1068 set r "" 1082 set r ""
1069 if { $reason != "" } { 1083 if { $reason != "" } {
1070 set r "reason=\"$reason\"," 1084 » set r "reason=\"$reason\","
1071 } 1085 }
1072 1086
1073 1087
1074 set a $after_reason 1088 set a $after_reason
1075 1089
1076 set any "\[^\n\]*" 1090 set any "\[^\n\]*"
1077 1091
1078 verbose -log "mi_expect_stop: expecting: \\*stopped,${r}${a}${bn}frame=\{add r=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname _syntax}$file\",line=\"$line\"|from=\"$file\")\}$after_stopped,thread-id=\"$deci mal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" 1092 verbose -log "mi_expect_stop: expecting: \\*stopped,${r}${a}${bn}frame=\{add r=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname _syntax}$file\",line=\"$line\"|from=\"$file\")\}$after_stopped,thread-id=\"$deci mal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re"
1079 gdb_expect { 1093 gdb_expect {
1080 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$ args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\" |from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n ($thread_selected_re|$breakpoint_re)*$prompt_re" { 1094 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$ args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\" |from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n ($thread_selected_re|$breakpoint_re)*$prompt_re" {
1081 pass "$test" 1095 pass "$test"
1082 if {[array names expect_out "2,string"] != ""} { 1096 if {[array names expect_out "2,string"] != ""} {
1083 return $expect_out(2,string) 1097 return $expect_out(2,string)
1084 } 1098 }
1085 # No debug info available but $file does match. 1099 # No debug info available but $file does match.
1086 return 0 1100 return 0
1087 } 1101 }
1088 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$any\",args=\[ \\\[\{\]$any\[\\\]\}\],file=\"$any\",fullname=\"${fullname_syntax}$any\",line=\" \[0-9\]*\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thre ad_selected_re|$breakpoint_re)*$prompt_re" { 1102 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$any\",args=\[ \\\[\{\]$any\[\\\]\}\],file=\"$any\",fullname=\"${fullname_syntax}$any\",line=\" \[0-9\]*\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thre ad_selected_re|$breakpoint_re)*$prompt_re" {
1089 verbose -log "got $expect_out(buffer)" 1103 » verbose -log "got $expect_out(buffer)"
1090 fail "$test (stopped at wrong place)" 1104 fail "$test (stopped at wrong place)"
1091 return -1 1105 return -1
1092 } 1106 }
1093 -re ".*\r\n$mi_gdb_prompt$" { 1107 -re ".*\r\n$mi_gdb_prompt$" {
1094 verbose -log "got $expect_out(buffer)" 1108 » verbose -log "got $expect_out(buffer)"
1095 fail "$test (unknown output after running)" 1109 fail "$test (unknown output after running)"
1096 return -1 1110 return -1
1097 } 1111 }
1098 timeout { 1112 timeout {
1099 fail "$test (timeout)" 1113 fail "$test (timeout)"
1100 return -1 1114 return -1
1101 } 1115 }
1102 } 1116 }
1103 } 1117 }
1104 1118
1105 # Wait for MI *stopped notification related to an interrupt request to 1119 # Wait for MI *stopped notification related to an interrupt request to
1106 # appear. 1120 # appear.
1107 proc mi_expect_interrupt { test } { 1121 proc mi_expect_interrupt { test } {
1108 global mi_gdb_prompt 1122 global mi_gdb_prompt
1109 global decimal 1123 global decimal
1110 global async 1124 global async
1111 1125
1112 if {$async} { 1126 if {$async} {
1113 set prompt_re "" 1127 set prompt_re ""
1114 } else { 1128 } else {
1115 set prompt_re "$mi_gdb_prompt$" 1129 set prompt_re "$mi_gdb_prompt$"
1116 } 1130 }
1117 1131
1118 set r "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\"" 1132 set r "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\""
1119 1133
1120 set any "\[^\n\]*" 1134 set any "\[^\n\]*"
1121 1135
1122 # A signal can land anywhere, just ignore the location 1136 # A signal can land anywhere, just ignore the location
1123 verbose -log "mi_expect_interrupt: expecting: \\*stopped,${r}$any\r\n$prompt _re" 1137 verbose -log "mi_expect_interrupt: expecting: \\*stopped,${r}$any\r\n$prompt _re"
1124 gdb_expect { 1138 gdb_expect {
1125 -re "\\*stopped,${r}$any\r\n$prompt_re" { 1139 -re "\\*stopped,${r}$any\r\n$prompt_re" {
1126 pass "$test" 1140 pass "$test"
1127 » return 0; 1141 » return 0
1128 } 1142 }
1129 -re ".*\r\n$mi_gdb_prompt$" { 1143 -re ".*\r\n$mi_gdb_prompt$" {
1130 verbose -log "got $expect_out(buffer)" 1144 verbose -log "got $expect_out(buffer)"
1131 fail "$test (unknown output after running)" 1145 fail "$test (unknown output after running)"
1132 return -1 1146 return -1
1133 } 1147 }
1134 timeout { 1148 timeout {
1135 fail "$test (timeout)" 1149 fail "$test (timeout)"
1136 return -1 1150 return -1
1137 } 1151 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 "$test" 1212 "$test"
1199 } 1213 }
1200 1214
1201 proc mi0_continue_to { bkptno func args file line test } { 1215 proc mi0_continue_to { bkptno func args file line test } {
1202 mi0_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \ 1216 mi0_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
1203 "$func" "$args" "$file" "$line" "" "$test" 1217 "$func" "$args" "$file" "$line" "" "$test"
1204 } 1218 }
1205 1219
1206 # Creates a breakpoint and checks the reported fields are as expected 1220 # Creates a breakpoint and checks the reported fields are as expected
1207 proc mi_create_breakpoint { location number disp func file line address test } { 1221 proc mi_create_breakpoint { location number disp func file line address test } {
1208 verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpo int\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file \",fullname=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" 1222 verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpo int\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file \",fullname=\".*\",line=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",origi nal-location=\".*\"\}"
1209 mi_gdb_test "222-break-insert $location" \ 1223 mi_gdb_test "222-break-insert $location" \
1210 "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\" ,enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",l ine=\"$line\",times=\"0\",original-location=\".*\"\}" \ 1224 » "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\" ,enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",l ine=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",original-location=\".*\"\ }" \
1211 $test 1225 » $test
1212 } 1226 }
1213 1227
1214 proc mi_list_breakpoints { expected test } { 1228 proc mi_list_breakpoints { expected test } {
1215 set fullname ".*" 1229 set fullname ".*"
1216 1230
1217 set body "" 1231 set body ""
1218 set first 1 1232 set first 1
1219 1233
1220 foreach item $expected { 1234 foreach item $expected {
1221 if {$first == 0} { 1235 » if {$first == 0} {
1222 set body "$body," 1236 » set body "$body,"
1223 set first 0 1237 » set first 0
1224 } 1238 » }
1225 set number [lindex $item 0] 1239 » set number [lindex $item 0]
1226 set disp [lindex $item 1] 1240 » set disp [lindex $item 1]
1227 set func [lindex $item 2] 1241 » set func [lindex $item 2]
1228 set file [lindex $item 3] 1242 » set file [lindex $item 3]
1229 set line [lindex $item 4] 1243 » set line [lindex $item 4]
1230 set address [lindex $item 5] 1244 » set address [lindex $item 5]
1231 set body "${body}bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$d isp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\".*$file\",${fullname },line=\"$line\",times=\"0\",original-location=\".*\"\}" 1245 » set body "${body}bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$d isp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\".*$file\",${fullname },line=\"$line\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\".* \"\}"
1232 set first 0 1246 » set first 0
1233 } 1247 }
1234 1248
1235 verbose -log "Expecting: 666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols =\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\ "\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhd r=\"What\".*\\\],body=\\\[$body\\\]\}" 1249 verbose -log "Expecting: 666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols =\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\ "\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhd r=\"What\".*\\\],body=\\\[$body\\\]\}"
1236 mi_gdb_test "666-break-list" \ 1250 mi_gdb_test "666-break-list" \
1237 "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{wid th=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\" .*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],bod y=\\\[$body\\\]\}" \ 1251 » "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{wid th=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\" .*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],bod y=\\\[$body\\\]\}" \
1238 $test 1252 » $test
1239 } 1253 }
1240 1254
1241 # Creates varobj named NAME for EXPRESSION. 1255 # Creates varobj named NAME for EXPRESSION.
1242 # Name cannot be "-". 1256 # Name cannot be "-".
1243 proc mi_create_varobj { name expression testname } { 1257 proc mi_create_varobj { name expression testname } {
1244 mi_gdb_test "-var-create $name * $expression" \ 1258 mi_gdb_test "-var-create $name * $expression" \
1245 "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*,has_m ore=\"0\"" \ 1259 » "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*,has_m ore=\"0\"" \
1246 $testname 1260 » $testname
1247 } 1261 }
1248 1262
1249 proc mi_create_floating_varobj { name expression testname } { 1263 proc mi_create_floating_varobj { name expression testname } {
1250 mi_gdb_test "-var-create $name @ $expression" \ 1264 mi_gdb_test "-var-create $name @ $expression" \
1251 "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type= .*" \ 1265 » "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type= .*" \
1252 $testname 1266 » $testname
1253 } 1267 }
1254 1268
1255 1269
1256 # Same as mi_create_varobj, but also checks the reported type 1270 # Same as mi_create_varobj, but also checks the reported type
1257 # of the varobj. 1271 # of the varobj.
1258 proc mi_create_varobj_checked { name expression type testname } { 1272 proc mi_create_varobj_checked { name expression type testname } {
1259 mi_gdb_test "-var-create $name * $expression" \ 1273 mi_gdb_test "-var-create $name * $expression" \
1260 "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=\"$type\ ".*" \ 1274 » "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=\"$type\ ".*" \
1261 $testname 1275 » $testname
1262 } 1276 }
1263 1277
1264 # Same as mi_create_floating_varobj, but assumes the test is creating 1278 # Same as mi_create_floating_varobj, but assumes the test is creating
1265 # a dynamic varobj that has children, so the value must be "{...}". 1279 # a dynamic varobj that has children, so the value must be "{...}".
1266 proc mi_create_dynamic_varobj {name expression testname} { 1280 # The "has_more" attribute is checked.
1281 proc mi_create_dynamic_varobj {name expression has_more testname} {
1267 mi_gdb_test "-var-create $name @ $expression" \ 1282 mi_gdb_test "-var-create $name @ $expression" \
1268 "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\"{\\.\\.\\. }\",type=.*" \ 1283 » "\\^done,name=\"$name\",numchild=\"0\",value=\"{\\.\\.\\.}\",type=.*,has _more=\"${has_more}\"" \
1269 $testname 1284 » $testname
1270 } 1285 }
1271 1286
1272 # Deletes the specified NAME. 1287 # Deletes the specified NAME.
1273 proc mi_delete_varobj { name testname } { 1288 proc mi_delete_varobj { name testname } {
1274 mi_gdb_test "-var-delete $name" \ 1289 mi_gdb_test "-var-delete $name" \
1275 "\\^done,ndeleted=.*" \ 1290 » "\\^done,ndeleted=.*" \
1276 $testname 1291 » $testname
1277 } 1292 }
1278 1293
1279 # Updates varobj named NAME and checks that all varobjs in EXPECTED 1294 # Updates varobj named NAME and checks that all varobjs in EXPECTED
1280 # are reported as updated, and no other varobj is updated. 1295 # are reported as updated, and no other varobj is updated.
1281 # Assumes that no varobj is out of scope and that no varobj changes 1296 # Assumes that no varobj is out of scope and that no varobj changes
1282 # types. 1297 # types.
1283 proc mi_varobj_update { name expected testname } { 1298 proc mi_varobj_update { name expected testname } {
1284 set er "\\^done,changelist=\\\[" 1299 set er "\\^done,changelist=\\\["
1285 set first 1 1300 set first 1
1286 foreach item $expected { 1301 foreach item $expected {
1287 set v "{name=\"$item\",in_scope=\"true\",type_changed=\"false\",has_more =\".\"}" 1302 » set v "{name=\"$item\",in_scope=\"true\",type_changed=\"false\",has_more =\".\"}"
1288 if {$first == 1} { 1303 » if {$first == 1} {
1289 set er "$er$v" 1304 » set er "$er$v"
1290 set first 0 1305 » set first 0
1291 } else { 1306 » } else {
1292 set er "$er,$v" 1307 » set er "$er,$v"
1293 } 1308 » }
1294 } 1309 }
1295 set er "$er\\\]" 1310 set er "$er\\\]"
1296 1311
1297 verbose -log "Expecting: $er" 2 1312 verbose -log "Expecting: $er" 2
1298 mi_gdb_test "-var-update $name" $er $testname 1313 mi_gdb_test "-var-update $name" $er $testname
1299 } 1314 }
1300 1315
1301 proc mi_varobj_update_with_child_type_change { name child_name new_type new_chil dren testname } { 1316 proc mi_varobj_update_with_child_type_change { name child_name new_type new_chil dren testname } {
1302 set v "{name=\"$child_name\",in_scope=\"true\",type_changed=\"true\",new_typ e=\"$new_type\",new_num_children=\"$new_children\",has_more=\".\"}" 1317 set v "{name=\"$child_name\",in_scope=\"true\",type_changed=\"true\",new_typ e=\"$new_type\",new_num_children=\"$new_children\",has_more=\".\"}"
1303 set er "\\^done,changelist=\\\[$v\\\]" 1318 set er "\\^done,changelist=\\\[$v\\\]"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 1391
1377 mi_gdb_test "-var-evaluate-expression $name" \ 1392 mi_gdb_test "-var-evaluate-expression $name" \
1378 "\\^done,value=\"$value\"" \ 1393 "\\^done,value=\"$value\"" \
1379 $testname 1394 $testname
1380 } 1395 }
1381 1396
1382 # Helper proc which constructs a child regexp for 1397 # Helper proc which constructs a child regexp for
1383 # mi_list_varobj_children and mi_varobj_update_dynamic. 1398 # mi_list_varobj_children and mi_varobj_update_dynamic.
1384 proc mi_child_regexp {children add_child} { 1399 proc mi_child_regexp {children add_child} {
1385 set children_exp {} 1400 set children_exp {}
1386 set whatever "\"\[^\"\]+\""
1387 1401
1388 if {$add_child} { 1402 if {$add_child} {
1389 set pre "child=" 1403 set pre "child="
1390 } else { 1404 } else {
1391 set pre "" 1405 set pre ""
1392 } 1406 }
1393 1407
1394 foreach item $children { 1408 foreach item $children {
1395 1409
1396 set name [lindex $item 0] 1410 » set name [lindex $item 0]
1397 set exp [lindex $item 1] 1411 » set exp [lindex $item 1]
1398 set numchild [lindex $item 2] 1412 » set numchild [lindex $item 2]
1399 if {[llength $item] == 5} { 1413 » if {[llength $item] == 5} {
1400 set type [lindex $item 3] 1414 » set type [lindex $item 3]
1401 set value [lindex $item 4] 1415 » set value [lindex $item 4]
1402 1416
1403 lappend children_exp\ 1417 » lappend children_exp\
1404 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\ "$value\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}" 1418 » » "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\ "$value\",type=\"$type\"(,thread-id=\"\[0-9\]+\")?}"
1405 } elseif {[llength $item] == 4} { 1419 » } elseif {[llength $item] == 4} {
1406 set type [lindex $item 3] 1420 » set type [lindex $item 3]
1407 1421
1408 lappend children_exp\ 1422 » lappend children_exp\
1409 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\" $type\"\(,thread-id=\"\[0-9\]+\")?}" 1423 » » "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\" $type\"(,thread-id=\"\[0-9\]+\")?}"
1410 } else { 1424 » } else {
1411 lappend children_exp\ 1425 » lappend children_exp\
1412 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread -id=\"\[0-9\]+\")?}" 1426 » » "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread -id=\"\[0-9\]+\")?}"
1413 } 1427 » }
1414 } 1428 }
1415 return [join $children_exp ","] 1429 return [join $children_exp ","]
1416 } 1430 }
1417 1431
1418 # Check the results of the: 1432 # Check the results of the:
1419 # 1433 #
1420 # -var-list-children VARNAME 1434 # -var-list-children VARNAME
1421 # 1435 #
1422 # command. The CHILDREN parement should be a list of lists. 1436 # command. The CHILDREN parement should be a list of lists.
1423 # Each inner list can have either 3 or 4 elements, describing 1437 # Each inner list can have either 3 or 4 elements, describing
(...skipping 14 matching lines...) Expand all
1438 proc mi_list_varobj_children { varname children testname } { 1452 proc mi_list_varobj_children { varname children testname } {
1439 mi_list_varobj_children_range $varname "" "" [llength $children] $children \ 1453 mi_list_varobj_children_range $varname "" "" [llength $children] $children \
1440 $testname 1454 $testname
1441 } 1455 }
1442 1456
1443 # Like mi_list_varobj_children, but sets a subrange. NUMCHILDREN is 1457 # Like mi_list_varobj_children, but sets a subrange. NUMCHILDREN is
1444 # the total number of children. 1458 # the total number of children.
1445 proc mi_list_varobj_children_range {varname from to numchildren children testnam e} { 1459 proc mi_list_varobj_children_range {varname from to numchildren children testnam e} {
1446 set options "" 1460 set options ""
1447 if {[llength $varname] == 2} { 1461 if {[llength $varname] == 2} {
1448 set options [lindex $varname 1] 1462 » set options [lindex $varname 1]
1449 set varname [lindex $varname 0] 1463 » set varname [lindex $varname 0]
1450 } 1464 }
1451 1465
1452 set whatever "\"\[^\"\]+\""
1453
1454 set children_exp_j [mi_child_regexp $children 1] 1466 set children_exp_j [mi_child_regexp $children 1]
1455 if {$numchildren} { 1467 if {$numchildren} {
1456 set expected "\\^done,numchild=\".*\",children=\\\[$children_exp_j.*\\\] " 1468 » set expected "\\^done,numchild=\".*\",children=\\\[$children_exp_j.*\\\] "
1457 } { 1469 } {
1458 set expected "\\^done,numchild=\"0\"" 1470 » set expected "\\^done,numchild=\"0\""
1459 } 1471 }
1460 1472
1461 if {"$to" == ""} { 1473 if {"$to" == ""} {
1462 append expected ",has_more=\"0\"" 1474 » append expected ",has_more=\"0\""
1463 } elseif {$to >= 0 && $numchildren > $to} { 1475 } elseif {$to >= 0 && $numchildren > $to} {
1464 append expected ",has_more=\"1\"" 1476 » append expected ",has_more=\"1\""
1465 } else { 1477 } else {
1466 append expected ",has_more=\"0\"" 1478 » append expected ",has_more=\"0\""
1467 } 1479 }
1468 1480
1469 verbose -log "Expecting: $expected" 1481 verbose -log "Expecting: $expected"
1470 1482
1471 mi_gdb_test "-var-list-children $options $varname $from $to" \ 1483 mi_gdb_test "-var-list-children $options $varname $from $to" \
1472 $expected $testname 1484 $expected $testname
1473 } 1485 }
1474 1486
1475 # Verifies that variable object VARNAME has NUMBER children, 1487 # Verifies that variable object VARNAME has NUMBER children,
1476 # where each one is named $VARNAME.<index-of-child> and has type TYPE. 1488 # where each one is named $VARNAME.<index-of-child> and has type TYPE.
1477 proc mi_list_array_varobj_children { varname number type testname } { 1489 proc mi_list_array_varobj_children { varname number type testname } {
1490 mi_list_array_varobj_children_with_index $varname $number 0 $type $testname
1491 }
1492
1493 # Same as mi_list_array_varobj_children, but allowing to pass a start index
1494 # for an array.
1495 proc mi_list_array_varobj_children_with_index { varname number start_index \
1496 type testname } {
1478 set t {} 1497 set t {}
1498 set index $start_index
1479 for {set i 0} {$i < $number} {incr i} { 1499 for {set i 0} {$i < $number} {incr i} {
1480 lappend t [list $varname.$i $i 0 $type] 1500 » lappend t [list $varname.$index $index 0 $type]
1501 » incr index
1481 } 1502 }
1482 mi_list_varobj_children $varname $t $testname 1503 mi_list_varobj_children $varname $t $testname
1483 } 1504 }
1484 1505
1485 # A list of two-element lists. First element of each list is 1506 # A list of two-element lists. First element of each list is
1486 # a Tcl statement, and the second element is the line 1507 # a Tcl statement, and the second element is the line
1487 # number of source C file where the statement originates. 1508 # number of source C file where the statement originates.
1488 set mi_autotest_data "" 1509 set mi_autotest_data ""
1489 # The name of the source file for autotesting. 1510 # The name of the source file for autotesting.
1490 set mi_autotest_source "" 1511 set mi_autotest_source ""
1491 1512
1492 proc count_newlines { string } { 1513 proc count_newlines { string } {
1493 return [regexp -all "\n" $string] 1514 return [regexp -all "\n" $string]
1494 } 1515 }
1495 1516
1496 # Prepares for running inline tests in FILENAME. 1517 # Prepares for running inline tests in FILENAME.
1497 # See comments for mi_run_inline_test for detailed 1518 # See comments for mi_run_inline_test for detailed
1498 # explanation of the idea and syntax. 1519 # explanation of the idea and syntax.
1499 proc mi_prepare_inline_tests { filename } { 1520 proc mi_prepare_inline_tests { filename } {
1500 1521
1501 global srcdir 1522 global srcdir
1502 global subdir 1523 global subdir
1503 global mi_autotest_source 1524 global mi_autotest_source
1504 global mi_autotest_data 1525 global mi_autotest_data
1505 1526
1506 set mi_autotest_data {} 1527 set mi_autotest_data {}
1507 1528
1508 set mi_autotest_source $filename 1529 set mi_autotest_source $filename
1509 1530
1510 if { ! [regexp "^/" "$filename"] } then { 1531 if { ! [regexp "^/" "$filename"] } then {
1511 set filename "$srcdir/$subdir/$filename" 1532 set filename "$srcdir/$subdir/$filename"
1512 } 1533 }
1513 1534
1514 set chan [open $filename] 1535 set chan [open $filename]
1515 set content [read $chan] 1536 set content [read $chan]
1516 set line_number 1 1537 set line_number 1
1517 while {1} { 1538 while {1} {
1518 set start [string first "/*:" $content] 1539 » set start [string first "/*:" $content]
1519 if {$start != -1} { 1540 » if {$start != -1} {
1520 set end [string first ":*/" $content] 1541 » set end [string first ":*/" $content]
1521 if {$end == -1} { 1542 » if {$end == -1} {
1522 error "Unterminated special comment in $filename" 1543 » » error "Unterminated special comment in $filename"
1523 } 1544 » }
1524
1525 set prefix [string range $content 0 $start]
1526 set prefix_newlines [count_newlines $prefix]
1527
1528 set line_number [expr $line_number+$prefix_newlines]
1529 set comment_line $line_number
1530 1545
1531 set comment [string range $content [expr $start+3] [expr $end-1]] 1546 » set prefix [string range $content 0 $start]
1547 » set prefix_newlines [count_newlines $prefix]
1532 1548
1533 set comment_newlines [count_newlines $comment] 1549 » set line_number [expr $line_number+$prefix_newlines]
1534 set line_number [expr $line_number+$comment_newlines] 1550 » set comment_line $line_number
1535 1551
1536 set comment [string trim $comment] 1552 » set comment [string range $content [expr $start+3] [expr $end-1]]
1537 set content [string range $content [expr $end+3] \ 1553
1538 [string length $content]] 1554 » set comment_newlines [count_newlines $comment]
1539 lappend mi_autotest_data [list $comment $comment_line] 1555 » set line_number [expr $line_number+$comment_newlines]
1540 } else { 1556
1541 break 1557 » set comment [string trim $comment]
1542 } 1558 » set content [string range $content [expr $end+3] \
1559 » » » [string length $content]]
1560 » lappend mi_autotest_data [list $comment $comment_line]
1561 » } else {
1562 » break
1563 » }
1543 } 1564 }
1544 close $chan 1565 close $chan
1545 } 1566 }
1546 1567
1547 # Helper to mi_run_inline_test below. 1568 # Helper to mi_run_inline_test below.
1548 # Return the list of all (statement,line_number) lists 1569 # Return the list of all (statement,line_number) lists
1549 # that comprise TESTCASE. The begin and end markers 1570 # that comprise TESTCASE. The begin and end markers
1550 # are not included. 1571 # are not included.
1551 proc mi_get_inline_test {testcase} { 1572 proc mi_get_inline_test {testcase} {
1552 1573
1553 global mi_gdb_prompt 1574 global mi_gdb_prompt
1554 global mi_autotest_data 1575 global mi_autotest_data
1555 global mi_autotest_source 1576 global mi_autotest_source
1556 1577
1557 set result {} 1578 set result {}
1558 1579
1559 set seen_begin 0 1580 set seen_begin 0
1560 set seen_end 0 1581 set seen_end 0
1561 foreach l $mi_autotest_data { 1582 foreach l $mi_autotest_data {
1562 1583
1563 set comment [lindex $l 0] 1584 » set comment [lindex $l 0]
1564 1585
1565 if {$comment == "BEGIN: $testcase"} { 1586 » if {$comment == "BEGIN: $testcase"} {
1566 set seen_begin 1 1587 » set seen_begin 1
1567 } elseif {$comment == "END: $testcase"} { 1588 » } elseif {$comment == "END: $testcase"} {
1568 set seen_end 1 1589 » set seen_end 1
1569 break 1590 » break
1570 } elseif {$seen_begin==1} { 1591 » } elseif {$seen_begin==1} {
1571 lappend result $l 1592 » lappend result $l
1572 } 1593 » }
1573 } 1594 }
1574 1595
1575 if {$seen_begin == 0} { 1596 if {$seen_begin == 0} {
1576 error "Autotest $testcase not found" 1597 » error "Autotest $testcase not found"
1577 } 1598 }
1578 1599
1579 if {$seen_begin == 1 && $seen_end == 0} { 1600 if {$seen_begin == 1 && $seen_end == 0} {
1580 error "Missing end marker for test $testcase" 1601 » error "Missing end marker for test $testcase"
1581 } 1602 }
1582 1603
1583 return $result 1604 return $result
1584 } 1605 }
1585 1606
1586 # Sets temporary breakpoint at LOCATION. 1607 # Sets temporary breakpoint at LOCATION.
1587 proc mi_tbreak {location} { 1608 proc mi_tbreak {location} {
1588 1609
1589 global mi_gdb_prompt 1610 global mi_gdb_prompt
1590 1611
1591 mi_gdb_test "-break-insert -t $location" \ 1612 mi_gdb_test "-break-insert -t $location" \
1592 {\^done,bkpt=.*} \ 1613 » {\^done,bkpt=.*} \
1593 "run to $location (set breakpoint)" 1614 » "run to $location (set breakpoint)"
1594 } 1615 }
1595 1616
1596 # Send COMMAND that must be a command that resumes 1617 # Send COMMAND that must be a command that resumes
1597 # the inferior (run/continue/next/etc) and consumes 1618 # the inferior (run/continue/next/etc) and consumes
1598 # the "^running" output from it. 1619 # the "^running" output from it.
1599 proc mi_send_resuming_command_raw {command test} { 1620 proc mi_send_resuming_command_raw {command test} {
1600 1621
1601 global mi_gdb_prompt 1622 global mi_gdb_prompt
1602 global thread_selected_re 1623 global thread_selected_re
1603 global library_loaded_re 1624 global library_loaded_re
1604 1625
1605 send_gdb "$command\n" 1626 send_gdb "$command\n"
1606 gdb_expect { 1627 gdb_expect {
1607 -re "\\^running\r\n\\*running,thread-id=\"\[^\"\]+\"\r\n($library_loaded _re)*($thread_selected_re)?${mi_gdb_prompt}" { 1628 » -re "\\^running\r\n\\*running,thread-id=\"\[^\"\]+\"\r\n($library_loaded _re)*($thread_selected_re)?${mi_gdb_prompt}" {
1608 # Note that lack of 'pass' call here -- this works around limitation 1629 » # Note that lack of 'pass' call here -- this works around limitation
1609 # in DejaGNU xfail mechanism. mi-until.exp has this: 1630 » # in DejaGNU xfail mechanism. mi-until.exp has this:
1610 # 1631 » #
1611 # setup_kfail gdb/2104 "*-*-*" 1632 » # setup_kfail gdb/2104 "*-*-*"
1612 # mi_execute_to ... 1633 » # mi_execute_to ...
1613 # 1634 » #
1614 # and mi_execute_to uses mi_send_resuming_command. If we use 'pass' here, 1635 » # and mi_execute_to uses mi_send_resuming_command. If we use 'pass' here,
1615 # it will reset kfail, so when the actual test fails, it will be fla gged 1636 » # it will reset kfail, so when the actual test fails, it will be fla gged
1616 # as real failure. 1637 » # as real failure.
1617 return 0 1638 return 0
1618 } 1639 » }
1619 -re "\\^error,msg=\"Displaced stepping is only supported in ARM mode\".* " { 1640 » -re "\\^error,msg=\"Displaced stepping is only supported in ARM mode\".* " {
1620 unsupported "$test (Thumb mode)" 1641 » unsupported "$test (Thumb mode)"
1621 return -1
1622 }
1623 -re "\\^error,msg=.*" {
1624 fail "$test (MI error)"
1625 return -1
1626 }
1627 -re ".*${mi_gdb_prompt}" {
1628 fail "$test (failed to resume)"
1629 return -1 1642 return -1
1630 } 1643 » }
1631 timeout { 1644 » -re "\\^error,msg=.*" {
1645 » fail "$test (MI error)"
1646 » return -1
1647 » }
1648 » -re ".*${mi_gdb_prompt}" {
1649 » fail "$test (failed to resume)"
1650 » return -1
1651 » }
1652 » timeout {
1632 fail "$test" 1653 fail "$test"
1633 return -1 1654 return -1
1634 } 1655 » }
1635 } 1656 }
1636 } 1657 }
1637 1658
1638 proc mi_send_resuming_command {command test} { 1659 proc mi_send_resuming_command {command test} {
1639 mi_send_resuming_command_raw -$command $test 1660 mi_send_resuming_command_raw -$command $test
1640 } 1661 }
1641 1662
1642 # Helper to mi_run_inline_test below. 1663 # Helper to mi_run_inline_test below.
1643 # Sets a temporary breakpoint at LOCATION and runs 1664 # Sets a temporary breakpoint at LOCATION and runs
1644 # the program using COMMAND. When the program is stopped 1665 # the program using COMMAND. When the program is stopped
1645 # returns the line at which it. Returns -1 if line cannot 1666 # returns the line at which it. Returns -1 if line cannot
1646 # be determined. 1667 # be determined.
1647 # Does not check that the line is the same as requested. 1668 # Does not check that the line is the same as requested.
1648 # The caller can check itself if required. 1669 # The caller can check itself if required.
1649 proc mi_continue_to_line {location test} { 1670 proc mi_continue_to_line {location test} {
1650 1671
1651 mi_tbreak $location 1672 mi_tbreak $location
1652 mi_send_resuming_command "exec-continue" "run to $location (exec-continue)" 1673 mi_send_resuming_command "exec-continue" "run to $location (exec-continue)"
1653 return [mi_get_stop_line $test] 1674 return [mi_get_stop_line $test]
1654 } 1675 }
1655 1676
1656 # Wait until gdb prints the current line. 1677 # Wait until gdb prints the current line.
1657 proc mi_get_stop_line {test} { 1678 proc mi_get_stop_line {test} {
1658 1679
1659 global mi_gdb_prompt 1680 global mi_gdb_prompt
1660 global async 1681 global async
1661 1682
1662 if {$async} { 1683 if {$async} {
1663 set prompt_re "" 1684 set prompt_re ""
1664 } else { 1685 } else {
1665 set prompt_re "$mi_gdb_prompt$" 1686 set prompt_re "$mi_gdb_prompt$"
1666 } 1687 }
1667 1688
1668 gdb_expect { 1689 gdb_expect {
1669 -re ".*line=\"(\[0-9\]*)\".*\r\n$prompt_re" { 1690 -re ".*line=\"(\[0-9\]*)\".*\r\n$prompt_re" {
1670 return $expect_out(1,string) 1691 » return $expect_out(1,string)
1671 } 1692 }
1672 -re ".*$mi_gdb_prompt" { 1693 -re ".*$mi_gdb_prompt" {
1673 fail "wait for stop ($test)" 1694 » fail "wait for stop ($test)"
1674 } 1695 }
1675 timeout { 1696 timeout {
1676 fail "wait for stop ($test)" 1697 » fail "wait for stop ($test)"
1677 } 1698 }
1678 } 1699 }
1679 } 1700 }
1680 1701
1681 # Run a MI test embedded in comments in a C file. 1702 # Run a MI test embedded in comments in a C file.
1682 # The C file should contain special comments in the following 1703 # The C file should contain special comments in the following
1683 # three forms: 1704 # three forms:
1684 # 1705 #
1685 # /*: BEGIN: testname :*/ 1706 # /*: BEGIN: testname :*/
1686 # /*: <Tcl statements> :*/ 1707 # /*: <Tcl statements> :*/
(...skipping 29 matching lines...) Expand all
1716 global decimal 1737 global decimal
1717 global fullname_syntax 1738 global fullname_syntax
1718 global mi_autotest_source 1739 global mi_autotest_source
1719 1740
1720 set commands [mi_get_inline_test $testcase] 1741 set commands [mi_get_inline_test $testcase]
1721 1742
1722 set first 1 1743 set first 1
1723 set line_now 1 1744 set line_now 1
1724 1745
1725 foreach c $commands { 1746 foreach c $commands {
1726 set statements [lindex $c 0] 1747 » set statements [lindex $c 0]
1727 set line [lindex $c 1] 1748 » set line [lindex $c 1]
1728 set line [expr $line-1] 1749 » set line [expr $line-1]
1729 1750
1730 # We want gdb to be stopped at the expression immediately 1751 » # We want gdb to be stopped at the expression immediately
1731 # before the comment. If this is the first comment, the 1752 » # before the comment. If this is the first comment, the
1732 # program is either not started yet or is in some random place, 1753 » # program is either not started yet or is in some random place,
1733 # so we run it. For further comments, we might be already 1754 » # so we run it. For further comments, we might be already
1734 # standing at the right line. If not continue till the 1755 » # standing at the right line. If not continue till the
1735 # right line. 1756 » # right line.
1736 1757
1737 if {$first==1} { 1758 » if {$first==1} {
1738 # Start the program afresh. 1759 » # Start the program afresh.
1739 mi_tbreak "$mi_autotest_source:$line" 1760 » mi_tbreak "$mi_autotest_source:$line"
1740 mi_run_cmd 1761 » mi_run_cmd
1741 set line_now [mi_get_stop_line "$testcase: step to $line"] 1762 » set line_now [mi_get_stop_line "$testcase: step to $line"]
1742 set first 0 1763 » set first 0
1743 } elseif {$line_now!=$line} { 1764 » } elseif {$line_now!=$line} {
1744 set line_now [mi_continue_to_line "$mi_autotest_source:$line" "conti nue to $line"] 1765 » set line_now [mi_continue_to_line "$mi_autotest_source:$line" "conti nue to $line"]
1745 } 1766 » }
1746 1767
1747 if {$line_now!=$line} { 1768 » if {$line_now!=$line} {
1748 fail "$testcase: go to line $line" 1769 » fail "$testcase: go to line $line"
1749 } 1770 » }
1750 1771
1751 # We're not at the statement right above the comment. 1772 » # We're not at the statement right above the comment.
1752 # Execute that statement so that the comment can test 1773 » # Execute that statement so that the comment can test
1753 # the state after the statement is executed. 1774 » # the state after the statement is executed.
1754 1775
1755 # Single-step past the line. 1776 » # Single-step past the line.
1756 if { [mi_send_resuming_command "exec-next" "$testcase: step over $line"] != 0 } { 1777 » if { [mi_send_resuming_command "exec-next" "$testcase: step over $line"] != 0 } {
1757 return -1 1778 return -1
1758 } 1779 }
1759 set line_now [mi_get_stop_line "$testcase: step over $line"] 1780 set line_now [mi_get_stop_line "$testcase: step over $line"]
1760 1781
1761 # We probably want to use 'uplevel' so that statements 1782 » # We probably want to use 'uplevel' so that statements
1762 # have direct access to global variables that the 1783 » # have direct access to global variables that the
1763 # main 'exp' file has set up. But it's not yet clear, 1784 » # main 'exp' file has set up. But it's not yet clear,
1764 # will need more experience to be sure. 1785 » # will need more experience to be sure.
1765 eval $statements 1786 » eval $statements
1766 } 1787 }
1767 } 1788 }
1768 1789
1769 proc get_mi_thread_list {name} { 1790 proc get_mi_thread_list {name} {
1770 global expect_out 1791 global expect_out
1771 1792
1772 # MI will return a list of thread ids: 1793 # MI will return a list of thread ids:
1773 # 1794 #
1774 # -thread-list-ids 1795 # -thread-list-ids
1775 # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N" 1796 # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 incr field_idx 2274 incr field_idx
2254 } 2275 }
2255 2276
2256 return $children_list 2277 return $children_list
2257 } 2278 }
2258 2279
2259 # The main procedure to call the given CALLBACK on the elements of the 2280 # The main procedure to call the given CALLBACK on the elements of the
2260 # given varobj TREE. See detailed explanation above. 2281 # given varobj TREE. See detailed explanation above.
2261 proc walk_tree {language tree callback} { 2282 proc walk_tree {language tree callback} {
2262 global root 2283 global root
2284 variable _root_idx
2263 2285
2264 if {[llength $tree] < 3} { 2286 if {[llength $tree] < 3} {
2265 error "tree does not contain enough elements" 2287 error "tree does not contain enough elements"
2266 } 2288 }
2267 2289
2290 set _root_idx 0
2291
2268 # Create root node and process the tree. 2292 # Create root node and process the tree.
2269 array set root [list language $language] 2293 array set root [list language $language]
2270 array set root [list obj_name "root"] 2294 array set root [list obj_name "root"]
2271 array set root [list display_name "root"] 2295 array set root [list display_name "root"]
2272 array set root [list type "root"] 2296 array set root [list type "root"]
2273 array set root [list path_expr "root"] 2297 array set root [list path_expr "root"]
2274 array set root [list parent "root"] 2298 array set root [list parent "root"]
2275 array set root [list children [get_tree_children root $tree]] 2299 array set root [list children [get_tree_children root $tree]]
2276 2300
2277 # Walk the tree 2301 # Walk the tree
(...skipping 30 matching lines...) Expand all
2308 ::varobj_tree::test_children_callback $variable 2332 ::varobj_tree::test_children_callback $variable
2309 } 2333 }
2310 2334
2311 # Walk the variable object tree given by TREE, calling the specified 2335 # Walk the variable object tree given by TREE, calling the specified
2312 # CALLBACK. By default this uses mi_varobj_tree_test_children_callback. 2336 # CALLBACK. By default this uses mi_varobj_tree_test_children_callback.
2313 proc mi_walk_varobj_tree {language tree \ 2337 proc mi_walk_varobj_tree {language tree \
2314 {callback \ 2338 {callback \
2315 mi_varobj_tree_test_children_callback}} { 2339 mi_varobj_tree_test_children_callback}} {
2316 ::varobj_tree::walk_tree $language $tree $callback 2340 ::varobj_tree::walk_tree $language $tree $callback
2317 } 2341 }
OLDNEW
« no previous file with comments | « gdb/testsuite/lib/java.exp ('k') | gdb/testsuite/lib/objc.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698