Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 2006-2012 Free Software Foundation, Inc. |
8625200f AS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
8625200f AS |
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 | |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8625200f AS |
15 | |
16 | # Test that the source command's verbose mode works, the 'set trace-commands' | |
17 | # command works, and that the nest depth is correct in various circumstances. | |
18 | ||
8625200f AS |
19 | gdb_exit |
20 | gdb_start | |
21 | ||
22 | # Create a file to source | |
23 | set fd [open "tracecommandsscript" w] | |
24 | puts $fd "\ | |
25 | echo in tracecommandsscript\\n | |
26 | define func | |
27 | echo in func \$arg0\\n | |
28 | end | |
29 | if 1 | |
30 | if 2 | |
31 | if 3 | |
32 | if 4 | |
33 | echo deep\\n | |
34 | func 999 | |
35 | end | |
36 | end | |
37 | end | |
38 | end | |
39 | " | |
40 | close $fd | |
41 | ||
42 | # Make sure that the show trace-commands exists and the default is 'off'. | |
43 | gdb_test "show trace-commands" "State of GDB CLI command tracing is off\\." \ | |
44 | "show trace-commands says off" | |
45 | ||
46 | # Source the script with verbose mode. | |
5fa290c1 | 47 | gdb_test_sequence "source -v tracecommandsscript" "source -v" { |
8625200f AS |
48 | {[\r\n]\+echo in tracecommandsscript\\n} |
49 | {[\r\n]\+define func} | |
50 | {[\r\n]\+if 1} | |
51 | {[\r\n]\+\+if 2} | |
52 | {[\r\n]\+\+\+if 3} | |
53 | {[\r\n]\+\+\+\+if 4} | |
54 | {[\r\n]\+\+\+\+\+echo deep\\n} | |
55 | {[\r\n]\+\+\+\+\+func 999} | |
56 | {[\r\n]\+\+\+\+\+\+echo in func 999\\n} | |
57 | } | |
58 | ||
59 | # Turn on command tracing. | |
27d3a1a2 | 60 | gdb_test_no_output "set trace-commands" "set trace-commands" |
8625200f AS |
61 | |
62 | # Make sure show trace-commands now gives 'on'. | |
63 | gdb_test "show trace-commands" \ | |
64 | {\+show trace-commands[\r\n]+State of GDB CLI command tracing is on\.} \ | |
65 | "show trace-commands says on" | |
66 | ||
67 | # Simple test | |
68 | gdb_test "echo hi\\n" {\+echo hi\\n[\r\n]+hi} "simple trace-commands test" | |
69 | ||
70 | # Nested test | |
5fa290c1 DE |
71 | gdb_test_sequence "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend" \ |
72 | "nested trace-commands test" { | |
8625200f AS |
73 | {[\r\n]\+if 1} |
74 | {[\r\n]\+\+set \$i = 0} | |
75 | {[\r\n]\+\+while \$i < 5} | |
76 | {[\r\n]\+\+\+func \$i} | |
77 | {[\r\n]\+\+\+\+echo in func \$i\\n} | |
78 | {[\r\n]\+\+\+set \$i \+= 1} | |
79 | {[\r\n]\+\+\+func \$i} | |
80 | {[\r\n]\+\+\+\+echo in func \$i\\n} | |
81 | {[\r\n]\+\+\+set \$i \+= 1} | |
82 | {[\r\n]\+\+\+func \$i} | |
83 | {[\r\n]\+\+\+\+echo in func \$i\\n} | |
84 | {[\r\n]\+\+\+set \$i \+= 1} | |
85 | {[\r\n]\+\+\+func \$i} | |
86 | {[\r\n]\+\+\+\+echo in func \$i\\n} | |
87 | {[\r\n]\+\+\+set \$i \+= 1} | |
88 | {[\r\n]\+\+\+func \$i} | |
89 | {[\r\n]\+\+\+\+echo in func \$i\\n} | |
90 | {[\r\n]\+\+\+set \$i \+= 1} | |
91 | } | |
92 | ||
93 | # Function with source works | |
5fa290c1 DE |
94 | gdb_test_sequence "define topfunc\nsource tracecommandsscript\nend" \ |
95 | "define user command" { | |
8625200f AS |
96 | {[\r\n]\+define topfunc} |
97 | } | |
5fa290c1 | 98 | gdb_test_sequence "topfunc" "nested trace-commands test with source" { |
8625200f AS |
99 | {[\r\n]\+topfunc} |
100 | {[\r\n]\+\+source tracecommandsscript} | |
101 | {[\r\n]\+\+echo in tracecommandsscript\\n} | |
102 | {[\r\n]\+\+define func} | |
103 | {[\r\n]\+\+if 1} | |
104 | {[\r\n]\+\+\+if 2} | |
105 | {[\r\n]\+\+\+\+if 3} | |
106 | {[\r\n]\+\+\+\+\+if 4} | |
107 | {[\r\n]\+\+\+\+\+\+echo deep\\n} | |
108 | {[\r\n]\+\+\+\+\+\+func 999} | |
109 | {[\r\n]\+\+\+\+\+\+\+echo in func 999\\n} | |
110 | } | |
111 | ||
112 | # Test nest depth resets properly on error | |
5fa290c1 DE |
113 | gdb_test_sequence "if 1\nif 2\nload\necho should not get here\\n\nend\nend" \ |
114 | "depth resets on error part 1" { | |
8625200f AS |
115 | {[\r\n]\+if 1} |
116 | {[\r\n]\+\+if 2} | |
117 | {[\r\n]\+\+\+load} | |
118 | {[\r\n]No executable file specified\.} | |
119 | {[\r\n]Use the "file" or "exec-file" command\.} | |
120 | } | |
121 | gdb_test "echo hi\\n" {[\r\n]\+echo hi\\n[\r\n]+hi} \ | |
122 | "depth resets on error part 2" |