From a4a168088d6032427769b0c9f1405e2eebcd5c66 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 8 Feb 2022 22:47:33 +0800 Subject: trace process --- xmake/core/base/os.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 18b59f61c..19f22e88f 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -268,6 +268,23 @@ function os._deduplicate_pathenv(value) return value end +-- trace process for profile(stuck,trace)? +function os._is_tracing_process() + local is_tracing = os._IS_TRACING_PROCESS + if is_tracing == nil then + local profile = os.getenv("XMAKE_PROFILE") + if profile then + profile = profile:trim() + if profile == "trace" or profile == "stuck" then + is_tracing = true + end + end + is_tracing = is_tracing or false + os._IS_TRACING_PROCESS = is_tracing + end + return is_tracing +end + -- match files or directories -- -- @param pattern the search pattern @@ -749,6 +766,11 @@ function os.execv(program, argv, opt) local proc = process.openv(filename, argv or {}, openopt) if proc ~= nil then + -- trace process + if os._is_tracing_process() then + utils.cprint("%s: ${color.dump.string}%s %s${clear}", proc, filename, argv and os.args(argv) or "") + end + -- wait process local waitok, status = proc:wait(-1) if waitok > 0 then -- cgit v1.3.1