-
Notifications
You must be signed in to change notification settings - Fork 24
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
Support Projects loaded from arbitrary URIs #21
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
:uri-pkl-repo: https://github.com/apple/pkl | ||
|
||
= Pkl Go Development Guide | ||
|
||
== Debugging the Pkl Server | ||
|
||
The pkl-go evaluator API runs `pkl server` as a subprocess, which presents obstacles for directly debugging the server process. | ||
It is possible to | ||
|
||
*Debug Stub Setup* | ||
|
||
. Create a file named `debugpkl` | ||
. Mark the file executable with `chmod +x debugpkl` | ||
. Populate the file with this content (note: the path to the executable will depend on where the Pkl repo is cloned): | ||
|
||
[,shell] | ||
---- | ||
#!/bin/sh | ||
|
||
exec java -agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y -jar /path/to/pkl/pkl-cli/build/executable/jpkl "$@" | ||
---- | ||
|
||
|
||
*IntelliJ IDEA Setup:* | ||
|
||
. Open the {uri-pkl-repo}[pkl] project | ||
. Build `jpkl` by running `./gradlew javaExecutable` so it is available to the script defined above | ||
. Run > Edit Configurations... | ||
. Add a new "Remote JVM Debug" configuration | ||
. Provide a name, eg. `debugpkl` | ||
. Under "Configuration", select the "Listen to remote JVM" debugger mode | ||
. Enable "Auto restart" | ||
. Ensure Host is "localhost" and Port is "5005" | ||
|
||
*Usage* | ||
|
||
. Configure pkl-go to use `debugpkl` as the server executable: `export PKL_EXEC=./debugpkl` | ||
. Optionally, turn on extra debug output: `export PKL_DEBUG=1` | ||
. Define breakpoints as desired in the Pkl codebase using IntelliJ | ||
. In IntelliJ, start debugging the "Remote JVM Debug" configuration defined above | ||
. Execute the process using pkl-go | ||
|
||
When the Pkl server execution reaches a defined breakpoint, it will pause and activate the debugger in IntelliJ. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@HT154 Does this work generally for debugging Pkl? I was just finding myself yesterday a bit annoyed at not being able to put breakpoints in Pkl sources.
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.
For debugging "regular"
pkl eval
invocations, you don't need to fuss with this, you can do it straight from intellij by finding the entrypoint (pkl-cli/src/main/kotlin/org/pkl/cli/Main.kt
) and starting to run/debug from themain
function. You can also modify the run configuration in that menu to pass CLI args, env vars, etc. as needed.The approach documented here does work for general debugging as well, but it's required for debugging
pkl server
because the host process (eg. via pkl-go) currently must spawn thepkl
process.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.
That's very cool, thanks Josh!