# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-load_lib "trace-support.exp";
+load_lib "trace-support.exp"
gdb_exit
# The rest of the testing needs actual tracing to work.
if { ![gdb_target_supports_trace] } then {
unsupported "Current target does not support trace"
- return 1;
+ return 1
}
gdb_delete_tracepoints
-set trcpt1 [gdb_gettpnum gdb_c_test];
+set trcpt1 [gdb_gettpnum gdb_c_test]
if { $trcpt1 <= 0 } then {
fail "setting tracepoints"
- return;
+ return
}
gdb_test "tvariable \$tvar5 = 15" \
gdb_test_no_output "tstop" ""
-gdb_test "print \$tvar5" " = 16" \
- "Print a trace state variable after run"
+# Save trace frames to tfile.
+set tracefile [standard_output_file ${testfile}]
+gdb_test "tsave ${tracefile}.tf" \
+ "Trace data saved to file '${tracefile}.tf'.*" \
+ "save tfile trace file"
+# Save trace frames to ctf.
+gdb_test "tsave -ctf ${tracefile}.ctf" \
+ "Trace data saved to directory '${tracefile}.ctf'.*" \
+ "save ctf trace file"
+
+proc check_tsv { data_source } {
+ with_test_prefix "${data_source}" {
+ gdb_test "tfind 0"
+ gdb_test "print \$tvar5" " = 16" \
+ "Print a trace state variable"
+ gdb_test "tfind" \
+ "Target failed to find requested trace frame.*"
+ }
+}
+
+# Check the tsv from the live inferior.
+check_tsv "live"
+
+# Change target to tfile.
+set test "change to tfile target"
+gdb_test_multiple "target tfile ${tracefile}.tf" "$test" {
+ -re "A program is being debugged already. Kill it. .y or n. " {
+ send_gdb "y\n"
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+}
+
+# Check the tsv from tfile.
+check_tsv "tfile"
+# Try to read ctf data if GDB supports.
+gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
+ -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
+ }
+ -re ".*\r\n$gdb_prompt $" {
+ check_tsv "ctf"
+ }
+}
+
+# Restart.
+clean_restart ${binfile}
+if ![runto_main] then {
+ fail "Can't run to main"
+ return
+}
+
+# If there are predefined TSVs, test these predefined TSVs are correctly
+# uploaded.
+if [target_info exists gdb,predefined_tsv] {
+ set tsv [target_info gdb,predefined_tsv]
+
+ # Test predefined TSVs are uploaded.
+ gdb_test "info tvariables" ".*${tsv}.*" "predefined tsvs are uploaded"
+} else {
+ # Otherwise (the predefined TSVs are not defined in the board file),
+ # test there is no TSVs in GDB.
+ gdb_test "info tvariables" "No trace state variables\." \
+ "no predefined tsvs"
+}