Skip to content

Conversation

@aarzilli
Copy link
Member

Add a fake delve.catch function that can be used to wrap the expression
of breakpoint conditions so that they do not stop if the expression can
not be evaluated correctly.

The main use case for this is that it's hard to set breakpoint
conditions on interface variables that assume different types but it
can also be useful in other cases (for example checking the value of a
pointer-to-struct that sometimes is nil).

Add a fake delve.catch function that can be used to wrap the expression
of breakpoint conditions so that they do not stop if the expression can
not be evaluated correctly.
The main use case for this is that it's hard to set breakpoint
conditions on interface variables that assume different types but it
can also be useful in other cases (for example checking the value of a
pointer-to-struct that sometimes is nil).
@derekparker
Copy link
Member

This is an interesting feature and I definitely see the use case. I'm wondering if a pseudo function is the right way to go here. Can we annotate the entire condition as being "no stop on error"? That does give the user less granularity over which parts of the expression they want to ignore errors for though. Also, catch implies try/catch semantics with control flow, which this doesn't have.

@aarzilli
Copy link
Member Author

This is an interesting feature and I definitely see the use case. I'm wondering if a pseudo function is the right way to go here. Can we annotate the entire condition as being "no stop on error"?

The delve.catch function here is only allowed if it surrounds the entire expression. Were you thinking of something like a flag (that would then translate into a field of api.Breakpoint)? The downside of that is that every frontend will have to do work to support it, whereas if it's part of the expression it seamlessly supported by everything.

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker merged commit 18970f4 into go-delve:master Nov 24, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants