如何使用 valgrind 启动程序?
#4191
-
我目前在尝试使用 task 完成目标。 但是,应该无法直接将 xmake 作为目标传递给 valgrind 现在,我面临的问题是:无法获得 但是,我想知道是否有正确的使用方式 |
Beta Was this translation helpful? Give feedback.
Answered by
waruqi
Sep 12, 2023
Replies: 3 comments 3 replies
-
重写 on_run 里面用 os.execv 去加载 valgrind 加载 target:targetfile() |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
-
我知道,但是还需要处理环境变量 task("valgrind")
set_menu {
usage = "xmake valgrind <target_name> [args...]"
, description = "valgrind"
, options = {
{nil, "prg_and_arg", "vs", nil, "prg_and_arg" }
}
}
on_run(function()
import("core.project.project")
import("core.project.config")
import("core.base.option")
config.load()
local args = option.get("prg_and_arg") or {}
local target_name = args[1]
if not target_name then
raise("no target")
end
local target = project.target(target_name)
if not target then
raise("target:"..target_name.." not found!")
end
-- XXX: deps so path
local envs = os.joinenvs( os.getenvs(), target:pkgenvs() )
envs = os.joinenvs( envs, target:get("runenv") )
envs = os.joinenvs( envs, target:get("runenvs") )
os.exec( "xmake" );
os.execv( "valgrind", table.join({"--vgdb=yes", "--leak-check=full", "--show-leak-kinds=all", "--log-file=aaa.vg", target:targetfile() }, table.slice( args, 2 ) ), { envs = envs } )
end) 文档中并没有提及 需要获得 xrepo 安装的包的lib 路径。 所以该函数可以随意使用吗? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
要看你的 target 是否需要了,如果没 package ,就没必要绑定 envs,如果需要,就用 target:pkgenvs ,是公开接口,但没文档化