Skip to content

swananan/ghostscope

Repository files navigation

GhostScope Logo

GhostScope

⚡ Next-Generation eBPF Userspace Runtime Tracer

Printf debugging evolved — Real-time tracing without stopping your application.

Version License: GPL Linux 4.4+ Rust 1.88.0

中文文档


Overview

GhostScope is a runtime tracing tool that brings the simplicity of printf debugging to production systems.

"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements." — Brian Kernighan

How It Works: The Magic of DWARF + eBPF

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 any instruction point in your running program. The combination is powerful: DWARF reveals the meaning of every byte in the process's virtual address space, while eBPF safely retrieves exactly what we need. The result? You can print variable values (local or global), function arguments, complex data structures, even stack backtraces from any point in your program — all without stopping or modifying it.

The Printf That Should Have Been

GhostScope transforms compiled binaries into observable systems. Place trace points at function entries, specific source lines, or anywhere in between. Print local variables, global variables, function parameters, complex nested structures, even stack backtraces. All with the simplicity of printf debugging, but the power of modern tracing.

The demo below shows GhostScope tracing an nginx worker process with debug information. You can see how GhostScope supports conditional logic, easily extracts information from complex data structures, and operates without disrupting the process.


GhostScope Demo

Real-time tracing of a running nginx worker process

✨ Highlights

Performance
Zero Overhead
One context switch + eBPF execution
Real-time
Real-Time Tracing
Live trace streaming
DWARF
DWARF-Aware
Full debug info support
Rust
Built with Rust
Memory safe & blazing fast

⚠️ Experimental Tool Disclaimer

GhostScope is currently in early development and under active iteration. While we strive for data accuracy, trace information may be incorrect or incomplete in certain scenarios, primarily due to unsupported features.

Recommendation: Use GhostScope's collected data as an auxiliary reference for troubleshooting, not as the sole source of truth. Cross-validate with other debugging tools before making critical decisions.

We are continuously improving stability and accuracy, and look forward to removing this disclaimer in future versions.

📚 Documentation

🎯 Getting Started

⚙️ Configuration

👨‍💻 Development

🤝 Contributing

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:

  • Code of Conduct
  • Development workflow
  • Coding standards
  • How to submit pull requests

📜 License

GhostScope is licensed under the GNU General Public License.

🙏 Acknowledgements

Built with amazing open source projects:

  • Aya - eBPF library for Rust (using its loader functionality)
  • LLVM - Compiler infrastructure
  • Inkwell - Safe LLVM bindings for Rust
  • Gimli - DWARF parser
  • Ratatui - Terminal UI framework
  • Tokio - Async runtime
  • Pest - PEG parser generator

Inspired by and learned from:

  • GDB - DWARF parsing optimizations
  • bpftrace - eBPF tracing techniques
  • cgdb - TUI design and user experience

Special thanks to these excellent resources that taught us a lot:

Blog Posts:

Books:

About

A DWARF-aware eBPF tracer with cgdb-like TUI - explore live processes at runtime

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Languages