Copyright year update in most files of the GDB Project.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / passc-dyn.exp
1 # Copyright 1998, 2005, 2007-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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/>.
15
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
17
18 load_lib "trace-support.exp";
19
20 if $tracelevel then {
21 strace $tracelevel
22 }
23
24
25 gdb_exit
26 gdb_start
27 set testfile "actions"
28 set srcfile ${testfile}.c
29 set binfile $objdir/$subdir/passc-dyn
30 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
31 executable {debug nowarnings}] != "" } {
32 untested passc-dyn.exp
33 return -1
34 }
35 gdb_load $binfile
36 gdb_test "tstop" ".*" ""
37 gdb_test "tfind none" ".*" ""
38 runto_main
39 gdb_reinitialize_dir $srcdir/$subdir
40
41 # We generously give ourselves one "pass" if we successfully
42 # detect that this test cannot be run on this target!
43 if { ![gdb_target_supports_trace] } then {
44 pass "Current target does not support trace"
45 return 1;
46
47 }
48
49 # If testing on a remote host, download the source file.
50 # remote_download host $srcdir/$subdir/$srcfile
51
52
53 #
54 # test passcount dynamically (live target)
55 #
56
57 set baseline [gdb_find_recursion_test_baseline $srcfile];
58
59 if { $baseline == -1 } then {
60 fail "Could not find gdb_recursion_test function"
61 return;
62 }
63
64 # define relative source line numbers:
65 # all subsequent line numbers are relative to this first one (baseline)
66
67 set testline2 [expr $baseline + 4]
68 set testline3 [expr $baseline + 5]
69 set testline4 [expr $baseline + 6]
70
71 #
72 # test passcount command semantics (live test)
73 #
74
75 ## Set three tracepoints with three different passcounts.
76 ## Verify that the experiment stops after the one with the
77 ## lowest passcount is hit.
78
79 gdb_delete_tracepoints
80 set tdp2 [gdb_gettpnum "$testline2"]
81 set tdp3 [gdb_gettpnum "$testline3"]
82 set tdp4 [gdb_gettpnum "$testline4"]
83 if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then {
84 fail "setting tracepoints"
85 return;
86 }
87
88 gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
89 "4.5: set passcount for tracepoint $tdp2"
90 gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
91 "4.5: set passcount for tracepoint $tdp3"
92 gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
93 "4.5: set passcount for tracepoint $tdp4"
94
95 gdb_test "tstart" ".*" ""
96
97 gdb_test "break end" ".*" ""
98 gdb_test "continue" \
99 "Continuing.*Breakpoint $decimal, end.*" \
100 "run trace experiment"
101 gdb_test "tstop" ".*" ""
102
103 gdb_test "tfind none" ".*" ""
104 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] {
105 untested passc-dyn.exp
106 return -1
107 }
108
109 gdb_test "tfind tracepoint $tdp2" ".*" ""
110 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] {
111 untested passc-dyn.exp
112 return -1
113 }
114
115 gdb_test "tfind tracepoint $tdp3" ".*" ""
116 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] {
117 untested passc-dyn.exp
118 return -1
119 }
120
121 gdb_test "tfind tracepoint $tdp4" ".*" ""
122 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] {
123 untested passc-dyn.exp
124 return -1
125 }
126
127 gdb_test "tfind tracepoint $tdp2" ".*" ""
128 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] {
129 untested passc-dyn.exp
130 return -1
131 }
132
133 gdb_test "tfind tracepoint $tdp3" ".*" ""
134 if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] {
135 untested passc-dyn.exp
136 return -1
137 }
138
139 ## We should now be at the last frame, because this frame's passcount
140 ## should have caused collection to stop. If we do a tfind now,
141 ## it should fail.
142
143 gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
144
145 # Finished!
146 gdb_test "tfind none" ".*" ""
147
This page took 0.033952 seconds and 5 git commands to generate.