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 you 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.
Table of contents
Chapter 1: Project Setup
Chapter 2: Compilation and Computer Architecture
Chapter 3: Attaching to a Process
Chapter 4: Pipes, procfs, and Automated Testing
Chapter 5: Registers
Chapter 6: Testing Registers with x64 Assembly
Chapter 7: Software Breakpoints
Chapter 8: Memory and Disassembly
Chapter 9: Hardware Breakpoints and Watchpoints
Chapter 10: Signals and Syscalls
Chapter 11: Object Files
Chapter 12: Debug Information
Chapter 13: Line Tables
Chapter 14: Source-Level Breakpoints and Stepping
Chapter 15: Call Frame Information
Chapter 16: Stack Unwinding
Chapter 17: Shared Libraries
Chapter 18: Multithreading
Chapter 19: DWARF Expressions
Chapter 20: Variables and Types
Chapter 21: Expression Evaluation
Chapter 22: Advanced Topics
Appendix: Check Your Knowledge Answers
Glossary
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 that turns debugger "magic" into engineering by walking you through building a native x64 Linux debugger in C++, from attaching to a process to unwinding stacks and evaluating expressions. Best for systems programmers, reverse engineers, and tool developers who want deep, practical insight into how debugging actually works.
【Book Arc】
- **Opening (~0%–13%)**: Sets up the project and mental model — directory structure, CMake, dependency management with vcpkg, and the compilation/architecture background (encoding, debug info, virtual memory, signals) needed before touching a live process.
- **Early (~13%–32%)**: Gets you attached to a running program — process launch/attach via ptrace, error handling, resuming and waiting on signals, then pipes, procfs, and automated testing to make the debugger testable.
- **Middle (~32%–55%)**: Core inspection and control — reading/writing x64 registers, validating them with assembly, software breakpoints, memory and disassembly, hardware breakpoints and watchpoints, and signal/syscall handling.
- **Late (~55%–80%)**: Connects machine code back to source — ELF object files, DWARF debug information, line tables, source-level breakpoints and stepping, call frame information, and stack unwinding.
- **Ending (~80%–100%)**: Advanced runtime features — shared libraries, multithreading, DWARF expressions, variables and types, expression evaluation, and a final advanced-topics chapter, plus appendix answers and a glossary.
【Key Takeaways】
- **A debugger is mostly an OS client** (Early): attaching, resuming, and waiting on signals all ride on ptrace and Linux process semantics, so the book teaches kernel behavior alongside tool code.
- **Registers are the first real interface to a process** (Early/Middle): reading and writing general-purpose, floating-point/vector, and debug registers, with x64 assembly tests to confirm your understanding.
- **Breakpoints come in two flavors with different trade-offs** (Middle): software breakpoints patch instructions and need site management, while hardware breakpoints/watchpoints use debug registers and watch memory access.
- **Disassembly and memory inspection make state legible** (Middle): turning raw bytes into instructions and readable memory is what makes the debugger usable rather than just a process controller.
- **Debug info is a bytecode problem, not a lookup table** (Late): ELF and DWARF — line tables, call frame information, DWARF expressions — must be parsed and interpreted to map machine code to source.
- **Stack unwinding is the payoff of CFI** (Late): backtraces depend on correctly interpreting call frame information, which is why it gets its own chapter before unwinding.
- **Real programs are shared and multithreaded** (Ending): shared library tracing and multithreading support are treated as advanced features layered on the core debugger.
- **Expression evaluation ties variables, types, and DWARF together** (Ending): locating and visualizing variables and calling functions in the debugged process is the culmination of the debug-info work.
【Reading Tips】
- Treat Chapters 1–4 as setup you must actually do, not skim — the testing infrastructure (pipes, procfs, automated tests) pays off for every later feature.
- Deep-read Chapters 5–9 if you care about breakpoints and registers; these are the most reusable mechanics for day-to-day debugging.
- Expect Chapters 11–16 (ELF, DWARF, CFI, unwinding) to be the hardest stretch — slow down and keep the glossary and "Check Your Knowledge" answers handy.
- Skim Chapter 22 on a first pass; return to it after the core debugger works.
- Keep a working build and run the tests as you go; this is a build-along book, not a read-only one.
【Coverage Limits】
This guide is based on stratified excerpts covering the front matter, table of contents, and early-to-middle chapter structure; later chapters are summarized from their titles and brief mentions, so specific implementation details beyond the excerpts are not covered.
Page 1
S Y B R A N D THE F INEST IN GEEK ENTERTA INMENT ™ nostarch.com ® ® B U IL D IN G A D E B U G G E R B R A N D F R O M B R E A K P O I N T S T O B A C K T R A...
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 Write a Native X64 Debugger From Scratch (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 to WeChat Moments
Building a Debugger Write a Native X64 Debugger From Scratch (Sy Brand)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Building a Debugger Write a Native X64 Debugger From Scratch (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
这本书讲的是如何用 C++ 从零开始,为 x64 Linux 系统写一个自己的调试器。作者 Sy Brand 的核心主张很直接:如果调试器对你来说像魔法一样难以理解,那么亲手写一个就是揭开这层魔法的最好方式。全书围绕这一目标展开,带领读者走完构建调试器的完整过程,从空文件系统起步,一步步深入 x64 Linux 系统的内部工作机制,并在此过程中扩展对操作系统的认识。
从目录线索看,读者可以抓住几条主要脉络。开篇先回答“什么是调试器”这一基本问题,为后续动手实践搭好概念框架。随后进入具体机制,书中涉及寄存器读取等内容,说明调试器如何观察和操作被调试程序的运行状态。再往后,ptrace 与 procfs 被单独列出,这是 Linux 上实现调试功能的关键接口,也是理解调试器与内核如何协作的核心环节;线程跟踪(Tracing Threads)则把讨论从单一线程扩展到更复杂的并发场景。书中还包含表达式求值器(Evaluator)的测试与总结,表明调试器不只是暂停和查看,还涉及对程序状态的解析与计算。各章末尾的 Summary 也提示这是一本按步骤推进、边做边总结的实践型读物。
整体而言,这不是一本只讲原理...
Digital LibraryAI Assistant
Hi — I can help you pick a book. Tell me a topic, language, or level, e.g. “a light English read”. If that's too broad, I'll ask one follow-up.
Loading comments...
Reply to Comment
Edit Comment