1 |
578 |
markom |
# Copyright (C) 1998, 1999 Cygnus Solutions
|
2 |
|
|
#
|
3 |
|
|
# This program is free software; you can redistribute it and/or modify
|
4 |
|
|
# it under the terms of the GNU General Public License as published by
|
5 |
|
|
# the Free Software Foundation; either version 2 of the License, or
|
6 |
|
|
# (at your option) any later version.
|
7 |
|
|
#
|
8 |
|
|
# This program is distributed in the hope that it will be useful,
|
9 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11 |
|
|
# GNU General Public License for more details.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with this program; if not, write to the Free Software
|
15 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# bug-gdb@prep.ai.mit.edu
|
19 |
|
|
|
20 |
|
|
# This file was written by Keith Seitz (keiths@cygnus.com)
|
21 |
|
|
|
22 |
|
|
# Read in the standard defs file
|
23 |
|
|
|
24 |
|
|
if {![gdbtk_read_defs]} {
|
25 |
|
|
break
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
global objdir test_ran
|
29 |
|
|
global console text
|
30 |
|
|
set console [ManagedWin::open Console]
|
31 |
|
|
set text [$console get_text]
|
32 |
|
|
|
33 |
|
|
##### #####
|
34 |
|
|
# #
|
35 |
|
|
# Helper functions for this module #
|
36 |
|
|
# #
|
37 |
|
|
##### #####
|
38 |
|
|
|
39 |
|
|
# console_command --
|
40 |
|
|
# Invoke STRING as a command in the console window and
|
41 |
|
|
# return the result
|
42 |
|
|
proc console_command {string} {
|
43 |
|
|
global console text
|
44 |
|
|
|
45 |
|
|
# Save current position
|
46 |
|
|
set line [lindex [split [$text index cmdmark] .] 0]
|
47 |
|
|
incr line 1
|
48 |
|
|
|
49 |
|
|
# Insert and invoke command
|
50 |
|
|
$text insert end $string
|
51 |
|
|
$console invoke
|
52 |
|
|
update
|
53 |
|
|
|
54 |
|
|
# Get the result
|
55 |
|
|
set end [lindex [split [$text index cmdmark] .] 0]
|
56 |
|
|
incr end -1
|
57 |
|
|
return [$text get $line.0 [list $end.0 lineend]]
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
# get_cmd_line --
|
61 |
|
|
# Return the command line
|
62 |
|
|
proc get_cmd_line {} {
|
63 |
|
|
global text
|
64 |
|
|
|
65 |
|
|
update
|
66 |
|
|
set index [$text index cmdmark]
|
67 |
|
|
return [$text get [list $index linestart] [list $index lineend]]
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
# clear_command_line --
|
71 |
|
|
# Clear the command line
|
72 |
|
|
proc clear_command_line {} {
|
73 |
|
|
global text
|
74 |
|
|
$text delete {cmdmark + 1 char} insert
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
##### #####
|
78 |
|
|
# #
|
79 |
|
|
# CONSOLE TESTS #
|
80 |
|
|
# #
|
81 |
|
|
##### #####
|
82 |
|
|
|
83 |
|
|
#
|
84 |
|
|
# Miscellaneous tests
|
85 |
|
|
#
|
86 |
|
|
|
87 |
|
|
# Test: console-misc-1
|
88 |
|
|
# Desc: Change console prompt
|
89 |
|
|
gdbtk_test console-misc-1 {change console prompt} {
|
90 |
|
|
# Insert the "set prompt" command into the text widget
|
91 |
|
|
console_command {set prompt (test) }
|
92 |
|
|
|
93 |
|
|
$text get {cmdmark linestart} {cmdmark lineend}
|
94 |
|
|
} {(test) }
|
95 |
|
|
if {$test_ran} {
|
96 |
|
|
console_command {set prompt (gdb) }
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
#
|
100 |
|
|
# Paste tests
|
101 |
|
|
#
|
102 |
|
|
|
103 |
|
|
# Test: console-paste-1
|
104 |
|
|
# Desc: Paste the X selection into console window
|
105 |
|
|
gdbtk_test console-paste-1 {paste X text} {
|
106 |
|
|
# This is cheesy, but it works... Create a text widget
|
107 |
|
|
# which holds the current selection...
|
108 |
|
|
text .test_text
|
109 |
|
|
.test_text insert end "this is some pasted text"
|
110 |
|
|
.test_text tag add sel 1.0 {1.0 lineend}
|
111 |
|
|
event generate .test_text <>
|
112 |
|
|
event generate $text <>
|
113 |
|
|
get_cmd_line
|
114 |
|
|
} {(gdb) this is some pasted text}
|
115 |
|
|
if {$test_ran} {
|
116 |
|
|
destroy .test_text
|
117 |
|
|
clear_command_line
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
#
|
121 |
|
|
# Test for errors
|
122 |
|
|
#
|
123 |
|
|
|
124 |
|
|
# Test: console-error-1
|
125 |
|
|
# Desc: Check if console window reports internal gdb errors
|
126 |
|
|
gdbtk_test console-error-1 {invoke unknown command} {
|
127 |
|
|
console_command {this_command_doesn't_exist}
|
128 |
|
|
} {Error: Undefined command: "this". Try "help".
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
#
|
132 |
|
|
# History tests
|
133 |
|
|
#
|
134 |
|
|
|
135 |
|
|
# Test: console-history-1.1
|
136 |
|
|
# Desc: Exercise the up-history functionality
|
137 |
|
|
gdbtk_test console-history-1.1 {up history once} {
|
138 |
|
|
# Add some commands into the command buffer
|
139 |
|
|
console_command {show annotate}
|
140 |
|
|
console_command {show complaints}
|
141 |
|
|
console_command {show confirm}
|
142 |
|
|
console_command {show height}
|
143 |
|
|
console_command {show language}
|
144 |
|
|
console_command {show print demangle}
|
145 |
|
|
console_command {show remotebaud}
|
146 |
|
|
console_command {show remotebreak}
|
147 |
|
|
console_command {show remotecache}
|
148 |
|
|
console_command {show remotedebug}
|
149 |
|
|
console_command {show remotedevice}
|
150 |
|
|
console_command {show remotelogbase}
|
151 |
|
|
console_command {help quit}
|
152 |
|
|
console_command {help si}
|
153 |
|
|
event generate $text
|
154 |
|
|
get_cmd_line
|
155 |
|
|
} {(gdb) help si}
|
156 |
|
|
if {$test_ran} {
|
157 |
|
|
clear_command_line
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
# Test: console-history-1.2
|
161 |
|
|
# Desc: Exercise the up-history functionality
|
162 |
|
|
gdbtk_test console-history-1.2 {up history twice} {
|
163 |
|
|
# Add some commands into the command buffer
|
164 |
|
|
console_command {show annotate}
|
165 |
|
|
console_command {show complaints}
|
166 |
|
|
console_command {show confirm}
|
167 |
|
|
console_command {show height}
|
168 |
|
|
console_command {show language}
|
169 |
|
|
console_command {show print demangle}
|
170 |
|
|
console_command {show remotebaud}
|
171 |
|
|
console_command {show remotebreak}
|
172 |
|
|
console_command {show remotecache}
|
173 |
|
|
console_command {show remotedebug}
|
174 |
|
|
console_command {show remotedevice}
|
175 |
|
|
console_command {show remotelogbase}
|
176 |
|
|
console_command {help quit}
|
177 |
|
|
console_command {help si}
|
178 |
|
|
event generate $text
|
179 |
|
|
event generate $text
|
180 |
|
|
get_cmd_line
|
181 |
|
|
} {(gdb) help quit}
|
182 |
|
|
if {$test_ran} {
|
183 |
|
|
clear_command_line
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
# Test: console-history-1.3
|
187 |
|
|
# Desc: Exercise the up-history functionality
|
188 |
|
|
gdbtk_test console-history-1.3 {up history four times} {
|
189 |
|
|
# Add some commands into the command buffer
|
190 |
|
|
console_command {show annotate}
|
191 |
|
|
console_command {show complaints}
|
192 |
|
|
console_command {show confirm}
|
193 |
|
|
console_command {show height}
|
194 |
|
|
console_command {show language}
|
195 |
|
|
console_command {show print demangle}
|
196 |
|
|
console_command {show remotebaud}
|
197 |
|
|
console_command {show remotebreak}
|
198 |
|
|
console_command {show remotecache}
|
199 |
|
|
console_command {show remotedebug}
|
200 |
|
|
console_command {show remotedevice}
|
201 |
|
|
console_command {show remotelogbase}
|
202 |
|
|
console_command {help quit}
|
203 |
|
|
console_command {help si}
|
204 |
|
|
|
205 |
|
|
for {set i 0} {$i < 4} {incr i} {
|
206 |
|
|
event generate $text
|
207 |
|
|
}
|
208 |
|
|
get_cmd_line
|
209 |
|
|
} {(gdb) show remotedevice}
|
210 |
|
|
if {$test_ran} {
|
211 |
|
|
clear_command_line
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
# Test: console-history-1.4
|
215 |
|
|
# Desc: Exercise the up-history functionality
|
216 |
|
|
gdbtk_test console-history-1.4 {up fourteen times} {
|
217 |
|
|
# Add some commands into the command buffer
|
218 |
|
|
console_command {show annotate}
|
219 |
|
|
console_command {show complaints}
|
220 |
|
|
console_command {show confirm}
|
221 |
|
|
console_command {show height}
|
222 |
|
|
console_command {show language}
|
223 |
|
|
console_command {show print demangle}
|
224 |
|
|
console_command {show remotebaud}
|
225 |
|
|
console_command {show remotebreak}
|
226 |
|
|
console_command {show remotecache}
|
227 |
|
|
console_command {show remotedebug}
|
228 |
|
|
console_command {show remotedevice}
|
229 |
|
|
console_command {show remotelogbase}
|
230 |
|
|
console_command {help quit}
|
231 |
|
|
console_command {help si}
|
232 |
|
|
for {set i 0} {$i < 14} {incr i} {
|
233 |
|
|
event generate $text
|
234 |
|
|
}
|
235 |
|
|
get_cmd_line
|
236 |
|
|
} {(gdb) show annotate}
|
237 |
|
|
if {$test_ran} {
|
238 |
|
|
clear_command_line
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
# Test: console-history-1.5
|
242 |
|
|
# Desc: Exercise the up-history search functionality
|
243 |
|
|
gdbtk_test console-history-1.5 {up search} {
|
244 |
|
|
# Add some commands into the command buffer
|
245 |
|
|
console_command {show height}
|
246 |
|
|
console_command {show annotate}
|
247 |
|
|
console_command {show complaints}
|
248 |
|
|
console_command {print main}
|
249 |
|
|
console_command {show remotelogbase}
|
250 |
|
|
console_command {help quit}
|
251 |
|
|
console_command {help si}
|
252 |
|
|
|
253 |
|
|
$text insert end "sh"
|
254 |
|
|
event generate $text
|
255 |
|
|
event generate $text
|
256 |
|
|
event generate $text
|
257 |
|
|
get_cmd_line
|
258 |
|
|
} {(gdb) show annotate}
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
# Test: console-history-1.6
|
262 |
|
|
# Desc: Exercise the down-history search functionality
|
263 |
|
|
gdbtk_test console-history-1.6 {down search} {
|
264 |
|
|
event generate $text
|
265 |
|
|
event generate $text
|
266 |
|
|
get_cmd_line
|
267 |
|
|
} {(gdb) show remotelogbase}
|
268 |
|
|
|
269 |
|
|
# Test: console-history-1.7
|
270 |
|
|
# Desc: Down-history search to bottom
|
271 |
|
|
# We go back down until the original partialcommand is displayed
|
272 |
|
|
gdbtk_test console-history-1.7 {down search to bottom} {
|
273 |
|
|
event generate $text
|
274 |
|
|
event generate $text
|
275 |
|
|
get_cmd_line
|
276 |
|
|
} {(gdb) sh}
|
277 |
|
|
|
278 |
|
|
# Test: console-history-1.8
|
279 |
|
|
# Desc: Up-history search to top
|
280 |
|
|
# We go up until there are no matches
|
281 |
|
|
gdbtk_test console-history-1.8 {up search to top} {
|
282 |
|
|
for {set i 0} {$i < 100} {incr i} {
|
283 |
|
|
event generate $text
|
284 |
|
|
}
|
285 |
|
|
get_cmd_line
|
286 |
|
|
} {(gdb) show annotate}
|
287 |
|
|
|
288 |
|
|
if {$test_ran} {
|
289 |
|
|
clear_command_line
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
# Test: console-history-2.1
|
293 |
|
|
# Desc: Exercise the down-history functionality
|
294 |
|
|
gdbtk_test console-history-2.1 {down once} {
|
295 |
|
|
# Add some commands into the command buffer
|
296 |
|
|
console_command {show annotate}
|
297 |
|
|
console_command {show complaints}
|
298 |
|
|
console_command {show confirm}
|
299 |
|
|
console_command {show height}
|
300 |
|
|
console_command {show language}
|
301 |
|
|
console_command {show print demangle}
|
302 |
|
|
console_command {show remotebaud}
|
303 |
|
|
console_command {show remotebreak}
|
304 |
|
|
console_command {show remotecache}
|
305 |
|
|
console_command {show remotedebug}
|
306 |
|
|
console_command {show remotedevice}
|
307 |
|
|
console_command {show remotelogbase}
|
308 |
|
|
console_command {help quit}
|
309 |
|
|
console_command {help si}
|
310 |
|
|
|
311 |
|
|
for {set i 0} {$i < 14} {incr i} {
|
312 |
|
|
event generate $text
|
313 |
|
|
}
|
314 |
|
|
event generate $text
|
315 |
|
|
get_cmd_line
|
316 |
|
|
} {(gdb) show complaints}
|
317 |
|
|
if {$test_ran} {
|
318 |
|
|
clear_command_line
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
# Test: console-history-2.2
|
322 |
|
|
# Desc: Exercise the down-history functionality
|
323 |
|
|
gdbtk_test console-history-2.2 {down twice} {
|
324 |
|
|
# Add some commands into the command buffer
|
325 |
|
|
console_command {show annotate}
|
326 |
|
|
console_command {show complaints}
|
327 |
|
|
console_command {show confirm}
|
328 |
|
|
console_command {show height}
|
329 |
|
|
console_command {show language}
|
330 |
|
|
console_command {show print demangle}
|
331 |
|
|
console_command {show remotebaud}
|
332 |
|
|
console_command {show remotebreak}
|
333 |
|
|
console_command {show remotecache}
|
334 |
|
|
console_command {show remotedebug}
|
335 |
|
|
console_command {show remotedevice}
|
336 |
|
|
console_command {show remotelogbase}
|
337 |
|
|
console_command {help quit}
|
338 |
|
|
console_command {help si}
|
339 |
|
|
|
340 |
|
|
for {set i 0} {$i < 14} {incr i} {
|
341 |
|
|
event generate $text
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
event generate $text
|
345 |
|
|
event generate $text
|
346 |
|
|
get_cmd_line
|
347 |
|
|
} {(gdb) show confirm}
|
348 |
|
|
if {$test_ran} {
|
349 |
|
|
clear_command_line
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
# Test: console-history-2.3
|
353 |
|
|
# Desc: Exercise the down-history functionality
|
354 |
|
|
gdbtk_test console-history-2.3 {down four times} {
|
355 |
|
|
# Add some commands into the command buffer
|
356 |
|
|
console_command {show annotate}
|
357 |
|
|
console_command {show complaints}
|
358 |
|
|
console_command {show confirm}
|
359 |
|
|
console_command {show height}
|
360 |
|
|
console_command {show language}
|
361 |
|
|
console_command {show print demangle}
|
362 |
|
|
console_command {show remotebaud}
|
363 |
|
|
console_command {show remotebreak}
|
364 |
|
|
console_command {show remotecache}
|
365 |
|
|
console_command {show remotedebug}
|
366 |
|
|
console_command {show remotedevice}
|
367 |
|
|
console_command {show remotelogbase}
|
368 |
|
|
console_command {help quit}
|
369 |
|
|
console_command {help si}
|
370 |
|
|
|
371 |
|
|
for {set i 0} {$i < 14} {incr i} {
|
372 |
|
|
event generate $text
|
373 |
|
|
}
|
374 |
|
|
|
375 |
|
|
for {set i 0} {$i < 4} {incr i} {
|
376 |
|
|
event generate $text
|
377 |
|
|
}
|
378 |
|
|
get_cmd_line
|
379 |
|
|
} {(gdb) show language}
|
380 |
|
|
if {$test_ran} {
|
381 |
|
|
clear_command_line
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
# Test: console-history-2.4
|
385 |
|
|
# Desc: Exercise the down-history functionality
|
386 |
|
|
gdbtk_test console-history-2.4 {down infinitely} {
|
387 |
|
|
# Add some commands into the command buffer
|
388 |
|
|
console_command {show annotate}
|
389 |
|
|
console_command {show complaints}
|
390 |
|
|
console_command {show confirm}
|
391 |
|
|
console_command {show height}
|
392 |
|
|
console_command {show language}
|
393 |
|
|
console_command {show print demangle}
|
394 |
|
|
console_command {show remotebaud}
|
395 |
|
|
console_command {show remotebreak}
|
396 |
|
|
console_command {show remotecache}
|
397 |
|
|
console_command {show remotedebug}
|
398 |
|
|
console_command {show remotedevice}
|
399 |
|
|
console_command {show remotelogbase}
|
400 |
|
|
console_command {help quit}
|
401 |
|
|
console_command {help si}
|
402 |
|
|
for {set i 0} {$i < 14} {incr i} {
|
403 |
|
|
event generate $text
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
for {set i 0} {$i < 20} {incr i} {
|
407 |
|
|
event generate $text
|
408 |
|
|
}
|
409 |
|
|
get_cmd_line
|
410 |
|
|
} {(gdb) }
|
411 |
|
|
if {$test_ran} {
|
412 |
|
|
clear_command_line
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
#
|
416 |
|
|
# gdb - gdbtk Interface Tests
|
417 |
|
|
#
|
418 |
|
|
|
419 |
|
|
# Test: console-interface-1.1
|
420 |
|
|
# Desc: Verify that a "file" command in the console window causes
|
421 |
|
|
# gdb to invoke the pre-/post-add-symbol hooks
|
422 |
|
|
set file_loaded 0
|
423 |
|
|
gdbtk_test console-interface-1.1 {file command goes through hooks} {
|
424 |
|
|
global TEST1_RESULT TEST2_RESULT
|
425 |
|
|
|
426 |
|
|
# This is really ugly, but its the only way to do this...
|
427 |
|
|
rename gdbtk_tcl_pre_add_symbol pre_add
|
428 |
|
|
rename gdbtk_tcl_post_add_symbol post_add
|
429 |
|
|
|
430 |
|
|
proc gdbtk_tcl_pre_add_symbol {file} {
|
431 |
|
|
global TEST1_RESULT
|
432 |
|
|
|
433 |
|
|
set TEST1_RESULT $file
|
434 |
|
|
pre_add $file
|
435 |
|
|
}
|
436 |
|
|
proc gdbtk_tcl_post_add_symbol {} {
|
437 |
|
|
global TEST2_RESULT
|
438 |
|
|
|
439 |
|
|
set TEST2_RESULT ok
|
440 |
|
|
post_add
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
# load a file and make sure we went through the pre/post_add_symbol hooks
|
444 |
|
|
set TEST1_RESULT {}
|
445 |
|
|
set TEST2_RESULT {}
|
446 |
|
|
set file [file join $objdir simple]
|
447 |
|
|
console_command "file $file"
|
448 |
|
|
if {$TEST1_RESULT != $file} {
|
449 |
|
|
set result "did not go through gdbtk_tcl_pre_add_symbol ($TEST1_RESULT)"
|
450 |
|
|
} elseif {$TEST2_RESULT != "ok"} {
|
451 |
|
|
set result "did not go through gdbtk_tcl_post_add_symbol"
|
452 |
|
|
} else {
|
453 |
|
|
set result {}
|
454 |
|
|
set file_loaded 1
|
455 |
|
|
}
|
456 |
|
|
|
457 |
|
|
set result
|
458 |
|
|
} {}
|
459 |
|
|
if {$test_ran} {
|
460 |
|
|
rename gdbtk_tcl_pre_add_symbol {}
|
461 |
|
|
rename gdbtk_tcl_post_add_symbol {}
|
462 |
|
|
rename pre_add gdbtk_tcl_pre_add_symbol
|
463 |
|
|
rename post_add gdbtk_tcl_post_add_symbol
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
#
|
467 |
|
|
# Exit
|
468 |
|
|
#
|
469 |
|
|
gdbtk_test_done
|