summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-08 10:49:28 +0800
committerGitHub <[email protected]>2022-02-08 10:49:28 +0800
commit6b74a4dcd274cf96f3b224975ca8a4580ebc0f65 (patch)
treec38cbda0839b5a278e9d7431449a0d4576bb54f0 /xmake
parentc80d0c5638f83d7de838a09554daa48800c71fe3 (diff)
parenta4a168088d6032427769b0c9f1405e2eebcd5c66 (diff)
Merge pull request #2032 from xmake-io/catch
catch ctrl-c to get backtrace of stuck
Diffstat (limited to 'xmake')
-rw-r--r--xmake/core/base/coroutine.lua6
-rw-r--r--xmake/core/base/os.lua22
-rw-r--r--xmake/plugins/show/lists/envs.lua2
3 files changed, 23 insertions, 7 deletions
diff --git a/xmake/core/base/coroutine.lua b/xmake/core/base/coroutine.lua
index 2f1c347a8..43a5d6d8a 100644
--- a/xmake/core/base/coroutine.lua
+++ b/xmake/core/base/coroutine.lua
@@ -31,8 +31,6 @@ coroutine._resume = coroutine._resume or coroutine.resume
-- resume coroutine
function coroutine.resume(co, ...)
-
- -- resume it
local ok, results = coroutine._resume(co, ...)
if not ok then
@@ -47,12 +45,8 @@ function coroutine.resume(co, ...)
errors = results:sub(pos + 1)
end
end
-
- -- failed
return false, errors
end
-
- -- ok
return true, results
end
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
diff --git a/xmake/plugins/show/lists/envs.lua b/xmake/plugins/show/lists/envs.lua
index 4092901fa..8e66db1e8 100644
--- a/xmake/plugins/show/lists/envs.lua
+++ b/xmake/plugins/show/lists/envs.lua
@@ -36,7 +36,7 @@ function main()
XMAKE_RAMDIR = {"Set the ramdisk directory.", os.getenv("XMAKE_RAMDIR")},
XMAKE_RCFILES = {"Set the runtime configuration files.", path.joinenv(project.rcfiles())},
XMAKE_TMPDIR = {"Set the temporary directory.", os.tmpdir()},
- XMAKE_PROFILE = {"Start profiler, e.g. perf, trace.", os.getenv("XMAKE_PROFILE")},
+ XMAKE_PROFILE = {"Start profiler, e.g. perf, trace, stuck.", os.getenv("XMAKE_PROFILE")},
XMAKE_PKG_CACHEDIR = {"Set the cache directory of packages.", os.getenv("XMAKE_PKG_CACHEDIR")},
XMAKE_PKG_INSTALLDIR = {"Set the install directory of packages.", os.getenv("XMAKE_PACKAGEDIR")}}
local width = 24