2011-02-16 Tom Tromey <tromey@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tsv.exp
1 # Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15
16 load_lib "trace-support.exp";
17
18 if $tracelevel then {
19 strace $tracelevel
20 }
21
22
23 gdb_exit
24 gdb_start
25 set testfile "actions"
26 set srcfile ${testfile}.c
27 set binfile $objdir/$subdir/tsv
28 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
29 executable {debug nowarnings}] != "" } {
30 untested tsv.exp
31 return -1
32 }
33 gdb_load $binfile
34
35 gdb_test "tvariable \$tvar1" \
36 "Trace state variable \\\$tvar1 created, with initial value 0." \
37 "Create a trace state variable"
38
39 gdb_test "tvariable \$tvar2 = 45" \
40 "Trace state variable \\\$tvar2 created, with initial value 45." \
41 "Create a trace state variable with initial value"
42
43 gdb_test "tvariable \$tvar2 = -92" \
44 "Trace state variable \\\$tvar2 now has initial value -92." \
45 "Change initial value of a trace state variable"
46
47 gdb_test "tvariable \$tvar3 = 2 + 3" \
48 "Trace state variable \\\$tvar3 created, with initial value 5." \
49 "Create a trace state variable with expression"
50
51 gdb_test "tvariable \$tvar3 = 1234567000000" \
52 "Trace state variable \\\$tvar3 now has initial value 1234567000000." \
53 "Init trace state variable to a 64-bit value"
54
55 gdb_test "tvariable main" \
56 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \
57 "tvariable syntax error, bad name"
58
59 gdb_test "tvariable \$tvar1 - 93" \
60 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \
61 "tvariable syntax error, not an assignment"
62
63 gdb_test "info tvariables" \
64 "Name\[\t \]+Initial\[\t \]+Current.*
65 \\\$tvar1\[\t \]+0\[\t \]+<undefined>.*
66 \\\$tvar2\[\t \]+-92\[\t \]+<undefined>.*
67 \\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \
68 "List tvariables"
69
70 gdb_test "print \$tvar2" " = void" \
71 "Print a trace state variable before run"
72
73 gdb_test_no_output "delete tvariable \$tvar2" \
74 "delete trace state variable"
75
76 gdb_test "info tvariables" \
77 "Name\[\t \]+Initial\[\t \]+Current.*
78 \\\$tvar1\[\t \]+0\[\t \]+<undefined>.*
79 \\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \
80 "List tvariables after deletion"
81
82 gdb_test "delete tvariable" \
83 "" \
84 "Delete all trace state variables" \
85 "Delete all trace state variables.*y or n.*$" \
86 "y"
87
88 gdb_test "info tvariables" \
89 "No trace state variables.*" \
90 "List tvariables after deleting all"
91
92 # Now try running a trace.
93
94 runto_main
95 gdb_reinitialize_dir $srcdir/$subdir
96
97 # The rest of the testing needs actual tracing to work.
98 if { ![gdb_target_supports_trace] } then {
99 pass "Current target does not support trace"
100 return 1;
101 }
102
103 # define relative source line numbers:
104 # all subsequent line numbers are relative to this first one (baseline)
105
106 set baseline [gdb_find_recursion_test_baseline $srcfile];
107 if { $baseline == -1 } then {
108 fail "Could not find gdb_recursion_test function"
109 return;
110 }
111
112 set testline1 [expr $baseline + 7]
113
114 gdb_delete_tracepoints
115 set trcpt1 [gdb_gettpnum gdb_c_test];
116 set trcpt2 [gdb_gettpnum gdb_asm_test];
117 set trcpt3 [gdb_gettpnum $testline1];
118 if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
119 fail "setting tracepoints"
120 return;
121 }
122
123 gdb_test "tvariable \$tvar5 = 15" \
124 "Trace state variable \\\$tvar5 created, with initial value 15." \
125 "Create a trace state variable tvar5"
126
127 gdb_trace_setactions "collect tsv for first tracepoint" \
128 "$trcpt1" \
129 "collect \$tvar5 += 1" "^$"
130
131 gdb_test "tstart" ".*" ""
132
133 gdb_test "print \$tvar5" " = 15" \
134 "Print a trace state variable at start of run"
135
136 # Be sure not to fall off the end of the program.
137 gdb_test "break end" ".*" ""
138 gdb_test "continue" \
139 "Continuing.*Breakpoint $decimal, end.*" \
140 "run trace experiment"
141
142 gdb_test "print \$tvar5" " = 16" \
143 "Print a trace state variable during run"
144
145 gdb_test "tstop" ".*" ""
146
147 gdb_test "print \$tvar5" " = 16" \
148 "Print a trace state variable after run"
149
150
This page took 0.032708 seconds and 4 git commands to generate.