-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy path073-backtrace.t
189 lines (174 loc) · 3.5 KB
/
073-backtrace.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# vim:set ft= ts=4 sw=4 et fdm=marker:
use Test::Nginx::Socket::Lua;
#worker_connections(1014);
#master_on();
#workers(2);
#log_level('warn');
repeat_each(2);
#repeat_each(1);
plan tests => repeat_each() * 51;
#no_diff();
no_long_string();
run_tests();
__DATA__
=== TEST 1: sanity
--- config
location /lua {
content_by_lua
' local function bar()
return lua_concat(3)
end
local function foo()
bar()
end
foo()
';
}
--- request
GET /lua
--- ignore_response
--- error_log
attempt to call global 'lua_concat'
: in function 'bar'
:5: in function 'foo'
:7: in main chunk
=== TEST 2: error(nil)
--- config
location /lua {
content_by_lua
' local function bar()
error(nil)
end
local function foo()
bar()
end
foo()
';
}
--- request
GET /lua
--- ignore_response
--- error_log eval
[
'lua entry thread aborted: runtime error: unknown reason',
'stack traceback:',
" in function 'error'",
": in function 'bar'",
":5: in function 'foo'",
qr/:7: in main chunk/,
]
=== TEST 3: deep backtrace in a single coroutine (more than 15)
--- config eval
my $s = "
location /lua {
content_by_lua '
";
my $prev;
for my $i (1..18) {
if (!defined $prev) {
$s .= "
local function func$i()
return error([[blah]])
end";
} else {
$s .= "
local function func$i()
local v = func$prev()
return v
end";
}
$prev = $i;
}
$s .= "
func$prev()
';
}
";
--- request
GET /lua
--- stap2
probe process("$LIBLUA_PATH").function("lua_concat") {
println("lua concat")
//print_ubacktrace()
}
--- stap_out2
--- ignore_response
--- error_log
: blah
: in function 'func1'
:7: in function 'func2'
:11: in function 'func3'
:15: in function 'func4'
:19: in function 'func5'
:23: in function 'func6'
:27: in function 'func7'
:31: in function 'func8'
:35: in function 'func9'
:39: in function 'func10'
:43: in function 'func11'
:47: in function 'func12'
:51: in function 'func13'
:55: in function 'func14'
:59: in function 'func15'
:63: in function 'func16'
:67: in function 'func17'
:71: in function 'func18'
:74: in main chunk
=== TEST 4: deep backtrace in a single coroutine (more than 22)
--- config eval
my $s = "
location /lua {
content_by_lua '
";
my $prev;
for my $i (1..23) {
if (!defined $prev) {
$s .= "
local function func$i()
return error([[blah]])
end";
} else {
$s .= "
local function func$i()
local v = func$prev()
return v
end";
}
$prev = $i;
}
$s .= "
func$prev()
';
}
";
--- request
GET /lua
--- stap2
probe process("$LIBLUA_PATH").function("lua_concat") {
println("lua concat")
//print_ubacktrace()
}
--- stap_out2
--- ignore_response
--- error_log
: blah
: in function 'func1'
:7: in function 'func2'
:11: in function 'func3'
:15: in function 'func4'
:19: in function 'func5'
:23: in function 'func6'
:27: in function 'func7'
:31: in function 'func8'
:35: in function 'func9'
:39: in function 'func10'
:43: in function 'func11'
:47: in function 'func12'
:59: in function 'func15'
:63: in function 'func16'
:67: in function 'func17'
:71: in function 'func18'
:75: in function 'func19'
:79: in function 'func20'
:83: in function 'func21'
...