+2014-04-22 Yao Qi <yao@codesourcery.com>
+
+ * lib/trace-support.exp (generate_tracefile): New procedure.
+ * gdb.trace/tfile.exp: Skip the test if generate_tracefile
+ return 0.
+ * gdb.trace/mi-traceframe-changed.exp: Invoke test_tfind_tfile
+ if generate_tracefile returns 1.
+
2014-04-18 Tom Tromey <palves@redhat.com>
Pedro alves <tromey@redhat.com>
remote_file host delete $tfile_basic
remote_file target delete $tfile_basic
-remote_exec target "$binfile"
-
-if {!$purely_local} {
- # Copy tracefile from target to host.
- remote_download host [remote_upload target tfile-basic.tf] \
- tfile-basic.tf
-}
-
proc test_tfind_tfile { } {
with_test_prefix "tfile" {
global binfile
}
}
-test_tfind_tfile
+# If tracefile is generated successfully, copy tracefile to host and
+# run tests.
+if [generate_tracefile $binfile] {
+ if {!$purely_local} {
+ # Copy tracefile from target to host.
+ remote_download host [remote_upload target tfile-basic.tf] \
+ tfile-basic.tf
+ }
+
+ test_tfind_tfile
+}
# Change to a different test case in order to run it on target, and get
# several traceframes.
set purely_local 0
}
-gdb_exit
-gdb_start
standard_testfile
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
executable \
untested ${testfile}.exp
return -1
}
-gdb_reinitialize_dir $srcdir/$subdir
# Make sure we are starting fresh.
remote_file host delete $tfile_basic
remote_file target delete $tfile_basic
remote_file target delete $tfile_error
-remote_exec target "$binfile"
+if { ![generate_tracefile $binfile] } {
+ unsupported "Unable to generate trace file"
+}
+
if {!$purely_local} {
# Copy tracefile from target to host through build.
remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf
remote_download host [remote_upload target tfile-error.tf] tfile-error.tf
}
-gdb_load $binfile
+clean_restart $binfile
# Program has presumably exited, now target a trace file it created.
return $objdir/../gdbserver/libinproctrace.so
}
}
+
+# Execute BINFILE on target to generate tracefile. Return 1 if
+# tracefile is generated successfully, return 0 otherwise.
+
+proc generate_tracefile { binfile } {
+ set status [remote_exec target "$binfile"]
+
+ if { [lindex $status 0] != 0 } {
+ # Failed to execute $binfile, for example on bare metal targets.
+ # Alternatively, load the binary and run it. If target doesn't
+ # have fileio capabilities, tracefile can't be generated. Skip
+ # the test.
+ if [target_info exists gdb,nofileio] {
+ return 0
+ }
+
+ clean_restart $binfile
+
+ if ![runto_main] then {
+ return 0
+ }
+ gdb_continue_to_end "" continue 1
+ gdb_exit
+ }
+
+ return 1
+}