Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 1998, 2007, 2008, 2009, 2010 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 | ||
18 | load_lib "trace-support.exp"; | |
19 | ||
20 | if $tracelevel then { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | set prms_id 0 | |
25 | set bug_id 0 | |
26 | ||
27 | gdb_exit | |
28 | gdb_start | |
29 | ||
f8b7eaf3 DJ |
30 | set testfile "actions" |
31 | set srcfile ${testfile}.c | |
32 | set binfile $objdir/$subdir/save-trace | |
33 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
34 | executable {debug nowarnings}] != "" } { | |
35 | untested save-trace.exp | |
36 | return -1 | |
c906108c SS |
37 | } |
38 | gdb_reinitialize_dir $srcdir/$subdir | |
39 | ||
40 | # If testing on a remote host, download the source file. | |
41 | # remote_download host $srcdir/$subdir/$srcfile | |
42 | ||
43 | gdb_file_cmd $binfile | |
44 | ||
45 | # define relative source line numbers: | |
46 | # all subsequent line numbers are relative to this first one (baseline) | |
47 | set baseline [gdb_find_recursion_test_baseline $srcfile]; | |
48 | if { $baseline == -1 } then { | |
49 | fail "Could not find gdb_recursion_test function" | |
50 | return; | |
51 | } | |
52 | ||
53 | set testline1 [expr $baseline + 4] | |
54 | set testline2 [expr $baseline + 5] | |
55 | set testline3 [expr $baseline + 6] | |
56 | set testline4 [expr $baseline + 7] | |
57 | set testline5 [expr $baseline + 8] | |
58 | set testline6 [expr $baseline + 9] | |
59 | ||
60 | # | |
61 | # test save-trace command | |
62 | # | |
63 | ||
64 | # setup a set of tracepoints to save | |
65 | ||
66 | gdb_delete_tracepoints | |
67 | ||
68 | foreach x { 1 2 3 4 5 6 } { | |
69 | set testline [expr \$testline$x]; | |
70 | set trcpt [gdb_gettpnum $testline]; | |
71 | set trcpt$x $trcpt; | |
72 | gdb_test "passcount $x" \ | |
73 | "Setting tracepoint $trcpt.* to $x" \ | |
74 | "10.x: set passcount for tracepoint $trcpt" | |
75 | ||
8bf6485c SS |
76 | gdb_test "condition $trcpt $x - 1 == $x / 2" \ |
77 | "" \ | |
78 | "10.x: set condition for tracepoint $trcpt" | |
79 | ||
c906108c SS |
80 | gdb_trace_setactions "10.x: set actions for tracepoint $x" \ |
81 | "" \ | |
82 | "collect q$x" "^$" \ | |
83 | "while-stepping $x" "^$" \ | |
84 | "collect q$x" "^$" \ | |
85 | "end" "^$" | |
86 | } | |
87 | ||
8bf6485c SS |
88 | gdb_test "set default-collect gdb_char_test, gdb_long_test - 100" \ |
89 | "" \ | |
90 | "10: set default-collect" | |
c906108c SS |
91 | |
92 | proc gdb_verify_tracepoints { testname } { | |
93 | global gdb_prompt; | |
94 | ||
95 | set ws "\[\t \]+" | |
96 | set nl "\[\r\n\]+" | |
97 | set ourstate 1; | |
98 | set result "pass"; | |
99 | send_gdb "info tracepoints\n"; | |
100 | gdb_expect 10 { | |
8bf6485c | 101 | -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 SS |
102 | # if { $expect_out(1,string) != $ourstate } { |
103 | # set result "fail"; | |
104 | # } | |
c906108c SS |
105 | incr ourstate; |
106 | exp_continue; | |
107 | } | |
108 | -re "$gdb_prompt $" { | |
109 | if { $ourstate >= 6 } { | |
110 | set result "pass"; | |
111 | } else { | |
112 | set result "fail"; | |
113 | } | |
114 | } | |
115 | default { | |
116 | set result "fail"; | |
117 | } | |
118 | } | |
119 | $result $testname; | |
8bf6485c SS |
120 | |
121 | gdb_test "show default-collect" \ | |
122 | "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \ | |
123 | "10: show default-collect" | |
c906108c SS |
124 | } |
125 | ||
126 | gdb_verify_tracepoints "10.x: verify trace setup"; | |
127 | ||
128 | # 10.1 Save current tracepoint definitions to a file | |
129 | ||
130 | remote_file host delete savetrace.tr | |
131 | gdb_test "save-tracepoints savetrace.tr" \ | |
132 | "Tracepoints saved to file 'savetrace.tr'." \ | |
133 | "10.1: save tracepoint definitions" | |
134 | ||
135 | # 10.2 Read back tracepoint definitions | |
136 | ||
137 | gdb_delete_tracepoints | |
138 | gdb_test "info tracepoints" "No tracepoints." "10.2: delete tracepoints" | |
139 | gdb_test "source savetrace.tr" \ | |
140 | "Tracepoint \[0-9\]+ at .*" \ | |
141 | "10.2: read back saved tracepoints" | |
142 | gdb_verify_tracepoints "10.2: verify recovered tracepoints"; | |
143 | remote_file host delete savetrace.tr | |
144 | ||
145 | # 10.3 repeat with a path to the file | |
146 | ||
e0f353ce | 147 | set escapedfilename [string_to_regexp $objdir/savetrace.tr] |
c906108c SS |
148 | remote_file host delete $objdir/savetrace.tr |
149 | gdb_test "save-tracepoints $objdir/savetrace.tr" \ | |
e0f353ce | 150 | "Tracepoints saved to file '${escapedfilename}'." \ |
c906108c SS |
151 | "10.3: save tracepoint definitions, full path" |
152 | ||
153 | gdb_delete_tracepoints | |
154 | gdb_test "info tracepoints" "No tracepoints." "10.3: delete tracepoints" | |
155 | gdb_test "source $objdir/savetrace.tr" \ | |
156 | "Tracepoint \[0-9\]+ at .*" \ | |
157 | "10.4: read saved tracepoints, full path" | |
158 | gdb_verify_tracepoints "10.3: verify recovered tracepoints, full path"; | |
159 | remote_file host delete $objdir/savetrace.tr | |
160 | ||
161 | # 10.5 invalid filename | |
162 | # [deferred -- not sure what a good invalid filename would be] | |
163 | ||
164 | # 10.6 save-trace (file already exists) | |
165 | # [expect it to clobber the old one] | |
166 | ||
167 | # 10.7 help save-tracepoints | |
168 | ||
169 | gdb_test "help save-tracepoints" \ | |
170 | "Save current tracepoint definitions as a script.*" \ | |
171 | "10.7: help save-tracepoints" |