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