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