The application debugging tool GdB learns to use
I. Introduction of GDB
GDB is a powerful program debugging tool released by GNU. GDB mainly accomplishes the following three functions:
1. Start the program that is being debugged.
2. Let the program being debugged stop at the specified location.
3, when the program is stopped, you can check the program status (such as variable values).
1.1gdb Use Process
1. Compile and build the executable file:
Gcc–g Tst.c-o TST
2. Start GDB
GDB TST (file name)
3. Set a breakpoint at the main function
Break Main
4. Running the program
Run
5. Debug the program with a richer gdb command.
1.2GDB command
1.list (l) View program
2.Break (b) Function name add breakpoint at the entrance of a function
3.Break (b) Line number adds a breakpoint on the specified line
4.Break (b) file name: line number Add a breakpoint on the specified line of the specified file
5. Info Break View all set breakpoints
6. Delete Breakpoint Number Remove Breakpoint
7.Next (N) Single-step program (does not enter sub-functions)
8.Step (s) Single Step Running program (enter sub function)
9.Continue (c) continue to run the program knowing the next power outage
Print (p) Variable name view specified variable value
Set Var=value sets the value of a variable
Quit (q) Exit GDB
Ii. Examples of Use
Application Debugging Tool GDB