CC ++ debugger GDB on Linux

xiaoxiao2021-03-06  40

The GNU debugger is called GDB, which is an interactive tool that works in character mode. In the X WINDOW system, there is a front-end graphics tool for GDB, called XXXGDB. GDB is a powerful debugger that completes the following debug tasks:

* Set breakpoints;

* Monitor the value of the program variable;

* Single step execution of the program;

* Modify the value of the variable.

You must compile the source file with the -g option before you can use the GDB debugger. CFLAGS variables can be defined in Makefile: cflags = -g

Usually use the following command when running a GDB debugger:

GDB Progname

Type HELP at the GDB prompt, the classification of the command will be listed, and the main categories are:

* aliases: command alias

* Breakpoints: breakpoint definition;

* DATA: Data View;

* Files: Specify and view files;

* INTERNALS: Maintenance command;

* Running: Program execution;

* Stack: Call Stack View;

* Statu: Status View;

* TRACEPOINTS: Tracking program execution.

Type the classification name of the command after Help, you can get a detailed list of this class command.

Common GDB Command Commands Explain that Break Num sets breakpoints on the specified row. BT displays all call stack frames. This command can be used to display the call sequence of the function. CLEAR Deletes the breakpoints set on a specific source file. The usage is: Clear FileName: Num. Continue continues to perform the program being debugging. This command is used to stop running due to processing signals or breakpoints. Display Expr is displayed for each program to stop the value of the expression. The expression consists of a variable defined by the program. File File loads the specified executable for debugging. Help name shows the help information of the specified command. Info Break displays the current breakpoint list, including the number of times at the breakpoint. Info files displays details of the debugged file. INFO FUNC displays all function names. INFO LOCAL displays local variable information in a function. INFO PROG displays the execution status of the debugged program. INFO VAR displays all global and static variable names. Kill terminates the procedure being debugged. List Displays the source code segment. Make Runs the Make tool without exiting GDB. NEXT performs a row source code forward without single step to enter other functions. Print EXPR displays the value of Expression EXPR. GDB use example

--------------------------------

List a wrong C source program bugging.c

--------------------------------

#include

#include

Static char buff [256];

Static char * string;

int main ()

{

Printf ("" please input a string: ");

Gets (string);

Printf ("Your String IS:% S", String);

}

-----------------------------------

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

New Post(0)