Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | # Copyright 1998, 2005, 2007, 2008, 2009, 2010, 2011 |
4c38e0a4 | 2 | # Free Software Foundation, Inc. |
c906108c SS |
3 | # |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Michael Snyder (msnyder@cygnus.com) |
18 | ||
19 | load_lib "trace-support.exp"; | |
20 | ||
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
c906108c SS |
25 | |
26 | gdb_exit | |
27 | gdb_start | |
f8b7eaf3 DJ |
28 | set testfile "actions" |
29 | set srcfile ${testfile}.c | |
30 | set binfile $objdir/$subdir/passc-dyn | |
31 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
32 | executable {debug nowarnings}] != "" } { | |
33 | untested passc-dyn.exp | |
34 | return -1 | |
c906108c | 35 | } |
f8b7eaf3 | 36 | gdb_load $binfile |
de7ff789 MS |
37 | gdb_test "tstop" ".*" "" |
38 | gdb_test "tfind none" ".*" "" | |
f8b7eaf3 | 39 | runto_main |
c906108c SS |
40 | gdb_reinitialize_dir $srcdir/$subdir |
41 | ||
42 | # We generously give ourselves one "pass" if we successfully | |
43 | # detect that this test cannot be run on this target! | |
44 | if { ![gdb_target_supports_trace] } then { | |
5f579bc5 | 45 | pass "Current target does not support trace" |
c906108c SS |
46 | return 1; |
47 | ||
48 | } | |
49 | ||
50 | # If testing on a remote host, download the source file. | |
51 | # remote_download host $srcdir/$subdir/$srcfile | |
52 | ||
53 | ||
54 | # | |
55 | # test passcount dynamically (live target) | |
56 | # | |
57 | ||
58 | set baseline [gdb_find_recursion_test_baseline $srcfile]; | |
59 | ||
60 | if { $baseline == -1 } then { | |
61 | fail "Could not find gdb_recursion_test function" | |
62 | return; | |
63 | } | |
64 | ||
65 | # define relative source line numbers: | |
66 | # all subsequent line numbers are relative to this first one (baseline) | |
67 | ||
68 | set testline2 [expr $baseline + 4] | |
69 | set testline3 [expr $baseline + 5] | |
70 | set testline4 [expr $baseline + 6] | |
71 | ||
72 | # | |
73 | # test passcount command semantics (live test) | |
74 | # | |
75 | ||
76 | ## Set three tracepoints with three different passcounts. | |
77 | ## Verify that the experiment stops after the one with the | |
78 | ## lowest passcount is hit. | |
79 | ||
80 | gdb_delete_tracepoints | |
81 | set tdp2 [gdb_gettpnum "$testline2"] | |
82 | set tdp3 [gdb_gettpnum "$testline3"] | |
83 | set tdp4 [gdb_gettpnum "$testline4"] | |
84 | if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then { | |
85 | fail "setting tracepoints" | |
86 | return; | |
87 | } | |
88 | ||
89 | gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \ | |
90 | "4.5: set passcount for tracepoint $tdp2" | |
91 | gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \ | |
92 | "4.5: set passcount for tracepoint $tdp3" | |
93 | gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \ | |
94 | "4.5: set passcount for tracepoint $tdp4" | |
95 | ||
de7ff789 | 96 | gdb_test "tstart" ".*" "" |
c906108c | 97 | |
de7ff789 | 98 | gdb_test "break end" ".*" "" |
f8b7eaf3 DJ |
99 | gdb_test "continue" \ |
100 | "Continuing.*Breakpoint $decimal, end.*" \ | |
101 | "run trace experiment" | |
de7ff789 | 102 | gdb_test "tstop" ".*" "" |
c906108c | 103 | |
de7ff789 | 104 | gdb_test "tfind none" ".*" "" |
c906108c | 105 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] { |
b60f0898 JB |
106 | untested passc-dyn.exp |
107 | return -1 | |
c906108c SS |
108 | } |
109 | ||
de7ff789 | 110 | gdb_test "tfind tracepoint $tdp2" ".*" "" |
c906108c | 111 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] { |
b60f0898 JB |
112 | untested passc-dyn.exp |
113 | return -1 | |
c906108c SS |
114 | } |
115 | ||
de7ff789 | 116 | gdb_test "tfind tracepoint $tdp3" ".*" "" |
c906108c | 117 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] { |
b60f0898 JB |
118 | untested passc-dyn.exp |
119 | return -1 | |
c906108c SS |
120 | } |
121 | ||
de7ff789 | 122 | gdb_test "tfind tracepoint $tdp4" ".*" "" |
c906108c | 123 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] { |
b60f0898 JB |
124 | untested passc-dyn.exp |
125 | return -1 | |
c906108c SS |
126 | } |
127 | ||
de7ff789 | 128 | gdb_test "tfind tracepoint $tdp2" ".*" "" |
c906108c | 129 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] { |
b60f0898 JB |
130 | untested passc-dyn.exp |
131 | return -1 | |
c906108c SS |
132 | } |
133 | ||
de7ff789 | 134 | gdb_test "tfind tracepoint $tdp3" ".*" "" |
c906108c | 135 | if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] { |
b60f0898 JB |
136 | untested passc-dyn.exp |
137 | return -1 | |
c906108c SS |
138 | } |
139 | ||
140 | ## We should now be at the last frame, because this frame's passcount | |
141 | ## should have caused collection to stop. If we do a tfind now, | |
142 | ## it should fail. | |
143 | ||
144 | gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test" | |
145 | ||
146 | # Finished! | |
de7ff789 | 147 | gdb_test "tfind none" ".*" "" |
c906108c | 148 |