Master the inner workings of your x64 Linux system and expand your OS expertise by writing your very own debugger using C++.
If debuggers seem like magic to you, there is no better way to demystify them than to write your own. This book will show you exactly how to do it, walking you through the entire process of building a debugger for x64 Linux systems using C++. As go from an empty filesystem folder to a fully fledged debugger capable of setting breakpoints, stepping through code, manipulating variables, and more, you’ll learn how to
Attach to a process
Read and write to registers
Set hardware and software breakpoints
Output disassembly
Support multithreading and other tasks
As you add features to your debugger, you’ll also pick up a wealth of knowledge about operating systems, compilers, software testing, and low-level programming that you can use in your day-to-day development.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on guide to demystifying debuggers by building one from scratch for x64 Linux in C++, taking you from an empty folder to a tool that sets breakpoints, steps through code, and inspects variables. Best for C++ programmers curious about operating systems, compilers, and low-level tooling.
【Book Arc】
- **Opening (~0%–8%)**: Sets up the project skeleton (CMake, vcpkg, directory layout) and lays the theoretical groundwork on compilation, computer architecture, user/kernel space, and how Linux loads programs.
- **Early (~8%–27%)**: Implements the debugger's core mechanics—attaching to processes, inter-process communication via pipes and procfs, automated testing, register access, and both software and hardware breakpoints/watchpoints.
- **Middle (~27%–57%)**: Dives into binary and debug-info formats: parsing ELF object files, DWARF debug information, line tables, and call frame information to enable source-level breakpoints, stepping, and stack unwinding.
- **Late (~57%–76%)**: Extends the debugger to real-world complexity—shared libraries, multithreading, DWARF expressions, variable/type visualization, and expression evaluation with inferior function calls.
- **Ending (~76%–100%)**: Surveys advanced topics (remote debugging, GDB/MI, DAP, time-travel debugging, non-stop mode) and closes with knowledge-check answers and a glossary.
【Key Takeaways】
- **Debuggers are built on OS primitives, not magic** (Early): attaching to processes, reading registers, and setting breakpoints all rely on Linux facilities like ptrace, procfs, and pipes—understanding these is the real payoff.
- **Breakpoints come in two flavors with distinct trade-offs** (Early): software breakpoints patch instructions while hardware breakpoints use debug registers; the book implements both plus watchpoints.
- **Binary formats are the bridge to source-level debugging** (Middle): parsing ELF and DWARF is what lets a debugger map machine addresses back to source lines, variables, and types.
- **Stack unwinding depends on call frame information** (Middle): DWARF CFI lets you generate backtraces and restore registers to pre-call state, a prerequisite for meaningful stepping.
- **Real programs are messy** (Late): shared libraries, multithreading, and inlined functions each require dedicated support beyond a single-threaded, statically-linked toy.
- **Expression evaluation is the hardest feature** (Late): calling functions inside the inferior process requires ABI knowledge, argument classification, calling conventions, and memory allocation in the target.
- **Testing is woven throughout** (Early–Late): each feature is paired with automated tests, reinforcing that debugger development demands rigorous verification.
- **The book is deliberately scoped** (Middle): the debugger is not thread-safe by design, trading robustness for focus on core concepts.
【Reading Tips】
- Deep-read Chapters 1–4 even if you know C++; the build setup and testing harness pay off across the whole book.
- Skim the DWARF/ELF parsing chapters (11–15) on first pass if binary formats are new—return to them when implementing source-level features.
- Treat the "Check Your Knowledge" questions as genuine checkpoints; the appendix answers are useful for self-assessment.
- Keep the companion GitHub repository (chapter-by-chapter branches) open alongside the text to compare your implementation.
- Don't skip Chapter 2's architecture background—it's the conceptual foundation for everything that follows.
【Coverage Limits】
This guide is synthesized from stratified excerpts covering the table of contents, introduction, and early chapters; specific code details, later-chapter depth, and the advanced topics chapter are only partially represented.
Excerpt 1
103 phone: +1.415.863.9900 www.nostarch.com ; info@nostarch.com Publisher: William Pollock Managing Editor: Jill Franklin Production Manager: Sabrina Plomita...
helps you begin an automated testing suite for the debugger. Chapter 5: Registers Details the hardware registers available on x64 systems, including general-...
le program that consumes it. Create a file at sdb/tools/sdb.cpp that calls sdb::say_hello : #include <libsdb/libsdb.hpp> int main() { sdb::say_hello(); }...
ing we can’t retrieve the source code from the machine code. Unfortunately, this is exactly what we want a debugger to do. We want to know which line of the...
riginate from another user-space process or from the kernel. A program can install a signal handler that calls some function when a specific signal is receiv...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Building a Debugger (Sy Brand)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Building a Debugger (Sy Brand)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment