Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 1998-2016 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 |
f8b7eaf3 DJ |
25 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ |
26 | executable {debug nowarnings}] != "" } { | |
27 | untested save-trace.exp | |
28 | return -1 | |
c906108c SS |
29 | } |
30 | gdb_reinitialize_dir $srcdir/$subdir | |
31 | ||
32 | # If testing on a remote host, download the source file. | |
33 | # remote_download host $srcdir/$subdir/$srcfile | |
34 | ||
35 | gdb_file_cmd $binfile | |
36 | ||
37 | # define relative source line numbers: | |
38 | # all subsequent line numbers are relative to this first one (baseline) | |
4ec70201 | 39 | set baseline [gdb_find_recursion_test_baseline $srcfile] |
c906108c | 40 | if { $baseline == -1 } then { |
bc6c7af4 | 41 | fail "could not find gdb_recursion_test function" |
4ec70201 | 42 | return |
c906108c SS |
43 | } |
44 | ||
45 | set testline1 [expr $baseline + 4] | |
46 | set testline2 [expr $baseline + 5] | |
47 | set testline3 [expr $baseline + 6] | |
48 | set testline4 [expr $baseline + 7] | |
49 | set testline5 [expr $baseline + 8] | |
50 | set testline6 [expr $baseline + 9] | |
51 | ||
52 | # | |
53 | # test save-trace command | |
54 | # | |
55 | ||
56 | # setup a set of tracepoints to save | |
57 | ||
58 | gdb_delete_tracepoints | |
59 | ||
60 | foreach x { 1 2 3 4 5 6 } { | |
4ec70201 PA |
61 | set testline [expr \$testline$x] |
62 | set trcpt [gdb_gettpnum $testline] | |
63 | set trcpt$x $trcpt | |
c906108c SS |
64 | gdb_test "passcount $x" \ |
65 | "Setting tracepoint $trcpt.* to $x" \ | |
045ccf91 | 66 | "set passcount for tracepoint $trcpt" |
c906108c | 67 | |
e68d8fd4 | 68 | gdb_test_no_output "condition $trcpt $x - 1 == $x / 2" \ |
045ccf91 | 69 | "set condition for tracepoint $trcpt" |
8bf6485c | 70 | |
045ccf91 | 71 | gdb_trace_setactions "set actions for tracepoint $x" \ |
c906108c SS |
72 | "" \ |
73 | "collect q$x" "^$" \ | |
74 | "while-stepping $x" "^$" \ | |
75 | "collect q$x" "^$" \ | |
76 | "end" "^$" | |
77 | } | |
78 | ||
c93e8391 SM |
79 | gdb_test "ftrace fast_tracepoint_loc" \ |
80 | "Fast tracepoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ | |
81 | "set a fast tracepoint" | |
82 | ||
e68d8fd4 | 83 | gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \ |
045ccf91 SM |
84 | "set default-collect" |
85 | ||
86 | # Save tracepoint definitions to a file, at path SAVE_PATH. | |
87 | proc gdb_save_tracepoints { save_path } { | |
88 | set save_path_regexp [string_to_regexp $save_path] | |
89 | remote_file host delete $save_path | |
90 | gdb_test "save tracepoints $save_path" \ | |
91 | "Saved to file '$save_path_regexp'." \ | |
92 | "save tracepoint definitions" | |
93 | } | |
94 | ||
95 | # Load tracepoint definitions from a file, from path SAVE_PATH. | |
96 | proc gdb_load_tracepoints { save_path } { | |
97 | # Cleanup existing tracepoints/collections | |
98 | gdb_delete_tracepoints | |
99 | gdb_test_no_output "set default-collect" "clear default-collect" | |
100 | ||
101 | gdb_test "info tracepoints" "No tracepoints." "delete tracepoints" | |
102 | ||
103 | gdb_test "source $save_path" "Tracepoint \[0-9\]+ at .*" \ | |
104 | "read back saved tracepoints" | |
105 | } | |
c906108c SS |
106 | |
107 | proc gdb_verify_tracepoints { testname } { | |
4ec70201 | 108 | global gdb_prompt |
c906108c SS |
109 | |
110 | set ws "\[\t \]+" | |
111 | set nl "\[\r\n\]+" | |
4ec70201 PA |
112 | set ourstate 1 |
113 | set result "pass" | |
0ab48859 | 114 | gdb_test_multiple "info tracepoints" "$testname" { |
8bf6485c | 115 | -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 | 116 | # if { $expect_out(1,string) != $ourstate } { |
4ec70201 | 117 | # set result "fail" |
1042e4c0 | 118 | # } |
4ec70201 PA |
119 | incr ourstate |
120 | exp_continue | |
c906108c SS |
121 | } |
122 | -re "$gdb_prompt $" { | |
c93e8391 | 123 | if { $ourstate >= 7 } { |
4ec70201 | 124 | set result "pass" |
c906108c | 125 | } else { |
4ec70201 | 126 | set result "fail" |
c906108c SS |
127 | } |
128 | } | |
129 | default { | |
4ec70201 | 130 | set result "fail" |
c906108c SS |
131 | } |
132 | } | |
4ec70201 | 133 | $result $testname |
8bf6485c SS |
134 | |
135 | gdb_test "show default-collect" \ | |
136 | "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \ | |
045ccf91 | 137 | "verify default-collect" |
c906108c SS |
138 | } |
139 | ||
045ccf91 SM |
140 | proc do_save_load_test { save_path } { |
141 | # Save current tracepoint definitions to a file | |
142 | gdb_save_tracepoints $save_path | |
c906108c | 143 | |
045ccf91 SM |
144 | # Clear existing tracepoints and reload from file |
145 | gdb_load_tracepoints $save_path | |
c906108c | 146 | |
045ccf91 SM |
147 | # Check if they match the expected tracepoints |
148 | gdb_verify_tracepoints "verify recovered tracepoints" | |
149 | } | |
c906108c | 150 | |
045ccf91 | 151 | gdb_verify_tracepoints "verify trace setup" |
c906108c | 152 | |
045ccf91 | 153 | with_test_prefix "relative" { |
266b65b3 SM |
154 | set filepath [standard_output_file "savetrace-relative.tr"] |
155 | ||
156 | # This only works because the pwd is a prefix of the standard output | |
157 | # directory. If this assumption becomes false, then this test needs to be | |
158 | # changed (the relative path from [pwd] to the standard output directory | |
159 | # will become a bit more complicated to compute). | |
160 | if {[string first [pwd] $filepath] != 0} { | |
161 | error "[pwd] is not a prefix of $filepath." | |
162 | } | |
163 | ||
164 | set filepath [string map "[pwd] ." $filepath] | |
165 | do_save_load_test "$filepath" | |
045ccf91 | 166 | } |
c906108c | 167 | |
045ccf91 SM |
168 | with_test_prefix "absolute" { |
169 | do_save_load_test [standard_output_file "savetrace-absolute.tr"] | |
170 | } | |
171 | ||
172 | # invalid filename | |
c906108c SS |
173 | # [deferred -- not sure what a good invalid filename would be] |
174 | ||
045ccf91 | 175 | # save-trace (file already exists) |
c906108c SS |
176 | # [expect it to clobber the old one] |
177 | ||
045ccf91 | 178 | # help save tracepoints |
c906108c | 179 | |
045ccf91 | 180 | gdb_test "help save tracepoints" \ |
c906108c | 181 | "Save current tracepoint definitions as a script.*" \ |
045ccf91 | 182 | "verify help save tracepoints" |