1 # Copyright 1998, 2005, 2007, 2008, 2009 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 3 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, see <http://www.gnu.org/licenses/>.
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp";
29 if [istarget "m68k-*-elf"] then {
30 load_lib "emc-support.exp";
31 set srcfile gdb_c_test.c
32 set binfile [board_info target d490_binfile];
33 gdb_test "set remotetimeout 6" "" ""
35 gdb_target_monitor $binfile
36 # Give a TSTOP and ignore errors, to make sure any previous trace is off
37 gdb_test "tstop" "" ""
38 gdb_test "tfind none" "" ""
39 send_gdb "compare-sections CS\n"
41 -re "MIS-MATCHED.*$gdb_prompt $" {
42 untested passc-dyn.exp
44 all tests in this module will fail.";
46 -re ".*$gdb_prompt $" { }
49 set testfile "actions"
50 set srcfile ${testfile}.c
51 set binfile $objdir/$subdir/passc-dyn
52 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
53 executable {debug nowarnings}] != "" } {
54 untested passc-dyn.exp
58 gdb_test "tstop" "" ""
59 gdb_test "tfind none" "" ""
62 gdb_reinitialize_dir $srcdir/$subdir
64 # We generously give ourselves one "pass" if we successfully
65 # detect that this test cannot be run on this target!
66 if { ![gdb_target_supports_trace] } then {
67 pass "Current target does not support trace"
72 # If testing on a remote host, download the source file.
73 # remote_download host $srcdir/$subdir/$srcfile
77 # test passcount dynamically (live target)
80 set baseline [gdb_find_recursion_test_baseline $srcfile];
82 if { $baseline == -1 } then {
83 fail "Could not find gdb_recursion_test function"
87 # define relative source line numbers:
88 # all subsequent line numbers are relative to this first one (baseline)
90 set testline2 [expr $baseline + 4]
91 set testline3 [expr $baseline + 5]
92 set testline4 [expr $baseline + 6]
95 # test passcount command semantics (live test)
98 ## Set three tracepoints with three different passcounts.
99 ## Verify that the experiment stops after the one with the
100 ## lowest passcount is hit.
102 gdb_delete_tracepoints
103 set tdp2 [gdb_gettpnum "$testline2"]
104 set tdp3 [gdb_gettpnum "$testline3"]
105 set tdp4 [gdb_gettpnum "$testline4"]
106 if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then {
107 fail "setting tracepoints"
111 gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
112 "4.5: set passcount for tracepoint $tdp2"
113 gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
114 "4.5: set passcount for tracepoint $tdp3"
115 gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
116 "4.5: set passcount for tracepoint $tdp4"
118 gdb_test "tstart" "" ""
120 if [istarget "m68k-*-elf"] then {
121 gdb_emclaptop_command "85,1,2,3,4,5,6"
123 gdb_emclaptop_command "85,7,8,9,A,B,C"
125 gdb_emclaptop_command "85,D,E,F,10,11,12"
129 ## Note! Must NOT give the tstop command, because the passcount
130 ## has already stopped the experiment. You would not
131 ## think this would be an error, but in EMC's mind it is...
134 gdb_test "break end" "" ""
135 gdb_test "continue" \
136 "Continuing.*Breakpoint $decimal, end.*" \
137 "run trace experiment"
138 gdb_test "tstop" "" ""
141 gdb_test "tfind none" "" ""
142 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] {
143 untested passc-dyn.exp
147 gdb_test "tfind tracepoint $tdp2" "" ""
148 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] {
149 untested passc-dyn.exp
153 gdb_test "tfind tracepoint $tdp3" "" ""
154 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] {
155 untested passc-dyn.exp
159 gdb_test "tfind tracepoint $tdp4" "" ""
160 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] {
161 untested passc-dyn.exp
165 gdb_test "tfind tracepoint $tdp2" "" ""
166 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] {
167 untested passc-dyn.exp
171 gdb_test "tfind tracepoint $tdp3" "" ""
172 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] {
173 untested passc-dyn.exp
177 ## We should now be at the last frame, because this frame's passcount
178 ## should have caused collection to stop. If we do a tfind now,
181 gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
184 gdb_test "tfind none" "" ""