mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Update debugging example
Update the debugging example to use make to make sure the debuggable `runsc` binary is installed as a docker runtime before attempting to start a container. Also use nginx as an example container and Accept as an example break point since it's easy to trigger. PiperOrigin-RevId: 379393892
This commit is contained in:
@@ -61,24 +61,39 @@ You can debug gVisor like any other Golang program. If you're running with
|
||||
Docker, you'll need to find the sandbox PID and attach the debugger as root.
|
||||
Here is an example:
|
||||
|
||||
Install a runsc with debug symbols (you can also use the
|
||||
[nightly release](../install/#nightly)):
|
||||
|
||||
```bash
|
||||
# Get a runsc with debug symbols (download nightly or build with symbols).
|
||||
bazel build -c dbg //runsc:runsc
|
||||
make dev BAZEL_OPTIONS="-c dbg"
|
||||
```
|
||||
|
||||
# Start the container you want to debug.
|
||||
docker run --runtime=runsc --rm --name=test -d alpine sleep 1000
|
||||
Start the container you want to debug using the runsc runtime with debug
|
||||
options:
|
||||
|
||||
# Find the sandbox PID.
|
||||
docker inspect test | grep Pid | head -n 1
|
||||
```bash
|
||||
docker run --runtime=$(git branch --show-current)-d --rm --name=test -p 8080:80 -d nginx
|
||||
```
|
||||
|
||||
# Attach your favorite debugger.
|
||||
sudo dlv attach <PID>
|
||||
Find the PID and attach your favorite debugger:
|
||||
|
||||
# Set a breakpoint and resume.
|
||||
break mm.MemoryManager.MMap
|
||||
```bash
|
||||
sudo dlv attach $(docker inspect test | grep Pid | head -n 1 | grep -oe "[0-9]*")
|
||||
```
|
||||
|
||||
Set a breakpoint for accept:
|
||||
|
||||
```bash
|
||||
break gvisor.dev/gvisor/pkg/sentry/socket/netstack.(*SocketOperations).Accept
|
||||
continue
|
||||
```
|
||||
|
||||
In a different window connect to nginx to trigger the breakpoint:
|
||||
|
||||
```bash
|
||||
curl http://localhost:8080/
|
||||
```
|
||||
|
||||
## Profiling
|
||||
|
||||
`runsc` integrates with Go profiling tools and gives you easy commands to
|
||||
|
||||
Reference in New Issue
Block a user