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