Preface:
I used to use the convenient ide debugging function in windows. It was quite inconvenient to use in the early stage. Here is a small record for getting started.
GDB can be regarded as a debug tool attached to the Linux-GCC compiler.
To debug a program using GDB, you only need to input a program similar to GDB xxx.exe under shell-command.
(Here, we emphasize that the-G parameter must be added during compilation to support debugging, for example, GCC-g xxx. C-o xxx.exe)
After the gdb prompt appears, you can first use "L" (list) to view SRC, and then add the breakpoint "B 21" (break at line 21) to a line)
Next, run the program "R" (run), then the program will automatically stay at the breakpoint,
If you want to continue running, type "C" (continue)
Use P (P var1) to view the variable)
Set the variable with set (set var1 = "ABC ")
Jump to a row and use Jump (jump 21)
Enter a function and use S (step)
For step-by-step operation, n (next) is used)
For more details about GDB command, refer to Google. Here is a brief introduction :)~