Introduction to the C language
$? is a special variable in the shell that represents the exit state of the previous command.
Incremental development: Write some code to compile and run, no problem to write the following.
To add the-G option at compile time, the resulting executable file can be debugged using GDB for source-level debugging:
The purpose of the Gcc-g main.c-o main-g option is to include source code information in the executable, such as the number of machine directives corresponding to the first few lines of source code. However, the source code is not embedded, so the source code can still be found when debugging with GDB.
GDB provides shell-like environments, common commands: List, start, Next, step (s), BackTrace (BT, view frame stack for function calls), info (view values of function local variables), print, Display (each time you stop to show the value of the specified variable, cancel the trace with Undisplay), break (abbreviated to B, the number of lines of code can be followed by the function name, you can also set a breakpoint to activate when a condition is met), delete breakpoints, disable breakpoints, enable (these three commands all add breakpoint number), info breakpoints (see which breakpoints are set), continue (abbreviated to C, run continuously until breakpoint), watch set observation point (watchpoints), X (Prints the value of the specified storage location, in bytes rather than variables),
Use assertions, assert,assert.h.
Depth-first search (usually using stacks), breadth-first search (using queues).
The essence of C language
"Linux C Programming One-stop learning" read notes