Building a Debugger

by Sy Brand

Programming

Book Details

Book Title

Building a Debugger

Author

Sy Brand

Publisher

No Starch Press, Inc

Publication Date

2025

ISBN

9781718504097

Number of Pages

1007

Language

English

Format

PDF

File Size

4.4MB

Subject

debugger development

Table of Contents

  • Cover Page
  • Title Page
  • Copyright Page
  • About the Author
  • About the Technical Reviewer
  • BRIEF CONTENTS
  • CONTENTS IN DETAIL
  • ACKNOWLEDGMENTS
  • INTRODUCTION
  • LIST OF ABBREVIATIONS
  • 1 PROJECT SETUP
  • The Directory Structure
  • Making the Dependencies Accessible
  • Dependency Management with vcpkg
  • Testing
  • Summary
  • 2 COMPILATION AND COMPUTER ARCHITECTURE
  • Compilation
  • Operating Systems and Debuggers
  • Computer Architecture
  • Summary
  • Check Your Knowledge
  • 3 ATTACHING TO A PROCESS
  • Process Interaction
  • Launching and Attaching to Processes
  • Adding a User Interface
  • Handling User Input
  • Manual Testing
  • Refactoring into a Library
  • Summary
  • Check Your Knowledge
  • 4 PIPES, PROCFS, AND AUTOMATED TESTING
  • Test Cases
  • Testing Process Launching
  • Pipes for Inter-Process Communication
  • The Linux procfs
  • Testing Process Attaching
  • Testing Process Resuming
  • Summary
  • Check Your Knowledge
  • 5 REGISTERS
  • x64 Registers
  • Interactions with ptrace
  • Describing Registers
  • Register Interactions
  • Summary
  • Check Your Knowledge
  • 6 TESTING REGISTERS WITH X64 ASSEMBLY
  • Why Test with Assembly?
  • An x64 Assembly Primer
  • Test Setup
  • Issuing Syscalls
  • printf
  • General-Purpose Registers
  • MMX
  • SSE
  • x87
  • Register Reads
  • Exposing Registers
  • Summary
  • Check Your Knowledge
  • 7 SOFTWARE BREAKPOINTS
  • Hardware vs. Software Breakpoints
  • Implementing Software Breakpoints
  • Adding Breakpoints to the Debugger
  • Determining Where to Set Breakpoints
  • Continuing
  • Automated Testing
  • Summary
  • Check Your Knowledge
  • 8 MEMORY AND DISASSEMBLY
  • Memory Operations
  • Disassembly
  • Summary
  • Check Your Knowledge
  • 9 HARDWARE BREAKPOINTS AND WATCHPOINTS
  • Debug Registers
  • Implementing Hardware Breakpoints
  • Testing Hardware Breakpoints
  • Watchpoints
  • Summary
  • Check Your Knowledge
  • 10 SIGNALS AND SYSCALLS
  • Signal Handlers
  • Printing Stop Information
  • Catchpoints
  • Testing Syscall Catchpoints
  • Signal and Interrupt Internals
  • Summary
  • Check Your Knowledge
  • 11 OBJECT FILES
  • What Is an ELF?
  • ELF Header Parsing
  • Section Header Parsing
  • String Tables
  • File Addresses, File Offsets, and Virtual Addresses
  • Parsing the Symbol Table
  • Creating a Target Type
  • Testing
  • Summary
  • Check Your Knowledge
  • 12 DEBUG INFORMATION
  • An Introduction to DWARF
  • Fetching a Constants File
  • Parsing Abbreviation Tables
  • Parsing Compile Unit Headers
  • Parsing DIEs
  • Reading Attributes
  • Augmenting DIEs with Attribute Support
  • Augmenting the dwarf Type
  • Testing the Parser
  • Summary
  • Check Your Knowledge
  • 13 LINE TABLES
  • Line Table Contents
  • Interpreting the Line Table Program
  • Retrieving Entries by Line or File Address
  • DIE Line Attribute Helpers
  • Testing the Interpreter
  • Summary
  • Check Your Knowledge
  • 14 SOURCE-LEVEL BREAKPOINTS AND STEPPING
  • Function Inlining
  • Retrieving Inlined Function Stacks
  • Source-Level Stepping
  • Source-Level Breakpoints
  • Printing Currently Executing Source Code
  • Testing
  • Summary
  • Check Your Knowledge
  • 15 CALL FRAME INFORMATION
  • A Backtrace Example
  • DWARF Call Frame Information
  • Parsing Common Information Entries
  • Parsing Frame Description Entries
  • Looking Up Frame Description Entries
  • Adding the Parsers to the Debugger
  • Summary
  • Check Your Knowledge
  • 16 STACK UNWINDING
  • Executing Call Frame Information
  • Executing Register Rules
  • Unwinding the Stack
  • Exposing Stack Unwinding to the User
  • Testing
  • Summary
  • Check Your Knowledge
  • 17 SHARED LIBRARIES
  • Program Loading
  • Loading Dependencies
  • Relocations
  • Tracing Shared Library Loading
  • Testing
  • Summary
  • Check Your Knowledge
  • 18 MULTITHREADING
  • Threads on Linux
  • Tracing Threads
  • Supporting Multithreaded Processes
  • Multithreaded Signal Handling
  • Tracing Threads in the Target
  • Exposing Threads to the User
  • Testing
  • Summary
  • Check Your Knowledge
  • 19 DWARF EXPRESSIONS
  • A Taxonomy of DWARF Expressions
  • Executing Simple Location Descriptions
  • Executing Location Lists
  • Exposing Attributes to the User
  • Augmenting the Stack Unwinder
  • Reading Global Variables
  • Testing
  • Summary
  • Check Your Knowledge
  • 20 VARIABLES AND TYPES
  • Type DIEs
  • Storing Type Information
  • Visualizing Typed Data
  • Finding Local Variables
  • Resolving Indirect Names
  • Exposing Variables to the User
  • Testing
  • Summary
  • Check Your Knowledge
  • 21 EXPRESSION EVALUATION
  • Supporting Expression Evaluation
  • Extending Name Lookup
  • Parsing Arguments
  • Overload Resolution
  • Calling Conventions
  • Calling Functions in the Debugger
  • Performing High-Level Inferior Calls
  • Evaluating Expressions
  • Exposing Expression Evaluation to the User
  • Testing the Evaluator
  • Summary
  • Check Your Knowledge
  • 22 ADVANCED TOPICS
  • Remote Debugging
  • Development Tool Communication
  • Thread-Local Storage
  • Time-Travel Debugging
  • Exception Catchpoints
  • Non-Stop Mode
  • Follow-Fork Mode
  • Summary
  • APPENDIX: CHECK YOUR KNOWLEDGE ANSWERS
  • GLOSSARY
  • INDEX