1 # Copyright
(C
) 1998 Free Software Foundation
, Inc.
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.
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.
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.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
22 # Support procedures
for trace testing
27 # Procedure
: gdb_target_supports_trace
28 # Returns true
if GDB is connected to a target that supports tracing.
29 # Allows tests to abort early
if not running
on a
trace-aware target.
32 proc gdb_target_supports_trace
{ } {
37 -re
"\[Tt\]race can only be run on.*$gdb_prompt $" {
40 -re
"\[Tt\]race can not be run on.*$gdb_prompt $" {
43 -re
"\[Tt\]arget does not support.*$gdb_prompt $" {
46 -re
".*\[Ee\]rror.*$gdb_prompt $" {
49 -re
".*\[Ww\]arning.*$gdb_prompt $" {
52 -re
".*$gdb_prompt $" {
63 # Procedure
: gdb_delete_tracepoints
64 # Many of the tests depend
on setting tracepoints at various places and
65 # running until that tracepoint is reached. At times
, we want to start
66 # with a clean slate with respect to tracepoints
, so this utility proc
67 # lets us
do this without duplicating this code everywhere.
70 proc gdb_delete_tracepoints
{} {
73 send_gdb
"delete tracepoints\n"
75 -re
"Delete all tracepoints.*y or n.*$" {
79 -re
".*$gdb_prompt $" { # This happens if there were no tracepoints }
81 perror
"Delete all tracepoints in delete_tracepoints (timeout)"
85 send_gdb
"info tracepoints\n"
87 -re
"No tracepoints.*$gdb_prompt $" {}
88 -re
"$gdb_prompt $" { perror "tracepoints not deleted" ; return }
89 timeout
{ perror
"info tracepoints (timeout)" ; return }
94 # Procedure
: gdb_trace_setactions
95 #
Define actions
for a tracepoint.
97 # testname
-- identifying string
for pass
/fail output
98 # tracepoint
-- to which tracepoint
do these actions apply?
(optional
)
99 #
args -- list of actions to be defined.
102 # non
-zero
-- failure
104 proc gdb_trace_setactions
{ testname tracepoint
args } {
109 send_gdb
"actions $tracepoint\n";
110 set expected_result
"";
112 -re
"No tracepoint number .*$gdb_prompt $" {
116 -re
"Enter actions for tracepoint $tracepoint.*>" {
117 if { [llength $
args] > 0 } {
118 set lastcommand
"[lindex $args $state]";
119 send_gdb
"[lindex $args $state]\n";
121 set expected_result
[lindex $
args $state
];
128 -re
"\(.*\)\[\r\n\]+\[ \t]*> $" {
129 if { $expected_result
!= "" } {
130 regsub
"^\[^\r\n\]+\[\r\n\]+" "$expect_out(1,string)" "" out;
131 if ![regexp $expected_result $out
] {
134 set expected_result
"";
136 if { $state
< [llength $
args] } {
137 send_gdb
"[lindex $args $state]\n";
139 set expected_result
[lindex $
args $state
];
143 set expected_result
"";
147 -re
"\(.*\)$gdb_prompt $" {
148 if { $expected_result
!= "" } {
149 if ![regexp $expected_result $expect_out
(1,string
)] {
152 set expected_result
"";
154 if { [llength $
args] < $state
} {
162 if { $testname
!= "" } {
165 if { $passfail
== "pass" } then {
173 # Procedure
: gdb_tfind_test
174 # Find a specified
trace frame.
176 # testname
-- identifying string
for pass
/fail output
177 # tfind_arg
-- frame
(line
, PC
, etc.
) identifier
178 # exp_res
-- Expected result of frame test
179 #
args -- Test expression
182 # non
-zero
-- failure
185 proc gdb_tfind_test
{ testname tfind_arg exp_res
args } {
188 if { "$args" != "" } {
192 set expr
"(int) \$trace_frame";
196 gdb_test
"tfind $tfind_arg" "" ""
197 send_gdb
"printf \"x \%d x\\n\", $expr\n";
199 -re
"x (-*\[0-9\]+) x" {
200 if { $expect_out
(1,string
) == $exp_res
} {
205 -re
"$gdb_prompt $" { }
207 $passfail
"$testname";
208 if { $passfail
== "pass" } then {
216 # Procedure
: gdb_readexpr
218 # gdb_expr
-- the expression whose value is desired
220 # the value of gdb_expr
, as evaluated by gdb.
221 #
[FIXME
: returns
-1 on error
, which is sometimes a legit value
]
224 proc gdb_readexpr
{ gdb_expr
} {
228 send_gdb
"print $gdb_expr\n"
230 -re
"\[$\].*= (\[0-9\]+).*$gdb_prompt $" {
231 set result $expect_out
(1,string
);
233 -re
"$gdb_prompt $" { }
240 # Procedure
: gdb_gettpnum
242 # tracepoint
(optional
): if supplied
, set a tracepoint here.
244 # the tracepoint ID of the most recently
set tracepoint.
247 proc gdb_gettpnum
{ tracepoint
} {
250 if { $tracepoint
!= "" } {
251 gdb_test
"trace $tracepoint" "" ""
253 return [gdb_readexpr
"\$tpnum"];
258 # Procedure
: gdb_find_function_baseline
260 # func_name
-- name of source function
262 # Sourcefile line of function definition
(open curly brace
),
263 # or
-1 on failure. Caller must check
return value.
265 # Works only
for open curly brace at beginning of source line
!
268 proc gdb_find_function_baseline
{ func_name
} {
273 send_gdb
"list $func_name\n"
275 #
-re
"\[\r\n\]\[\{\].*$gdb_prompt $" {
282 # Procedure
: gdb_find_function_baseline
284 # filename
: name of source file of desired function.
286 # Sourcefile line of function definition
(open curly brace
),
287 # or
-1 on failure. Caller must check
return value.
289 # Works only
for open curly brace at beginning of source line
!
292 proc gdb_find_recursion_test_baseline
{ filename
} {
297 gdb_test
"list $filename:1" "" ""
298 send_gdb
"search gdb_recursion_test line 0\n"
300 -re
"(\[0-9\]+)\[\t \]+\{.*line 0.*$gdb_prompt $" {
301 set baseline $expect_out
(1,string
);
303 -re
"$gdb_prompt $" { }