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