]>
Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 1998-2019 Free Software Foundation, Inc. |
c906108c SS |
2 | # |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This file was written by Michael Snyder (msnyder@cygnus.com) |
17 | ||
4ec70201 | 18 | load_lib "trace-support.exp" |
c906108c | 19 | |
c906108c SS |
20 | |
21 | gdb_exit | |
22 | gdb_start | |
23 | ||
497a5eb0 | 24 | standard_testfile actions.c |
8bca2978 SL |
25 | if ![gdb_trace_common_supports_arch] { |
26 | unsupported "no trace-common.h support for arch" | |
27 | return -1 | |
28 | } | |
f8b7eaf3 DJ |
29 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ |
30 | executable {debug nowarnings}] != "" } { | |
5b362f04 | 31 | untested "failed to compile" |
f8b7eaf3 | 32 | return -1 |
c906108c SS |
33 | } |
34 | gdb_reinitialize_dir $srcdir/$subdir | |
35 | ||
36 | # If testing on a remote host, download the source file. | |
37 | # remote_download host $srcdir/$subdir/$srcfile | |
38 | ||
39 | gdb_file_cmd $binfile | |
40 | ||
41 | # define relative source line numbers: | |
42 | # all subsequent line numbers are relative to this first one (baseline) | |
4ec70201 | 43 | set baseline [gdb_find_recursion_test_baseline $srcfile] |
c906108c | 44 | if { $baseline == -1 } then { |
bc6c7af4 | 45 | fail "could not find gdb_recursion_test function" |
4ec70201 | 46 | return |
c906108c SS |
47 | } |
48 | ||
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] | |
55 | ||
56 | # | |
57 | # test save-trace command | |
58 | # | |
59 | ||
60 | # setup a set of tracepoints to save | |
61 | ||
62 | gdb_delete_tracepoints | |
63 | ||
64 | foreach x { 1 2 3 4 5 6 } { | |
4ec70201 PA |
65 | set testline [expr \$testline$x] |
66 | set trcpt [gdb_gettpnum $testline] | |
67 | set trcpt$x $trcpt | |
c906108c SS |
68 | gdb_test "passcount $x" \ |
69 | "Setting tracepoint $trcpt.* to $x" \ | |
045ccf91 | 70 | "set passcount for tracepoint $trcpt" |
c906108c | 71 | |
e68d8fd4 | 72 | gdb_test_no_output "condition $trcpt $x - 1 == $x / 2" \ |
045ccf91 | 73 | "set condition for tracepoint $trcpt" |
8bf6485c | 74 | |
045ccf91 | 75 | gdb_trace_setactions "set actions for tracepoint $x" \ |
c906108c SS |
76 | "" \ |
77 | "collect q$x" "^$" \ | |
78 | "while-stepping $x" "^$" \ | |
79 | "collect q$x" "^$" \ | |
80 | "end" "^$" | |
81 | } | |
82 | ||
c93e8391 SM |
83 | gdb_test "ftrace fast_tracepoint_loc" \ |
84 | "Fast tracepoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ | |
85 | "set a fast tracepoint" | |
86 | ||
e68d8fd4 | 87 | gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \ |
045ccf91 SM |
88 | "set default-collect" |
89 | ||
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" | |
97 | } | |
98 | ||
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" | |
104 | ||
105 | gdb_test "info tracepoints" "No tracepoints." "delete tracepoints" | |
106 | ||
107 | gdb_test "source $save_path" "Tracepoint \[0-9\]+ at .*" \ | |
108 | "read back saved tracepoints" | |
109 | } | |
c906108c SS |
110 | |
111 | proc gdb_verify_tracepoints { testname } { | |
4ec70201 | 112 | global gdb_prompt |
c906108c SS |
113 | |
114 | set ws "\[\t \]+" | |
115 | set nl "\[\r\n\]+" | |
4ec70201 PA |
116 | set ourstate 1 |
117 | set result "pass" | |
0ab48859 | 118 | gdb_test_multiple "info tracepoints" "$testname" { |
8bf6485c | 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" { |
1042e4c0 | 120 | # if { $expect_out(1,string) != $ourstate } { |
4ec70201 | 121 | # set result "fail" |
1042e4c0 | 122 | # } |
4ec70201 PA |
123 | incr ourstate |
124 | exp_continue | |
c906108c SS |
125 | } |
126 | -re "$gdb_prompt $" { | |
c93e8391 | 127 | if { $ourstate >= 7 } { |
4ec70201 | 128 | set result "pass" |
c906108c | 129 | } else { |
4ec70201 | 130 | set result "fail" |
c906108c SS |
131 | } |
132 | } | |
133 | default { | |
4ec70201 | 134 | set result "fail" |
c906108c SS |
135 | } |
136 | } | |
4ec70201 | 137 | $result $testname |
8bf6485c SS |
138 | |
139 | gdb_test "show default-collect" \ | |
140 | "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \ | |
045ccf91 | 141 | "verify default-collect" |
c906108c SS |
142 | } |
143 | ||
045ccf91 SM |
144 | proc do_save_load_test { save_path } { |
145 | # Save current tracepoint definitions to a file | |
146 | gdb_save_tracepoints $save_path | |
c906108c | 147 | |
045ccf91 SM |
148 | # Clear existing tracepoints and reload from file |
149 | gdb_load_tracepoints $save_path | |
c906108c | 150 | |
045ccf91 SM |
151 | # Check if they match the expected tracepoints |
152 | gdb_verify_tracepoints "verify recovered tracepoints" | |
153 | } | |
c906108c | 154 | |
045ccf91 | 155 | gdb_verify_tracepoints "verify trace setup" |
c906108c | 156 | |
045ccf91 | 157 | with_test_prefix "relative" { |
266b65b3 SM |
158 | set filepath [standard_output_file "savetrace-relative.tr"] |
159 | ||
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." | |
166 | } | |
167 | ||
168 | set filepath [string map "[pwd] ." $filepath] | |
169 | do_save_load_test "$filepath" | |
045ccf91 | 170 | } |
c906108c | 171 | |
045ccf91 SM |
172 | with_test_prefix "absolute" { |
173 | do_save_load_test [standard_output_file "savetrace-absolute.tr"] | |
174 | } | |
175 | ||
176 | # invalid filename | |
c906108c SS |
177 | # [deferred -- not sure what a good invalid filename would be] |
178 | ||
045ccf91 | 179 | # save-trace (file already exists) |
c906108c SS |
180 | # [expect it to clobber the old one] |
181 | ||
045ccf91 | 182 | # help save tracepoints |
c906108c | 183 | |
045ccf91 | 184 | gdb_test "help save tracepoints" \ |
c906108c | 185 | "Save current tracepoint definitions as a script.*" \ |
045ccf91 | 186 | "verify help save tracepoints" |