Add comment missing from previous patch.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / save-trace.exp
CommitLineData
b6ba6518 1# Copyright 1998 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
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
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.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Michael Snyder (msnyder@cygnus.com)
21
22load_lib "trace-support.exp";
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28set prms_id 0
29set bug_id 0
30
31gdb_exit
32gdb_start
33
34if [istarget "m68k-*-elf"] then {
35 set srcfile gdb_c_test.c
36 set binfile [board_info target d490_binfile];
37} else {
38 set testfile "actions"
39 set srcfile ${testfile}.c
40 set binfile $objdir/$subdir/$testfile
41 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
fc91c6c2 42 executable {debug nowarnings}] != "" } {
b60f0898
JB
43 untested save-trace.exp
44 return -1
c906108c
SS
45 }
46}
47gdb_reinitialize_dir $srcdir/$subdir
48
49# If testing on a remote host, download the source file.
50# remote_download host $srcdir/$subdir/$srcfile
51
52gdb_file_cmd $binfile
53
54# define relative source line numbers:
55# all subsequent line numbers are relative to this first one (baseline)
56set baseline [gdb_find_recursion_test_baseline $srcfile];
57if { $baseline == -1 } then {
58 fail "Could not find gdb_recursion_test function"
59 return;
60}
61
62set testline1 [expr $baseline + 4]
63set testline2 [expr $baseline + 5]
64set testline3 [expr $baseline + 6]
65set testline4 [expr $baseline + 7]
66set testline5 [expr $baseline + 8]
67set testline6 [expr $baseline + 9]
68
69#
70# test save-trace command
71#
72
73# setup a set of tracepoints to save
74
75gdb_delete_tracepoints
76
77foreach x { 1 2 3 4 5 6 } {
78 set testline [expr \$testline$x];
79 set trcpt [gdb_gettpnum $testline];
80 set trcpt$x $trcpt;
81 gdb_test "passcount $x" \
82 "Setting tracepoint $trcpt.* to $x" \
83 "10.x: set passcount for tracepoint $trcpt"
84
85 gdb_trace_setactions "10.x: set actions for tracepoint $x" \
86 "" \
87 "collect q$x" "^$" \
88 "while-stepping $x" "^$" \
89 "collect q$x" "^$" \
90 "end" "^$"
91}
92
93
94proc gdb_verify_tracepoints { testname } {
95 global gdb_prompt;
96
97 set ws "\[\t \]+"
98 set nl "\[\r\n\]+"
99 set ourstate 1;
100 set result "pass";
101 send_gdb "info tracepoints\n";
102 gdb_expect 10 {
103 -re "y\[\t \]+0x\[0-9a-fA-F\]+\[\t \]+(\[0-9\]+)\[\t \]+(\[0-9\]+)\[\t \]+in gdb_recursion_test\[^\r\n\]+" {
104 if { $expect_out(1,string) != $expect_out(2,string) } {
105 #set result "fail";
106 }
107 if { $expect_out(1,string) != $ourstate } {
108 set result "fail";
109 }
110 incr ourstate;
111 exp_continue;
112 }
113 -re "$gdb_prompt $" {
114 if { $ourstate >= 6 } {
115 set result "pass";
116 } else {
117 set result "fail";
118 }
119 }
120 default {
121 set result "fail";
122 }
123 }
124 $result $testname;
125 return $result;
126}
127
128gdb_verify_tracepoints "10.x: verify trace setup";
129
130# 10.1 Save current tracepoint definitions to a file
131
132remote_file host delete savetrace.tr
133gdb_test "save-tracepoints savetrace.tr" \
134 "Tracepoints saved to file 'savetrace.tr'." \
135 "10.1: save tracepoint definitions"
136
137# 10.2 Read back tracepoint definitions
138
139gdb_delete_tracepoints
140gdb_test "info tracepoints" "No tracepoints." "10.2: delete tracepoints"
141gdb_test "source savetrace.tr" \
142 "Tracepoint \[0-9\]+ at .*" \
143 "10.2: read back saved tracepoints"
144gdb_verify_tracepoints "10.2: verify recovered tracepoints";
145remote_file host delete savetrace.tr
146
147# 10.3 repeat with a path to the file
148
e0f353ce 149set escapedfilename [string_to_regexp $objdir/savetrace.tr]
c906108c
SS
150remote_file host delete $objdir/savetrace.tr
151gdb_test "save-tracepoints $objdir/savetrace.tr" \
e0f353ce 152 "Tracepoints saved to file '${escapedfilename}'." \
c906108c
SS
153 "10.3: save tracepoint definitions, full path"
154
155gdb_delete_tracepoints
156gdb_test "info tracepoints" "No tracepoints." "10.3: delete tracepoints"
157gdb_test "source $objdir/savetrace.tr" \
158 "Tracepoint \[0-9\]+ at .*" \
159 "10.4: read saved tracepoints, full path"
160gdb_verify_tracepoints "10.3: verify recovered tracepoints, full path";
161remote_file host delete $objdir/savetrace.tr
162
163# 10.5 invalid filename
164# [deferred -- not sure what a good invalid filename would be]
165
166# 10.6 save-trace (file already exists)
167# [expect it to clobber the old one]
168
169# 10.7 help save-tracepoints
170
171gdb_test "help save-tracepoints" \
172 "Save current tracepoint definitions as a script.*" \
173 "10.7: help save-tracepoints"
This page took 0.929884 seconds and 4 git commands to generate.