-
Notifications
You must be signed in to change notification settings - Fork 602
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
Improve debugging with dlv dap
(in VSCode, for example)
#2651
Merged
AkihiroSuda
merged 3 commits into
lima-vm:master
from
norio-nomura:improve-debugging-with-dlv-dap
Oct 3, 2024
Merged
Improve debugging with dlv dap
(in VSCode, for example)
#2651
AkihiroSuda
merged 3 commits into
lima-vm:master
from
norio-nomura:improve-debugging-with-dlv-dap
Oct 3, 2024
Conversation
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
AkihiroSuda
reviewed
Oct 2, 2024
norio-nomura
force-pushed
the
improve-debugging-with-dlv-dap
branch
2 times, most recently
from
October 2, 2024 23:44
8db66e1
to
bfe4623
Compare
AkihiroSuda
reviewed
Oct 3, 2024
…o `codesign` a executable produced by linker By passing `-toolexec hack/toolexec-for-codesign.sh` to the Go build options, the executable will be `codesign`ed with `vz.entitlements` after linking. This eliminates the need to prepare a pre-signed debug binary when running `dlv dap` (in VSCode, for example) for debugging. usage in `launch.json`: ```json { "version": "0.2.0", "configurations": [ { "name": "Debug limactl hostagent for debug instance", "type": "go", "request": "launch", "mode": "debug", "program": "${workspaceFolder}/cmd/limactl", "buildFlags": [ "-toolexec", "${workspaceFolder}/hack/toolexec-for-codesign.sh", ], "env": { "CGO_ENABLED": "1" }, "cwd": "${userHome}/.lima/debug", "args": [ "hostagent", "--pidfile", "ha.pid", "--socket", "ha.sock", "debug" ], "preLaunchTask": "prepare launching hostagent for debug instance", "postDebugTask": "clean up after stopping hostagent for debug instance" }, ] } ``` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
…uestagent` When debugging `cmd/limactl` with `dlv dap`, the executable appears as follows: `cmd/limactl/__debug_bin2611107549`. In this case, `limactl` fails to locate `lima-guestagent` relative to the expected executable path and results in the following error: ```json { "level": "fatal", "msg": "failed to find \"lima-guestagent.Linux-aarch64\" binary for \"/Users/norio/ghq/github.com/lima-vm/lima/cmd/limactl/__debug_bin2611107549\", attempted [/Users/norio/ghq/github.com/lima-vm/lima/cmd/limactl/lima-guestagent.Linux-aarch64 /Users/norio/ghq/github.com/lima-vm/lima/cmd/share/lima/lima-guestagent.Linux-aarch64]", "time": "2024-09-24T15:02:23+09:00" } ``` To avoid this error, it was necessary to create a symbolic link (`ln -sf ../_output/share cmd/share`) so that `lima-guestagent*` exists at the expected relative path. This change adds `_output/share/lima/lima-guestagent.*` to the search directories, making the symbolic link creation unnecessary before running `dlv dap` for debugging. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
… when `logrus.GetLevel() == logrus.DebugLevel`. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
norio-nomura
force-pushed
the
improve-debugging-with-dlv-dap
branch
from
October 3, 2024 05:57
bfe4623
to
9c75559
Compare
AkihiroSuda
approved these changes
Oct 3, 2024
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.
Thanks
Thanks! 🙏🏻 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
-
hack/toolexec-for-codesign.sh
: add a wrapper script for-toolexec
tocodesign
an executable produced by linkerBy passing
-toolexec hack/toolexec-for-codesign.sh
to the Go build options, the executable will becodesign
ed withvz.entitlements
after linking. This eliminates the need to prepare a pre-signed debug binary when runningdlv dap
(in VSCode, for example) for debugging.usage in
launch.json
:- pkg/usrlocalsharelima: add a candidate directory to searching
lima-guestagent
When debugging
cmd/limactl
withdlv dap
, the executable appears as follows:cmd/limactl/__debug_bin2611107549
.In this case,
limactl
fails to locatelima-guestagent
relative to the expected executable path and results in the following error:To avoid this error, it was necessary to create a symbolic link (
ln -sf ../_output/share cmd/share
) so thatlima-guestagent*
exists at the expected relative path.This change adds
_output/share/lima/lima-guestagent.*
to the search directories, making the symbolic link creation unnecessary before runningdlv dap
for debugging.