Wednesday, October 24, 2012
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
(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
Debug by some analysis statical tools
-lclint or splint: analyze coding without compile or running to find logic coding.
-ctag: list all function that we used in program
-cflow: list all called hierarchy of function
-ctag: list all function that we used in program
-cflow: list all called hierarchy of function
Subscribe to:
Comments (Atom)