Useful gdb commands

From wiki.network-crawler.de
Jump to: navigation, search

Conditional breakpoints for strings

(gdb) b main.c:123
(gdb) set $str = "hello"
(gdb) cond 1 strcmp (s.whatever, $str) == 0

Watchpoints to memory

watch *((int*)0x84c52d0)

Info about threads

(gdb) info threads

Executing gdb

gdb -ex run <program name>
gdb -ex run --args <program name> arg1 arg2 ...