-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: add debugger support #739
Conversation
We have released an implementation of the example client as a standalone package at grafana/jsonnet-debugger. It is also integrated into the latest version of our vscode-jsonnet extension. The debugger uses the grafana/go-jsonnet-debugger fork to implement the functionality until the PR is merged |
@@ -287,6 +308,13 @@ func (i *interpreter) newCall(env environment, trimmable bool) error { | |||
} | |||
|
|||
func (i *interpreter) evaluate(a ast.Node, tc tailCallStatus) (value, error) { | |||
i.evalHook.pre(i, a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably make evalHook a pointer and avoid a virtual call here if it's null (so that the performance overhead when not debugging is smaller). Not sure how significant that is, given other overhead.
@@ -0,0 +1,401 @@ | |||
package jsonnet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's quite a bit of complexity here - some tests would be nice.
Really cool stuff. Added some comments for potential follow-up, but merging as it is. |
The `valueToString` operation introduced by google#742 is incompatible with the way the implementation from google#739 as it tries to manifest an object from stack while the implementation needed by the debugger returns the value as-is without further evaluation.
The `valueToString` operation introduced by google#742 is incompatible with the way the implementation from google#739 as it tries to manifest an object from stack while the implementation needed by the debugger returns the value as-is without further evaluation.
This PR adds an extension point for future debugger implementations.
We first investigated having the entire debugger codebase only use go-jsonnet as a dependency, but many of the fields and types needed to implement this are not exposed to external packages.
To solve this, we added a new
Debugger
type, which allows debugging frontends to control the evaluation of a specific file.The API type is heavily inspired by the Debug Adapter Protocol and can be used to implement basic debugging functionality like:
Example implementations of clients using this interface can be found in the example-clients branch of our fork.
The following recording shows the basic capabilities in action by using the DAP example client with VSCode:
dap.mp4