Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/DebuggerInit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### 初始化流程
简单概述几种加载luadebug调试器的方式

前端vscode的参数会被完整传递到前端程序lua-debug代理进程中,该进程负责加载lua-debug.so/.dll到lua虚拟机环境中.

参数传递分为两个阶段,初始化阶段目前只传递了部分参数, 第二阶段调试器加载后DAP协议的initialized消息中传递了所有参数

## Launch
1. 应用程序支持标准lua支持的-e参数
2. 注入器

## Attach
1. 主动连接调试器
2. 注入器

### 主动连接
在源代码里主动dofile debugger.lua

## Details

### '-e'

通过`DBG 'address[/ansi]/luaversion'` 在字符串中传递启动参数

目前只能传递 address utf8 luaversion 三个参数

### Injector

使用注入器, 加载attach_lua函数作为主入口,最终挂载attach.lua

通过ipc_send_luaversion传递参数

实际上只能传递luaversion这个参数
4 changes: 2 additions & 2 deletions extension/script/debugger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ if debug.getregistry()["lua-debug"] then
end

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