1 # Copyright
1998-2023 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 # This file was written by Michael Snyder
(msnyder@cygnus.com
)
18 load_lib
"trace-support.exp"
21 standard_testfile actions.c
22 require gdb_trace_common_supports_arch
23 if { [gdb_compile
"$srcdir/$subdir/$srcfile" $binfile \
24 executable
{debug nowarnings
}] != "" } {
25 untested
"failed to compile"
32 #
define relative source line numbers
:
33 # all subsequent line numbers are relative to this first one
(baseline
)
34 set baseline
[gdb_find_recursion_test_baseline $srcfile
]
35 if {$baseline
== -1} {
36 fail
"could not find gdb_recursion_test function"
40 set testline1
[expr $baseline
+ 4]
41 set testline2
[expr $baseline
+ 5]
42 set testline3
[expr $baseline
+ 6]
43 set testline4
[expr $baseline
+ 7]
44 set testline5
[expr $baseline
+ 8]
45 set testline6
[expr $baseline
+ 9]
48 # test save
-trace command
51 # setup a
set of tracepoints to save
53 gdb_delete_tracepoints
55 foreach x
{ 1 2 3 4 5 6 } {
56 set testline
[expr \$testline$x
]
57 set trcpt
[gdb_gettpnum $testline
]
59 gdb_test
"passcount $x" \
60 "Setting tracepoint $trcpt.* to $x" \
61 "set passcount for tracepoint $trcpt"
63 gdb_test_no_output
"condition $trcpt $x - 1 == $x / 2" \
64 "set condition for tracepoint $trcpt"
66 gdb_trace_setactions
"set actions for tracepoint $x" \
69 "while-stepping $x" "^$" \
74 gdb_test
"ftrace fast_tracepoint_loc" \
75 "Fast tracepoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
76 "set a fast tracepoint"
78 gdb_test_no_output
"set default-collect gdb_char_test, gdb_long_test - 100" \
81 # Save tracepoint definitions to a file
, at path SAVE_PATH.
82 proc gdb_save_tracepoints
{ save_path
} {
83 set save_path_regexp
[string_to_regexp $save_path
]
84 remote_file host
delete $save_path
85 gdb_test
"save tracepoints $save_path" \
86 "Saved to file '$save_path_regexp'." \
87 "save tracepoint definitions"
90 #
Load tracepoint definitions from a file
, from path SAVE_PATH.
91 proc gdb_load_tracepoints
{ save_path
} {
92 # Cleanup existing tracepoints
/collections
93 gdb_delete_tracepoints
94 gdb_test_no_output
"set default-collect" "clear default-collect"
96 gdb_test
"info tracepoints" "No tracepoints." "delete tracepoints"
98 gdb_test
"source $save_path" "Tracepoint \[0-9\]+ at .*" \
99 "read back saved tracepoints"
102 proc gdb_verify_tracepoints
{ testname
} {
109 gdb_test_multiple
"info tracepoints" "$testname" {
110 -re
"\[0-9\]+\[\t \]+tracepoint\[\t \]+keep y\[\t \]+0x\[0-9a-fA-F\]+ in gdb_recursion_test\[^\r\n\]+\r\n\[ \t]+trace only if \[0-9\] - 1 == \[0-9\] / 2" {
111 #
if { $expect_out
(1,string
) != $ourstate
} {
117 -re
"$gdb_prompt $" {
118 if { $ourstate
>= 7 } {
130 gdb_test
"show default-collect" \
131 "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
132 "verify default-collect"
135 proc do_save_load_test
{ save_path
} {
136 # Save current tracepoint definitions to a file
137 gdb_save_tracepoints $save_path
139 # Clear existing tracepoints and reload from file
140 gdb_load_tracepoints $save_path
142 # Check
if they match the expected tracepoints
143 gdb_verify_tracepoints
"verify recovered tracepoints"
146 gdb_verify_tracepoints
"verify trace setup"
148 with_test_prefix
"relative" {
149 set filepath
[standard_output_file
"savetrace-relative.tr"]
151 # This only works because the pwd is a prefix of the standard output
152 # directory.
If this assumption becomes false
, then this test needs to be
153 # changed
(the relative path from
[pwd
] to the standard output directory
154 # will become a bit more complicated to compute
).
155 if {[string first
[pwd
] $filepath
] != 0} {
156 error
"[pwd] is not a prefix of $filepath."
159 set filepath
[string map
"[pwd] ." $filepath]
160 do_save_load_test
"$filepath"
163 with_test_prefix
"absolute" {
164 do_save_load_test
[standard_output_file
"savetrace-absolute.tr"]
168 #
[deferred
-- not sure what a good invalid filename would be
]
170 # save
-trace (file already
exists)
171 #
[expect it to clobber the old one
]
173 # help save tracepoints
175 gdb_test
"help save tracepoints" \
176 "Save current tracepoint definitions as a script.*" \
177 "verify help save tracepoints"