1 # Copyright
1998-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 # This file was written by Michael Snyder
(msnyder@cygnus.com
)
18 load_lib
"trace-support.exp"
24 standard_testfile actions.c
25 if ![gdb_trace_common_supports_arch
] {
26 unsupported
"no trace-common.h support for arch"
29 if { [gdb_compile
"$srcdir/$subdir/$srcfile" $binfile \
30 executable
{debug nowarnings
}] != "" } {
31 untested
"failed to compile"
34 gdb_reinitialize_dir $srcdir
/$subdir
36 #
If testing
on a remote host
, download the source file.
37 # remote_download host $srcdir
/$subdir
/$srcfile
41 #
define relative source line numbers
:
42 # all subsequent line numbers are relative to this first one
(baseline
)
43 set baseline
[gdb_find_recursion_test_baseline $srcfile
]
44 if { $baseline
== -1 } then {
45 fail
"could not find gdb_recursion_test function"
49 set testline1
[expr $baseline
+ 4]
50 set testline2
[expr $baseline
+ 5]
51 set testline3
[expr $baseline
+ 6]
52 set testline4
[expr $baseline
+ 7]
53 set testline5
[expr $baseline
+ 8]
54 set testline6
[expr $baseline
+ 9]
57 # test save
-trace command
60 # setup a
set of tracepoints to save
62 gdb_delete_tracepoints
64 foreach x
{ 1 2 3 4 5 6 } {
65 set testline
[expr \$testline$x
]
66 set trcpt
[gdb_gettpnum $testline
]
68 gdb_test
"passcount $x" \
69 "Setting tracepoint $trcpt.* to $x" \
70 "set passcount for tracepoint $trcpt"
72 gdb_test_no_output
"condition $trcpt $x - 1 == $x / 2" \
73 "set condition for tracepoint $trcpt"
75 gdb_trace_setactions
"set actions for tracepoint $x" \
78 "while-stepping $x" "^$" \
83 gdb_test
"ftrace fast_tracepoint_loc" \
84 "Fast tracepoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
85 "set a fast tracepoint"
87 gdb_test_no_output
"set default-collect gdb_char_test, gdb_long_test - 100" \
90 # Save tracepoint definitions to a file
, at path SAVE_PATH.
91 proc gdb_save_tracepoints
{ save_path
} {
92 set save_path_regexp
[string_to_regexp $save_path
]
93 remote_file host
delete $save_path
94 gdb_test
"save tracepoints $save_path" \
95 "Saved to file '$save_path_regexp'." \
96 "save tracepoint definitions"
99 #
Load tracepoint definitions from a file
, from path SAVE_PATH.
100 proc gdb_load_tracepoints
{ save_path
} {
101 # Cleanup existing tracepoints
/collections
102 gdb_delete_tracepoints
103 gdb_test_no_output
"set default-collect" "clear default-collect"
105 gdb_test
"info tracepoints" "No tracepoints." "delete tracepoints"
107 gdb_test
"source $save_path" "Tracepoint \[0-9\]+ at .*" \
108 "read back saved tracepoints"
111 proc gdb_verify_tracepoints
{ testname
} {
118 gdb_test_multiple
"info tracepoints" "$testname" {
119 -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" {
120 #
if { $expect_out
(1,string
) != $ourstate
} {
126 -re
"$gdb_prompt $" {
127 if { $ourstate
>= 7 } {
139 gdb_test
"show default-collect" \
140 "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
141 "verify default-collect"
144 proc do_save_load_test
{ save_path
} {
145 # Save current tracepoint definitions to a file
146 gdb_save_tracepoints $save_path
148 # Clear existing tracepoints and reload from file
149 gdb_load_tracepoints $save_path
151 # Check
if they match the expected tracepoints
152 gdb_verify_tracepoints
"verify recovered tracepoints"
155 gdb_verify_tracepoints
"verify trace setup"
157 with_test_prefix
"relative" {
158 set filepath
[standard_output_file
"savetrace-relative.tr"]
160 # This only works because the pwd is a prefix of the standard output
161 # directory.
If this assumption becomes false
, then this test needs to be
162 # changed
(the relative path from
[pwd
] to the standard output directory
163 # will become a bit more complicated to compute
).
164 if {[string first
[pwd
] $filepath
] != 0} {
165 error
"[pwd] is not a prefix of $filepath."
168 set filepath
[string map
"[pwd] ." $filepath]
169 do_save_load_test
"$filepath"
172 with_test_prefix
"absolute" {
173 do_save_load_test
[standard_output_file
"savetrace-absolute.tr"]
177 #
[deferred
-- not sure what a good invalid filename would be
]
179 # save
-trace (file already
exists)
180 #
[expect it to clobber the old one
]
182 # help save tracepoints
184 gdb_test
"help save tracepoints" \
185 "Save current tracepoint definitions as a script.*" \
186 "verify help save tracepoints"