summaryrefslogtreecommitdiffhomepage
path: root/g3doc
diff options
context:
space:
mode:
authorIan Lewis <ianlewis@google.com>2021-06-14 18:47:16 -0700
committergVisor bot <gvisor-bot@google.com>2021-06-14 18:50:14 -0700
commitbccc4461545655f4f1b5b03e83e6a1ededde48d8 (patch)
tree4477e492809a31f03c9e7dfec83a3742c2686fd6 /g3doc
parent20c68160459a5f2393facc30f24be5770e628428 (diff)
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
Diffstat (limited to 'g3doc')
-rw-r--r--g3doc/user_guide/debugging.md35
1 files changed, 25 insertions, 10 deletions
diff --git a/g3doc/user_guide/debugging.md b/g3doc/user_guide/debugging.md
index 54fdce34f..2291b5fab 100644
--- a/g3doc/user_guide/debugging.md
+++ b/g3doc/user_guide/debugging.md
@@ -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:
+
+```bash
+sudo dlv attach $(docker inspect test | grep Pid | head -n 1 | grep -oe "[0-9]*")
+```
-# Set a breakpoint and resume.
-break mm.MemoryManager.MMap
+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