1999-01-29 Martin Hunt <hunt@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdbtk / srcwin.test
CommitLineData
c98fe0c1
JI
1# Copyright (C) 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 Martin Hunt (hunt@cygnus.com)
21
22# Read in the standard defs file
23
24if {![gdbtk_read_defs]} {
25 break
26}
27
40a7f1e9
MH
28global objdir srcdir
29
30
31# move the pointer to the center of the bbox relative to $win
32proc move_mouse_to {win bbox} {
33 set x [expr [lindex $bbox 0] + [lindex $bbox 2] / 2]
34 set y [expr [lindex $bbox 1] + [lindex $bbox 3] / 2]
35 warp_pointer . [winfo rootx $win] [winfo rooty $win]
36
37 set nx 0
38 set ny 0
39
40 while {$nx != $x || $ny != $y} {
41 if {$nx < $x} {incr nx}
42 if {$ny < $y} {incr ny}
43 warp_pointer $win $x $y
44 }
45}
c98fe0c1
JI
46
47
48##### #####
49# #
50# SECTION 1: Mode Tests #
51# #
52##### #####
53
54# Load the test executable
55if {$tcl_platform(platform) == "windows"} {
56 set file [file join $objdir list.exe]
57} else {
58 set file [file join $objdir list]
59}
60
61# This isn't a test case, since if this fails, we're hosed.
62if {[catch {gdb_cmd "file $file" 1} t]} {
63 # an error occured loading the file
64 gdbtk_test_error "loading \"$file\": $t"
65}
66
67set srcwin [ManagedWin::open SrcWin]
68set stw [$srcwin test_get twin]
69set twin [$stw test_get twin]
70
71# get things started
72gdb_cmd "break main"
73run_executable
74
75# Test: srcwin-1.1
76# Desc: Check for something in source window
77gdbtk_test srcwin-1.1 "source window has contents" {
78 set file1(source) [$twin get 1.0 end]
79 expr {![string compare $file1(source) ""]}
80} {0}
81
82
83# Test: srcwin-1.2
84# Desc: source->assembly mode change
85gdbtk_test srcwin-1.2 "source->assembly mode change" {
86 $srcwin mode "" ASSEMBLY
87 set twin [$stw test_get twin]
88 set file1(assembly) [$twin get 1.0 end]
89 expr {![string compare $file1(source) $file1(assembly)]}
90} {0}
91
92# Test: srcwin-1.3
93# Desc: assembly->mixed mode change
94gdbtk_test srcwin-1.3 "assembly->mixed mode change" {
95 $srcwin mode "" MIXED
96 set twin [$stw test_get twin]
97 set file1(mixed) [$twin get 1.0 end]
98 expr {![string compare $file1(mixed) $file1(assembly)]}
99} {0}
100
101# Test: srcwin-1.4
102# Desc: mixed->src+asm mode change
103gdbtk_test srcwin-1.4 "mixed->src+asm mode change" {
104 $srcwin mode "" SRC+ASM
105 set twin [$stw test_get twin]
106 set bwin [$stw test_get bwin]
107 set s [$twin get 1.0 end]
108 set a [$bwin get 1.0 end]
109 expr {[string compare $a $file1(assembly)] ||
110 [string compare $s $file1(source)] ||
111 ![winfo ismapped $bwin]}
112} {0}
113
114# Test: srcwin-1.5
115# Desc: src+asm->source mode change
116gdbtk_test srcwin-1.5 "src+asm->source mode change" {
117 $srcwin mode "" SOURCE
118 set twin [$stw test_get twin]
119 set a [$twin get 1.0 end]
120 set bwin [$stw test_get bwin]
121 expr {[string compare $file1(source) $a] ||
122 [winfo ismapped $bwin]}
123} {0}
124
125# Test: srcwin-1.6
126# Desc: source->mixed mode change
127gdbtk_test srcwin-1.6 "source->mixed mode change" {
128 $srcwin mode "" MIXED
129 set twin [$stw test_get twin]
130 set a [$twin get 1.0 end]
131 string compare $file1(mixed) $a
132} {0}
133
134# Test: srcwin-1.7
135# Desc: mixed->source mode change
136gdbtk_test srcwin-1.7 "mixed->source mode change" {
137 $srcwin mode "" SOURCE
138 set twin [$stw test_get twin]
139 set a [$twin get 1.0 end]
140 string compare $file1(source) $a
141} {0}
142
143# Test: srcwin-1.8
144# Desc: source->src+asm mode change
145gdbtk_test srcwin-1.8 "source->src+asm mode change" {
146 $srcwin mode "" SRC+ASM
147 set twin [$stw test_get twin]
148 set bwin [$stw test_get bwin]
149 set s [$twin get 1.0 end]
150 set a [$bwin get 1.0 end]
151 expr {[string compare $a $file1(assembly)] ||
152 [string compare $s $file1(source)] ||
153 ![winfo ismapped $bwin]}
154} {0}
155
156# Test: srcwin-1.9
157# Desc: src+asm->assembly mode change
158gdbtk_test srcwin-1.9 "src+asm->assembly mode change" {
159 $srcwin mode "" ASSEMBLY
160 set twin [$stw test_get twin]
161 set a [$twin get 1.0 end]
162 string compare $file1(assembly) $a
163} {0}
164
165# Test: srcwin-1.10
166# Desc: assembly->src+asm mode change
167gdbtk_test srcwin-1.10 "assembly->src+asm mode change" {
168 $srcwin mode "" SRC+ASM
169 set twin [$stw test_get twin]
170 set bwin [$stw test_get bwin]
171 set s [$twin get 1.0 end]
172 set a [$bwin get 1.0 end]
173 expr {[string compare $a $file1(assembly)] ||
174 [string compare $s $file1(source)] ||
175 ![winfo ismapped $bwin]}
176} {0}
177
178# Test: srcwin-1.11
179# Desc: src+asm->mixed mode change
180gdbtk_test srcwin-1.11 "src+asm->mixed mode change" {
181 $srcwin mode "" MIXED
182 set twin [$stw test_get twin]
183 set a [$twin get 1.0 end]
184 set bwin [$stw test_get bwin]
185 expr {[string compare $file1(mixed) $a] ||
186 [winfo ismapped $bwin]}
187} {0}
188
189# Test: srcwin-1.12
190# Desc: mixed->assembly mode change
191gdbtk_test srcwin-1.12 "mixed->assembly mode change" {
192 $srcwin mode "" ASSEMBLY
193 set twin [$stw test_get twin]
194 set a [$twin get 1.0 end]
195 string compare $file1(assembly) $a
196} {0}
197
198# Test: srcwin-1.13
199# Desc: assembly->source mode change
200gdbtk_test srcwin-1.13 "assembly->source mode change" {
201 $srcwin mode "" SOURCE
202 set twin [$stw test_get twin]
203 set a [$twin get 1.0 end]
204 string compare $file1(source) $a
205} {0}
206
207
208##### #####
209# #
210# SECTION 2: Basic Operations #
211# #
212##### #####
213
214# Test: srcwin-2.1
215# Desc: check contents of filename combobox
216gdbtk_test srcwin-2.1 "check contents of filename combobox" {
217 set statbar [$srcwin test_get _statbar]
218 set names [$statbar.name listget 0 end]
219 set r 0
220 foreach f {list0.c list1.c list0.h} {
221 if {[lsearch $names $f] != -1} {
222 incr r
223 }
224 }
225 set r
226} {3}
227
228# Test: srcwin-2.2
229# Desc: check contents of function combobox
230gdbtk_test srcwin-2.2 "check contents of function combobox" {
231 set names [$statbar.func listget 0 end]
232 set r 0
233 foreach f {main foo unused} {
234 if {[lsearch $names $f] != -1} {
235 incr r
236 }
237 }
238 set r
239} {3}
240
241# Test: srcwin-2.3
242# Desc: goto filename
243gdbtk_test srcwin-2.3 "goto filename" {
244 set func [$srcwin test_get _name 1]
245 $func "" list1.c
246 set twin [$stw test_get twin]
247 set file2(source) [$twin get 1.0 end]
248 expr {![string compare $file1(source) $file2(source)]}
249} {0}
250
251# Test: srcwin-2.4
252# Desc: check contents of function combobox
253gdbtk_test srcwin-2.4 "check contents of function combobox" {
254 set names [$statbar.func listget 0 end]
255 set r 0
256 foreach f {bar long_line oof unused} {
257 if {[lsearch $names $f] != -1} {
258 incr r
259 }
260 }
261 set r
262} {4}
263
264# Test: srcwin-2.5
265# Desc: function combobox entry field should be empty after switching to a new file
266gdbtk_test srcwin-2.5 "function combobox entry field should be empty" {
267 set names [$statbar.func get]
268 string length $names
269} {0}
270
271# Test: srcwin-2.6
272# Desc: goto function
273gdbtk_test srcwin-2.6 "goto function bar" {
274 $srcwin goto_func "" bar
275 set r 0
276
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.
279
280 # We know that list1.c should have BROWSE_TAG set at index 5.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]}]} {
284 foreach {k v i} $z {
285 if {$k == "tagon"} {
286 if {$v == "BROWSE_TAG"} {
287 if {$i == "5.2"} {
288 incr r
289 } else {
290 incr r 5
291 }
292 }
293 if {$v == "STACK_TAG"} { incr r 10}
294 if {$v == "PC_TAG"} { incr r 100}
295 }
296 }
297 } else {
298 set r -1
299 }
300
301 if {$r == 1} {
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}
306 }
307 set r
308} {1}
309
310# Test: srcwin-2.7
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.
316
317gdbtk_test srcwin-2.7 "goto function oof" {
318 $srcwin goto_func "" oof
319 set r 0
320
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.
323
324 # We know that list1.c should have BROWSE_TAG set at index 32.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]}]} {
328 foreach {k v i} $z {
329 if {$k == "tagon"} {
330 if {$v == "BROWSE_TAG"} {
331 if {$i == "32.2"} {
332 set line_number [$twin get "$i wordstart" "$i wordend"]
333 if {$line_number == "32"} {
334 incr r
335 } else {
336 incr r -100
337 }
338 } else {
339 incr r 5
340 }
341 }
342 if {$v == "STACK_TAG"} {incr r 10}
343 if {$v == "PC_TAG"} {incr r 100}
344 }
345 }
346 } else {
347 set r -1
348 }
349
350 if {$r == 1} {
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}
355 }
356 set r
357} {1}
358
359# Test: srcwin-2.8
360# Desc: This test issues a next command while browsing list1.c.
361# It should display list0.c and highlight the correct line.
362gdbtk_test srcwin-2.8 "step while browsing" {
363 gdb_immediate "next" 1
364 set r 0
365 set name [$statbar.name get]
366 set func [$statbar.func get]
367
368 # check contents of name and function comboboxes
369 if {$name != "list0.c"} {set r -1}
370 if {$func != "main"} {set r -2}
371
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}
376
377 # check for PC_TAG on correct line
378 if {$r == 0} {
379 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
380 foreach {k v i} $z {
381 if {$k == "tagon"} {
382 if {$v == "PC_TAG"} {
383 if {$i == "11.2"} {
384 incr r
385 } else {
386 incr r 5
387 }
388 }
389 if {$v == "STACK_TAG"} {incr r 10}
390 if {$v == "BROWSE_TAG"} {incr r 100}
391 }
392 }
393 } else {
394 set r -4
395 }
396 }
397 set r
398} {1}
399
400# Test: srcwin-2.9
401# Desc: This test issues a next command while the current
402# PC is ready to call a function. It should not go into the function and
403# should update the PC highlight correctly.
404gdbtk_test srcwin-2.9 "next" {
405 gdb_immediate "next" 1
406 set r 0
407 set name [$statbar.name get]
408 set func [$statbar.func get]
409
410 # check contents of name and function comboboxes
411 if {$name != "list0.c"} {set r -1}
412 if {$func != "main"} {set r -2}
413
414 # check that correct file is displayed
415 set twin [$stw test_get twin]
416 set a [$twin get 1.0 end]
417 if {[string compare $file1(source) $a]} {set r -3}
418
419 # check for PC_TAG on correct line
420 if {$r == 0} {
421 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
422 foreach {k v i} $z {
423 if {$k == "tagon"} {
424 if {$v == "PC_TAG"} {
425 if {$i == "12.2"} {
426 incr r
427 } else {
428 incr r 5
429 }
430 }
431 if {$v == "STACK_TAG"} {incr r 10}
432 if {$v == "BROWSE_TAG"} {incr r 100}
433 }
434 }
435 } else {
436 set r -4
437 }
438 }
439 set r
440} {1}
441
442# Test: srcwin-2.10
443# Desc: This test issues a step command while the current
444# PC is ready to call a function. It should step into the function.
445gdbtk_test srcwin-2.10 "step" {
446 gdb_immediate "step" 1
447 set r 0
448 set name [$statbar.name get]
449 set func [$statbar.func get]
450
451 # check contents of name and function comboboxes
452 if {$name != "list0.h"} {set r -1}
453 if {$func != "foo"} {set r -2}
454
455 # check that a new file is displayed
456 set twin [$stw test_get twin]
40a7f1e9
MH
457 set file3(source) [$twin get 1.0 end]
458 if {![string compare $file1(source) $file3(source)]} {set r -3}
c98fe0c1
JI
459
460 # check for PC_TAG on correct line
461 if {$r == 0} {
462 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
463 foreach {k v i} $z {
464 if {$k == "tagon"} {
465 if {$v == "PC_TAG"} {
466 if {$i == "8.2"} {
467 incr r
468 } else {
469 incr r 5
470 }
471 }
472 if {$v == "STACK_TAG"} {incr r 10}
473 if {$v == "BROWSE_TAG"} {incr r 100}
474 }
475 }
476 } else {
477 set r -4
478 }
479 }
480 set r
481} {1}
482
483# Test: srcwin-2.11
484# Desc: This test issues a break and a continue
485gdbtk_test srcwin-2.11 "set BP and continue" {
486 gdb_immediate "break oof" 1
487 gdb_immediate "continue" 1
488 set r 0
489 set name [$statbar.name get]
490 set func [$statbar.func get]
491
492 # check contents of name and function comboboxes
493 if {$name != "list1.c"} {set r -1}
494 if {$func != "oof"} {set r -2}
495
496 # check that the correct file is displayed
497 # we must clear the breakpoint first so it doesn't mess up the
498 # comparison...
499 gdb_immediate "clear oof" 1
500 set twin [$stw test_get twin]
501 set a [$twin get 1.0 end]
502 if {[string compare $file2(source) $a]} {set r -3}
503
504 # check for PC_TAG on correct line
505 if {$r == 0} {
506 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
507 foreach {k v i} $z {
508 if {$k == "tagon"} {
509 if {$v == "PC_TAG"} {
510 if {$i == "32.2"} {
511 incr r
512 } else {
513 incr r 5
514 }
515 }
516 if {$v == "STACK_TAG"} {incr r 10}
517 if {$v == "BROWSE_TAG"} {incr r 100}
518 }
519 }
520 } else {
521 set r -4
522 }
523 }
524 set r
525} {1}
526
527##### #####
528# #
529# SECTION 3: Stack Operations #
530# #
531##### #####
532
533# Test: srcwin-3.1
534# Desc: This tests "stack up"
535gdbtk_test srcwin-3.1 "stack up (1)" {
536 $srcwin stack up
537 set r 0
538 set name [$statbar.name get]
539 set func [$statbar.func get]
540
541 # check contents of name and function comboboxes
542 if {$name != "list1.c"} {set r -1}
543 if {$func != "long_line"} {set r -2}
544
545 # check that the correct file is displayed
546 set twin [$stw test_get twin]
547 set a [$twin get 1.0 end]
548 if {[string compare $file2(source) $a]} {set r -3}
549
550 # check for PC_TAG and STACK_TAG on correct lines
551 if {$r == 0} {
552 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
553 foreach {k v i} $z {
554 if {$k == "tagon"} {
555 if {$v == "PC_TAG"} {
556 if {$i == "32.2"} {
557 incr r
558 } else {
559 incr r 5
560 }
561 }
562 if {$v == "STACK_TAG"} {
563 if {$i == "22.2"} {
564 incr r
565 } else {
566 incr r 10
567 }
568 }
569 if {$v == "BROWSE_TAG"} {incr r 100}
570 }
571 }
572 } else {
573 set r -4
574 }
575 }
576 set r
577} {2}
578
579# Test: srcwin-3.2
580# Desc: Another "stack up" test
581gdbtk_test srcwin-3.2 "stack up (2)" {
582 $srcwin stack up
583 set r 0
584 set name [$statbar.name get]
585 set func [$statbar.func get]
586
587 # check contents of name and function comboboxes
588 if {$name != "list1.c"} {set r -1}
589 if {$func != "bar"} {set r -2}
590
591 # check that the correct file is displayed
592 set twin [$stw test_get twin]
593 set a [$twin get 1.0 end]
594 if {[string compare $file2(source) $a]} {set r -3}
595
596 # check for PC_TAG and STACK_TAG on correct lines
597 if {$r == 0} {
598 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
599 foreach {k v i} $z {
600 if {$k == "tagon"} {
601 if {$v == "PC_TAG"} {
602 if {$i == "32.2"} {
603 incr r
604 } else {
605 incr r 5
606 }
607 }
608 if {$v == "STACK_TAG"} {
609 if {$i == "7.2"} {
610 incr r
611 } else {
612 incr r 10
613 }
614 }
615 if {$v == "BROWSE_TAG"} {incr r 100}
616 }
617 }
618 } else {
619 set r -4
620 }
621 }
622 set r
623} {2}
624
625# Test: srcwin-3.3
626# Desc: Another "stack up" test
627gdbtk_test srcwin-3.3 "stack up (3)" {
628 $srcwin stack up
629 set r 0
630 set name [$statbar.name get]
631 set func [$statbar.func get]
632
633 # check contents of name and function comboboxes
634 if {$name != "list0.h"} {set r -1}
635 if {$func != "foo"} {set r -2}
636
637 # check that the correct file is displayed
638 set twin [$stw test_get twin]
639 set a [$twin get 1.0 end]
640 if {![string compare $file2(source) $a]} {set r -3}
641
642 # check for PC_TAG and STACK_TAG on correct lines
643 if {$r == 0} {
644 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
645 foreach {k v i} $z {
646 if {$k == "tagon"} {
647 if {$v == "STACK_TAG"} {
648 if {$i == "8.2"} {
649 incr r
650 } else {
651 incr r 5
652 }
653 }
654 if {$v == "PC_TAG"} {incr r 10}
655 if {$v == "BROWSE_TAG"} {incr r 100}
656 }
657 }
658 } else {
659 set r -4
660 }
661 }
662 set r
663} {1}
664
665# Test: srcwin-3.4
666# Desc: Another "stack up" test
667gdbtk_test srcwin-3.4 "stack up (4)" {
668 $srcwin stack up
669 set r 0
670 set name [$statbar.name get]
671 set func [$statbar.func get]
672
673 # check contents of name and function comboboxes
674 if {$name != "list0.c"} {set r -1}
675 if {$func != "main"} {set r -2}
676
677 # check that the correct file is displayed
678 set twin [$stw test_get twin]
679 set a [$twin get 1.0 end]
680 if {[string compare $file1(source) $a]} {set r -3}
681
682 # check for PC_TAG and STACK_TAG on correct lines
683 if {$r == 0} {
684 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
685 foreach {k v i} $z {
686 if {$k == "tagon"} {
687 if {$v == "STACK_TAG"} {
688 if {$i == "12.2"} {
689 incr r
690 } else {
691 dbug X $i
692 incr r 5
693 }
694 }
695 if {$v == "PC_TAG"} {incr r 10}
696 if {$v == "BROWSE_TAG"} {incr r 100}
697 }
698 }
699 } else {
700 set r -4
701 }
702 }
703 set r
704} {1}
705
706# Test: srcwin-3.5
707# Desc: "stack up" when we are at the top
708gdbtk_test srcwin-3.5 "stack up when at the top" {
709 $srcwin stack up
710 set r 0
711 set name [$statbar.name get]
712 set func [$statbar.func get]
713
714 # check contents of name and function comboboxes
715 if {$name != "list0.c"} {set r -1}
716 if {$func != "main"} {set r -2}
717
718 # check that the correct file is displayed
719 set twin [$stw test_get twin]
720 set a [$twin get 1.0 end]
721 if {[string compare $file1(source) $a]} {set r -3}
722
723 # check for PC_TAG and STACK_TAG on correct lines
724 if {$r == 0} {
725 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
726 foreach {k v i} $z {
727 if {$k == "tagon"} {
728 if {$v == "STACK_TAG"} {
729 if {$i == "12.2"} {
730 incr r
731 } else {
732 incr r 5
733 }
734 }
735 if {$v == "PC_TAG"} {incr r 10}
736 if {$v == "BROWSE_TAG"} {incr r 100}
737 }
738 }
739 } else {
740 set r -4
741 }
742 }
743 set r
744} {1}
745
746# Test: srcwin-3.6
747# Desc: "stack down" test
748gdbtk_test srcwin-3.6 "stack down" {
749 $srcwin stack down
750 set r 0
751 set name [$statbar.name get]
752 set func [$statbar.func get]
753
754 # check contents of name and function comboboxes
755 if {$name != "list0.h"} {set r -1}
756 if {$func != "foo"} {set r -2}
757
758 # check that the correct file is displayed
759 set twin [$stw test_get twin]
760 set a [$twin get 1.0 end]
761 if {![string compare $file2(source) $a]} {set r -3}
762
763 # check for PC_TAG and STACK_TAG on correct lines
764 if {$r == 0} {
765 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
766 foreach {k v i} $z {
767 if {$k == "tagon"} {
768 if {$v == "STACK_TAG"} {
769 if {$i == "8.2"} {
770 incr r
771 } else {
772 incr r 5
773 }
774 }
775 if {$v == "PC_TAG"} {incr r 10}
776 if {$v == "BROWSE_TAG"} {incr r 100}
777 }
778 }
779 } else {
780 set r -4
781 }
782 }
783 set r
784} {1}
785
786# Test: srcwin-3.7
787# Desc: "stack bottom" test
788gdbtk_test srcwin-3.7 "stack bottom" {
789 $srcwin stack bottom
790 set r 0
791 set name [$statbar.name get]
792 set func [$statbar.func get]
793
794 # check contents of name and function comboboxes
795 if {$name != "list1.c"} {set r -1}
796 if {$func != "oof"} {set r -2}
797
798 # check that the correct file is displayed
799 set twin [$stw test_get twin]
800 set a [$twin get 1.0 end]
801 if {[string compare $file2(source) $a]} {set r -3}
802
803 # check for PC_TAG on correct line
804 if {$r == 0} {
805 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
806 foreach {k v i} $z {
807 if {$k == "tagon"} {
808 if {$v == "PC_TAG"} {
809 if {$i == "32.2"} {
810 incr r
811 } else {
812 incr r 5
813 }
814 }
815 if {$v == "STACK_TAG"} {incr r 10}
816 if {$v == "BROWSE_TAG"} {incr r 100}
817 }
818 }
819 } else {
820 set r -4
821 }
822 }
823 set r
824} {1}
825
826# Test: srcwin-3.8
827# Desc: "stack down" when at bottom
828gdbtk_test srcwin-3.8 "stack down when at bottom" {
829 $srcwin stack down
830 set r 0
831 set name [$statbar.name get]
832 set func [$statbar.func get]
833
834 # check contents of name and function comboboxes
835 if {$name != "list1.c"} {set r -1}
836 if {$func != "oof"} {set r -2}
837
838 # check that the correct file is displayed
839 set twin [$stw test_get twin]
840 set a [$twin get 1.0 end]
841 if {[string compare $file2(source) $a]} {set r -3}
842
843 # check for PC_TAG on correct line
844 if {$r == 0} {
845 if {![catch {set z [$twin dump -tag 1.0 end]}]} {
846 foreach {k v i} $z {
847 if {$k == "tagon"} {
848 if {$v == "PC_TAG"} {
849 if {$i == "32.2"} {
850 incr r
851 } else {
852 incr r 5
853 }
854 }
855 if {$v == "STACK_TAG"} {incr r 10}
856 if {$v == "BROWSE_TAG"} {incr r 100}
857 }
858 }
859 } else {
860 set r -4
861 }
862 }
863 set r
864} {1}
865
866# 4.1 bp, multiple, balloon, etc
40a7f1e9
MH
867
868# Test: srcwin-4.1
869# Desc: Set BP in another file. Tests bp and cache functions
870gdbtk_test srcwin-4.1 "set BP in another file" {
871 gdb_immediate "break foo" 1
872 $srcwin goto_func "" foo
873 set r 0
874 set name [$statbar.name get]
875 set func [$statbar.func get]
876
877 # check contents of name and function comboboxes
878 if {$name != "list0.h"} {set r -1}
879 if {$func != "foo"} {set r -2}
880
881 set twin [$stw test_get twin]
882
883 # check for BROWSE_TAG and BP image on correct line
884 if {$r == 0} {
885 if {![catch {set z [$twin dump 1.0 end]}]} {
886 foreach {k v i} $z {
887 if {$k == "tagon"} {
888 if {$v == "BROWSE_TAG"} {
889 if {$i == "8.2"} {
890 incr r
891 } else {
892 incr r 5
893 }
894 }
895 if {$v == "STACK_TAG"} {incr r 10}
896 if {$v == "PC_TAG"} {incr r 100}
897 } elseif {$k == "image"} {
898 if {$i == "8.0"} {
899 incr r
900 } else {
901 set r -200
902 }
903 }
904 }
905 } else {
906 set r -4
907 }
908 }
909
910 if {$r == 2} {
911 # clear BP and compare with previous contents. This should succeed,
912 gdb_immediate "clear foo" 1
913 set a [$twin get 1.0 end]
914 if {[string compare $file3(source) $a]} {set r -3}
915 }
916
917 set r
918} {2}
919
920# Test: srcwin-4.2
921# Desc: Test temporary BP
922gdbtk_test srcwin-4.2 "temporary BP" {
923 set r 0
924 if {[catch {gdb_immediate "tbreak foo" 1} msg]} {
925 set r -500
926 }
927 set name [$statbar.name get]
928 set func [$statbar.func get]
929
930 # check contents of name and function comboboxes
931 if {$name != "list0.h"} {set r -1}
932 if {$func != "foo"} {set r -2}
933
934 set twin [$stw test_get twin]
935
936 # check for BROWSE_TAG and BP image on correct line
937 if {$r == 0} {
938 if {![catch {set z [$twin dump 1.0 end]}]} {
939 foreach {k v i} $z {
940 if {$k == "tagon"} {
941 if {$v == "BROWSE_TAG"} {
942 if {$i == "8.2"} {
943 incr r
944 } else {
945 incr r 5
946 }
947 }
948 if {$v == "STACK_TAG"} {incr r 10}
949 if {$v == "PC_TAG"} {incr r 100}
950 } elseif {$k == "image"} {
951 if {$i == "8.0"} {
952 incr r
953 } else {
954 set r -200
955 }
956 }
957 }
958 } else {
959 set r -4
960 }
961 }
962
963 gdb_immediate "continue" 1
964
965 # now check for PC_TAG and no image
966 if {$r == 2} {
967 if {![catch {set z [$twin dump 1.0 end]}]} {
968 foreach {k v i} $z {
969 if {$k == "tagon"} {
970 if {$v == "PC_TAG"} {
971 if {$i == "8.2"} {
972 incr r
973 } else {
974 incr r 5
975 }
976 }
977 if {$v == "STACK_TAG"} {incr r 10}
978 if {$v == "BROWSE_TAG"} {incr r 100}
979 } elseif {$k == "image"} {
980 set r -200
981 }
982 }
983 } else {
984 set r -4
985 }
986 }
987
988 set r
989} {3}
990
991# Test: srcwin-4.3
992# Desc: Test BP balloons
993gdbtk_test srcwin-4.3 "BP Balloons" {
994 # move pointer out of the way
995 warp_pointer . 0 0
996 set r 0
997 gdb_immediate "break 10" 1
998 gdb_immediate "tbreak 10" 1
999
1000 set twin [$stw test_get twin]
1001
1002 # check for BROWSE_TAG and BP image on correct line
1003 if {$r == 0} {
1004 if {![catch {set z [$twin dump 1.0 end]}]} {
1005 foreach {k v i} $z {
1006 if {$k == "tagon"} {
1007 if {$v == "PC_TAG"} {
1008 if {$i == "8.2"} {
1009 incr r
1010 } else {
1011 incr r 5
1012 }
1013 }
1014 if {$v == "STACK_TAG"} {incr r 10}
1015 if {$v == "BROWSE_TAG"} {incr r 100}
1016 } elseif {$k == "image"} {
1017 if {$i == "10.0"} {
1018 incr r
1019 # we found the bp image, now we will test the bp balloon messages
1020 set balloon [winfo toplevel [namespace tail $srcwin]].__balloon
1021 # shouldn't be mapped yet
1022 if {[winfo ismapped $balloon]} {
1023 set r -3000
1024 break
1025 }
1026 move_mouse_to $twin [$twin bbox $i]
1027 #wait a second for the balloon message to appear
1028 sleep 1
1029 if {![winfo ismapped $balloon]} {
1030 set r -4000
1031 break
1032 }
1033 # read the contents of the balloon and parse it into lines
1034 set a [split [$balloon.label cget -text] \n]
1035 set i 0
1036 # foreach line parse it and check the type and make sure it is enabled
1037 foreach line $a {
1038 if {[lindex $line 0] == "breakpoint"} {continue}
1039 incr i
1040 set enabled [lindex $line 0]
1041 set bptype [lindex $line 2]
1042 switch $i {
1043 1 {
1044 if {$bptype != "donttouch"} {set r -1000}
1045 }
1046 2 {
1047 if {$bptype != "delete"} {set r -2000}
1048 }
1049 }
1050 }
1051 } else {
1052 set r -200
1053 }
1054 }
1055 }
1056 } else {
1057 set r -4
1058 }
1059 }
1060 set r
1061} {2}
1062
c98fe0c1 1063# 5.1 balloon variables
40a7f1e9
MH
1064# Test: srcwin-5.1
1065# Desc: variable balloon test
1066gdbtk_test srcwin-5.1 "variable balloon test" {
1067 # move pointer out of the way
1068 warp_pointer . 0 0
1069 set r 0
1070 set twin [$stw test_get twin]
1071
1072 # move pointer to variable "x" and check balloon
1073 set index [string first "x++" [$twin get 10.0 10.end]]
1074 move_mouse_to $twin [$twin bbox 10.$index]
1075 sleep 1
1076 if {[winfo ismapped $balloon]} {
1077 if {![string compare "x=2" [$balloon.label cget -text]]} {incr r}
1078 gdb_immediate "continue" 1
1079 if {![string compare "x=4" [$balloon.label cget -text]]} {incr r}
1080 } else {
1081 set r -1
1082 }
c98fe0c1 1083
40a7f1e9
MH
1084 set r
1085} {2}
c98fe0c1 1086
40a7f1e9
MH
1087# 6.1 mixed mode disassembly of include file
1088# Test: srcwin-6.1
1089# Desc: Some versions of GDBtk can't do mixed-mode disassembly of a function
1090# that is in an include file.
1091gdbtk_test srcwin-6.1 "mixed mode disassembly of include file" {
1092 set r 0
1093 $srcwin mode "" MIXED
c98fe0c1 1094
40a7f1e9
MH
1095 # check contents of name and function comboboxes
1096 set name [$statbar.name get]
1097 set func [$statbar.func get]
1098 if {$name != "list0.h"} {set r -1}
1099 if {$func != "foo"} {set r -2}
1100
1101 # check contents of source window
1102 set twin [$stw test_get twin]
1103 set text [$twin get 1.0 end]
1104 # Is it correct? I don't know. Guess we look for some pieces of source...
1105 if {[string first "static void" $text] != -1 &&
1106 [string first "foo (x)" $text] != -1 &&
1107 [string first "bar (x++);" $text] != -1} {
1108 set r 1
1109 }
1110
1111 set r
1112} {1}
1113
1114gdbtk_test_done
c98fe0c1
JI
1115
1116# Local variables:
1117# mode: tcl
40a7f1e9 1118# change-log-default-name: "ChangeLog-gdbtk"
c98fe0c1 1119# End:
This page took 0.097506 seconds and 4 git commands to generate.