Tuesday, October 23, 2012

Tips for using gdb

1. Stack trace
    (gdb) backtrace-bt
2. Print value of variable:
    - (gdb) p variable
    - Print one array:
            (gdb) print a[0]@5 --> print 5 element of array
            (gdb) display a[0]@5 
3. List a snippet of code
   (gdb) list
4. Auto execute debug command when reach to break point
   (gdb) commands (breaking point number)
   Type commands for when breaking point 1 is hit, one per line
   End with a line saying just "end"
   >cont
   >end
5. Display information of break points
   (gdb) info
6. Delete breaking point
   (gdb) delete break 1  

No comments:

Post a Comment