gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tspeed.exp
1 # Copyright 2011
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 load_lib "trace-support.exp"
18
19 set testfile "tspeed"
20 set srcfile ${testfile}.c
21 set executable $testfile
22 set binfile $objdir/$subdir/$executable
23
24 set ipalib $objdir/../gdbserver/libinproctrace.so
25
26 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
27 executable [concat {debug nowarnings c} libs=$ipalib]] != "" } {
28 untested tspeed.exp
29 return -1
30 }
31
32 # Typically we need a little extra time for this test.
33 set timeout 180
34
35 set ws "\[\r\n\t \]+"
36 set cr "\[\r\n\]+"
37
38 #
39 # Utility procs
40 #
41
42 proc prepare_for_trace_test {} {
43 global executable
44
45 clean_restart $executable
46
47 runto_main
48
49 set testline [gdb_get_line_number "set pre-run breakpoint here"]
50
51 gdb_test "break $testline" ".*" ""
52
53 set testline [gdb_get_line_number "set post-run breakpoint here"]
54
55 gdb_test "break $testline" ".*" ""
56 }
57
58 proc run_trace_experiment {} {
59
60 gdb_test "continue" \
61 ".*Breakpoint \[0-9\]+, main .*" \
62 "advance to trace begin"
63
64 gdb_test_no_output "tstart" "start trace experiment"
65
66 gdb_test "continue" \
67 ".*Breakpoint \[0-9\]+, main .*" \
68 "advance through tracing"
69
70 gdb_test "tstatus" ".*Trace .*" "check on trace status"
71
72 gdb_test "tstop" "" ""
73 }
74
75 proc gdb_slow_trace_speed_test { } {
76
77 gdb_delete_tracepoints
78
79 gdb_test "print iters = init_iters" ".* = .*";
80
81 set testline [gdb_get_line_number "set tracepoint here"]
82
83 gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \
84 "Tracepoint \[0-9\]+ at .*" \
85 "set slow tracepoint"
86
87 # Begin the test.
88 run_trace_experiment
89 }
90
91 proc gdb_fast_trace_speed_test { } {
92 global gdb_prompt
93
94 gdb_delete_tracepoints
95
96 gdb_test "print iters = init_iters" ".* = .*";
97
98 set run_ftrace 0
99
100 set testline [gdb_get_line_number "set tracepoint here"]
101
102 gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \
103 "set conditional fast tracepoint" {
104 -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
105 pass "set conditional fast tracepoint, done"
106 set run_ftrace 1
107 }
108 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
109 pass "set conditional fast tracepoint, not allowed at line"
110 }
111 }
112
113 # If the fast tracepoint couldn't be set, don't bother with the run.
114 if { $run_ftrace == 1 } then {
115
116 # Begin the test.
117 run_trace_experiment
118 }
119 }
120
121 proc gdb_trace_collection_test {} {
122
123 prepare_for_trace_test
124
125 gdb_slow_trace_speed_test
126
127 gdb_fast_trace_speed_test
128 }
129
130 clean_restart $executable
131 runto_main
132
133 # We generously give ourselves one "pass" if we successfully
134 # detect that this test cannot be run on this target!
135 if { ![gdb_target_supports_trace] } then {
136 pass "Current target does not support trace"
137 return 1;
138 }
139
140 # Body of test encased in a proc so we can return prematurely.
141 gdb_trace_collection_test
This page took 0.034933 seconds and 4 git commands to generate.