gdb is an amazingly versatile and flexible tool, and mastering it can save you huge amounts of time when trying to debug problems in your code, here is some unusual commands for gdb
1) Logging :
Set logging file log.txt
Set logging on
To redirect all console output to log.txt
2) Frames and Stacks
Fr : To check frames and move stacked functions.
3) Conditional breakpoints:
break WHERE iF COND
4) Use a custom command to run every time gdb hit breakpoints
command <#>
use : # b
breakpoint 1 hits at soemfunction
#command 1
list commands 1per line for to run after breakpoint 1, end with word end
> print a
>print b
end
5) Debugging macros :
use flags -ggdb3 during compilation
6) The x command :
x (for "examine")
is used to output regions of memory in various formats. It takes two arguments
in a slightly unusual syntax:
x/ Address
other than these usual command bt,untill,count,watchpoint,source is much effective