DWARF-aware eBPF tracer for source-level userspace tracing - Explore in a TUI or automate with a scriptable CLI
DWARF-aware eBPF tracer for source-level userspace tracing - Explore in a TUI or automate with a scriptable CLI
GhostScope is a source-aware userspace tracer for live Linux processes. With DWARF debug info, it lets you attach at function, source-line, or instruction granularity, print the values that matter, and emit source-aware call stacks without debugger-controlled suspension of the target.
C has the strongest end-to-end coverage. For Rust targets, GhostScope provides targeted support for common values and demangles application, standard-library, and inline backtrace frames. See Source Language Support and Limitations for the exact boundaries.
"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements." — Brian Kernighan
perf probe when you want a quick one-off probe at a function, source line, or local variable inside the perf ecosystem.For the full, centrally maintained comparison, see the Tool Comparison. You can also refer to the FAQ.
GhostScope supports two modes: an interactive TUI mode, and a CLI mode built around --script and --script-file. The latter is the more AI-optimized workflow for automation and agent-driven runtime analysis.
Install the shared skill for Codex or Claude Code:
curl -fsSL https://raw.githubusercontent.com/swananan/ghostscope/main/scripts/skills/install_ghostscope_runtime_analysis_skill.sh | bash -s -- --copyIf you already have the repository checked out locally, ./scripts/skills/install_ghostscope_runtime_analysis_skill.sh --copy works too.
Use --codex, --claude, or --all when you want to force a target. Restart Codex or Claude Code after installation.
When the agent shares your workspace, it can often discover the source checkout path and DWARF/debug-symbol status on its own. If it cannot determine them reliably, it should ask before generating a source-backed trace. Two useful prompt patterns are: ask for the values you want to see, then ask for the call stack that explains how execution reached that point.
Context the agent can discover locally in this example:
/mnt/500g/code/openresty/openresty-1.27.1.1/build/nginx-1.27.1/usr/local/openresty/nginx/sbin/nginx$ghostscope-runtime-analysis trace the running nginx worker and show the raw request body bytesGenerated command:
WORKER_PID=$(pgrep -n -f 'nginx: worker process')
sudo ghostscope -p "$WORKER_PID" --script-file /tmp/ghostscope-nginx-body-discard.gs --script-output plainGenerated script:
trace /mnt/500g/code/openresty/openresty-1.27.1.1/build/nginx-1.27.1/src/http/ngx_http_request_body.c:671 {
if size > 0 {
let req_line_len = r.request_line.len;
let body_len = size;
print "src=discard-preread pid={} req={:p} line={:s.req_line_len$} body_len={} body={:x.body_len$}",
$pid, r, r.request_line.data, body_len, r.header_in.pos;
}
}Demo:
$ghostscope-runtime-analysis trace the running nginx worker and show which request reached ngx_http_process_request, plus the source-aware call stackGenerated command:
WORKER_PID=$(pgrep -n -f 'nginx: worker process')
sudo ghostscope -p "$WORKER_PID" --script-file /tmp/ghostscope-nginx-request-stack.gs --script-output prettyGenerated script:
trace ngx_http_process_request {
let method_len = r.method_name.len;
let uri_len = r.uri.len;
let line_len = r.request_line.len;
print "nginx pid={} method={:s.method_len$} uri={:s.uri_len$} line={:s.line_len$}",
$pid, r.method_name.data, r.uri.data, r.request_line.data;
bt full;
}Here print answers "what request state reached this probe?", while bt full answers "how did nginx get here?" using DWARF-unwound, source-aware stack frames.
Demo:
For best results, make sure the relevant source tree is available, the modules you care about carry DWARF debug information, and GhostScope has the privileges needed to load eBPF programs. When that information is not discoverable locally, the skill should ask for it before generating a source-backed trace. Re-run the same installer after pulling updates; the installed skill is versioned and refreshes automatically when the version changes.
GhostScope turns compiled binaries into observable systems. In the TUI, that experience unfolds progressively: first find the function or source line you care about, then inspect the variables visible at that point, enter Script Mode from that location, and finally watch values and call stacks update while the target keeps running. It feels less like a generic dashboard and more like source-guided runtime printf debugging with execution context.
The demo below follows exactly that path on a DWARF-enabled nginx worker: locate the code path, drop a trace at the right line, add a small script, and immediately see conditional logic, source-oriented variable access, call-stack context, and live output from the running process.
Imagine navigating a vast, uncharted forest of binary data — memory addresses, register values, stack frames — all meaningless numbers without context. DWARF debug information is our map: it tells us that stack address RSP-0x18 stores local variable count, heap address 0x5621a8c0 is a user object with string pointer user.name at offset +0x20; it tracks where each variable lives throughout program execution — parameter x is in register RDI now but will move to stack offset RSP-0x10 later.
With this map in hand, GhostScope leverages eBPF and uprobe technology to safely extract binary data from instruction points in your running program. The combination is powerful: DWARF reveals the meaning of bytes in the process's virtual address space, while eBPF retrieves the requested data. The result is source-aware variable values and call stacks without debugger-controlled suspension or intentional application-state changes. Each uprobe hit still adds synchronous trap and eBPF work, so tracing is not timing-transparent.
GhostScope is currently in early development and under active iteration. Within the supported envelope, a known inability to recover or attribute data should be reported explicitly rather than rendered as a plausible value.
Implementation defects may still violate that contract. Use GhostScope's collected data as an auxiliary reference for troubleshooting, and cross-validate with other debugging tools before making critical decisions.
The normative guarantees, assumptions, and failure semantics are documented in Design Guarantees and Trust Model.
See Limitations for unsupported and explicitly degraded scenarios.
Installation Guide System requirements and setup
Quick Tutorial Learn the basics in 10 minutes
Tool Comparison Choose between GhostScope, perf, GDB, bpftrace, and SystemTap
FAQ Common questions answered
Limitations Known limitations and constraints
Value Diagnostics
Understand unavailable values, read failures, display fallbacks, and capture limits;
read offline with ghostscope --value-diagnostics-help
Configuration Reference All configuration options
TUI Reference Complete keyboard shortcuts and panel navigation
Command Reference All available commands for Input Mode
Script Language
Write trace scripts; read offline with ghostscope --script-help
Architecture Overview System design and internals
Design Guarantees and Trust Model Supported operating envelope, invariants, and failure semantics
Development Guide Build and extend GhostScope
Contributing Guide Join the community
Roadmap Planned features and milestones
We welcome contributions! Whether it's bug reports, feature requests, documentation improvements, or code contributions, we appreciate your help in making GhostScope better.
Please see our Contributing Guide for:
GhostScope is licensed under the GNU General Public License.
Built with amazing open source projects:
Inspired by and learned from:
Special thanks to these excellent resources that taught us a lot:
Blog Posts:
Books:
No open issues yet, or sync has not completed.