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