Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright 2011-2012 Free Software Foundation, Inc. |
3c9057f3 SS |
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 | load_lib "trace-support.exp" | |
17 | ||
18 | set testfile "tspeed" | |
19 | set srcfile ${testfile}.c | |
20 | set executable $testfile | |
21 | set binfile $objdir/$subdir/$executable | |
22 | ||
c0d4d1c0 | 23 | set ipalib [get_in_proc_agent] |
3c9057f3 SS |
24 | |
25 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
26 | executable [concat {debug nowarnings c} libs=$ipalib]] != "" } { | |
27 | untested tspeed.exp | |
28 | return -1 | |
29 | } | |
30 | ||
31 | # Typically we need a little extra time for this test. | |
32 | set timeout 180 | |
33 | ||
34 | set ws "\[\r\n\t \]+" | |
35 | set cr "\[\r\n\]+" | |
36 | ||
37 | # | |
38 | # Utility procs | |
39 | # | |
40 | ||
41 | proc prepare_for_trace_test {} { | |
42 | global executable | |
43 | ||
44 | clean_restart $executable | |
45 | ||
46 | runto_main | |
47 | ||
48 | set testline [gdb_get_line_number "set pre-run breakpoint here"] | |
49 | ||
50 | gdb_test "break $testline" ".*" "" | |
51 | ||
52 | set testline [gdb_get_line_number "set post-run breakpoint here"] | |
53 | ||
54 | gdb_test "break $testline" ".*" "" | |
55 | } | |
56 | ||
57 | proc run_trace_experiment {} { | |
58 | ||
59 | gdb_test "continue" \ | |
60 | ".*Breakpoint \[0-9\]+, main .*" \ | |
61 | "advance to trace begin" | |
62 | ||
63 | gdb_test_no_output "tstart" "start trace experiment" | |
64 | ||
65 | gdb_test "continue" \ | |
66 | ".*Breakpoint \[0-9\]+, main .*" \ | |
67 | "advance through tracing" | |
68 | ||
69 | gdb_test "tstatus" ".*Trace .*" "check on trace status" | |
70 | ||
71 | gdb_test "tstop" "" "" | |
72 | } | |
73 | ||
74 | proc gdb_slow_trace_speed_test { } { | |
75 | ||
76 | gdb_delete_tracepoints | |
77 | ||
78 | gdb_test "print iters = init_iters" ".* = .*"; | |
79 | ||
80 | set testline [gdb_get_line_number "set tracepoint here"] | |
81 | ||
82 | gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \ | |
83 | "Tracepoint \[0-9\]+ at .*" \ | |
84 | "set slow tracepoint" | |
85 | ||
86 | # Begin the test. | |
87 | run_trace_experiment | |
88 | } | |
89 | ||
90 | proc gdb_fast_trace_speed_test { } { | |
968643aa | 91 | global gdb_prompt |
3c9057f3 SS |
92 | |
93 | gdb_delete_tracepoints | |
94 | ||
95 | gdb_test "print iters = init_iters" ".* = .*"; | |
96 | ||
97 | set run_ftrace 0 | |
98 | ||
99 | set testline [gdb_get_line_number "set tracepoint here"] | |
100 | ||
101 | gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \ | |
102 | "set conditional fast tracepoint" { | |
968643aa | 103 | -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" { |
3c9057f3 SS |
104 | pass "set conditional fast tracepoint, done" |
105 | set run_ftrace 1 | |
106 | } | |
968643aa | 107 | -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" { |
3c9057f3 SS |
108 | pass "set conditional fast tracepoint, not allowed at line" |
109 | } | |
110 | } | |
111 | ||
112 | # If the fast tracepoint couldn't be set, don't bother with the run. | |
113 | if { $run_ftrace == 1 } then { | |
114 | ||
115 | # Begin the test. | |
116 | run_trace_experiment | |
117 | } | |
118 | } | |
119 | ||
120 | proc gdb_trace_collection_test {} { | |
121 | ||
122 | prepare_for_trace_test | |
123 | ||
124 | gdb_slow_trace_speed_test | |
125 | ||
126 | gdb_fast_trace_speed_test | |
127 | } | |
128 | ||
129 | clean_restart $executable | |
130 | runto_main | |
131 | ||
3c9057f3 | 132 | if { ![gdb_target_supports_trace] } then { |
10010058 | 133 | unsupported "Current target does not support trace" |
3c9057f3 SS |
134 | return 1; |
135 | } | |
136 | ||
137 | # Body of test encased in a proc so we can return prematurely. | |
138 | gdb_trace_collection_test |