]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/tfile.exp
fix up gdb.mi
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tfile.exp
CommitLineData
8acc9f48 1# Copyright 2010-2013 Free Software Foundation, Inc.
00bf0b85
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
16# Test of trace file support.
17
18# Note that unlike most of the tracing tests, this can be run on
19# targets lacking tracepoint support; the program tfile.c has the
20# ability to generate synthetic trace files directly, and the tfile
21# target is available to all GDB configs.
22
4ec70201 23load_lib "trace-support.exp"
00bf0b85 24
00bf0b85
SS
25gdb_exit
26gdb_start
497a5eb0 27standard_testfile
00bf0b85
SS
28if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
29 executable {debug nowarnings}] != "" } {
3b48433d 30 untested ${testfile}.exp
00bf0b85
SS
31 return -1
32}
33gdb_reinitialize_dir $srcdir/$subdir
34
35# Make sure we are starting fresh.
1dcaed0d
YQ
36remote_file host delete tfile-basic.tf
37remote_file host delete tfile-error.tf
38remote_file target delete tfile-basic.tf
39remote_file target delete tfile-error.tf
00bf0b85 40
61b1d759
YQ
41remote_exec target "$binfile"
42# Copy tracefile from target to host through build.
1dcaed0d
YQ
43remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf
44remote_download host [remote_upload target tfile-error.tf] tfile-error.tf
00bf0b85 45
61b1d759 46gdb_load $binfile
00bf0b85
SS
47
48# Program has presumably exited, now target a trace file it created.
49
1dcaed0d
YQ
50gdb_test "target tfile tfile-basic.tf" "Created tracepoint.*" \
51 "target tfile"
00bf0b85
SS
52
53gdb_test "info trace" ".*tracepoint.*in write_basic_trace_file.*" \
54 "info tracepoints on trace file"
55
af54718e
SS
56gdb_test "tfind 0" \
57 "Found trace frame 0, tracepoint \[0-9\]+.
58\#0 write_basic_trace_file ().*" \
59 "tfind 0 on trace file"
00bf0b85 60
fce3c1f0
SS
61# Note that there is no tracepoint collecting these globals, we
62# just happen to know they are covered by the trace frame.
63
00bf0b85
SS
64gdb_test "print testglob" " = 31415" "print testglob on trace file"
65
fce3c1f0
SS
66gdb_test "print testglob2" " = 271828" "print testglob2 on trace file"
67
3f1175a9
PA
68# This global is not covered by the trace frame, but since it's const,
69# we should be able to read it from the executable.
70
fce3c1f0
SS
71gdb_test "print constglob" " = 10000" "print constglob on trace file"
72
3f1175a9
PA
73# Similarly, disassembly should find the read-only pieces in the executable.
74gdb_test "disassemble main" \
75 "Dump of assembler code for function main:.* $hex <\\+0\\>:.*End of assembler dump\."
76
77# This global is also not covered by the trace frame, and since it's
78# non-const, we should _not_ read it from the executable, as that
79# would show the variable's initial value, not the current at time the
80# trace frame was created.
81
82gdb_test "print nonconstglob" \
83 " = <unavailable>" "print nonconstglob on trace file"
84
00bf0b85
SS
85gdb_test "tfind" "Target failed to find requested trace frame." \
86 "tfind does not find a second frame in trace file"
87
88gdb_test "tstatus" \
89 "Using a trace file.*
90Trace stopped by a tstop command.*
4daf5ac0
SS
91Collected 1 trace frame.*
92Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).*
00bf0b85
SS
93Looking at trace frame 0, tracepoint .*" \
94 "tstatus on trace file"
95
ffd5ec24
PA
96gdb_test "tfind end" "No longer looking at any trace frame" "leave tfind mode"
97
98gdb_test "backtrace" "No stack\." \
99 "no stack if no traceframe selected"
100
101gdb_test "info registers" "The program has no registers now\." \
102 "no registers if no traceframe selected"
103
6c28cbf2 104# Now start afresh, using only a trace file.
00bf0b85 105
6c28cbf2
SS
106gdb_exit
107gdb_start
00bf0b85 108
6c28cbf2 109gdb_load $binfile
00bf0b85 110
1dcaed0d
YQ
111gdb_test "target tfile tfile-error.tf" "Created tracepoint.*" \
112 "target tfile"
00bf0b85 113
6c28cbf2
SS
114gdb_test "tstatus" \
115 "Using a trace file.*
116Trace stopped by an error \\(made-up error, tracepoint 1\\).*
117Collected 0 trace frame.*
118Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).*
119Not looking at any trace frame.*" \
120 "tstatus on error trace file"
c91c8c16 121
c0ea94eb
YQ
122gdb_test "info threads" "No threads\..*"
123gdb_test "info inferiors" "\\* 1 <null>\[ \t\]+${binfile}.*"
124
c91c8c16
PA
125# Make sure we can reopen without error.
126gdb_test \
1dcaed0d 127 "interpreter-exec mi \"-target-select tfile tfile-basic.tf\"" \
c91c8c16 128 "\\^connected.*"
f5911ea1
HAQ
129
130gdb_test "interpreter-exec mi \"-trace-status\"" \
1dcaed0d 131 "\\^done,supported=\"file\",trace-file=\".*tfile-basic.tf\",running=\"0\",stop-reason=\"request\",frames=\"${decimal}\",frames-created=\"${decimal}\",buffer-size=\"${decimal}\",buffer-free=\"${decimal}\",disconnected=\".*\",circular=\".*\",user-name=\"\",notes=\"\",start-time=\".*\",stop-time=\".*\"" \
f5911ea1 132 "-trace-status"
9852c492
YQ
133
134# Test completion works well.
135
1dcaed0d 136gdb_test "target tfile tfile-basic\t" "Assuming tracepoint.*" \
9852c492 137 "complete-command 'target tfile'"