$ show go-delve/delve
Delve is a full-featured debugger for the Go programming language. It provides a command-line interface (CLI) and supports integration with IDEs via the Debug Adapter Protocol (DAP). The debugger allows users to control program execution, inspect variables and memory, set breakpoints and watchpoints, examine stack traces and goroutines, and evaluate expressions. It supports multiple operating systems (Linux, Windows, macOS, FreeBSD) and architectures (amd64, arm64, ppc64le, riscv64, loong64) and includes advanced features such as eBPF-based tracing, reverse debugging via Mozilla rr, and core dump analysis. The architecture is modular, with clear abstractions for OS-specific, architecture-specific, and backend-specific code, enabling maintainability and extensibility.
The LLM identified 5 files worth highlighting for reuse:
Defines the Arch interface that abstracts architecture-specific details (register sizes, breakpoint instructions, frame unwinding). Each architecture (amd64, arm64, etc.) implements this interface, allowing the debugger core to remain architecture-agnostic. This pattern enables clean separation of concerns and easy porting to new architectures.
Provides a robust and efficient parser for DWARF debug information, which is essential for mapping machine code to source lines, variable locations, and type information. The reader is self-contained and handles the complexity of the DWARF format, making it reusable in other projects requiring DWARF parsing.
Implements software and hardware breakpoint management, including support for logical breakpoints (multiple breakpoints at the same address) and tracepoints. It handles the intricacies of enabling/disabling breakpoints without disrupting the target process, a critical and non-trivial aspect of any debugger.
Implements the Debug Adapter Protocol (DAP) server, allowing Delve to integrate with IDEs and editors (like VS Code, Eclipse). The implementation follows the DAP specification closely and provides a clean separation between the debugger backend and the communication protocol, making it a reusable component for other debug adapters.
Integrates Starlark scripting into the debugger, allowing users to extend debugger functionality with custom scripts. It exposes debugger state (threads, variables, breakpoints) to Starlark and enables the definition of new commands. This pattern provides a powerful and flexible way to customize the debugger without modifying core code.