1 # Copyright 2006, 2007, 2008 Free Software Foundation, 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 3 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, see <http://www.gnu.org/licenses/>.
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.
26 # Create a file to source
27 set fd [open "tracecommandsscript" w]
29 echo in tracecommandsscript\\n
31 echo in func \$arg0\\n
46 # Make sure that the show trace-commands exists and the default is 'off'.
47 gdb_test "show trace-commands" "State of GDB CLI command tracing is off\\." \
48 "show trace-commands says off"
50 # Source the script with verbose mode.
51 send_gdb "source -v tracecommandsscript\n"
52 gdb_expect_list "source -v" ".*$gdb_prompt $" {
53 {[\r\n]\+echo in tracecommandsscript\\n}
59 {[\r\n]\+\+\+\+\+echo deep\\n}
60 {[\r\n]\+\+\+\+\+func 999}
61 {[\r\n]\+\+\+\+\+\+echo in func 999\\n}
64 # Turn on command tracing.
65 gdb_test "set trace-commands" "" "set trace-commands"
67 # Make sure show trace-commands now gives 'on'.
68 gdb_test "show trace-commands" \
69 {\+show trace-commands[\r\n]+State of GDB CLI command tracing is on\.} \
70 "show trace-commands says on"
73 gdb_test "echo hi\\n" {\+echo hi\\n[\r\n]+hi} "simple trace-commands test"
76 send_gdb "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend\n"
77 gdb_expect_list "nested trace-commands test" ".*$gdb_prompt $" {
79 {[\r\n]\+\+set \$i = 0}
80 {[\r\n]\+\+while \$i < 5}
81 {[\r\n]\+\+\+func \$i}
82 {[\r\n]\+\+\+\+echo in func \$i\\n}
83 {[\r\n]\+\+\+set \$i \+= 1}
84 {[\r\n]\+\+\+func \$i}
85 {[\r\n]\+\+\+\+echo in func \$i\\n}
86 {[\r\n]\+\+\+set \$i \+= 1}
87 {[\r\n]\+\+\+func \$i}
88 {[\r\n]\+\+\+\+echo in func \$i\\n}
89 {[\r\n]\+\+\+set \$i \+= 1}
90 {[\r\n]\+\+\+func \$i}
91 {[\r\n]\+\+\+\+echo in func \$i\\n}
92 {[\r\n]\+\+\+set \$i \+= 1}
93 {[\r\n]\+\+\+func \$i}
94 {[\r\n]\+\+\+\+echo in func \$i\\n}
95 {[\r\n]\+\+\+set \$i \+= 1}
98 # Function with source works
99 send_gdb "define topfunc\nsource tracecommandsscript\nend\n"
100 gdb_expect_list "define user command" ".*$gdb_prompt $" {
101 {[\r\n]\+define topfunc}
104 gdb_expect_list "nested trace-commands test with source" ".*$gdb_prompt $" {
106 {[\r\n]\+\+source tracecommandsscript}
107 {[\r\n]\+\+echo in tracecommandsscript\\n}
108 {[\r\n]\+\+define func}
112 {[\r\n]\+\+\+\+\+if 4}
113 {[\r\n]\+\+\+\+\+\+echo deep\\n}
114 {[\r\n]\+\+\+\+\+\+func 999}
115 {[\r\n]\+\+\+\+\+\+\+echo in func 999\\n}
118 # Test nest depth resets properly on error
119 send_gdb "if 1\nif 2\nload\necho should not get here\\n\nend\nend\n"
120 gdb_expect_list "depth resets on error part 1" ".*$gdb_prompt $" {
124 {[\r\n]No executable file specified\.}
125 {[\r\n]Use the "file" or "exec-file" command\.}
127 gdb_test "echo hi\\n" {[\r\n]\+echo hi\\n[\r\n]+hi} \
128 "depth resets on error part 2"