]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/tsv.exp
Fixup testcases outputting own name as a test name and standardize failed compilation...
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tsv.exp
CommitLineData
618f726f 1# Copyright 2009-2016 Free Software Foundation, Inc.
f61e138d
SS
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
4ec70201 16load_lib "trace-support.exp"
f61e138d 17
f61e138d
SS
18
19gdb_exit
20gdb_start
497a5eb0 21standard_testfile actions.c
f61e138d
SS
22if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
23 executable {debug nowarnings}] != "" } {
84c93cd5 24 untested "failed to compile"
f61e138d
SS
25 return -1
26}
0914bcdb 27gdb_load $binfile
f61e138d
SS
28
29gdb_test "tvariable \$tvar1" \
30 "Trace state variable \\\$tvar1 created, with initial value 0." \
bb95117e 31 "create a trace state variable"
f61e138d
SS
32
33gdb_test "tvariable \$tvar2 = 45" \
34 "Trace state variable \\\$tvar2 created, with initial value 45." \
bb95117e 35 "create a trace state variable with initial value"
f61e138d
SS
36
37gdb_test "tvariable \$tvar2 = -92" \
38 "Trace state variable \\\$tvar2 now has initial value -92." \
bb95117e 39 "change initial value of a trace state variable"
f61e138d
SS
40
41gdb_test "tvariable \$tvar3 = 2 + 3" \
42 "Trace state variable \\\$tvar3 created, with initial value 5." \
bb95117e 43 "create a trace state variable with expression"
f61e138d
SS
44
45gdb_test "tvariable \$tvar3 = 1234567000000" \
46 "Trace state variable \\\$tvar3 now has initial value 1234567000000." \
bb95117e 47 "init trace state variable to a 64-bit value"
f61e138d 48
1773c82c
HAQ
49gdb_test "tvariable $" \
50 "Must supply a non-empty variable name" \
51 "tvariable syntax error, not empty variable name"
52
f61e138d 53gdb_test "tvariable main" \
1773c82c 54 "Name of trace variable should start with '\\\$'" \
f61e138d
SS
55 "tvariable syntax error, bad name"
56
1773c82c
HAQ
57gdb_test "tvariable \$\$" \
58 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \
59 "tvariable syntax error, bad name 2"
60
61gdb_test "tvariable \$123" \
62 "\\\$123 is not a valid trace state variable name" \
63 "tvariable syntax error, bad name 3"
64
f61e138d
SS
65gdb_test "tvariable \$tvar1 - 93" \
66 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \
67 "tvariable syntax error, not an assignment"
68
1773c82c
HAQ
69gdb_test "tvariable \$tvar0 = 1 = 1" \
70 "Left operand of assignment is not an lvalue\." \
71 "tvariable creation fails with invalid expression"
72
f61e138d
SS
73gdb_test "info tvariables" \
74 "Name\[\t \]+Initial\[\t \]+Current.*
75\\\$tvar1\[\t \]+0\[\t \]+<undefined>.*
76\\\$tvar2\[\t \]+-92\[\t \]+<undefined>.*
77\\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \
78 "List tvariables"
79
0914bcdb
SS
80gdb_test "print \$tvar2" " = void" \
81 "Print a trace state variable before run"
82
e68d8fd4 83gdb_test_no_output "delete tvariable \$tvar2" \
f61e138d
SS
84 "delete trace state variable"
85
86gdb_test "info tvariables" \
87 "Name\[\t \]+Initial\[\t \]+Current.*
88\\\$tvar1\[\t \]+0\[\t \]+<undefined>.*
89\\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \
90 "List tvariables after deletion"
91
0ab48859
MS
92gdb_test "delete tvariable" \
93 "" \
94 "Delete all trace state variables" \
95 "Delete all trace state variables.*y or n.*$" \
96 "y"
f61e138d
SS
97
98gdb_test "info tvariables" \
99 "No trace state variables.*" \
bb95117e 100 "list tvariables after deleting all"
f61e138d 101
0914bcdb
SS
102# Now try running a trace.
103
104runto_main
105gdb_reinitialize_dir $srcdir/$subdir
106
107# The rest of the testing needs actual tracing to work.
108if { ![gdb_target_supports_trace] } then {
bc6c7af4 109 unsupported "current target does not support trace"
ae59b1da 110 return 1
0914bcdb
SS
111}
112
0914bcdb 113gdb_delete_tracepoints
4ec70201 114set trcpt1 [gdb_gettpnum gdb_c_test]
045dd51f
YQ
115
116if { $trcpt1 <= 0 } then {
0914bcdb 117 fail "setting tracepoints"
4ec70201 118 return
0914bcdb
SS
119}
120
121gdb_test "tvariable \$tvar5 = 15" \
122 "Trace state variable \\\$tvar5 created, with initial value 15." \
bb95117e 123 "create a trace state variable tvar5"
0914bcdb
SS
124
125gdb_trace_setactions "collect tsv for first tracepoint" \
126 "$trcpt1" \
127 "collect \$tvar5 += 1" "^$"
128
045dd51f 129gdb_test_no_output "tstart" ""
0914bcdb
SS
130
131gdb_test "print \$tvar5" " = 15" \
132 "Print a trace state variable at start of run"
133
134# Be sure not to fall off the end of the program.
135gdb_test "break end" ".*" ""
136gdb_test "continue" \
137 "Continuing.*Breakpoint $decimal, end.*" \
138 "run trace experiment"
139
140gdb_test "print \$tvar5" " = 16" \
141 "Print a trace state variable during run"
142
045dd51f 143gdb_test_no_output "tstop" ""
0914bcdb 144
8ddb1965
YQ
145# Save trace frames to tfile.
146set tracefile [standard_output_file ${testfile}]
147gdb_test "tsave ${tracefile}.tf" \
148 "Trace data saved to file '${tracefile}.tf'.*" \
149 "save tfile trace file"
393fd4c3
YQ
150# Save trace frames to ctf.
151gdb_test "tsave -ctf ${tracefile}.ctf" \
152 "Trace data saved to directory '${tracefile}.ctf'.*" \
153 "save ctf trace file"
8ddb1965
YQ
154
155proc check_tsv { data_source } {
156 with_test_prefix "${data_source}" {
157 gdb_test "tfind 0"
158 gdb_test "print \$tvar5" " = 16" \
159 "Print a trace state variable"
160 gdb_test "tfind" \
161 "Target failed to find requested trace frame.*"
162 }
163}
0914bcdb 164
8ddb1965
YQ
165# Check the tsv from the live inferior.
166check_tsv "live"
167
168# Change target to tfile.
169set test "change to tfile target"
170gdb_test_multiple "target tfile ${tracefile}.tf" "$test" {
171 -re "A program is being debugged already. Kill it. .y or n. " {
172 send_gdb "y\n"
173 exp_continue
174 }
175 -re "$gdb_prompt $" {
176 pass "$test"
177 }
178}
f61e138d 179
8ddb1965 180# Check the tsv from tfile.
393fd4c3 181
8ddb1965 182check_tsv "tfile"
393fd4c3
YQ
183# Try to read ctf data if GDB supports.
184gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
185 -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
186 }
187 -re ".*\r\n$gdb_prompt $" {
188 check_tsv "ctf"
189 }
190}
a0743c90
YQ
191
192# Restart.
193clean_restart ${binfile}
194
195if ![runto_main] then {
bc6c7af4 196 fail "can't run to main"
a0743c90
YQ
197 return
198}
199
200# If there are predefined TSVs, test these predefined TSVs are correctly
201# uploaded.
202if [target_info exists gdb,predefined_tsv] {
203 set tsv [target_info gdb,predefined_tsv]
204
205 # Test predefined TSVs are uploaded.
206 gdb_test "info tvariables" ".*${tsv}.*" "predefined tsvs are uploaded"
207} else {
208 # Otherwise (the predefined TSVs are not defined in the board file),
209 # test there is no TSVs in GDB.
210 gdb_test "info tvariables" "No trace state variables\." \
211 "no predefined tsvs"
212}