Skip to content

Commit 563a325

Browse files
authored
Merge branch 'actboy168:master' into master
2 parents cb0ed3c + 2bae990 commit 563a325

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

docs/DebuggerInit.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
### 初始化流程
2+
简单概述几种加载luadebug调试器的方式
3+
4+
前端vscode的参数会被完整传递到前端程序lua-debug代理进程中,该进程负责加载lua-debug.so/.dll到lua虚拟机环境中.
5+
6+
参数传递分为两个阶段,初始化阶段目前只传递了部分参数, 第二阶段调试器加载后DAP协议的initialized消息中传递了所有参数
7+
8+
## Launch
9+
1. 应用程序支持标准lua支持的-e参数
10+
2. 注入器
11+
12+
## Attach
13+
1. 主动连接调试器
14+
2. 注入器
15+
16+
### 主动连接
17+
在源代码里主动dofile debugger.lua
18+
19+
## Details
20+
21+
### '-e'
22+
23+
通过`DBG 'address[/ansi]/luaversion'` 在字符串中传递启动参数
24+
25+
目前只能传递 address utf8 luaversion 三个参数
26+
27+
### Injector
28+
29+
使用注入器, 加载attach_lua函数作为主入口,最终挂载attach.lua
30+
31+
通过ipc_send_luaversion传递参数
32+
33+
实际上只能传递luaversion这个参数

extension/script/debugger.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ if debug.getregistry()["lua-debug"] then
4747
end
4848

4949
local function detectLuaDebugPath(cfg)
50-
local PLATFORM
51-
do
50+
local PLATFORM = cfg.platform or os.getenv "LUA_DEBUG_PLATFORM"
51+
if not PLATFORM then
5252
local function shell(command)
5353
--NOTICE: io.popen可能会多线程不安全
5454
local f = assert(io.popen(command, 'r'))

0 commit comments

Comments
 (0)