Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2011-2022 Free Software Foundation, Inc. |
f196051f SS |
2 | # This program is free software; you can redistribute it and/or modify |
3 | # it under the terms of the GNU General Public License as published by | |
4 | # the Free Software Foundation; either version 3 of the License, or | |
5 | # (at your option) any later version. | |
6 | # | |
7 | # This program is distributed in the hope that it will be useful, | |
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | # GNU General Public License for more details. | |
11 | # | |
12 | # You should have received a copy of the GNU General Public License | |
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | ||
15 | load_lib "trace-support.exp" | |
16 | ||
497a5eb0 | 17 | standard_testfile actions.c |
f196051f | 18 | set executable $testfile |
f196051f SS |
19 | set expfile tstatus.exp |
20 | ||
8bca2978 SL |
21 | if ![gdb_trace_common_supports_arch] { |
22 | unsupported "no trace-common.h support for arch" | |
23 | return -1 | |
24 | } | |
25 | ||
5b362f04 | 26 | if [prepare_for_testing "failed to prepare" $executable $srcfile \ |
f196051f | 27 | [list debug]] { |
f196051f SS |
28 | return -1 |
29 | } | |
30 | ||
31 | if ![runto_main] { | |
bc6c7af4 | 32 | fail "can't run to main to check for trace support" |
f196051f SS |
33 | return -1 |
34 | } | |
35 | ||
36 | if ![gdb_target_supports_trace] { | |
37 | unsupported "target does not support trace" | |
38 | return -1 | |
39 | } | |
40 | ||
e2be70a0 YQ |
41 | set tstatus_output "" |
42 | ||
f196051f | 43 | proc run_trace_experiment {} { |
968643aa | 44 | global gdb_prompt |
5ae4861a | 45 | global decimal |
e2be70a0 | 46 | global tstatus_output |
f196051f SS |
47 | |
48 | # gdb_test_no_output "set debug remote 1" "" | |
49 | ||
50 | gdb_test "continue" \ | |
51 | ".*Breakpoint \[0-9\]+, begin .*" \ | |
52 | "advance to trace begin" | |
53 | ||
54 | gdb_test_no_output "tstart my tracing note" "start trace experiment" | |
55 | ||
56 | gdb_test "continue" \ | |
57 | ".*Breakpoint \[0-9\]+, end .*" \ | |
58 | "advance through tracing" | |
59 | ||
60 | # Now play with tstatus a bit. | |
f196051f | 61 | |
049109b0 PA |
62 | # Since support for notes, user, stop reason, etc. is optional, we |
63 | # need to match both with and without cases. | |
64 | ||
65 | set test "tstatus reports trace note" | |
66 | gdb_test_multiple "tstatus" $test { | |
968643aa | 67 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: my tracing note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { |
049109b0 | 68 | pass $test |
f196051f | 69 | } |
968643aa | 70 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { |
049109b0 | 71 | unsupported $test |
f196051f SS |
72 | } |
73 | } | |
74 | ||
75 | gdb_test "set trace-notes different note" "" "change tracing note" | |
76 | ||
049109b0 PA |
77 | set test "tstatus reports different trace note" |
78 | gdb_test_multiple "tstatus" $test { | |
968643aa | 79 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { |
049109b0 | 80 | pass $test |
f196051f | 81 | } |
968643aa | 82 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { |
049109b0 | 83 | unsupported $test |
f196051f SS |
84 | } |
85 | } | |
86 | ||
87 | gdb_test "set trace-user me me me" "" "change tracing user" | |
88 | ||
049109b0 PA |
89 | set test "tstatus reports trace user" |
90 | gdb_test_multiple "tstatus" $test { | |
968643aa | 91 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { |
049109b0 | 92 | pass $test |
f196051f | 93 | } |
968643aa | 94 | -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { |
049109b0 | 95 | unsupported $test |
f196051f SS |
96 | } |
97 | } | |
98 | ||
99 | gdb_test_no_output "tstop because I can" "trace stopped with note" | |
100 | ||
049109b0 PA |
101 | set test "tstatus reports trace stop reason" |
102 | gdb_test_multiple "tstatus" $test { | |
e2be70a0 YQ |
103 | -re "(Trace stopped by a tstop command \\(because I can\\)\..*Trace will stop if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\.).*\r\n$gdb_prompt $" { |
104 | set tstatus_output $expect_out(1,string) | |
049109b0 | 105 | pass $test |
f196051f | 106 | } |
e2be70a0 YQ |
107 | -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" { |
108 | set tstatus_output $expect_out(1,string) | |
049109b0 | 109 | unsupported $test |
f196051f SS |
110 | } |
111 | } | |
112 | ||
049109b0 PA |
113 | set test "info trace reports tracepoint hit count and traceframe usage" |
114 | gdb_test_multiple "info trace" $test { | |
5ae4861a | 115 | -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\r\n\]+\[\t ]+trace buffer usage ${decimal} bytes\.\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" { |
049109b0 | 116 | pass $test |
f196051f | 117 | } |
968643aa | 118 | -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" { |
049109b0 | 119 | unsupported $test |
f196051f SS |
120 | } |
121 | } | |
122 | } | |
123 | ||
124 | proc test_tracepoints {} { | |
968643aa | 125 | global gdb_prompt |
f196051f | 126 | |
194ed413 | 127 | gdb_breakpoint "begin" qualified |
f196051f | 128 | |
194ed413 | 129 | gdb_breakpoint "end" qualified |
f196051f SS |
130 | |
131 | gdb_test "trace gdb_c_test" "Tracepoint .*" \ | |
132 | "tracepoint at gdb_c_test" | |
133 | ||
134 | gdb_trace_setactions "collect at set_point: define actions" \ | |
135 | "" \ | |
136 | "collect parm" "^$" | |
f196051f SS |
137 | |
138 | run_trace_experiment | |
139 | ||
140 | } | |
141 | ||
f196051f | 142 | test_tracepoints |
e2be70a0 YQ |
143 | |
144 | set tracefile [standard_output_file ${testfile}] | |
145 | # Save trace frames to tfile. | |
146 | gdb_test "tsave ${tracefile}.tf" \ | |
147 | "Trace data saved to file '${tracefile}.tf'.*" \ | |
148 | "save tfile trace file" | |
393fd4c3 YQ |
149 | # Save trace frames to CTF. |
150 | gdb_test "tsave -ctf ${tracefile}.ctf" \ | |
151 | "Trace data saved to directory '${tracefile}.ctf'.*" \ | |
152 | "save ctf trace file" | |
e2be70a0 YQ |
153 | |
154 | # Change target to tfile. | |
155 | set test "change to tfile target" | |
156 | gdb_test_multiple "target tfile ${tracefile}.tf" "$test" { | |
157 | -re "A program is being debugged already. Kill it. .y or n. " { | |
158 | send_gdb "y\n" | |
159 | exp_continue | |
160 | } | |
161 | -re "$gdb_prompt $" { | |
162 | pass "$test" | |
163 | } | |
164 | } | |
165 | ||
166 | # Convert "(because I can) to "\(because I can\)" | |
167 | set tstatus_output [string map {\( \\(} $tstatus_output] | |
168 | set tstatus_output [string map {\) \\)} $tstatus_output] | |
169 | ||
170 | # The status should be identical to the status of live inferior. | |
171 | gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \ | |
172 | "tstatus on tfile target" | |
393fd4c3 YQ |
173 | |
174 | # Change target to ctf if GDB supports. | |
175 | gdb_test_multiple "target ctf ${tracefile}.ctf" "" { | |
176 | -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" { | |
177 | } | |
178 | -re ".*\r\n$gdb_prompt $" { | |
179 | gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \ | |
180 | "tstatus on ctf target" | |
181 | } | |
182 | } |