Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.trace / read-memory.exp
blobc42bac02f8a56f78a8f7a21fe8252353fee0c221
1 #   Copyright 2013-2024 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"
18 standard_testfile
20 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nopie}]} {
21     return -1
24 if ![runto_main] {
25     return -1
28 if ![gdb_target_supports_trace] {
29     unsupported "target does not support trace"
30     return -1
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}
40     if ![runto_main] {
41         return -1
42     }
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.*" \
51         "continue to end"
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\]+.*" \
66         "tfind 0"
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'.*" \
79     "save tfile trace"
81 # Test read memory when changing target from remote to ${target}.
83 proc test_from_remote { target } {
84     global gdb_prompt testfile
85     global tracefile
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. " {
94                 send_gdb "y\n"
95                 exp_continue
96             }
97             -re "$gdb_prompt $" {
98                 pass "$test"
99             }
100         }
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"
107         }
108         with_test_prefix "w/ setting traceframe" {
109             gdb_test "tfind 0" "Found trace frame 0, tracepoint \[0-9\]+.*" \
110                 "tfind 0"
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"
117         }
118     }
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
127     global tracefile
129     # Restart GDB and read the trace data in ${target} target.
130     clean_restart
131     gdb_file_cmd $binfile
133     gdb_test "target ${target} ${tracefile}.${target}" ".*" \
134         "change to ${target} target"
136     with_test_prefix "exec to ${target} w/o setting traceframe" {
137         gdb_test "print testglob" " = <unavailable>"
138         gdb_test "print testglob_not_collected" " = <unavailable>"
139         gdb_test "print constglob" " = 10000"
140         gdb_test "print constglob_not_collected" " = 100"
141     }
143     with_test_prefix "exec to ${target} w/ setting traceframe" {
144         gdb_test "tfind 0" "Found trace frame 0, tracepoint \[0-9\]+.*" \
145             "tfind 0"
146         gdb_test "print testglob" " = 1"
147         gdb_test "print testglob_not_collected" " = <unavailable>"
148         gdb_test "print constglob" " = 10000"
149         gdb_test "print constglob_not_collected" " = 100"
150         gdb_test "tfind" "Target failed to find requested trace frame." \
151             "tfind does not find a second frame"
152     }
155 teset_from_exec "tfile"