-
-
Notifications
You must be signed in to change notification settings - Fork 118
Description
I use gdb or vscode-cpptools to debug cpp program. When I debug with gdb, the console window is useless because the program output to repl window. So I want hide the console window in this situation. However, if I debug with the vscode-cpptools, the console window is necessary because it show the output. Could I configurate the layout according the adapter?
Here is my nvim config
Click me
{
"mfussenegger/nvim-dap",
dependencies = {
{
"nvim-telescope/telescope-dap.nvim",
config = function()
require("telescope").load_extension("dap")
end,
},
},
event = "VeryLazy",
config = function()
local dap = require("dap")
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
}
dap.adapters.cppdbg = {
id = "cppdbg",
type = "executable",
command = "/usr/share/cpptools-debug/bin/OpenDebugAD7",
}
dap.configurations.cpp = {
{
name = "Launch (vscode-cpptools)",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopAtEntry = true,
setupCommands = {
{
text = "-enable-pretty-printing",
description = "enable pretty printing",
ignoreFailures = false,
},
},
},
{
name = "Select and attach to process (vscode-cpptools)",
type = "cppdbg",
request = "attach",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
pid = function()
local name = vim.fn.input("Executable name (filter): ")
return require("dap.utils").pick_process({ filter = name })
end,
cwd = "${workspaceFolder}",
setupCommands = {
{
text = "-enable-pretty-printing",
description = "enable pretty printing",
ignoreFailures = false,
},
},
},
{
name = "Attach to gdbserver :1234 (vscode-cpptools)",
type = "cppdbg",
request = "launch",
MIMode = "gdb",
miDebuggerServerAddress = "localhost:1234",
miDebuggerPath = "/usr/bin/gdb",
cwd = "${workspaceFolder}",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
setupCommands = {
{
text = "-enable-pretty-printing",
description = "enable pretty printing",
ignoreFailures = false,
},
},
},
{
name = "Launch (gdb)",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Select and attach to process (gdb)",
type = "gdb",
request = "attach",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
pid = function()
local name = vim.fn.input("Executable name (filter): ")
return require("dap.utils").pick_process({ filter = name })
end,
cwd = "${workspaceFolder}",
},
{
name = "Attach to gdbserver :1234 (gdb)",
type = "gdb",
request = "attach",
target = "localhost:1234",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
},
}
dap.configurations.c = dap.configurations.cpp
end,
},
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio",
},
opts = function()
local dap, dapui = require("dap"), require("dapui")
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
return {
layouts = {
{
elements = {
{
id = "stacks",
size = 0.5,
},
{
id = "watches",
size = 0.25,
},
{
id = "scopes",
size = 0.25,
},
},
position = "right",
size = 80,
},
{
elements = {
{
id = "console",
size = 0.5,
},
},
position = "bottom",
size = 40,
},
},
}
end,
},
Here is my env
Click me
██████████████████ ████████ xyz1001@xyz1001-20yn
██████████████████ ████████ --------------------
██████████████████ ████████ OS: Manjaro Linux x86_64
██████████████████ ████████ Host: 20YN ThinkBook 14p Gen 2
████████ ████████ Kernel: 6.12.17-1-MANJARO
████████ ████████ ████████ Uptime: 24 days, 21 hours, 20 mins
████████ ████████ ████████ Packages: 1573 (pacman)
████████ ████████ ████████ Shell: zsh 5.9
████████ ████████ ████████ Resolution: 3840x2160
████████ ████████ ████████ DE: Plasma 6.3.2
████████ ████████ ████████ WM: KWin
████████ ████████ ████████ Theme: Breeze [GTK2/3]
████████ ████████ ████████ Icons: breeze [GTK2/3]
████████ ████████ ████████ Terminal: tmux
CPU: AMD Ryzen 7 5800H with Radeon Graphics (16) @ 4.463GHz
GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series
Memory: 13543MiB / 27922MiB