add cuda debugger to debugger.run
-- imports
import("core.base.option")
import("core.project.config")
+import("detect.tools.find_cudagdb")
+import("detect.tools.find_cudamemcheck")
import("detect.tools.find_gdb")
import("detect.tools.find_lldb")
import("detect.tools.find_windbg")
@@ -49,6 +51,27 @@ function _run_gdb(program, argv)
return true
end
+-- run cuda-gdb
+function _run_cudagdb(program, argv)
+
+ -- find cudagdb
+ local gdb = find_cudagdb({program = config.get("debugger")})
+ if not gdb then
+ return false
+ end
+
+ -- patch arguments
+ argv = argv or {}
+ table.insert(argv, 1, program)
+ table.insert(argv, 1, "--args")
+
+ -- run it
+ os.execv(gdb, argv)
+
+ -- ok
+ return true
+end
+
-- run lldb
function _run_lldb(program, argv)
@@ -95,6 +118,26 @@ function _run_windbg(program, argv)
return true
end
+-- run cuda-memcheck
+function _run_cudamemcheck(program, argv)
+
+ -- find cudamemcheck
+ local cudamemcheck = find_cudamemcheck({program = config.get("debugger")})
+ if not cudamemcheck then
+ return false
+ end
+
+ -- patch arguments
+ argv = argv or {}
+ table.insert(argv, 1, program)
+
+ -- run it
+ os.execv(cudamemcheck, argv)
+
+ -- ok
+ return true
+end
+
-- run x64dbg
function _run_x64dbg(program, argv)
@@ -176,6 +219,8 @@ function main(program, argv)
{
{"lldb" , _run_lldb}
, {"gdb" , _run_gdb}
+ , {"cudagdb" , _run_cudagdb}
+ , {"cudamemcheck", _run_cudamemcheck}
}
-- for windows target or on windows?
@@ -190,6 +235,16 @@ function main(program, argv)
local debugger = config.get("debugger")
if debugger then
debugger = debugger:lower()
+
+ -- try exactmatch first
+ for _, _debugger in ipairs(debuggers) do
+ if debugger:startswith(_debugger[1]) then
+ if _debugger[2](program, argv) then
+ return
+ end
+ end
+ end
+
for _, _debugger in ipairs(debuggers) do
if debugger:find(_debugger[1]) then
if _debugger[2](program, argv) then
