-
Notifications
You must be signed in to change notification settings - Fork 133
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
Proposal: allow conditional exception breakpoints #137
Comments
What DAP already provides:Currently DAP provides two independent mechanisms for configuring exception behaviour:
How does the new request for "conditional exceptions" fit into the existing mechanisms?In general supporting an optional conditional makes sense both on the In the former case the problem is that it is not possible to communicate a condition back into the debug adapter because For the latter case ( Proposalsee below: #137 (comment) |
Thank you for the context. That makes sense. I could actually see exceptionoptions being useful for js-debug in browser breakpoints, but that user experience that VS has is not very Code-like... Probably the least ugly way to enable this for filter-based exceptions would be adding Alternately, add a new |
@connor4312 thanks a lot for your feedback. Here is a proposal: First the capability that controls whether a client is allowed to use filter options (i.e. for now only a "condition") interface Capabilities {
// ...
/**
* NEW: The debug adapter supports 'filterOptions' as an argument on the 'setExceptionBreakpoints' request.
*/
supportsExceptionFilterOptions?: boolean;
// ...
} The center of the feature is to allow passing "filter options" instead of just "filter IDs" to the interface SetExceptionBreakpointsArguments {
/**
* IDs of checked exception options. The set of IDs is returned via the 'exceptionBreakpointFilters' capability.
*/
filters: string[];
/**
* NEW: Configuration options for exception filters returned by the 'exceptionBreakpointFilters' capability.
* This attribute is only honored by a debug adapter if the capability 'supportsExceptionFilterOptions' is true.
*/
filterOptions: ExceptionFilterOptions[];
/**
* Configuration options for selected exceptions.
* The attribute is only honored by a debug adapter if the capability 'supportsExceptionOptions' is true.
*/
exceptionOptions?: ExceptionOptions[];
} The filters returned from the interface ExceptionBreakpointsFilter {
/**
* The internal ID of the filter. This value is passed to the setExceptionBreakpoints request.
*/
filter: string;
/**
* The name of the filter. This will be shown in the UI.
*/
label: string;
/**
* Initial value of the filter. If not specified a value 'false' is assumed.
*/
default?: boolean;
/**
* NEW: Whether the user can set a condition for this exception or filter.
*/
supportsCondition?: boolean;
} The // NEW
interface ExceptionFilterOptions {
/**
* ID of exception filter returned by the 'exceptionBreakpointFilters' capability.
*/
filterID: string;
/**
* An optional expression for conditional exceptions.
* The exception will break into the debugger if the result of the condition is true.
*/
condition?: string;
} @isidorn @connor4312 I'd appreciate your feedback. |
This makes good sense to me from the protocol point of view. For the VS Code side we would have to discuss how to show the UI for specifying the condition on an exception breakpoint. @connor4312 and me alreay started this discussion in another issue (can not find it now). Somewhat similar to microsoft/vscode#3646 |
This makes sense in general to me.
|
Thanks for the feedback!
Currently there is no capability for this. Please note that we can never extend an existing capability to cover new cases because that would break backward compatibility. So we would have to introduce a new capability for this.
I'm leaning towards the current proposal for the following reason:
Since we will have to support the "filters" argument for all old clients that don't know about the new "filterOptions" argument, the only question is whether a debug adapter accepts both or only one. From an implementation perspective it is probably simpler to support both by having "filters" just calling "filterOptions". If we want to support only one, then we need a client capability that tells the debug adapter what to expect. I don't think that this is worth the effort.
good find, I'll fix the proposal. |
Here is the updated proposal: First the capability that controls whether a client is allowed to use filter options (i.e. for now only a "condition"): interface Capabilities {
// ...
/**
* The debug adapter supports 'filterOptions' as an argument on the 'setExceptionBreakpoints' request.
*/
supportsExceptionFilterOptions?: boolean;
// ...
} The center of the feature is to allow passing "filter options" instead of just "filter Ids" to the interface SetExceptionBreakpointsArguments {
/**
* Ids of checked exception options. The set of Ids is returned via the 'exceptionBreakpointFilters' capability.
*/
filters: string[];
/**
* Configuration options for exception filters returned by the 'exceptionBreakpointFilters' capability.
* This attribute is only honored by a debug adapter if the capability 'supportsExceptionFilterOptions' is true.
*/
filterOptions: ExceptionFilterOptions[];
/**
* Configuration options for selected exceptions.
* The attribute is only honored by a debug adapter if the capability 'supportsExceptionOptions' is true.
*/
exceptionOptions?: ExceptionOptions[];
} The filters returned from the interface ExceptionBreakpointsFilter {
/**
* The internal Id of the filter. This value is passed to the setExceptionBreakpoints request.
*/
filter: string;
/**
* The name of the filter. This will be shown in the UI.
*/
label: string;
/**
* Initial value of the filter. If not specified a value 'false' is assumed.
*/
default?: boolean;
/**
* Whether the user can set a condition for this exception or filter.
*/
supportsCondition?: boolean;
} The interface ExceptionFilterOptions {
/**
* Id of an exception filter returned by the 'exceptionBreakpointFilters' capability.
*/
filterId: string;
/**
* An optional expression for conditional exceptions.
* The exception will break into the debugger if the result of the condition is true.
*/
condition?: string;
} |
Looks good to me |
Is the format of the exception condition documented anywhere? I ended up at this issue from a link in the docs, but I can't find any docs on the condition syntax itself. Specifically, is there an ability to write a condition that will only break only exceptions that are NOT thrown from files in the |
The format is language-specific. In JavaScript, we take any JavaScript expression with |
Refs: microsoft/vscode#104453 which requests the ability to set exception breakpoints which are caught conditionally.
I think the implementation can be straightforward from a DAP perspective, with the addition of a new switch in the ExceptionBreakpointsFilter
I think the logical place would be in the
exceptionOptions
, however it doesn't look like VS Code uses this property and it hasn't been referenced or updated in this repo was initially pushed to Github. Would this be a reason to start using it?cc @isidorn
The text was updated successfully, but these errors were encountered: