1 # Copyright (C) 1998 Cygnus Solutions
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Keith Seitz (keiths@cygnus.com)
22 # Read in the standard defs file
24 if {![gdbtk_read_defs]} {
28 global objdir test_ran
30 set console [ManagedWin::open Console]
31 set text [$console get_text]
35 # Helper functions for this module #
40 # Invoke STRING as a command in the console window and
42 proc console_command {string} {
45 # Save current position
46 set line [lindex [split [$text index cmdmark] .] 0]
49 # Insert and invoke command
50 $text insert end $string
55 set end [lindex [split [$text index cmdmark] .] 0]
57 return [$text get $line.0 [list $end.0 lineend]]
61 # Return the command line
62 proc get_cmd_line {} {
66 set index [$text index cmdmark]
67 return [$text get [list $index linestart] [list $index lineend]]
70 # clear_command_line --
71 # Clear the command line
72 proc clear_command_line {} {
74 $text delete {cmdmark + 1 char} insert
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) }
93 $text get {cmdmark linestart} {cmdmark lineend}
96 console_command {set prompt (gdb) }
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...
109 .test_text insert end "this is some pasted text"
110 .test_text tag add sel 1.0 {1.0 lineend}
112 event generate $text <<Paste>>
114 } {(gdb) this is some pasted text}
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".
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 <Up>
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 <Up>
179 event generate $text <Up>
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}
205 for {set i 0} {$i < 4} {incr i} {
206 event generate $text <Up>
209 } {(gdb) show remotedevice}
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 <Up>
236 } {(gdb) show annotate}
241 # Test: console-history-2.1
242 # Desc: Exercise the down-history functionality
243 gdbtk_test console-history-2.1 {down once} {
244 # Add some commands into the command buffer
245 console_command {show annotate}
246 console_command {show complaints}
247 console_command {show confirm}
248 console_command {show height}
249 console_command {show language}
250 console_command {show print demangle}
251 console_command {show remotebaud}
252 console_command {show remotebreak}
253 console_command {show remotecache}
254 console_command {show remotedebug}
255 console_command {show remotedevice}
256 console_command {show remotelogbase}
257 console_command {help quit}
258 console_command {help si}
260 for {set i 0} {$i < 14} {incr i} {
261 event generate $text <Up>
263 event generate $text <Down>
265 } {(gdb) show complaints}
270 # Test: console-history-2.2
271 # Desc: Exercise the down-history functionality
272 gdbtk_test console-history-2.2 {down twice} {
273 # Add some commands into the command buffer
274 console_command {show annotate}
275 console_command {show complaints}
276 console_command {show confirm}
277 console_command {show height}
278 console_command {show language}
279 console_command {show print demangle}
280 console_command {show remotebaud}
281 console_command {show remotebreak}
282 console_command {show remotecache}
283 console_command {show remotedebug}
284 console_command {show remotedevice}
285 console_command {show remotelogbase}
286 console_command {help quit}
287 console_command {help si}
289 for {set i 0} {$i < 14} {incr i} {
290 event generate $text <Up>
293 event generate $text <Down>
294 event generate $text <Down>
296 } {(gdb) show confirm}
301 # Test: console-history-2.3
302 # Desc: Exercise the down-history functionality
303 gdbtk_test console-history-2.3 {down four times} {
304 # Add some commands into the command buffer
305 console_command {show annotate}
306 console_command {show complaints}
307 console_command {show confirm}
308 console_command {show height}
309 console_command {show language}
310 console_command {show print demangle}
311 console_command {show remotebaud}
312 console_command {show remotebreak}
313 console_command {show remotecache}
314 console_command {show remotedebug}
315 console_command {show remotedevice}
316 console_command {show remotelogbase}
317 console_command {help quit}
318 console_command {help si}
320 for {set i 0} {$i < 14} {incr i} {
321 event generate $text <Up>
324 for {set i 0} {$i < 4} {incr i} {
325 event generate $text <Down>
328 } {(gdb) show language}
333 # Test: console-history-2.4
334 # Desc: Exercise the down-history functionality
335 gdbtk_test console-history-2.4 {down infinitely} {
336 # Add some commands into the command buffer
337 console_command {show annotate}
338 console_command {show complaints}
339 console_command {show confirm}
340 console_command {show height}
341 console_command {show language}
342 console_command {show print demangle}
343 console_command {show remotebaud}
344 console_command {show remotebreak}
345 console_command {show remotecache}
346 console_command {show remotedebug}
347 console_command {show remotedevice}
348 console_command {show remotelogbase}
349 console_command {help quit}
350 console_command {help si}
351 for {set i 0} {$i < 14} {incr i} {
352 event generate $text <Up>
355 for {set i 0} {$i < 20} {incr i} {
356 event generate $text <Down>
365 # gdb - gdbtk Interface Tests
368 # Test: console-interface-1.1
369 # Desc: Verify that a "file" command in the console window causes
370 # gdb to invoke the pre-/post-add-symbol hooks
372 gdbtk_test console-interface-1.1 {file command goes through hooks} {
373 global TEST1_RESULT TEST2_RESULT
375 # This is really ugly, but its the only way to do this...
376 rename gdbtk_tcl_pre_add_symbol pre_add
377 rename gdbtk_tcl_post_add_symbol post_add
379 proc gdbtk_tcl_pre_add_symbol {file} {
382 set TEST1_RESULT $file
385 proc gdbtk_tcl_post_add_symbol {} {
392 # load a file and make sure we went through the pre/post_add_symbol hooks
395 set file [file join $objdir simple]
396 console_command "file $file"
397 if {$TEST1_RESULT != $file} {
398 set result "did not go through gdbtk_tcl_pre_add_symbol ($TEST1_RESULT)"
399 } elseif {$TEST2_RESULT != "ok"} {
400 set result "did not go through gdbtk_tcl_post_add_symbol"
409 rename gdbtk_tcl_pre_add_symbol {}
410 rename gdbtk_tcl_post_add_symbol {}
411 rename pre_add gdbtk_tcl_pre_add_symbol
412 rename post_add gdbtk_tcl_post_add_symbol