1 # Copyright (C) 1999, 2001 Red Hat, Inc.
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 Martin Hunt (hunt@cygnus.com)
22 ###########################################################
23 # same as srcwin.test, except test debugging executables #
24 # build without "-g" #
25 ###########################################################
27 # Read in the standard defs file
29 if {![gdbtk_read_defs]} {
37 # SECTION 1: Mode Tests #
41 # Load the test executable
42 if {$tcl_platform(platform) == "windows"} {
43 set file [file join $objdir list.exe]
45 set file [file join $objdir list]
48 # This isn't a test case, since if this fails, we're hosed.
49 if {[catch {gdb_cmd "file $file" 1} t]} {
50 # an error occured loading the file
51 gdbtk_test_error "loading \"$file\": $t"
54 set srcwin [ManagedWin::open SrcWin]
55 set stw [$srcwin test_get twin]
56 set twin [$stw test_get twin]
57 set statbar [$srcwin test_get _statbar]
64 # Desc: Check for something in source window
65 gdbtk_test srcwin3-1.1 "source window has contents" {
67 set source(main) [$twin get 1.0 end]
68 if {$source(main) == ""} {set r -1}
69 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
74 # Desc: source->assembly mode change
75 gdbtk_test srcwin3-1.2 "source->assembly mode change" {
77 $srcwin mode "" ASSEMBLY
78 set twin [$stw test_get twin]
79 if {$source(main) != [$twin get 1.0 end]} {set r -1}
80 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
85 # Desc: assembly->mixed mode change
86 gdbtk_test srcwin3-1.3 "assembly->mixed mode change" {
89 set twin [$stw test_get twin]
90 if {$source(main) != [$twin get 1.0 end]} {set r -1}
91 if {[$statbar.mode get] != "MIXED"} {set r -2}
96 # Desc: mixed->src+asm mode change
97 gdbtk_test srcwin3-1.4 "mixed->src+asm mode change" {
99 # mode change may fail if fallover to ASSEMBLY fails
100 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
101 set twin [$stw test_get twin]
102 if {[$twin get 1.0 end] != $source(main)} {set r -1}
103 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
108 # Desc: src+asm->source mode change
109 gdbtk_test srcwin3-1.5 "src+asm->source mode change" {
111 $srcwin mode "" SOURCE
112 set twin [$stw test_get twin]
113 if {[$stw test_get bwin] != ""} {set r -2}
114 if {[$twin get 1.0 end] != $source(main)} {set r -1}
115 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
120 # Desc: source->mixed mode change
121 gdbtk_test srcwin3-1.6 "source->mixed mode change" {
123 $srcwin mode "" MIXED
124 set twin [$stw test_get twin]
125 if {[$twin get 1.0 end] != $source(main)} {set r -1}
126 if {[$statbar.mode get] != "MIXED"} {set r -2}
131 # Desc: mixed->source mode change
132 gdbtk_test srcwin3-1.7 "mixed->source mode change" {
134 $srcwin mode "" SOURCE
135 set twin [$stw test_get twin]
136 if {[$twin get 1.0 end] != $source(main)} {set r -1}
137 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
142 # Desc: source->src+asm mode change
143 gdbtk_test srcwin3-1.8 "source->src+asm mode change" {
145 # mode change may fail if fallover to ASSEMBLY fails
146 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
147 set twin [$stw test_get twin]
148 set bwin [$stw test_get bwin]
149 if {[$twin get 1.0 end] != $source(main)} {set r -1}
150 if {$bwin != ""} {set r -2}
151 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
156 # Desc: src+asm->assembly mode change
157 gdbtk_test srcwin3-1.9 "src+asm->assembly mode change" {
159 $srcwin mode "" ASSEMBLY
160 set twin [$stw test_get twin]
161 if {[$twin get 1.0 end] != $source(main)} {set r -1}
162 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
167 # Desc: assembly->src+asm mode change
168 gdbtk_test srcwin3-1.10 "assembly->src+asm mode change" {
170 # mode change may fail if fallover to ASSEMBLY fails
171 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
172 set twin [$stw test_get twin]
173 set bwin [$stw test_get bwin]
174 if {[$twin get 1.0 end] != $source(main)} {set r -1}
175 if {$bwin != ""} {set r -2}
176 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
181 # Desc: src+asm->mixed mode change
182 gdbtk_test srcwin3-1.11 "src+asm->mixed mode change" {
184 $srcwin mode "" MIXED
185 set twin [$stw test_get twin]
186 if {[$twin get 1.0 end] != $source(main)} {set r -1}
187 if {[$statbar.mode get] != "MIXED"} {set r -2}
192 # Desc: mixed->assembly mode change
193 gdbtk_test srcwin3-1.12 "mixed->assembly mode change" {
195 $srcwin mode "" ASSEMBLY
196 set twin [$stw test_get twin]
197 if {[$twin get 1.0 end] != $source(main)} {set r -1}
198 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
203 # Desc: assembly->source mode change
204 gdbtk_test srcwin3-1.13 "assembly->source mode change" {
206 $srcwin mode "" SOURCE
207 set twin [$stw test_get twin]
208 if {[$twin get 1.0 end] != $source(main)} {set r -1}
209 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
216 # SECTION 2: Basic Operations #
221 # Desc: check contents of function combobox
222 # There won't be any because we have no debug info
223 gdbtk_test srcwin3-2.2 "check contents of function combobox" {
224 set names [$statbar.func listget 0 end]
229 # Desc: goto filename - this won't work, but should leave things as they were
230 gdbtk_test srcwin3-2.3 "goto filename" {
231 set func [$srcwin test_get _name 1]
233 set twin [$stw test_get twin]
234 string compare $source(main) [$twin get 1.0 end]
238 # Desc: goto function
239 gdbtk_test srcwin3-2.6 "goto function bar" {
240 $srcwin goto_func "" bar
242 set twin [$stw test_get twin]
243 set source(bar) [$twin get 1.0 end]
245 if {$source(bar) == $source(main)} {set r -1000}
247 # now get a dump of all tags and check that only one line is
248 # marked BROWSE_TAG and no lines are STACK_TAG or PC_TAG.
250 # We know that list1.c should have BROWSE_TAG set at index 5.2
251 # for function "bar". If list1.c is changed or the layout of the source
252 # window is changed, this must be updated.
253 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
256 if {$v == "BROWSE_TAG"} {
259 if {$v == "STACK_TAG"} { incr r 10}
260 if {$v == "PC_TAG"} { incr r 100}
268 # things are OK so far, so just verify the function name is displayed
269 # in the combobox entry field.
270 set names [$statbar.func get]
271 if {[string compare $names "bar"]} {set r -2}
277 # Desc: goto function "oof". This tests that the correct line is highlighted
278 # with BROWSE_TAG and no other lines are highlighted. It also checks that
279 # the combobox has the correct function name in it.
281 gdbtk_test srcwin3-2.7 "goto function oof" {
282 $srcwin goto_func "" oof
285 set twin [$stw test_get twin]
286 set source(oof) [$twin get 1.0 end]
288 if {$source(bar) == $source(oof)} {set r -1000}
289 if {$source(oof) == $source(main)} {set r -2000}
291 # now get a dump of all tags and check that only one line is
292 # marked BROWSE_TAG and no lines are STACK_TAG or PC_TAG.
294 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
297 if {$v == "BROWSE_TAG"} {
300 if {$v == "STACK_TAG"} {incr r 10}
301 if {$v == "PC_TAG"} {incr r 100}
309 # things are OK so far, so just verify the function name is displayed
310 # in the combobox entry field.
311 set names [$statbar.func get]
312 if {[string compare $names "oof"]} {set r -2}
318 # Desc: This test issues a nexti command while browsing oof.
319 # It should jump back to main
320 gdbtk_test srcwin3-2.8 "nexti while browsing" {
321 gdb_immediate "nexti" 1
323 set name [$statbar.name get]
324 set func [$statbar.func get]
326 # check contents of function combobox
327 if {$func != "main"} {set r -2}
328 if {$name != ""} {set r -1}
330 # check that correct file is displayed
331 set twin [$stw test_get twin]
332 set a [$twin get 1.0 end]
333 if {[string compare $source(main) $a]} {set r -3}
337 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
340 if {$v == "PC_TAG"} {
343 if {$v == "STACK_TAG"} {incr r 10}
344 if {$v == "BROWSE_TAG"} {incr r 100}
355 # Desc: This test issues a break and a continue
356 gdbtk_test srcwin3-2.11 "set BP and continue" {
357 gdb_immediate "break oof" 1
358 gdb_immediate "continue" 1
360 set name [$statbar.name get]
361 set func [$statbar.func get]
363 # check contents of name and function comboboxes
364 if {$name != ""} {set r -1}
365 if {$func != "oof"} {set r -2}
367 # check that the correct file is displayed
368 # we must clear the breakpoint first so it doesn't mess up the
370 gdb_immediate "clear oof" 1
371 set twin [$stw test_get twin]
372 set a [$twin get 1.0 end]
373 if {[string compare $source(oof) $a]} {set r -3}
377 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
380 if {$v == "PC_TAG"} {
383 if {$v == "STACK_TAG"} {incr r 10}
384 if {$v == "BROWSE_TAG"} {incr r 100}
396 # SECTION 3: Stack Operations #
401 # Desc: This tests "stack up"
402 gdbtk_test srcwin3-3.1 "stack up (1)" {
405 set name [$statbar.name get]
406 set func [$statbar.func get]
408 # check contents of name and function comboboxes
409 if {$name != ""} {set r -1}
410 if {$func != "long_line"} {set r -2}
412 # check that the correct file is displayed
413 set twin [$stw test_get twin]
414 set source(long_line) [$twin get 1.0 end]
415 if {![string compare $source(long_line) $source(oof)]} {set r -3}
417 # check for PC_TAG and STACK_TAG on correct lines
419 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
422 if {$v == "PC_TAG"} {incr r 5}
423 if {$v == "STACK_TAG"} {incr r}
424 if {$v == "BROWSE_TAG"} {incr r 100}
435 # Desc: Another "stack up" test
436 gdbtk_test srcwin3-3.2 "stack up (2)" {
439 set name [$statbar.name get]
440 set func [$statbar.func get]
442 # check contents of name and function comboboxes
443 if {$name != ""} {set r -1}
444 if {$func != "bar"} {set r -2}
446 # check that the correct file is displayed
447 set twin [$stw test_get twin]
448 set a [$twin get 1.0 end]
449 if {[string compare $source(bar) $a]} {set r -3}
451 # check for PC_TAG and STACK_TAG on correct lines
453 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
456 if {$v == "PC_TAG"} {
459 if {$v == "STACK_TAG"} {
462 if {$v == "BROWSE_TAG"} {incr r 100}
473 # Desc: Another "stack up" test
474 gdbtk_test srcwin3-3.3 "stack up (3)" {
477 set name [$statbar.name get]
478 set func [$statbar.func get]
480 # check contents of name and function comboboxes
481 if {$name != ""} {set r -1}
482 if {$func != "foo"} {set r -2}
484 # check that the correct file is displayed
485 set twin [$stw test_get twin]
486 set source(foo) [$twin get 1.0 end]
487 if {![string compare $source(foo) $source(bar)]} {set r -3}
489 # check for PC_TAG and STACK_TAG on correct lines
491 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
494 if {$v == "STACK_TAG"} {
497 if {$v == "PC_TAG"} {incr r 10}
498 if {$v == "BROWSE_TAG"} {incr r 100}
509 # Desc: Another "stack up" test
510 gdbtk_test srcwin3-3.4 "stack up (4)" {
513 set name [$statbar.name get]
514 set func [$statbar.func get]
516 # check contents of name and function comboboxes
517 if {$name != ""} {set r -1}
518 if {$func != "main"} {set r -2}
520 # check that the correct file is displayed
521 set twin [$stw test_get twin]
522 set a [$twin get 1.0 end]
523 if {[string compare $source(main) $a]} {set r -3}
525 # check for STACK_TAG
527 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
530 if {$v == "STACK_TAG"} {
533 if {$v == "PC_TAG"} {incr r 10}
534 if {$v == "BROWSE_TAG"} {incr r 100}
544 # Disabled for now because there are different correct results.
545 # Test should be rewritten to include those.
547 # Desc: "stack up" when we are at the top
548 #gdbtk_test srcwin3-3.5 "stack up when at the top" {
551 # set name [$statbar.name get]
552 # set func [$statbar.func get]
554 # check contents of name and function comboboxes
555 # if {$name != ""} {set r -1}
556 # if {$func != "main"} {set r -2}
558 # check that the correct file is displayed
559 # set twin [$stw test_get twin]
560 # set a [$twin get 1.0 end]
561 # if {[string compare $source(main) $a]} {set r -3}
563 # check for STACK_TAG
565 # if {![catch {set z [$twin dump -tag 1.0 end]}]} {
566 # foreach {k v i} $z {
567 # if {$k == "tagon"} {
568 # if {$v == "STACK_TAG"} {
571 # if {$v == "PC_TAG"} {incr r 10}
572 # if {$v == "BROWSE_TAG"} {incr r 100}
583 # Desc: "stack down" test
584 gdbtk_test srcwin3-3.6 "stack down" {
587 set name [$statbar.name get]
588 set func [$statbar.func get]
590 # check contents of name and function comboboxes
591 if {$name != ""} {set r -1}
592 if {$func != "foo"} {set r -2}
594 # check that the correct file is displayed
595 set twin [$stw test_get twin]
596 set a [$twin get 1.0 end]
597 if {[string compare $source(foo) $a]} {set r -3}
599 # check for PC_TAG and STACK_TAG on correct lines
601 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
604 if {$v == "STACK_TAG"} {
607 if {$v == "PC_TAG"} {incr r 10}
608 if {$v == "BROWSE_TAG"} {incr r 100}
619 # Desc: "stack bottom" test
620 gdbtk_test srcwin3-3.7 "stack bottom" {
623 set name [$statbar.name get]
624 set func [$statbar.func get]
626 # check contents of name and function comboboxes
627 if {$name != ""} {set r -1}
628 if {$func != "oof"} {set r -2}
630 # check that the correct file is displayed
631 set twin [$stw test_get twin]
632 set a [$twin get 1.0 end]
633 if {[string compare $source(oof) $a]} {set r -3}
635 # check for PC_TAG on correct line
637 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
640 if {$v == "PC_TAG"} {
643 if {$v == "STACK_TAG"} {incr r 10}
644 if {$v == "BROWSE_TAG"} {incr r 100}
655 # Desc: "stack down" when at bottom
656 gdbtk_test srcwin3-3.8 "stack down when at bottom" {
659 set name [$statbar.name get]
660 set func [$statbar.func get]
662 # check contents of name and function comboboxes
663 if {$name != ""} {set r -1}
664 if {$func != "oof"} {set r -2}
666 # check that the correct file is displayed
667 set twin [$stw test_get twin]
668 set a [$twin get 1.0 end]
669 if {[string compare $source(oof) $a]} {set r -3}
671 # check for PC_TAG on correct line
673 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
676 if {$v == "PC_TAG"} {
679 if {$v == "STACK_TAG"} {incr r 10}
680 if {$v == "BROWSE_TAG"} {incr r 100}
690 # 4.1 bp, multiple, balloon, etc
693 # Desc: Set BP in another file. Tests bp and cache functions
694 gdbtk_test srcwin3-4.1 "set BP in another file" {
695 gdb_immediate "break foo" 1
696 $srcwin goto_func "" foo
698 set name [$statbar.name get]
699 set func [$statbar.func get]
701 # check contents of name and function comboboxes
702 if {$name != ""} {set r -1}
703 if {$func != "foo"} {set r -2}
705 set twin [$stw test_get twin]
707 # check for BROWSE_TAG and BP image
709 if {![catch {set z [$twin dump 1.0 end]}]} {
712 if {$v == "BROWSE_TAG"} {
715 if {$v == "STACK_TAG"} {incr r 10}
716 if {$v == "PC_TAG"} {incr r 100}
717 } elseif {$k == "image"} {
727 # clear BP and compare with previous contents. This should succeed,
728 gdb_immediate "clear foo" 1
729 set a [$twin get 1.0 end]
730 if {[string compare $source(foo) $a]} {set r -3}
737 # Desc: Test temporary BP
738 gdbtk_test srcwin3-4.2 "temporary BP" {
740 if {[catch {gdb_immediate "tbreak foo" 1} msg]} {
743 set name [$statbar.name get]
744 set func [$statbar.func get]
746 # check contents of name and function comboboxes
747 if {$name != ""} {set r -1}
748 if {$func != "foo"} {set r -2}
750 set twin [$stw test_get twin]
752 # check for BROWSE_TAG and BP image on correct line
754 if {![catch {set z [$twin dump 1.0 end]}]} {
757 if {$v == "BROWSE_TAG"} {
760 if {$v == "STACK_TAG"} {incr r 10}
761 if {$v == "PC_TAG"} {incr r 100}
762 } elseif {$k == "image"} {
771 gdb_immediate "continue" 1
773 # now check for PC_TAG and no image
775 if {![catch {set z [$twin dump 1.0 end]}]} {
778 if {$v == "PC_TAG"} {
781 if {$v == "STACK_TAG"} {incr r 10}
782 if {$v == "BROWSE_TAG"} {incr r 100}
783 } elseif {$k == "image"} {
799 # change-log-default-name: "ChangeLog-gdbtk"