How to use GDB

Jun 10, 2023

GDB

This is a course teaches how to use gdb.

Debug is very important, not only in development pirior, but also reproduce throw when in particular environment, such as at customer’s hardware.

A shortcut is record herein, if you want to learn basic action, just follow Ref - gdb-demo git.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
g++ buggyLinkedList.cpp
./a.out

# when use gdb
g++ -g buggyLinkedList.cpp
gdb ./a.out
run
print list->tail
quit
info args
info locals
po args
p ${commands}
break 63 # break addIntToEndOList
step
next
finish
continue
watch list->head

Ref

gdb-demo git