forked from openresty/openresty-gdb-utils
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ngx-lua.gdb
83 lines (71 loc) · 2.47 KB
/
ngx-lua.gdb
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
set $LUA_NOREF = -2
define ngx-lua-code-cache
set $r = (ngx_http_request_t *) $arg0
set $loc_conf = (ngx_http_lua_loc_conf_t *) $r->loc_conf[ngx_http_lua_module.ctx_index]
if $loc_conf->enable_code_cache == 0
print "lua code cache off"
else
print "lua code cache on"
end
end
define ngx-lua-main-conf
set $r = (ngx_http_request_t *) $arg0
set $main_conf = (ngx_http_lua_main_conf_t *) $r->main_conf[ngx_http_lua_module.ctx_index]
printf "lua main VM: %p\n", $main_conf->lua
printf "pending timers: %d (max=%d)\n", $main_conf->pending_timers, \
$main_conf->max_pending_timers
printf "running timers: %d (max=%d)\n", $main_conf->running_timers, \
$main_conf->max_running_timers
printf "regex cache entries: %d (max=%d)\n", \
$main_conf->regex_cache_entries, \
$main_conf->regex_cache_max_entries
printf "regex match limit: %d\n", $main_conf->regex_match_limit
end
define ngx-lua-thread
set $coctx = (ngx_http_lua_co_ctx_t *) $arg0
echo $arg1
printf " thread is %p, L=%p, ref=%d, status: %s\n", \
$coctx, $coctx->co, $coctx->co_ref, \
ngx_http_lua_co_status_names[$coctx->co_status]
end
define ngx-lua-uthreads
set $r = (ngx_http_request_t *) $arg0
set $ctx = (ngx_http_lua_ctx_t *) $r->ctx[ngx_http_lua_module.ctx_index]
if $ctx->on_abort_co_ctx
printf "it has an on_abort thread %p\n", $ctx->on_abort_co_ctx
end
set $entry_co_ctx = &($ctx->entry_co_ctx)
if $entry_co_ctx->co_ref != $LUA_NOREF
ngx-lua-thread $entry_co_ctx entry
end
printf "there are %d user threads.\n", $ctx->uthreads
if $ctx->flushing_coros
printf "there are %d coroutines waiting on ngx.flush.\n",
$ctx->flushing_coros
end
set $part = &$ctx->user_co_ctx->part
set $cc = (ngx_http_lua_co_ctx_t *) $part->elts
set $n = 0
set $i = 0
while 1
if $i >= $part->nelts
if !$part->next
loop_break
end
set $part = $part->next
set $cc = (ngx_http_lua_co_ctx_t *) $part->elts
set $i = 0
end
set $i++
set $ref = $cc[$i].co_ref
if $ref != $LUA_NOREF
set $n++
printf "#%d ", $n
ngx-lua-thread &$cc[$i] user
end
end
printf "Found %d user threads.\n", $n
if $ctx->exited
printf "request already exited with code %d.\n", $ctx->exit_code
end
end