mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 19:54:35 +08:00
# `hack/codesign/debugserver` This script wraps the LLDB `debugserver` to `codesign` the target executable. This is needed for [Delve](https://github.com/go-delve/delve) to work properly on macOS with the virtualization framework. ## How to use this script with Delve ### Use `DELVE_DEBUGSERVER_PATH` environment variable Override `debugserver` by setting the `DELVE_DEBUGSERVER_PATH` environment variable. Ref: [Environment variables - Using Delve](https://github.com/go-delve/delve/blob/master/Documentation/usage/README.md#environment-variables) e.g. in `.vscode/launch.json`: ```jsonc { "version": "0.2.0", "configurations": [ { "name": "hostagent for input instance", "type": "go", "request": "launch", "mode": "debug", // Use integratedTerminal to stop using ctrl+C "console": "integratedTerminal", "program": "${workspaceFolder}/cmd/limactl", "buildFlags": [ "-ldflags=-X github.com/lima-vm/lima/pkg/version.Version=2.0.0-alpha.0", ], "env": { "CGO_ENABLED": "1", "DELVE_DEBUGSERVER_PATH": "${workspaceFolder}/hack/codesign/debugserver", "LIMA_SSH_PORT_FORWARDER": "true", }, "cwd": "${userHome}/.lima/${input:targetInstance}", "args": [ "--debug", "hostagent", "--pidfile", "ha.pid", "--socket", "ha.sock", "--guestagent", "${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-aarch64", "${input:targetInstance}" ], }, ], "inputs": [ { "id": "targetInstance", "type": "promptString", "description": "Input target instance parameter for `limactl` command", } ] } ``` ### Override `debugserver` in the PATH You can also override the `debugserver` in the PATH environment variable. e.g. in `.vscode/launch.json`: ```diff "env": { "CGO_ENABLED": "1", - "DELVE_DEBUGSERVER_PATH": "${workspaceFolder}/hack/codesign/debugserver", + "PATH": "${workspaceFolder}/hack/codesign:${env:PATH}", }, ``` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>