You could debug tests with Delve debugger. Run:
make test-mac-debug
This command will run build gvisor
binary with debugger enabled.
Note: By default it would use
--continue
dlv
option to not pausegvisor
execution on start, if debugger is not connected. To pausegvisor
execution until debugger is connected just remove"--continue"
parameter from this line
And debug server with 2345
port, you could use any delve
client to interact with debugger
Create new Go Remote
debug configuration:
- Click Edit | Run Configurations. Alternatively, click the list of run/debug configurations on the toolbar and select Edit Configurations.
- In the Run/Debug Configurations dialog, click the Add button (the Add button) and select Go Remote.
- Set meaningful name
- In the Host field, keep
localhost
- In the Port field, keep
2345
port number - Click OK button
Run gvisor
tests with debug with:
make test-mac-debug
wait until Listening for remote connections (connections are not authenticated nor encrypted)
message it appears.
Click on debug button on Golang, ensure that your Go Remote
profile is selected.
Have fun with debugging.
Create/edit launch.json
by adding this configuration:
{
"name": "Connect to Gvisor",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "localhost"
}
Run gvisor
tests with debug with:
make test-mac-debug
wait until Listening for remote connections (connections are not authenticated nor encrypted)
message it appears.
Execute the launch attach request(Connect to Gvisor
).
Have fun with debugging.
Connect to debugger server with:
dlv connect :2345
Example of usage:
Type 'help' for list of commands.
(dlv) break main.main
Breakpoint 1 set at 0xe735776 for main.main() ./work/redhat/gvisor-tap-vsock/cmd/gvproxy/main.go:59
(dlv) continue
> [Breakpoint 1] main.main() ./work/redhat/gvisor-tap-vsock/cmd/gvproxy/main.go:59 (hits goroutine(1):1 total:1) (PC: 0xe735776)
54: hostIP = "192.168.127.254"
55: host = "host"
56: gateway = "gateway"
57: )
58:
=> 59: func main() {
60: version := types.NewVersion("gvproxy")
61: version.AddFlag()
62: flag.Var(&endpoints, "listen", "control endpoint")
63: flag.BoolVar(&debug, "debug", false, "Print debug info")
64: flag.IntVar(&mtu, "mtu", 1500, "Set the MTU")
More info about CLI client here
For available editor integration look there