First, GDB's function:
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 status of the program
4, dynamic change the execution environment of the program
Second, the basic use of GDB process:
1. Compile and build the executable file: gdb-g hello.c-o Hello
2. Start Gdb:gdb Hello
3. Set breakpoints somewhere: Break line number or broken function name
4. Running Program: Run
5, the use of more extensive GDB debugging commands for program debugging
iii. Common Debug command options:
Option (abbreviated) command option format description
Run (r) run [parameter 1][parameter 2] ... Run the program, and the argument list that follows is the parameter passed into the Mian function, or it can have no
List (l) list [Start row] [end line] list[line number] list [filename] [line number] [Start row] [end row] Default display 10 rows
Print (p) p (print) [variable name] printing variable name can also be called with the function eg Print Add (3,5)
Break (b) breaking [line number] or breaking [function name] or breaking routine entry set breakpoint
Delete (d) d (delete) [Breakpoint designator] Delete Breakpoint
Info b View all breakpoints
next (N) step execution without entering functions
Step (s) Stepping into a function
Continue (c) resumes execution of the function until the function ends or encounters a new breakpoint
set set [variable name] =[value] Set the value of the variable
whatis whatis [variable name] View types of variables
finish executes the current function and, if there is a return value, prints the return value
quit (q) Exit GDB Debugging
Help (h) format h (Help) [command name] See how to use the specified command.