From 6ee109aca465e88b6e00a7b36b865649afb4e809 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Mon, 29 Jul 2019 18:35:27 -0700 Subject: [PATCH] Added section about attaching debugger --- content/docs/user_guide/debugging.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/content/docs/user_guide/debugging.md b/content/docs/user_guide/debugging.md index 761721bd3..d8fb97184 100644 --- a/content/docs/user_guide/debugging.md +++ b/content/docs/user_guide/debugging.md @@ -56,6 +56,30 @@ sudo runsc --root /var/run/docker/runtime-runsc/moby debug --stacks 63254c6ab3a6 > `/var/run/docker/runtime-[runtime-name]/moby`. If in doubt, `--root` is logged to > `runsc` logs. +## Debugger + +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. Other than +that, it's business as usual. + +```bash +# Start the container you want to debug. +docker run --runtime=runsc --rm --name=test -d alpine sleep 1000 + +# Find the sandbox PID. +docker inspect test | grep Pid | head -n 1 + +# Attach your favorite debugger. +sudo dlv attach + +# Set a breakpoint and resume. +break mm.MemoryManager.MMap +continue +``` + +> Note: if the debugger cannot find symbols, rebuild runsc in debug mode: +> `bazel build -c dbg //runsc:runsc` + ## Profiling `runsc` integrates with Go profiling tools and gives you easy commands to profile