From 9074bbff083934ab80556372e01f9075817750be Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Wed, 29 Oct 2025 15:15:18 +0100 Subject: [PATCH] [DAP] Add option to launch gdb with args to the binary --- nvim/lua/plugins/testing/debuggers/gdb.lua | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nvim/lua/plugins/testing/debuggers/gdb.lua b/nvim/lua/plugins/testing/debuggers/gdb.lua index 3e38c9b..afb410c 100644 --- a/nvim/lua/plugins/testing/debuggers/gdb.lua +++ b/nvim/lua/plugins/testing/debuggers/gdb.lua @@ -17,6 +17,29 @@ dap.configurations.c = { cwd = "${workspaceFolder}", stopAtBeginningOfMainSubprogram = false, }, + { + name = "Launch (with args)", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + args = function() + local arguments = vim.fn.input("Arguments: ") + if string.len(arguments) < 1 then + return {} + end + local table = { "--args" } + local index = 1 + for arg in string.gmatch(arguments, "[^%s]+") do + table[index] = arg + index = index + 1 + end + return table + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, { name = "Select and attach to process", type = "gdb",