1 # Copyright
2013-2022 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 load_lib
"trace-support.exp"
20 if {[prepare_for_testing
"failed to prepare" $testfile $srcfile {debug nopie}]} {
28 if ![gdb_target_supports_trace
] {
29 unsupported
"target does not support trace"
33 #
Set tracepoints
, start tracing and collect data.
35 proc set_tracepoint_and_collect
{ } {
36 global testfile srcfile
38 # Start with a fresh gdb.
39 clean_restart $
{testfile
}
43 gdb_breakpoint
"end" qualified
44 gdb_test
"trace start" "Tracepoint \[0-9\] at .*"
45 gdb_trace_setactions
"set action for tracepoint" "" \
46 "collect testglob" "^$" \
47 "collect constglob" "^$"
49 gdb_test_no_output
"tstart"
50 gdb_test
"continue" ".*Breakpoint.* end .*at.*$srcfile.*" \
52 gdb_test_no_output
"tstop"
55 with_test_prefix
"live" {
56 set_tracepoint_and_collect
58 gdb_test
"print testglob" " = 2"
59 gdb_test
"print testglob_not_collected" " = 12"
60 gdb_test
"print constglob" " = 10000"
61 gdb_test
"print constglob_not_collected" " = 100"
64 with_test_prefix
"live target tfind" {
65 gdb_test
"tfind 0" "Found trace frame 0, tracepoint \[0-9\]+.*" \
67 gdb_test
"print testglob" " = 1"
68 gdb_test
"print testglob_not_collected" " = <unavailable>"
69 gdb_test
"print constglob" " = 10000"
70 gdb_test
"print constglob_not_collected" " = 100"
71 gdb_test
"tfind" "Target failed to find requested trace frame." \
72 "tfind does not find a second frame"
75 # Save
trace frames to
trace file.
76 set tracefile
[standard_output_file $
{testfile
}]
77 gdb_test
"tsave ${tracefile}.tfile" \
78 "Trace data saved to file '${tracefile}.tfile'.*" \
81 # Test read memory when changing target from remote to $
{target
}.
83 proc test_from_remote
{ target
} {
84 global gdb_prompt testfile
87 with_test_prefix
"remote to ${target}" {
88 set_tracepoint_and_collect
90 # Change target to $
{target
}.
91 set test
"change target"
92 gdb_test_multiple
"target ${target} ${tracefile}.${target}" "$test" {
93 -re
"A program is being debugged already. Kill it. .y or n. " {
102 with_test_prefix
"w/o setting traceframe" {
103 gdb_test
"print testglob" " = <unavailable>"
104 gdb_test
"print testglob_not_collected" " = <unavailable>"
105 gdb_test
"print constglob" " = 10000"
106 gdb_test
"print constglob_not_collected" " = 100"
108 with_test_prefix
"w/ setting traceframe" {
109 gdb_test
"tfind 0" "Found trace frame 0, tracepoint \[0-9\]+.*" \
111 gdb_test
"print testglob" " = 1"
112 gdb_test
"print testglob_not_collected" " = <unavailable>"
113 gdb_test
"print constglob" " = 10000"
114 gdb_test
"print constglob_not_collected" " = 100"
115 gdb_test
"tfind" "Target failed to find requested trace frame." \
116 "tfind does not find a second frame"
121 test_from_remote
"tfile"
123 # Test read memory when changing target from exec to $
{target
}
125 proc teset_from_exec
{ target
} {
126 global srcdir subdir binfile testfile
129 # Restart GDB and read the
trace data in $
{target
} target.
132 gdb_reinitialize_dir $srcdir
/$subdir
133 gdb_file_cmd $binfile
135 gdb_test
"target ${target} ${tracefile}.${target}" ".*" \
136 "change to ${target} target"
138 with_test_prefix
"exec to ${target} w/o setting traceframe" {
139 gdb_test
"print testglob" " = <unavailable>"
140 gdb_test
"print testglob_not_collected" " = <unavailable>"
141 gdb_test
"print constglob" " = 10000"
142 gdb_test
"print constglob_not_collected" " = 100"
145 with_test_prefix
"exec to ${target} w/ setting traceframe" {
146 gdb_test
"tfind 0" "Found trace frame 0, tracepoint \[0-9\]+.*" \
148 gdb_test
"print testglob" " = 1"
149 gdb_test
"print testglob_not_collected" " = <unavailable>"
150 gdb_test
"print constglob" " = 10000"
151 gdb_test
"print constglob_not_collected" " = 100"
152 gdb_test
"tfind" "Target failed to find requested trace frame." \
153 "tfind does not find a second frame"
157 teset_from_exec
"tfile"