Skip to content

Commit 7b0a4b6

Browse files
fesilyfesil
andauthored
Fix linux process inject (#308)
* fix lua-debug export * fix linux attach inject --------- Co-authored-by: fesil <285451120@qq.com>
1 parent a6a380e commit 7b0a4b6

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

compile/common/lua-debug.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ lm:executable "lua-debug" {
3333
},
3434
linux = {
3535
crt = "static",
36+
ldflags = "-rdynamic"
3637
},
3738
netbsd = {
3839
crt = "static",

compile/common/package_json.lua

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,22 @@ else
270270
end
271271

272272
attributes.attach = {
273-
}
274-
275-
if OS == "win32" or OS == "darwin" then
276-
attributes.attach.processId = {
273+
processId = {
277274
default = "${command:pickProcess}",
278275
markdownDescription = "Id of process to attach to.",
279276
type = "string",
280-
}
281-
attributes.attach.processName = {
277+
},
278+
processName = {
282279
default = "lua.exe",
283280
markdownDescription = "Name of process to attach to.",
284281
type = "string",
285282
}
286-
json.contributes.debuggers[1].variables = {
287-
pickProcess = "extension.lua-debug.pickProcess",
288-
}
289-
end
283+
}
284+
285+
json.contributes.debuggers[1].variables = {
286+
pickProcess = "extension.lua-debug.pickProcess",
287+
}
288+
290289

291290
attributes.launch = {
292291
luaexe = {

compile/linux/runtime.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require "compile.common.runtime"
44
require "compile.common.launcher"
55

66
lm:lua_dll 'launcher' {
7+
bindir = "publish/bin/",
78
export_luaopen = "off",
89
deps = {
910
"launcher_source",

extension/script/frontend/process_inject.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ function _M.gdb_inject(pid, entry, injectdll, gdb_path)
5151

5252
local launcher = {
5353
"-ex",
54-
-- 6 = RTDL_NOW|RTDL_LOCAL
55-
('print (void*)dlopen("%s", 6)'):format(injectdll),
54+
-- 6 = RTDL_NOW|RTDL_LOCAL macos
55+
-- 2 = RTDL_NOW linux
56+
('print (void*)dlopen("%s", %d)'):format(injectdll, platform_os == macos and 6 or 2),
5657
"-ex",
5758
('call ((void(*)())&%s)()'):format(entry),
5859
"-ex",
@@ -93,8 +94,9 @@ function _M.lldb_inject(pid, entry, injectdll, lldb_path)
9394

9495
local launcher = {
9596
"-o",
96-
-- 6 = RTDL_NOW|RTDL_LOCAL
97-
('expression (void*)dlopen("%s", 6)'):format(injectdll),
97+
-- 6 = RTDL_NOW|RTDL_LOCAL macos
98+
-- 2 = RTDL_NOW linux
99+
('expression (void*)dlopen("%s", %d)'):format(injectdll, platform_os == macos and 6 or 2),
98100
"-o",
99101
('expression ((void(*)())&%s)()'):format(entry),
100102
"-o",
@@ -153,9 +155,6 @@ function _M.windows_inject(process, entry)
153155
end
154156

155157
function _M.inject(process, entry, args)
156-
if platform_os ~= windows and platform_os ~= macos then
157-
return false, "unsupported inject"
158-
end
159158
if platform_os ~= windows and type(process) == "userdata" then
160159
process = process:get_id()
161160
end

extension/script/frontend/proxy.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ end
8080
local function proxy_attach(pkg)
8181
local args = pkg.arguments
8282
platform_os.init(args)
83-
if platform_os() ~= "windows" and platform_os() ~= "macos" then
84-
attach_tcp(pkg, args)
85-
return
86-
end
8783
if args.processId then
8884
local processId = tonumber(args.processId)
8985
local ok, errmsg = attach_process(pkg, processId)

0 commit comments

Comments
 (0)