How to create conditional breakpoints #670
-
|
From issues such as this it seems like nvim-dap supports creating conditional breakpoints, but I can't find any documentation on how. When I look at the available commands for DAP, I see DapToggleBreakpoint but nothing for conditional breakpoints. Any help is appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
|
See |
Beta Was this translation helpful? Give feedback.
-
|
Thanks a lot for this functionality! It's great to have that in neovim! I am still struggling to make conditional breakpoints work. I can specify the condition, it is shown in the dap-ui Breakpoints window and repl does not report any error. Still the debugger stops at the breakpoint even though the condition is not met. So e.g. I set the condition to Another example, I set the condition to result = validate_checksum(fops, fp, header.checksum, header.size);
if (result) { // <- Breakpoint set here
fops.seek(fp, next_pos, SEEK_SET);
}But the debugger stops every time the breakpoint is reached, no matter what I tried to set the condition as string with What am I missing? |
Beta Was this translation helpful? Give feedback.
-
|
Take a look at code from PR #1325; it enhances |
Beta Was this translation helpful? Give feedback.
-
|
Here are the keymaps I use specifically for breakpoints, it could perhaps help someone: Lazyvim return {
"mfussenegger/nvim-dap",
dependencies = {
...
},
keys = {
....,
{
"<leader>db",
function()
require("dap").toggle_breakpoint()
end,
desc = "Debug: Toggle Breakpoint",
},
{
"<leader>dB",
function()
local condition = vim.fn.input("Breakpoint condition (optional): ")
local hit_condition = vim.fn.input("Hit count (optional): ")
-- Convert empty strings to nil
condition = condition ~= "" and condition or nil
hit_condition = hit_condition ~= "" and hit_condition or nil
require("dap").toggle_breakpoint(condition, hit_condition)
end,
desc = "Debug: Toggle Advanced Breakpoint",
},
},
...
} |
Beta Was this translation helpful? Give feedback.





See
:help dap.toggle_breakpoint