Debuggers: gdb vs lldm

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

CompilerFull formProjectCompilerRecommendation
GDBGNU DebuggerPart of the GNU ProjectGNU CompilerWhile using gcc
LLDBLow Level DebuggerPart of Apple’s LLVM (Low Level Virtual Machine) ProjectLLVM CompilerWhile using clang

References

Footnotes

  1. Stack Overflow- how does gdb work?

  2. Stack Overflow- GDB Vs LLDB debuggers