1. Introduction to GDB:
The GNU Debugger, called GDB, is an interactive tool that works in character mode. Many programmers are used to program development with graphical interfaces, such as integrated development environments such as Vc and VB. However, GDB is more powerful in Unix/Linux environments.
As a powerful debugging tool, GDB can complete the following debugging tasks:
(1) set the breakpoint.
(2) value of the monitoring program variable.
(3) One-step execution of the program.
(4) modify the value of a variable.
2. Use of GDB
Common gdb commands:
A) load the application:
GDB test (load application)
GDB + file test (program in the path)
GDB + attach 6678 (load a process PID)
B) run the program:
R (un) c) continue to run the program: C (ontinue) d) set the breakpoint:
• B 100 -- set a breakpoint in row 100 of the current file • B/mnt/HGFS/anycore/src/newcore/schedule/backupschedule/fileschedule/ncfilepushstreamevent. cpp: 104
-Set a breakpoint on the specified row of the specified file. e) cancel the breakpoint. D 1 -- Cancel the first breakpoint. d -- Cancel all breakpoints. f) display the current breakpoint information. • info breakg) display the code.
• L (IST) • List 10 h) one step
• Do not enter the function's internal step: n (EXT) -- do not enter the function's internal step (F10) • track the function's internal step: S (TEP) -- enter the function's internal step (F11) i) jump out of the current function
Fini (SH) J) display the variable value
• P a • P Str. c_str • P Vec. Size () k) Set the variable value
Set a = 10
M) Use the shell command • Shell PS-A • Shell pwd
CTRL + D Exit shell command
N) print stack information • Bt (backtrace) O) List threads • info threadsp) Jump to thread • thread n
Address: http://www.cnblogs.com/CodeSu/archive/2012/11/07/2758675.html