Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 998 Bytes

File metadata and controls

46 lines (37 loc) · 998 Bytes

GDB Debugging Guide

Instructions for using GDB to inspect memory and verify custom data structures for the Algorithmic Efficiency Lab.

Compilation for Debugging

Compile using the debug flag (-g):

g++ -g -Iinclude main.cpp -o lab_exec

Common GDB Commands

Start Debugging

gdb ./lab_exec

Set Breakpoints

Set a breakpoint at the start of the data structure tests:

break testDataStructures

Run the Program

run

Inspecting Memory

While at a breakpoint, use the following to inspect pointers and structures:

print ll.head
print *ll.head

Step Through Execution

  • n (next): Execute the next line.
  • s (step): Step into a function (e.g., append or insert).
  • c (continue): Run until the next breakpoint.

Backtrace

If the program terminates unexpectedly (e.g., segment fault), use:

backtrace

This will identify the exact line in the memory management logic where the error occurred.