]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/trace-commands.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / trace-commands.exp
CommitLineData
6aba47ca 1# Copyright 2006, 2007 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
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# 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.
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
24gdb_exit
25gdb_start
26
27# Create a file to source
28set fd [open "tracecommandsscript" w]
29puts $fd "\
30echo in tracecommandsscript\\n
31define func
32 echo in func \$arg0\\n
33end
34if 1
35 if 2
36 if 3
37 if 4
38 echo deep\\n
39 func 999
40 end
41 end
42 end
43end
44"
45close $fd
46
47# Make sure that the show trace-commands exists and the default is 'off'.
48gdb_test "show trace-commands" "State of GDB CLI command tracing is off\\." \
49 "show trace-commands says off"
50
51# Source the script with verbose mode.
52send_gdb "source -v tracecommandsscript\n"
53gdb_expect_list "source -v" ".*$gdb_prompt $" {
54 {[\r\n]\+echo in tracecommandsscript\\n}
55 {[\r\n]\+define func}
56 {[\r\n]\+if 1}
57 {[\r\n]\+\+if 2}
58 {[\r\n]\+\+\+if 3}
59 {[\r\n]\+\+\+\+if 4}
60 {[\r\n]\+\+\+\+\+echo deep\\n}
61 {[\r\n]\+\+\+\+\+func 999}
62 {[\r\n]\+\+\+\+\+\+echo in func 999\\n}
63}
64
65# Turn on command tracing.
66gdb_test "set trace-commands" "" "set trace-commands"
67
68# Make sure show trace-commands now gives 'on'.
69gdb_test "show trace-commands" \
70 {\+show trace-commands[\r\n]+State of GDB CLI command tracing is on\.} \
71 "show trace-commands says on"
72
73# Simple test
74gdb_test "echo hi\\n" {\+echo hi\\n[\r\n]+hi} "simple trace-commands test"
75
76# Nested test
77send_gdb "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend\n"
78gdb_expect_list "nested trace-commands test" ".*$gdb_prompt $" {
79 {[\r\n]\+if 1}
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}
97}
98
99# Function with source works
100send_gdb "define topfunc\nsource tracecommandsscript\nend\n"
101gdb_expect_list "define user command" ".*$gdb_prompt $" {
102 {[\r\n]\+define topfunc}
103}
104send_gdb "topfunc\n"
105gdb_expect_list "nested trace-commands test with source" ".*$gdb_prompt $" {
106 {[\r\n]\+topfunc}
107 {[\r\n]\+\+source tracecommandsscript}
108 {[\r\n]\+\+echo in tracecommandsscript\\n}
109 {[\r\n]\+\+define func}
110 {[\r\n]\+\+if 1}
111 {[\r\n]\+\+\+if 2}
112 {[\r\n]\+\+\+\+if 3}
113 {[\r\n]\+\+\+\+\+if 4}
114 {[\r\n]\+\+\+\+\+\+echo deep\\n}
115 {[\r\n]\+\+\+\+\+\+func 999}
116 {[\r\n]\+\+\+\+\+\+\+echo in func 999\\n}
117}
118
119# Test nest depth resets properly on error
120send_gdb "if 1\nif 2\nload\necho should not get here\\n\nend\nend\n"
121gdb_expect_list "depth resets on error part 1" ".*$gdb_prompt $" {
122 {[\r\n]\+if 1}
123 {[\r\n]\+\+if 2}
124 {[\r\n]\+\+\+load}
125 {[\r\n]No executable file specified\.}
126 {[\r\n]Use the "file" or "exec-file" command\.}
127}
128gdb_test "echo hi\\n" {[\r\n]\+echo hi\\n[\r\n]+hi} \
129 "depth resets on error part 2"