Banner image

How does a debugger work?1

Let’s take GDB for example.

The basic theory is that GDB will replace a program instruction with a trap, illegal divide, or some other instruction that will cause an exception, and then when it’s encountered, GDB will take the exception and stop the program. When the user says to continue, GDB will restore the original instruction, single-step, re-insert the trap, and continue on.

GDB and LLDB2

Compiler Full form Project Compiler Recommendation
GDB GNU Debugger Part of the GNU Project GNU Compiler While using gcc
LLDB Low Level Debugger Part of Apple’s LLVM (Low Level Virtual Machine) Project LLVM Compiler While using clang


References