-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathhookmgr.lua
More file actions
145 lines (124 loc) · 3.03 KB
/
hookmgr.lua
File metadata and controls
145 lines (124 loc) · 3.03 KB
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
---@meta
---
---@class LuaDebugHookmgr
---在调试器VM提供了一个hook管理器。理论上它可以用visitor提供的API,完全由Lua实现。但出于对性能的考虑,所以将hook的管理有C++实现,这也是luadebug中唯一考虑了性能的一个模块。
---
local hookmgr = {}
---
---@param callback fun(name:string,...):boolean|nil
---初始化hookmgr,并注册一个回调函数。当有事件被触发时,会调用回调函数。事件可以是rdebug.probe/rdebug.event触发的,也可以是hookmgr内部触发的内置事件。
---* `newproto` proto也就是函数原型,每次调试器遇到新的proto就会触发这个事件。返回值需要告诉调试器这个proto是否包含断点,然后调试器会自动调用hookmgr.break_add或hookmgr.break_del。
---* `bp` 执行有断点的proto时会触发,需要自己检查是否命中了行号。
---* `step` 满足单步状态时触发。
---* `funcbp` 每次进入一个函数时会触发。需要用hookmgr.funcbp_open激活。
---* `update` 每隔一段时间触发。需要用hookmgr.update_open激活。
---* `exception` 每次触发非内存错误时触发。需要用hookmgr.exception_open激活。需要补丁支持。
---* `thread` 每次进入或退出thread会触发。需要用hookmgr.thread_open激活。需要补丁支持。
---
function hookmgr.init(callback)
end
---
---@param co thread
---设置当前调试的协程为co。
---
function hookmgr.sethost(co)
end
---
---@return thread
---获取当前调试的协程。
---
function hookmgr.gethost()
end
---
---@param co thread
---更新指定协程的hookmask。(因为Lua不会帮你更新)
---
function hookmgr.updatehookmask(co)
end
---
---@return integer
---获取当前的栈层级。
---
function hookmgr.stacklevel()
end
---
---@param proto lightuserdata
---设置proto有断点。
---
function hookmgr.break_add(proto)
end
---
---@param proto lightuserdata
---设置proto没断点。
---
function hookmgr.break_del(proto)
end
---
---@param enable boolean
---启用`bp`事件。
---
function hookmgr.break_open(enable)
end
---
---仅在本次函数调用中关闭`bp`事件。
---
function hookmgr.break_closeline()
end
---
---@param enable boolean
---启用`funcbp`事件。
---
function hookmgr.funcbp_open(enable)
end
---
---步入。
---
function hookmgr.step_in()
end
---
---步出。
---
function hookmgr.step_out()
end
---
---步过。
---
function hookmgr.step_over()
end
---
---取消`step_in/step_out/step_over`的状态。
---
function hookmgr.step_cancel()
end
---
---@param enable boolean
---启用`update`事件。
---
function hookmgr.update_open(enable)
end
---
---@param enable boolean
---启用`exception`事件。
---
function hookmgr.exception_open(enable)
end
---
---@param enable boolean
---启用`thread`事件。
---
function hookmgr.thread_open(enable)
end
---
---@param co thread
---@return thread
---获取coroutine调用方
---
function hookmgr.coroutine_from(co)
end
---
---@param enable boolean
---启用luajit的jit支持
---
function hookmgr.enable_jit(enable)
end
return hookmgr