nvim/debugger.lua
2024-04-02 09:17:20 +02:00

101 lines
2.7 KiB
Lua

local dap = require("dap")
dap.adapters.gdb = {
id = 'gdb',
type = 'executable',
command = 'gdb',
args = { '--quiet', '--interpreter=dap' },
}
dap.adapters.gdb = {
id = 'gdb',
type = 'executable',
command = 'gdb',
args = { '--quiet', '--interpreter=dap' },
}
dap.configurations.c = {
{
name = 'Run executable (GDB)',
type = 'gdb',
request = 'launch',
-- This requires special handling of 'run_last', see
-- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
program = function()
local path = vim.fn.input({
prompt = 'Path to executable: ',
default = vim.fn.getcwd() .. '/',
completion = 'file',
})
return (path and path ~= '') and path or dap.ABORT
end,
},
{
name = 'Run executable with arguments (GDB)',
type = 'gdb',
request = 'launch',
-- This requires special handling of 'run_last', see
-- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
program = function()
local path = vim.fn.input({
prompt = 'Path to executable: ',
default = vim.fn.getcwd() .. '/',
completion = 'file',
})
return (path and path ~= '') and path or dap.ABORT
end,
args = function()
local args_str = vim.fn.input({
prompt = 'Arguments: ',
})
return vim.split(args_str, ' +')
end,
},
{
name = 'Attach to process (GDB)',
type = 'gdb',
request = 'attach',
processId = require('dap.utils').pick_process,
},
{
name = "Debug J-Link",
type = "cdbg",
request = "launch",
cwd = "${workspaceFolder}",
program = function()
local path = vim.fn.input({
prompt = 'Path to executable: ',
default = vim.fn.getcwd() .. '/',
completion = 'file',
})
return (path and path ~= '') and path or dap.ABORT
end,
stopAtEntry = false,
MIMode = "gdb",
miDebuggerServerAddress = function()
local address = vim.fn.input({
prompt = 'Server address: ',
default = 'localhost:3333',
})
return address
end,
miDebuggerPath = "gdb-multiarch",
serverLaunchTimeout = 5000,
postRemoteConnectCommands = {
{
text = "monitor reset",
ignoreFailures = false
},
{
text = "load",
ignoreFailures = false
},
},
}
}