GDB basic usage

xiaoxiao2021-03-06  18

Current location: Home >> Programming Technology | Copyright Description

gdb basic usage 2004-04-23 15:18 pm Author: The author is from: Linux knowledge base Contact: unknown related sites http://www.jimmy-lam.com/studyarea/goldencat/debug.htmhttp://phi. Sinica.edu.tw/~tyuan/pcfarm.old/manuals/gnu/gdb_basic.htmlgdb Using the User When the program is wrong and generates the fast positioning error function, the Core file name (generally Core, may also be CORE) .xxxx) The key R Run running used by the debugger. The program has not run using C Cuntinue before running. After running the interrupt, continue to run q Exit Kill Termination debugging program h help help command completion function Step STEP Function next does not follow the function B BREAKPOINT set breakpoint. Usage: b Function Name Interrupts this function B file name: The line number is interrupted in this file. If it is the current file, then the file name and: I can omit the current breakpoint number to use Info Break. Forbidden Disable Disable Distort number. Delete the delete break point number .l list lists the code line. One column 10 lines. Connection uses List will scroll the display. You can also keep up with the file name behind List: The line number Watch observes the value of a variable. The value of this variable prints a variable is printed at each interruption. Different from Watch is that Print only shows how to change a value here. When you undermpt, you will use PB, this time you will see B's value, that is, $ 1 = 15. You can also use P to change a value, such as the next command PB = 100, try this, you will find that the value of B is 100: $ 1 = 100. Online Copy Basic Usage Method Introduction Introduction Program Code Errors can be divided into number categories, except for the most easily unlocated syntax errors, the compiler will tell you that most of the errors can be classified as execution errors. The function of GDB is to find an error when executing. If there is no error program, we can only add an instruction of the output variable value to the state of the program execution. With GDB unligerator, we can set up the execution of the program anywhere, and then check the variable values ​​and more variables at will, and execute the program line by line. The process of unligably executing is usually: 1. Enter the error program and specify the executable. 2. Specify the directory where the program code is located. 3. Set the execution program after breakpoint. 4. After the program is interrupted, it can be (1) to see the program execution state; check the variable value or change the variable value (2) step-by-step execution, or the full-speed execution program to the next breakpoint or until the end of the program. 5. Leaving the error procedure. The following will be divided into the following references: 1. Enter GDB and specify executable 2. Specify the directory and search program code where the program code is located 3. Setting and clearing the breakpoint 4. Full-speed and step-by-step execution program 5. Viewing and Change Variable Value 6. Viewing the program execution status 7. Read the Core file information Enter GDB and specify the executable: 1. Go to GDB and read the executable (file name to 'program'), ready to make the error. GDB Program Specifies the directory code where the program code is located and the program code increases the directory DIR to the collection code (if your program code and executive file are placed in the same directory, you do not need to specify the program code where the program code is located. :( GDB) Directory Dir2. Viewing the program code, the format is: (GDB) list => Displays the program code of the five lines of each five lines before and after execution program code; or display the program code (GDB) List function from the last list => Display the program code before and after the program starts. (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.

Add a little (recently I just used GDB, I feel is not bad, but when I am still added with printf, I will use the GDB direct debugger, not the coreGDB executable file name (enter GDB environment) SET AGS -? (set the parameters, the program to you want to debug) In addition, you can set the breakpoint with Break FunctionName and Break Linenum to see the current breakpoint information to clear the breakpoint with CLEAR. Companies If the breakpoint set by FunctionName can only use the breakpoint set by LINENUM with LINENUM, you can only use Clear LineNumbtw: You can go to www.sunfreeWare.com to download GDB or more experience I have learned GDB in recent days, All I have made mistakes I hope to help with the GDB rookies that are equal to me. If you can use the DDD graphical differential, you can use the delete breakpoint to remove the breakpoint. You can use INFO BREAK to get me to talk about my experience: R (the parameters of the program) can set up the runtime The parameter shell runs things that run the shell environment, such as Shell Make, after completion of the RWP, you can run the parameters that have been added last time, no need to knock the parameters B file name: The line number is very useful,嘿嘿 Info B See the breakpoint information Disable break point Suspension a breakpoint Enable break point number launches a breakpoint Delete Delete a breakpoint, does not break the point, all delete the X / 32uxb pointer 16 Enter the 32-byte data indicted by the pointer, but I still don't use core debug, huh, 全 completely all categories 1:

Non-technical class 2:

Basic knowledge 3:

Directive Daquan 4:

Shell5:

Installation start 6:

XWindow7:

KDE8:

gnome9:

Input French 10:

Beautifying Chinese 11:

Network configuration 12:

Storage backup 13:

Miscellaneous Tool 14:

Programming Technology 15:

Network security 16:

Kernel Technology 17:

Speed ​​optimization 18:

Apache19:

Email20:

FTP Service 21:

CVS Service 22:

Agent Service 23:

Samba24:

Domain Name Service 25:

Network filtering 26:

Other Services 27:

NFS28:

Oracle29:

DHCP30:

MySQL31:

PHP32:

LDAP

Copyright © 2005 Linux Knowledge Baolo 者 者者 究者.

Powered by: Linux Knowledge Baolo Version 1.0.0

转载请注明原文地址:https://www.9cbs.com/read-44126.html

New Post(0)