gdb basic usage 2004-04-23 15:18 pm Author: The author is from: Linux knowledge base is set out: http: //www.linuxhero.com/docs Address: Unknown Related Websites http://www.jimmy-lam.com /studyarea/goldencat/debug.htmhtp://phi.sinica.edu.tw/~tyuan/pcfarm.old/manuals/gnu/gdb_basic.htmlGDB uses When the program is wrong and generates a fast positioning error function GDB program The name file name (typically Core, or the core.xxxx) Debugger uses the key R Run run. The program has not run before running before running. After running the interrupt, continue to run q Exit Kill Termination debugging program h help help
(GDB) List - => The last ten lines of the last display of the program code. Setup and clearing 1. Setup breakpoints (instructions are BREAK, you can abbreviate (b), format: (GDB) Break filename.c: 30 => 310 lines in FileName.c Stop execution. (GDB) Break function => Execute the execution of the interrupt program when entering the function. (GDB) Break filename.c: function => Sets the breakpoint at the function function in the program code file filename.c. (GDB) Break => In the next command sets breakpoints. (GDB) Break ... if Cond => Only interrupt when Cond is established. Conden must be written in the C language. 2. Show each breakpoint Information. (GDB) Info Break3. Clear breakpoint (command is clear), format with break. For example: (gdb) Clear filename.c: 304. Clear breakpoint, NUM is the breakpoint number displayed in INFO BREAK. (GDB) DELETE NUM full-speed and step-by-step execution procedure 1. Execute the program from the beginning until the breakpoint is executed or the program is executed. (GDB) Run2. After the program is interrupted, the full-speed execution program to the next breakpoint Or the end of the program (Continue instructions can be discolished as c). (GDB) Continue3. Execute a row. If the call function, the program code is considered to be a row (NEXT instructions can be short-written). (GDB). NEXT4. Execute a row of programs. If the call function, enter the function progress line (STEP instructions can be short-handed as s). (GDB) Step5. Execute a row, if the program is in the final program is the last program One line, the first line of the loop has been executed until the first line of the loop is stopped (Until instructions can be short-written as u). (GDB) Until6. Perform the current program to return to the previous layer. (GDB) FINISH review and change the variable Value 1. Print describes the results of the description (Print instructions can be short-handed as P). For example, (GDB) Print A => Displays the content of the A variable. (GDB) Print sizeof (a) => Display a variable length .2. DISPLAY describes the narrative value, each breakpoint or one step is executed. Such as (GDB) Display A3. Change Variable: (GDB) Print (a = 10) => The value of the amount A is set to 10. Viewing the program execution status 1. When the program is executed, it is a program (BACKTRACE instruction to be a BT), which is to view the function call stack. (GDB) BackTrace Reads Core File Information 1. Reads in Program and Program.core files to view the program variable value and program flow status when Core Dump. GDB Program Core Description: The 'Core' file is executed by the Program file, and the Core file name generated when Core Dump is encountered. If you still need this CORE file, we recommend that you change the file name to Program.core. After entering the above command, you can read the status of the program core DUMP with the view variable value provided by GDB and the program execution status.