Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Debugging and Profiling (C++)

Program Duration: 7 half days

Program Outline
The training program explains the importance of debugging and explores various types of
debugging. Some of the commonly used debugging tools on Windows/macOS are introduced,
and their usage illustrated with examples. The emphasis then shifts to debugging performance
issues and the concept of program profiling is explained in that context. Commonly used
memory profiling tools on Windows/macOS are explained with sample programs. Several
useful tips on debugging and profiling are provided throughout the training program. Lots of
exercises are provided for hands-on experience with the concepts learned.

Pre-requisites
The participants are expected to have a good understanding of C/C++ and should have
worked on a medium-sized software project for several months.
Hardware and Software Requirements
Each participant needs a computer with Windows/macOS installed. For Windows machines,
the Debugging Tools for Windows, which is part of the Windows SDK, needs to be installed
from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/. Further, the
Concurrency Visualizer extension for Visual Studio needs to be installed by clicking on
Extensions > Manage Extensions in the Visual Studio menu, and then searching for
Concurrency Visualizer in the Visual Studio Marketplace. For macOS machines, the latest
version of Xcode needs to be installed.

Pre-reading Material
None.
Program Contents
Day 1 (Windows & macOS)
1. Importance of debugging
2. Defensive coding
o Using assertions in code
o Preconditions and postconditions
o Compile time assertions
o Tracing & logging in Windows & macOS
3. Reproducing the problem
o Isolating the causes of failure
o Automation is your friend
4. Overview of debugging in Xcode & Visual Studio
o Debug windows - Watch, breakpoints, memory, threads, tasks, registers
o Attaching to running process
5. Understanding debugging symbols
6. Symbols in Visual Studio, Xcode
7. Setting up symbol paths in Visual Studio
8. Understand program stack
9. Debugging with static analysis tools
10. Debugging optimized code
o Overview of compiler optimizations
o Problems created by optimizations for debugging
o Turning off optimizations using compiler directives
11. Debugging Multithreaded applications
o Deadlocks & avoidance
o Race conditions
12. Memory Issues
o Uninitialized pointers
o Buffer overflow (stack & heap)
o Invalid/dangling pointers
o Double delete
o Memory leaks

Day 2 & Day 3 (Mac)


13. Detecting memory issues with XCode
o Using instruments to find leaks
o Guarded memory allocator (libgmalloc)
o Enabling libgmalloc to detect memory corruptions
o libgmalloc options
14. Address sanitizer in Xcode
15. ASAN options
16. Crash & hang analysis on macOS
o Common commands
o Debugging Crashes on Xcode
o Sampling processes
o Process hangs & spindumps
Day 4 (Windows)
17. Detecting Leaks in Visual Studio (Intrusive approach)
o Overview of leak detection concept
o Using CRT functions to detect leaks – pros & cons
o Taking snapshots through Visual Studio
o Writing hooks
o Customizing leak reports

Day 5 (Windows)
18. Debugging tools for Windows
19. Detecting leaks in release builds – UMDH
o UMDH options
o Understanding stack backtraces to locate leaks
20. Detecting memory issues with Visual Studio
o Concept of heap corruption detection
o Crt function for detecting heap corruption
o Address sanitizer

Day 6 & Day 7 (Windows)


21. Debugging using core dumps
o Dumping process memory as a dump
o Types of dump files
22. Dump file analysis
o Types of dump files
o Setting up symbols
o Access violation
o Heap & stack corruption
o Double free
o Page heap
23. Common WinDbg commands
o Setting up symbols
o Generating dumps
24. Stack & heap corruption
o Access violation
o Hang
o Critical section deadlock
o Mutex deadlock

~o~

You might also like