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)
23 # same as srcwin.test, except test debugging executables
24 # when source files are missing.
26 # Read in the standard defs file
28 if {![gdbtk_read_defs]} {
36 # SECTION 1: Mode Tests #
40 # Load the test executable
41 set program [file join $objdir list]
42 if {[catch {gdbtk_test_file $program} t]} {
43 # This isn't a test case, since if this fails, we're hosed.
44 gdbtk_test_error "loading \"$program\": $t"
47 set srcwin [ManagedWin::open SrcWin]
48 set stw [$srcwin test_get twin]
49 set twin [$stw test_get twin]
50 set statbar [$srcwin test_get _statbar]
57 # Desc: Check for something in source window
58 gdbtk_test srcwin2-1.1 "source window has contents" {
60 set file1(source) [$twin get 1.0 end]
61 if {$file1(source) == ""} {set r -1}
62 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
67 # Desc: source->assembly mode change
68 gdbtk_test srcwin2-1.2 "source->assembly mode change" {
69 $srcwin mode "" ASSEMBLY
70 set twin [$stw test_get twin]
71 set file1(assembly) [$twin get 1.0 end]
72 # source == assembly because for there is no source
73 string compare $file1(source) $file1(assembly)
77 # Desc: assembly->mixed mode change
78 gdbtk_test srcwin2-1.3 "assembly->mixed mode change" {
81 set twin [$stw test_get twin]
82 set file1(mixed) [$twin get 1.0 end]
83 # mixed != assembly because the lines with source should
84 # be noted, even if source in unavailable.
85 if {$file1(mixed) == $file1(assembly)} {set r -1}
86 if {[$statbar.mode get] != "MIXED"} {set r -2}
91 # Desc: mixed->src+asm mode change
92 gdbtk_test srcwin2-1.4 "mixed->src+asm mode change" {
94 # mode change may fail if fallover to ASSEMBLY fails
95 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
96 set twin [$stw test_get twin]
97 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
98 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
103 # Desc: src+asm->source mode change
104 gdbtk_test srcwin2-1.5 "src+asm->source mode change" {
106 $srcwin mode "" SOURCE
107 set twin [$stw test_get twin]
108 if {[$stw test_get bwin] != ""} {set r -2}
109 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
110 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
115 # Desc: source->mixed mode change
116 gdbtk_test srcwin2-1.6 "source->mixed mode change" {
118 $srcwin mode "" MIXED
119 set twin [$stw test_get twin]
120 if {[$twin get 1.0 end] != $file1(mixed)} {set r -1}
121 if {[$statbar.mode get] != "MIXED"} {set r -2}
126 # Desc: mixed->source mode change
127 gdbtk_test srcwin2-1.7 "mixed->source mode change" {
129 $srcwin mode "" SOURCE
130 set twin [$stw test_get twin]
131 if {[$twin get 1.0 end] != $file1(source)} {set r -1}
132 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
137 # Desc: source->src+asm mode change
138 gdbtk_test srcwin2-1.8 "source->src+asm mode change" {
140 # mode change may fail if fallover to ASSEMBLY fails
141 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
142 set twin [$stw test_get twin]
143 set bwin [$stw test_get bwin]
144 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
145 if {$bwin != ""} {set r -2}
146 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
151 # Desc: src+asm->assembly mode change
152 gdbtk_test srcwin2-1.9 "src+asm->assembly mode change" {
154 $srcwin mode "" ASSEMBLY
155 set twin [$stw test_get twin]
156 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
157 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
162 # Desc: assembly->src+asm mode change
163 gdbtk_test srcwin2-1.10 "assembly->src+asm mode change" {
165 # mode change may fail if fallover to ASSEMBLY fails
166 if {[catch {$srcwin mode "" SRC+ASM}]} { set r -5 }
167 set twin [$stw test_get twin]
168 set bwin [$stw test_get bwin]
169 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
170 if {$bwin != ""} {set r -2}
171 if {[$statbar.mode get] != "ASSEMBLY"} {set r -3}
176 # Desc: src+asm->mixed mode change
177 gdbtk_test srcwin2-1.11 "src+asm->mixed mode change" {
179 $srcwin mode "" MIXED
180 set twin [$stw test_get twin]
181 if {[$twin get 1.0 end] != $file1(mixed)} {set r -1}
182 if {[$statbar.mode get] != "MIXED"} {set r -2}
187 # Desc: mixed->assembly mode change
188 gdbtk_test srcwin2-1.12 "mixed->assembly mode change" {
190 $srcwin mode "" ASSEMBLY
191 set twin [$stw test_get twin]
192 if {[$twin get 1.0 end] != $file1(assembly)} {set r -1}
193 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
198 # Desc: assembly->source mode change
199 gdbtk_test srcwin2-1.13 "assembly->source mode change" {
201 $srcwin mode "" SOURCE
202 set twin [$stw test_get twin]
203 if {[$twin get 1.0 end] != $file1(source)} {set r -1}
204 if {[$statbar.mode get] != "ASSEMBLY"} {set r -2}
211 # SECTION 2: Basic Operations #
216 # Desc: check contents of filename combobox
217 gdbtk_test srcwin2-2.1 "check contents of filename combobox" {
218 set names [$statbar.name listget 0 end]
220 foreach f {list0.c list1.c list0.h} {
221 if {[lsearch $names $f] != -1} {
229 # Desc: check contents of function combobox
230 gdbtk_test srcwin2-2.2 "check contents of function combobox" {
231 set names [$statbar.func listget 0 end]
233 foreach f {main foo unused} {
234 if {[lsearch $names $f] != -1} {
242 # Desc: goto filename
243 gdbtk_test srcwin2-2.3 "goto filename" {
244 set func [$srcwin test_get _name 1]
246 set twin [$stw test_get twin]
247 set file2(source) [$twin get 1.0 end]
248 expr {![string compare $file1(source) $file2(source)]}
252 # Desc: check contents of function combobox
253 gdbtk_test srcwin2-2.4 "check contents of function combobox" {
254 set names [$statbar.func listget 0 end]
256 foreach f {bar long_line oof unused} {
257 if {[lsearch $names $f] != -1} {
265 # Desc: function combobox entry field should be empty after switching to a new file
266 gdbtk_test srcwin2-2.5 "function combobox entry field should be empty" {
267 set names [$statbar.func get]
272 # Desc: goto function
273 gdbtk_test srcwin2-2.6 "goto function bar" {
274 $srcwin goto_func "" bar
277 # now get a dump of all tags and check that only one line is
278 # marked BROWSE_TAG and no lines are STACK_TAG or PC_TAG.
280 # We know that list1.c should have BROWSE_TAG set at index 10.2
281 # for function "bar". If list1.c is changed or the layout of the source
282 # window is changed, this must be updated.
283 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
286 if {$v == "BROWSE_TAG"} {
293 if {$v == "STACK_TAG"} { incr r 10}
294 if {$v == "PC_TAG"} { incr r 100}
302 # things are OK so far, so just verify the function name is displayed
303 # in the combobox entry field.
304 set names [$statbar.func get]
305 if {[string compare $names "bar"]} {set r -2}
311 # Desc: goto function "oof". This tests that the correct line is highlighted
312 # with BROWSE_TAG and no other lines are highlighted. It also checks that
313 # the combobox has the correct function name in it. Finally, list1.c
314 # has an extremely long line, line 32, that breaks some functions. We verify
315 # that the GDBtk has the correct line number.
317 gdbtk_test srcwin2-2.7 "goto function oof" {
318 $srcwin goto_func "" oof
321 # now get a dump of all tags and check that only one line is
322 # marked BROWSE_TAG and no lines are STACK_TAG or PC_TAG.
324 # We know that list1.c should have BROWSE_TAG set at index 38.2
325 # for function "oof". If list1.c is changed or the layout of the source
326 # window is changed, this must be updated.
327 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
330 if {$v == "BROWSE_TAG"} {
332 set line_number [$twin get "$i wordstart" "$i wordend"]
333 if {$line_number == "38"} {
342 if {$v == "STACK_TAG"} {incr r 10}
343 if {$v == "PC_TAG"} {incr r 100}
351 # things are OK so far, so just verify the function name is displayed
352 # in the combobox entry field.
353 set names [$statbar.func get]
354 if {[string compare $names "oof"]} {set r -2}
360 # Desc: This test issues a next command while browsing list1.c.
361 # It should display list0.c and highlight the correct line.
362 gdbtk_test srcwin2-2.8 "step while browsing" {
363 gdb_immediate "next" 1
365 set name [$statbar.name get]
366 set func [$statbar.func get]
368 # check contents of name and function comboboxes
369 if {$name != "list0.c"} {set r -1}
370 if {$func != "main"} {set r -2}
372 # check that correct file is displayed
373 set twin [$stw test_get twin]
374 set a [$twin get 1.0 end]
375 if {[string compare $file1(source) $a]} {set r -3}
379 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
382 if {$v == "PC_TAG"} {
385 if {$v == "STACK_TAG"} {incr r 10}
386 if {$v == "BROWSE_TAG"} {incr r 100}
397 # Desc: This test issues a break and a continue
398 gdbtk_test srcwin2-2.11 "set BP and continue" {
399 gdb_immediate "break oof" 1
400 gdb_immediate "continue" 1
402 set name [$statbar.name get]
403 set func [$statbar.func get]
405 # check contents of name and function comboboxes
406 if {$name != "list1.c"} {set r -1}
407 if {$func != "oof"} {set r -2}
409 # check that the correct file is displayed
410 # we must clear the breakpoint first so it doesn't mess up the
412 gdb_immediate "clear oof" 1
413 set twin [$stw test_get twin]
414 set a [$twin get 1.0 end]
415 if {[string compare $file2(source) $a]} {set r -3}
417 # check for PC_TAG on correct line
419 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
422 if {$v == "PC_TAG"} {
429 if {$v == "STACK_TAG"} {incr r 10}
430 if {$v == "BROWSE_TAG"} {incr r 100}
442 # SECTION 3: Stack Operations #
447 # Desc: This tests "stack up"
448 gdbtk_test srcwin2-3.1 "stack up (1)" {
451 set name [$statbar.name get]
452 set func [$statbar.func get]
454 # check contents of name and function comboboxes
455 if {$name != "list1.c"} {set r -1}
456 if {$func != "long_line"} {set r -2}
458 # check that the correct file is displayed
459 set twin [$stw test_get twin]
460 set a [$twin get 1.0 end]
461 if {[string compare $file2(source) $a]} {set r -3}
463 # check for PC_TAG and STACK_TAG on correct lines
465 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
468 if {$v == "PC_TAG"} {
475 if {$v == "STACK_TAG"} {
482 if {$v == "BROWSE_TAG"} {incr r 100}
493 # Desc: Another "stack up" test
494 gdbtk_test srcwin2-3.2 "stack up (2)" {
497 set name [$statbar.name get]
498 set func [$statbar.func get]
500 # check contents of name and function comboboxes
501 if {$name != "list1.c"} {set r -1}
502 if {$func != "bar"} {set r -2}
504 # check that the correct file is displayed
505 set twin [$stw test_get twin]
506 set a [$twin get 1.0 end]
507 if {[string compare $file2(source) $a]} {set r -3}
509 # check for PC_TAG and STACK_TAG on correct lines
511 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
514 if {$v == "PC_TAG"} {
521 if {$v == "STACK_TAG"} {
528 if {$v == "BROWSE_TAG"} {incr r 100}
539 # Desc: Another "stack up" test
540 gdbtk_test srcwin2-3.3 "stack up (3)" {
543 set name [$statbar.name get]
544 set func [$statbar.func get]
546 # check contents of name and function comboboxes
547 if {$name != "list0.h"} {set r -1}
548 if {$func != "foo"} {set r -2}
550 # check that the correct file is displayed
551 set twin [$stw test_get twin]
552 set file3(source) [$twin get 1.0 end]
553 if {![string compare $file2(source) $file3(source)]} {set r -3}
555 # check for PC_TAG and STACK_TAG on correct lines
557 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
560 if {$v == "STACK_TAG"} {
567 if {$v == "PC_TAG"} {incr r 10}
568 if {$v == "BROWSE_TAG"} {incr r 100}
579 # Desc: Another "stack up" test
580 gdbtk_test srcwin2-3.4 "stack up (4)" {
583 set name [$statbar.name get]
584 set func [$statbar.func get]
586 # check contents of name and function comboboxes
587 if {$name != "list0.c"} {set r -1}
588 if {$func != "main"} {set r -2}
590 # check that the correct file is displayed
591 set twin [$stw test_get twin]
592 set a [$twin get 1.0 end]
593 if {[string compare $file1(source) $a]} {set r -3}
595 # check for STACK_TAG
597 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
600 if {$v == "STACK_TAG"} {
603 if {$v == "PC_TAG"} {incr r 10}
604 if {$v == "BROWSE_TAG"} {incr r 100}
615 # Disabled for now because there are different correct results.
616 # Test should be rewritten to include those.
618 # Desc: "stack up" when we are at the top
619 #gdbtk_test srcwin2-3.5 "stack up when at the top" {
622 # set name [$statbar.name get]
623 # set func [$statbar.func get]
625 # check contents of name and function comboboxes
626 # if {$name != "list0.c"} {set r -1}
627 # if {$func != "main"} {set r -2}
629 # check that the correct file is displayed
630 # set twin [$stw test_get twin]
631 # set a [$twin get 1.0 end]
632 # if {[string compare $file1(source) $a]} {set r -3}
634 # check for STACK_TAG
636 # if {![catch {set z [$twin dump -tag 1.0 end]}]} {
637 # foreach {k v i} $z {
638 # if {$k == "tagon"} {
639 # if {$v == "STACK_TAG"} {
642 # if {$v == "PC_TAG"} {incr r 10}
643 # if {$v == "BROWSE_TAG"} {incr r 100}
654 # Desc: "stack down" test
655 gdbtk_test srcwin2-3.6 "stack down" {
658 set name [$statbar.name get]
659 set func [$statbar.func get]
661 # check contents of name and function comboboxes
662 if {$name != "list0.h"} {set r -1}
663 if {$func != "foo"} {set r -2}
665 # check that the correct file is displayed
666 set twin [$stw test_get twin]
667 set a [$twin get 1.0 end]
668 if {![string compare $file2(source) $a]} {set r -3}
670 # check for PC_TAG and STACK_TAG on correct lines
672 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
675 if {$v == "STACK_TAG"} {
682 if {$v == "PC_TAG"} {incr r 10}
683 if {$v == "BROWSE_TAG"} {incr r 100}
694 # Desc: "stack bottom" test
695 gdbtk_test srcwin2-3.7 "stack bottom" {
698 set name [$statbar.name get]
699 set func [$statbar.func get]
701 # check contents of name and function comboboxes
702 if {$name != "list1.c"} {set r -1}
703 if {$func != "oof"} {set r -2}
705 # check that the correct file is displayed
706 set twin [$stw test_get twin]
707 set a [$twin get 1.0 end]
708 if {[string compare $file2(source) $a]} {set r -3}
710 # check for PC_TAG on correct line
712 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
715 if {$v == "PC_TAG"} {
722 if {$v == "STACK_TAG"} {incr r 10}
723 if {$v == "BROWSE_TAG"} {incr r 100}
734 # Desc: "stack down" when at bottom
735 gdbtk_test srcwin2-3.8 "stack down when at bottom" {
738 set name [$statbar.name get]
739 set func [$statbar.func get]
741 # check contents of name and function comboboxes
742 if {$name != "list1.c"} {set r -1}
743 if {$func != "oof"} {set r -2}
745 # check that the correct file is displayed
746 set twin [$stw test_get twin]
747 set a [$twin get 1.0 end]
748 if {[string compare $file2(source) $a]} {set r -3}
750 # check for PC_TAG on correct line
752 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
755 if {$v == "PC_TAG"} {
762 if {$v == "STACK_TAG"} {incr r 10}
763 if {$v == "BROWSE_TAG"} {incr r 100}
773 # 4.1 bp, multiple, balloon, etc
776 # Desc: Set BP in another file. Tests bp and cache functions
777 gdbtk_test srcwin2-4.1 "set BP in another file" {
778 gdb_immediate "break foo" 1
779 $srcwin goto_func "" foo
781 set name [$statbar.name get]
782 set func [$statbar.func get]
784 # check contents of name and function comboboxes
785 if {$name != "list0.h"} {set r -1}
786 if {$func != "foo"} {set r -2}
788 set twin [$stw test_get twin]
790 # check for BROWSE_TAG and BP image on correct line
792 if {![catch {set z [$twin dump 1.0 end]}]} {
795 if {$v == "BROWSE_TAG"} {
802 if {$v == "STACK_TAG"} {incr r 10}
803 if {$v == "PC_TAG"} {incr r 100}
804 } elseif {$k == "image"} {
818 # clear BP and compare with previous contents. This should succeed,
819 gdb_immediate "clear foo" 1
820 set a [$twin get 1.0 end]
821 if {[string compare $file3(source) $a]} {set r -3}
828 # Desc: Test temporary BP
829 gdbtk_test srcwin2-4.2 "temporary BP" {
831 if {[catch {gdb_immediate "tbreak foo" 1} msg]} {
834 set name [$statbar.name get]
835 set func [$statbar.func get]
837 # check contents of name and function comboboxes
838 if {$name != "list0.h"} {set r -1}
839 if {$func != "foo"} {set r -2}
841 set twin [$stw test_get twin]
843 # check for BROWSE_TAG and BP image on correct line
845 if {![catch {set z [$twin dump 1.0 end]}]} {
848 if {$v == "BROWSE_TAG"} {
855 if {$v == "STACK_TAG"} {incr r 10}
856 if {$v == "PC_TAG"} {incr r 100}
857 } elseif {$k == "image"} {
870 gdb_immediate "continue" 1
872 # now check for PC_TAG and no image
874 if {![catch {set z [$twin dump 1.0 end]}]} {
877 if {$v == "PC_TAG"} {
884 if {$v == "STACK_TAG"} {incr r 10}
885 if {$v == "BROWSE_TAG"} {incr r 100}
886 } elseif {$k == "image"} {