Modern C++
Programming
17. Debugging and Testing
Federico Busato
2026-01-06
Table of Contents
1 Debugging Overview
Errors, Defects, and Failures
Cost of Software Defects
Software Defects Classification
Program Error and Classification
Software Defect Analysis
2 Assertions
Run-time Assertions
Contracts
std::stacktrace
1/107
Table of Contents
3 Execution Debugging
Breakpoints
Watchpoints / Catchpoints
Control Flow
Stack and Info
Print
Disassemble
std::breakpoint
2/107
Table of Contents
4 Memory Debugging
valgrind
5 Hardening Techniques
Stack Usage
Standard C Library Hardening
Standard C++ Library Hardening
Undefined Behavior Protections
Control Flow Protections
3/107
Table of Contents
6 Sanitizers
Address Sanitizer
Leak Sanitizer
Memory Sanitizers
Undefined Behavior Sanitizer
Type Sanitizer
Sampling-Based Sanitizer
7 Debugging Summary
8 Compiler Warnings
4/107
Table of Contents
9 Static Analysis
Compiler-Provided Static Analyzers
Open-Source Static Analyzers
Proprietary Static Analyzers
10 Code Testing
Unit Testing
Test-Driven Development (TDD)
Code Coverage
Fuzz Testing
5/107
Table of Contents
11 Code Quality
clang-tidy
12 Code Complexity
Cyclomatic Complexity
Cognitive Complexity
6/107