1 # Copyright 2006, 2007 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 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 # Test that the source command's verbose mode works, the 'set trace-commands'
18 # command works, and that the nest depth is correct in various circumstances.
27 # Create a file to source
28 set fd [open "tracecommandsscript" w]
30 echo in tracecommandsscript\\n
32 echo in func \$arg0\\n
47 # Make sure that the show trace-commands exists and the default is 'off'.
48 gdb_test "show trace-commands" "State of GDB CLI command tracing is off\\." \
49 "show trace-commands says off"
51 # Source the script with verbose mode.
52 send_gdb "source -v tracecommandsscript\n"
53 gdb_expect_list "source -v" ".*$gdb_prompt $" {
54 {[\r\n]\+echo in tracecommandsscript\\n}
60 {[\r\n]\+\+\+\+\+echo deep\\n}
61 {[\r\n]\+\+\+\+\+func 999}
62 {[\r\n]\+\+\+\+\+\+echo in func 999\\n}
65 # Turn on command tracing.
66 gdb_test "set trace-commands" "" "set trace-commands"
68 # Make sure show trace-commands now gives 'on'.
69 gdb_test "show trace-commands" \
70 {\+show trace-commands[\r\n]+State of GDB CLI command tracing is on\.} \
71 "show trace-commands says on"
74 gdb_test "echo hi\\n" {\+echo hi\\n[\r\n]+hi} "simple trace-commands test"
77 send_gdb "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend\n"
78 gdb_expect_list "nested trace-commands test" ".*$gdb_prompt $" {
80 {[\r\n]\+\+set \$i = 0}
81 {[\r\n]\+\+while \$i < 5}
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 {[\r\n]\+\+\+func \$i}
92 {[\r\n]\+\+\+\+echo in func \$i\\n}
93 {[\r\n]\+\+\+set \$i \+= 1}
94 {[\r\n]\+\+\+func \$i}
95 {[\r\n]\+\+\+\+echo in func \$i\\n}
96 {[\r\n]\+\+\+set \$i \+= 1}
99 # Function with source works
100 send_gdb "define topfunc\nsource tracecommandsscript\nend\n"
101 gdb_expect_list "define user command" ".*$gdb_prompt $" {
102 {[\r\n]\+define topfunc}
105 gdb_expect_list "nested trace-commands test with source" ".*$gdb_prompt $" {
107 {[\r\n]\+\+source tracecommandsscript}
108 {[\r\n]\+\+echo in tracecommandsscript\\n}
109 {[\r\n]\+\+define func}
113 {[\r\n]\+\+\+\+\+if 4}
114 {[\r\n]\+\+\+\+\+\+echo deep\\n}
115 {[\r\n]\+\+\+\+\+\+func 999}
116 {[\r\n]\+\+\+\+\+\+\+echo in func 999\\n}
119 # Test nest depth resets properly on error
120 send_gdb "if 1\nif 2\nload\necho should not get here\\n\nend\nend\n"
121 gdb_expect_list "depth resets on error part 1" ".*$gdb_prompt $" {
125 {[\r\n]No executable file specified\.}
126 {[\r\n]Use the "file" or "exec-file" command\.}
128 gdb_test "echo hi\\n" {[\r\n]\+echo hi\\n[\r\n]+hi} \
129 "depth resets on error part 2"