Debian Codegraph @

testsuite/systemtap.context/backtrace.tcl

raw
1 set m1 0
2 set m2 0
3 set m3 0
4 set m4 0
5 set m5 0
6 set m6 0
7 set module1 0
8 set kernel 0
9 set script_exit 0
10 set eof_found 0
11
12 spawn stap -d kernel -d systemtap_test_module1 $srcdir/$subdir/backtrace.stp
13 #exp_internal 1
14 expect {
15 -timeout 120
16 "<no kernel backtrace at begin>\r\n" {
17 pass "backtrace of begin probe"
18 sleep 1
19 exec echo 0 > /proc/stap_test_cmd
20 exp_continue
21 }
22
23 -re {^WARNING: Missing unwind data for a module[^\r\n]*\r\n} { exp_continue }
24
25 #backtrace from yyy_func2
26 -re {^backtrace from module\(\"systemtap_test_module2\"\)\.function\(\"yyy_func2@[^\r\n]+\r\n} {
27 incr m1
28 expect {
29 -timeout 5
30 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
31 if {$m1 == 1} {incr m1}
32 exp_continue
33 }
34 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
35 if {$m1 == 2} {incr m1}
36 exp_continue
37 }
38 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
39 if {$m1 == 3} {incr module1}
40 exp_continue
41 }
42 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
43 if {$module1 == 1} {incr kernel}
44 # we expect at least one [kernel] frame, maybe more.
45 }
46 eof { set eof_found 1; fail "early test shutdown (m1 eof)" }
47 }
48 if {! $eof_found} { exp_continue }
49 }
50 -re {.*--- yyy_func2 ---\r\nthe stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
51 incr m2
52 expect {
53 -timeout 5
54 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
55 if {$m2 == 1} {incr m2}
56 exp_continue
57 }
58 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
59 if {$m2 == 2} {incr m2}
60 exp_continue
61 }
62 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
63 if {$m2 == 3} {incr module1}
64 exp_continue
65 }
66 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
67 if {$module1 == 2} {incr kernel}
68 # we expect at least one [kernel] frame, maybe more.
69 }
70 eof { set eof_found 1; fail "early test shutdown (m2 eof)" }
71 }
72 if {! $eof_found} { exp_continue }
73 }
74
75 #backtrace from yyy_func3
76 -re {.*backtrace from module\(\"systemtap_test_module2\"\)\.function\(\"yyy_func3@[^\r\n]+\r\n} {
77 incr m3
78 expect {
79 -timeout 5
80 -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
81 if {$m3 == 1} {incr m3}
82 exp_continue
83 }
84 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
85 if {$m3 == 2} {incr m3}
86 exp_continue
87 }
88 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
89 if {$m3 == 3} {incr m3}
90 exp_continue
91 }
92 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
93 if {$m3 == 4} {incr module1}
94 exp_continue
95 }
96 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
97 if {$module1 == 3} {incr kernel}
98 # we expect at least one [kernel] frame, maybe more.
99 }
100 eof { set eof_found 1; fail "early test shutdown (m3 eof)" }
101 }
102 if {! $eof_found} { exp_continue }
103 }
104 -re {.*--- yyy_func3 ---\r\nthe stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
105 incr m4
106 expect {
107 -timeout 5
108 -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
109 if {$m4 == 1} {incr m4}
110 exp_continue
111 }
112 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
113 if {$m4 == 2} {incr m4}
114 exp_continue
115 }
116 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
117 if {$m4 == 3} {incr m4}
118 exp_continue
119 }
120 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
121 if {$m4 == 4} {incr module1}
122 exp_continue
123 }
124 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
125 if {$module1 == 4} {incr kernel}
126 # we expect at least one [kernel] frame, maybe more.
127 }
128 eof { set eof_found 1; fail "early test shutdown (m4 eof)" }
129 }
130 if {! $eof_found} { exp_continue }
131 }
132
133 #backtrace from yyy_func4
134 -re {.*backtrace from module\(\"systemtap_test_module2\"\)\.function\(\"yyy_func4@[^\r\n]+\r\n} {
135 incr m5
136 expect {
137 -timeout 5
138 -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]\r\n} {
139 if {$m5 == 1} {incr m5}
140 exp_continue
141 }
142 -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
143 if {$m5 == 2} {incr m5}
144 exp_continue
145 }
146 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
147 if {$m5 == 3} {incr m5}
148 exp_continue
149 }
150 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
151 if {$m5 == 4} {incr m5}
152 exp_continue
153 }
154 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
155 if {$m5 == 5} {incr module1}
156 exp_continue
157 }
158 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
159 if {$module1 == 5} {incr kernel}
160 # we expect at least one [kernel] frame, maybe more.
161 }
162 eof { set eof_found 1; fail "early test shutdown (m5 eof)" }
163 }
164 if {! $eof_found} { exp_continue }
165 }
166 -re {.*--- yyy_func4 ---\r\nthe stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
167 incr m6
168 expect {
169 -timeout 5
170 -re {^ 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]\r\n} {
171 if {$m6 == 1} {incr m6}
172 exp_continue
173 }
174 -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
175 if {$m6 == 2} {incr m6}
176 exp_continue
177 }
178 -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
179 if {$m6 == 3} {incr m6}
180 exp_continue
181 }
182 -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
183 if {$m6 == 4} {incr m6}
184 exp_continue
185 }
186 -re {^ 0x[a-f0-9]+ : stm_write_cmd[^\[]+\[systemtap_test_module1\]\r\n} {
187 if {$m6 == 5} {incr module1}
188 exp_continue
189 }
190 -re {^ 0x[a-f0-9]+ : [a-z_]+[^\[]+\[kernel\]\r\n} {
191 if {$module1 == 6} {incr kernel}
192 # we expect at least one [kernel] frame, maybe more.
193 }
194 eof { set eof_found 1; fail "early test shutdown (m6 eof)" }
195 }
196 if {! $eof_found} { exp_continue }
197 }
198 eof {
199 # good backtrace.stp called exit().
200 incr script_exit;
201 }
202 }
203 kill -INT -[exp_pid] 2
204 if {$m1 == 3} {
205 pass "backtrace of yyy_func2"
206 } else {
207 fail "backtrace of yyy_func2 ($m1)"
208 }
209 if {$m2 == 3} {
210 pass "print_syms of yyy_func2"
211 } else {
212 fail "print_syms of yyy_func2 ($m2)"
213 }
214 if {$m3 == 4} {
215 pass "backtrace of yyy_func3"
216 } else {
217 fail "backtrace of yyy_func3 ($m3)"
218 }
219 if {$m4 == 4} {
220 pass "print_syms of yyy_func3"
221 } else {
222 fail "print_syms of yyy_func3 ($m4)"
223 }
224 if {$m5 == 5} {
225 pass "backtrace of yyy_func4"
226 } else {
227 fail "backtrace of yyy_func4 ($m5)"
228 }
229 if {$m6 == 5} {
230 pass "print_syms of yyy_func4"
231 } else {
232 fail "print_syms of yyy_func4 ($m6)"
233 }
234 if {$module1 == 6} {
235 pass "print_syms found systemtap_test_module1"
236 } else {
237 fail "print_syms didn't find systemtap_test_module1 ($module1)"
238 }
239 if {$kernel >= 6} {
240 pass "print_syms found \[kernel\]"
241 } else {
242 fail "print_syms didn't find \[kernel\] ($kernel)"
243 }
244 if {$script_exit == 1} {
245 pass "backtrace.stp called exit"
246 } else {
247 fail "backtrace.stp didn't call exit ($script_exit)"
248 }
249
250 catch { close }
251 catch { wait }