Skip to content

Commit

Permalink
Merge pull request #6130 from Gaweringo/add-raddbg-debugger
Browse files Browse the repository at this point in the history
feat(debugger): add raddbg as a debugger option
  • Loading branch information
waruqi authored Feb 3, 2025
2 parents fffc419 + 6e24f29 commit 5e865e2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
47 changes: 47 additions & 0 deletions xmake/modules/detect/tools/find_raddbg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--!A cross-platform build utility based on Lua
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, gaweringo
-- @file find_raddbg.lua
--

-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")

-- find raddbg
--
-- @param opt the argument options, e.g. {version = true, program="raddbg"}
--
-- @return program, version
--
-- @code
--
-- local raddbg = find_raddbg()
-- local raddbg, version = find_raddbg({version = true})
-- local raddbg, version = find_raddbg({version = true, program = "raddbg"})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "raddbg", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
18 changes: 18 additions & 0 deletions xmake/modules/devel/debugger/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ function _run_seergdb(program, argv, opt)
return true
end

-- run rad debugger
function _run_raddbg(program, argv, opt)
opt = opt or {}
local raddbg = find_tool("raddbg", {program = config.get("debugger")})
if not raddbg then
return false
end

-- patch arguments
argv = argv or {}
table.insert(argv, 1, program)

-- run it
os.execv(raddbg.program, argv, table.join(opt, {exclusive = true}))
return true
end

-- run program with debugger
--
-- @param program the program name
Expand Down Expand Up @@ -327,6 +344,7 @@ function main(program, argv, opt)
table.insert(debuggers, 1, {"x64dbg", _run_x64dbg})
table.insert(debuggers, 1, {"vsjitdebugger", _run_vsjitdebugger})
table.insert(debuggers, 1, {"devenv", _run_devenv})
table.insert(debuggers, 1, {"raddbg", _run_raddbg})
end

-- get debugger from configuration
Expand Down

0 comments on commit 5e865e2

Please sign in to comment.