Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2011-2019 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 | ||
8bca2978 SL |
18 | if {[skip_shlib_tests]} { |
19 | return 0 | |
20 | } | |
21 | ||
497a5eb0 | 22 | standard_testfile |
3c9057f3 | 23 | set executable $testfile |
3c9057f3 | 24 | |
8bca2978 SL |
25 | # Check that the target supports trace. |
26 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { | |
27 | untested "failed to compile" | |
28 | return -1 | |
29 | } | |
30 | ||
31 | clean_restart ${testfile} | |
32 | ||
33 | if ![runto_main] { | |
34 | fail "can't run to main to check for trace support" | |
35 | return -1 | |
36 | } | |
37 | ||
38 | if ![gdb_target_supports_trace] { | |
39 | unsupported "target does not support trace" | |
40 | return -1 | |
41 | } | |
42 | ||
43 | # Compile the test case with the in-process agent library. | |
c0d4d1c0 | 44 | set ipalib [get_in_proc_agent] |
3c9057f3 SS |
45 | |
46 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
f9c49bff | 47 | executable [concat {debug c} shlib=$ipalib]] != "" } { |
84c93cd5 | 48 | untested "failed to compile" |
3c9057f3 SS |
49 | return -1 |
50 | } | |
51 | ||
52 | # Typically we need a little extra time for this test. | |
53 | set timeout 180 | |
54 | ||
55 | set ws "\[\r\n\t \]+" | |
56 | set cr "\[\r\n\]+" | |
57 | ||
58 | # | |
59 | # Utility procs | |
60 | # | |
61 | ||
62 | proc prepare_for_trace_test {} { | |
63 | global executable | |
f9c49bff | 64 | global ipalib |
3c9057f3 SS |
65 | |
66 | clean_restart $executable | |
c708f4d2 | 67 | gdb_load_shlib $ipalib |
3c9057f3 SS |
68 | |
69 | runto_main | |
70 | ||
71 | set testline [gdb_get_line_number "set pre-run breakpoint here"] | |
72 | ||
73 | gdb_test "break $testline" ".*" "" | |
74 | ||
75 | set testline [gdb_get_line_number "set post-run breakpoint here"] | |
76 | ||
77 | gdb_test "break $testline" ".*" "" | |
78 | } | |
79 | ||
80 | proc run_trace_experiment {} { | |
81 | ||
82 | gdb_test "continue" \ | |
83 | ".*Breakpoint \[0-9\]+, main .*" \ | |
84 | "advance to trace begin" | |
85 | ||
86 | gdb_test_no_output "tstart" "start trace experiment" | |
87 | ||
88 | gdb_test "continue" \ | |
89 | ".*Breakpoint \[0-9\]+, main .*" \ | |
90 | "advance through tracing" | |
91 | ||
92 | gdb_test "tstatus" ".*Trace .*" "check on trace status" | |
93 | ||
94 | gdb_test "tstop" "" "" | |
95 | } | |
96 | ||
97 | proc gdb_slow_trace_speed_test { } { | |
98 | ||
99 | gdb_delete_tracepoints | |
100 | ||
4ec70201 | 101 | gdb_test "print iters = init_iters" ".* = .*" |
3c9057f3 SS |
102 | |
103 | set testline [gdb_get_line_number "set tracepoint here"] | |
104 | ||
105 | gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \ | |
106 | "Tracepoint \[0-9\]+ at .*" \ | |
107 | "set slow tracepoint" | |
108 | ||
109 | # Begin the test. | |
110 | run_trace_experiment | |
111 | } | |
112 | ||
113 | proc gdb_fast_trace_speed_test { } { | |
968643aa | 114 | global gdb_prompt |
3c9057f3 SS |
115 | |
116 | gdb_delete_tracepoints | |
117 | ||
4ec70201 | 118 | gdb_test "print iters = init_iters" ".* = .*" |
3c9057f3 SS |
119 | |
120 | set run_ftrace 0 | |
121 | ||
122 | set testline [gdb_get_line_number "set tracepoint here"] | |
123 | ||
124 | gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \ | |
125 | "set conditional fast tracepoint" { | |
968643aa | 126 | -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" { |
3c9057f3 SS |
127 | pass "set conditional fast tracepoint, done" |
128 | set run_ftrace 1 | |
129 | } | |
968643aa | 130 | -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" { |
3c9057f3 SS |
131 | pass "set conditional fast tracepoint, not allowed at line" |
132 | } | |
133 | } | |
134 | ||
135 | # If the fast tracepoint couldn't be set, don't bother with the run. | |
136 | if { $run_ftrace == 1 } then { | |
137 | ||
138 | # Begin the test. | |
139 | run_trace_experiment | |
140 | } | |
141 | } | |
142 | ||
143 | proc gdb_trace_collection_test {} { | |
144 | ||
145 | prepare_for_trace_test | |
146 | ||
147 | gdb_slow_trace_speed_test | |
148 | ||
149 | gdb_fast_trace_speed_test | |
150 | } | |
151 | ||
152 | clean_restart $executable | |
c708f4d2 AB |
153 | gdb_load_shlib $ipalib |
154 | ||
3c9057f3 SS |
155 | runto_main |
156 | ||
3c9057f3 | 157 | if { ![gdb_target_supports_trace] } then { |
bc6c7af4 | 158 | unsupported "current target does not support trace" |
ae59b1da | 159 | return 1 |
3c9057f3 SS |
160 | } |
161 | ||
162 | # Body of test encased in a proc so we can return prematurely. | |
163 | gdb_trace_collection_test |