1 # Copyright 1998, 2005, 2007, 2008 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
19 # This file was written by Michael Snyder (msnyder@cygnus.com)
21 load_lib "trace-support.exp";
32 if [istarget "m68k-*-elf"] then {
33 load_lib "emc-support.exp";
34 set srcfile gdb_c_test.c
35 set binfile [board_info target d490_binfile];
36 gdb_test "set remotetimeout 6" "" ""
38 gdb_target_monitor $binfile
39 # Give a TSTOP and ignore errors, to make sure any previous trace is off
40 gdb_test "tstop" "" ""
41 gdb_test "tfind none" "" ""
42 send_gdb "compare-sections CS\n"
44 -re "MIS-MATCHED.*$gdb_prompt $" {
45 untested passc-dyn.exp
47 all tests in this module will fail.";
49 -re ".*$gdb_prompt $" { }
52 set testfile "actions"
53 set srcfile ${testfile}.c
54 set binfile $objdir/$subdir/$testfile
55 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
56 executable {debug nowarnings}] != "" } {
57 untested passc-dyn.exp
61 gdb_test "tstop" "" ""
62 gdb_test "tfind none" "" ""
65 gdb_reinitialize_dir $srcdir/$subdir
67 # We generously give ourselves one "pass" if we successfully
68 # detect that this test cannot be run on this target!
69 if { ![gdb_target_supports_trace] } then {
70 pass "Current target does not support trace"
75 # If testing on a remote host, download the source file.
76 # remote_download host $srcdir/$subdir/$srcfile
80 # test passcount dynamically (live target)
83 set baseline [gdb_find_recursion_test_baseline $srcfile];
85 if { $baseline == -1 } then {
86 fail "Could not find gdb_recursion_test function"
90 # define relative source line numbers:
91 # all subsequent line numbers are relative to this first one (baseline)
93 set testline2 [expr $baseline + 4]
94 set testline3 [expr $baseline + 5]
95 set testline4 [expr $baseline + 6]
98 # test passcount command semantics (live test)
101 ## Set three tracepoints with three different passcounts.
102 ## Verify that the experiment stops after the one with the
103 ## lowest passcount is hit.
105 gdb_delete_tracepoints
106 set tdp2 [gdb_gettpnum "$testline2"]
107 set tdp3 [gdb_gettpnum "$testline3"]
108 set tdp4 [gdb_gettpnum "$testline4"]
109 if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then {
110 fail "setting tracepoints"
114 gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
115 "4.5: set passcount for tracepoint $tdp2"
116 gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
117 "4.5: set passcount for tracepoint $tdp3"
118 gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
119 "4.5: set passcount for tracepoint $tdp4"
121 gdb_test "tstart" "" ""
123 if [istarget "m68k-*-elf"] then {
124 gdb_emclaptop_command "85,1,2,3,4,5,6"
126 gdb_emclaptop_command "85,7,8,9,A,B,C"
128 gdb_emclaptop_command "85,D,E,F,10,11,12"
132 ## Note! Must NOT give the tstop command, because the passcount
133 ## has already stopped the experiment. You would not
134 ## think this would be an error, but in EMC's mind it is...
137 gdb_test "break end" "" ""
138 gdb_test "continue" \
139 "Continuing.*Breakpoint $decimal, end.*" \
140 "run trace experiment"
141 gdb_test "tstop" "" ""
144 gdb_test "tfind none" "" ""
145 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] {
146 untested passc-dyn.exp
150 gdb_test "tfind tracepoint $tdp2" "" ""
151 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] {
152 untested passc-dyn.exp
156 gdb_test "tfind tracepoint $tdp3" "" ""
157 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] {
158 untested passc-dyn.exp
162 gdb_test "tfind tracepoint $tdp4" "" ""
163 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] {
164 untested passc-dyn.exp
168 gdb_test "tfind tracepoint $tdp2" "" ""
169 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] {
170 untested passc-dyn.exp
174 gdb_test "tfind tracepoint $tdp3" "" ""
175 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] {
176 untested passc-dyn.exp
180 ## We should now be at the last frame, because this frame's passcount
181 ## should have caused collection to stop. If we do a tfind now,
184 gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
187 gdb_test "tfind none" "" ""