summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-08 22:47:33 +0800
committerruki <[email protected]>2022-02-08 22:47:33 +0800
commita4a168088d6032427769b0c9f1405e2eebcd5c66 (patch)
treec38cbda0839b5a278e9d7431449a0d4576bb54f0
parent41122c0c4597ae3b50a9d2479e348b9c542d7066 (diff)
trace process
-rw-r--r--xmake/core/base/os.lua22
1 files changed, 22 insertions, 0 deletions
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