Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2010-2016 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 | 23 | load_lib "trace-support.exp" |
00bf0b85 | 24 | |
32cfb09d TT |
25 | if {![is_remote host] && ![is_remote target]} { |
26 | set tfile_basic [standard_output_file tfile-basic.tf] | |
27 | set tfile_error [standard_output_file tfile-error.tf] | |
28 | set tfile_dir [file dirname $tfile_basic]/ | |
29 | set purely_local 1 | |
30 | } else { | |
31 | set tfile_basic tfile-basic.tf | |
32 | set tfile_error tfile-error.tf | |
33 | set tfile_dir "" | |
34 | set purely_local 0 | |
35 | } | |
36 | ||
497a5eb0 | 37 | standard_testfile |
00bf0b85 | 38 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ |
32cfb09d | 39 | executable \ |
1b5d0ab3 | 40 | [list debug \ |
32cfb09d TT |
41 | "additional_flags=-DTFILE_DIR=\"$tfile_dir\""]] \ |
42 | != "" } { | |
3b48433d | 43 | untested ${testfile}.exp |
00bf0b85 SS |
44 | return -1 |
45 | } | |
00bf0b85 SS |
46 | |
47 | # Make sure we are starting fresh. | |
32cfb09d TT |
48 | remote_file host delete $tfile_basic |
49 | remote_file host delete $tfile_error | |
50 | remote_file target delete $tfile_basic | |
51 | remote_file target delete $tfile_error | |
00bf0b85 | 52 | |
b4429ea2 | 53 | if { ![generate_tracefile $binfile] } { |
bc6c7af4 | 54 | unsupported "unable to generate trace file" |
ebcc6c3a | 55 | return -1 |
b4429ea2 YQ |
56 | } |
57 | ||
32cfb09d TT |
58 | if {!$purely_local} { |
59 | # Copy tracefile from target to host through build. | |
60 | remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf | |
61 | remote_download host [remote_upload target tfile-error.tf] tfile-error.tf | |
62 | } | |
00bf0b85 | 63 | |
b4429ea2 | 64 | clean_restart $binfile |
00bf0b85 SS |
65 | |
66 | # Program has presumably exited, now target a trace file it created. | |
67 | ||
32cfb09d TT |
68 | gdb_test "target tfile $tfile_basic" "Created tracepoint.*" \ |
69 | "target tfile [file tail $tfile_basic]" | |
00bf0b85 SS |
70 | |
71 | gdb_test "info trace" ".*tracepoint.*in write_basic_trace_file.*" \ | |
72 | "info tracepoints on trace file" | |
73 | ||
af54718e SS |
74 | gdb_test "tfind 0" \ |
75 | "Found trace frame 0, tracepoint \[0-9\]+. | |
76 | \#0 write_basic_trace_file ().*" \ | |
77 | "tfind 0 on trace file" | |
00bf0b85 | 78 | |
fce3c1f0 SS |
79 | # Note that there is no tracepoint collecting these globals, we |
80 | # just happen to know they are covered by the trace frame. | |
81 | ||
00bf0b85 SS |
82 | gdb_test "print testglob" " = 31415" "print testglob on trace file" |
83 | ||
fce3c1f0 SS |
84 | gdb_test "print testglob2" " = 271828" "print testglob2 on trace file" |
85 | ||
3f1175a9 PA |
86 | # This global is not covered by the trace frame, but since it's const, |
87 | # we should be able to read it from the executable. | |
88 | ||
fce3c1f0 SS |
89 | gdb_test "print constglob" " = 10000" "print constglob on trace file" |
90 | ||
3f1175a9 PA |
91 | # Similarly, disassembly should find the read-only pieces in the executable. |
92 | gdb_test "disassemble main" \ | |
93 | "Dump of assembler code for function main:.* $hex <\\+0\\>:.*End of assembler dump\." | |
94 | ||
95 | # This global is also not covered by the trace frame, and since it's | |
96 | # non-const, we should _not_ read it from the executable, as that | |
97 | # would show the variable's initial value, not the current at time the | |
98 | # trace frame was created. | |
99 | ||
100 | gdb_test "print nonconstglob" \ | |
101 | " = <unavailable>" "print nonconstglob on trace file" | |
102 | ||
00bf0b85 SS |
103 | gdb_test "tfind" "Target failed to find requested trace frame." \ |
104 | "tfind does not find a second frame in trace file" | |
105 | ||
106 | gdb_test "tstatus" \ | |
107 | "Using a trace file.* | |
108 | Trace stopped by a tstop command.* | |
4daf5ac0 SS |
109 | Collected 1 trace frame.* |
110 | Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).* | |
00bf0b85 SS |
111 | Looking at trace frame 0, tracepoint .*" \ |
112 | "tstatus on trace file" | |
113 | ||
ffd5ec24 PA |
114 | gdb_test "tfind end" "No longer looking at any trace frame" "leave tfind mode" |
115 | ||
116 | gdb_test "backtrace" "No stack\." \ | |
117 | "no stack if no traceframe selected" | |
118 | ||
119 | gdb_test "info registers" "The program has no registers now\." \ | |
120 | "no registers if no traceframe selected" | |
121 | ||
6c28cbf2 | 122 | # Now start afresh, using only a trace file. |
00bf0b85 | 123 | |
6c28cbf2 SS |
124 | gdb_exit |
125 | gdb_start | |
00bf0b85 | 126 | |
6c28cbf2 | 127 | gdb_load $binfile |
00bf0b85 | 128 | |
32cfb09d TT |
129 | gdb_test "target tfile $tfile_error" "Created tracepoint.*" \ |
130 | "target tfile [file tail $tfile_error]" | |
00bf0b85 | 131 | |
6c28cbf2 SS |
132 | gdb_test "tstatus" \ |
133 | "Using a trace file.* | |
134 | Trace stopped by an error \\(made-up error, tracepoint 1\\).* | |
135 | Collected 0 trace frame.* | |
136 | Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).* | |
137 | Not looking at any trace frame.*" \ | |
138 | "tstatus on error trace file" | |
c91c8c16 PA |
139 | |
140 | # Make sure we can reopen without error. | |
141 | gdb_test \ | |
32cfb09d TT |
142 | "interpreter-exec mi \"-target-select tfile $tfile_basic\"" \ |
143 | "\\^connected.*" \ | |
144 | "interpreter-exec mi \"-target-select tfile tfile-basic.tf\"" | |
f5911ea1 HAQ |
145 | |
146 | gdb_test "interpreter-exec mi \"-trace-status\"" \ | |
32cfb09d | 147 | "\\^done,supported=\"file\",trace-file=\".*$tfile_basic\",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 | 148 | "-trace-status" |
9852c492 YQ |
149 | |
150 | # Test completion works well. | |
151 | ||
0d4d0e77 YQ |
152 | if { [readline_is_used] } { |
153 | gdb_test "target tfile [file rootname $tfile_basic]\t" \ | |
154 | "Assuming tracepoint.*" \ | |
155 | "complete-command 'target tfile'" | |
156 | } |