Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SetExceptionBreakpoint Optional Args #1378

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/dap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ clear_breakpoints() *dap.clear_breakpoints()*

Removes all breakpoints

set_exception_breakpoints({filters}, {exceptionOptions})
set_exception_breakpoints({filters}, {exceptionOptions},
{filterOptions})
*dap.set_exception_breakpoints()*

Sets breakpoints on exceptions filtered by `filters`. If `filters` is not
Expand All @@ -797,6 +798,9 @@ set_exception_breakpoints({filters}, {exceptionOptions})
{exceptionOptions} ExceptionOptions[]?
(https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionOptions)

{filterOptions} ExceptionFilterOptions[]?
(https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionFilterOptions)

>lua
-- Ask user to stop on which kinds of exceptions
require'dap'.set_exception_breakpoints()
Expand Down
11 changes: 8 additions & 3 deletions lua/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ M.defaults = setmetatable(
{
fallback = {
exception_breakpoints = 'default';
---@type table[]|nil
exception_options = nil;
---@type table[]|nil
exception_filter_options = nil;

---@type "statement"|"line"|"instruction"
stepping_granularity = 'statement';

Expand Down Expand Up @@ -952,15 +957,15 @@ end
-- setExceptionBreakpoints (https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetExceptionBreakpoints)
--- filters: string[]
--- exceptionOptions: exceptionOptions?: ExceptionOptions[] (https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionOptions)
function M.set_exception_breakpoints(filters, exceptionOptions)
--- filterOptions: filterOptions?: ExceptionFilterOptions[] (https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionFilterOptions)
function M.set_exception_breakpoints(filters, exceptionOptions, filterOptions)
if session then
session:set_exception_breakpoints(filters, exceptionOptions)
session:set_exception_breakpoints(filters, exceptionOptions, filterOptions)
else
notify('Cannot set exception breakpoints: No active session!', vim.log.levels.INFO)
end
end


function M.run_to_cursor()
local lsession = session
if not lsession then
Expand Down
16 changes: 13 additions & 3 deletions lua/dap/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ function Session:event_initialized()
local bps = breakpoints.get()
self:set_breakpoints(bps, function()
if self.capabilities.exceptionBreakpointFilters then
self:set_exception_breakpoints(dap().defaults[self.config.type].exception_breakpoints, nil, on_done)
self:set_exception_breakpoints(
dap().defaults[self.config.type].exception_breakpoints,
dap().defaults[self.config.type].exception_options,
dap().defaults[self.config.type].exception_filter_options,
on_done)
else
on_done()
end
Expand Down Expand Up @@ -991,7 +995,7 @@ do
end
end

function Session:set_exception_breakpoints(filters, exceptionOptions, on_done)
function Session:set_exception_breakpoints(filters, exceptionOptions, filterOptions, on_done)
if not self.capabilities.exceptionBreakpointFilters then
utils.notify("Debug adapter doesn't support exception breakpoints", vim.log.levels.INFO)
return
Expand Down Expand Up @@ -1021,12 +1025,18 @@ function Session:set_exception_breakpoints(filters, exceptionOptions, on_done)
return
end

if filterOptions and not self.capabilities.supportsExceptionFilterOptions then
utils.notify('Debug adapter does not support FilterOptions', vim.log.levels.INFO)
return
end

-- setExceptionBreakpoints (https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetExceptionBreakpoints)
--- filters: string[]
--- exceptionOptions: exceptionOptions?: ExceptionOptions[] (https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionOptions)
--- filterOptions: filterOptions?: ExceptionFilterOptions[] (https://microsoft.github.io/debug-adapter-protocol/specification#Types_ExceptionFilterOptions)
self:request(
'setExceptionBreakpoints',
{ filters = filters, exceptionOptions = exceptionOptions },
{ filters = filters, exceptionOptions = exceptionOptions, filterOptions = filterOptions },
function(err, _)
if err then
utils.notify('Error setting exception breakpoints: ' .. utils.fmt_error(err), vim.log.levels.ERROR)
Expand Down