From the fourth edition of "Linux program Design", People's post and telecommunications publishing house
Compiling and debugging of C language Program
<< using GCC compilation, GDB debugging >>
Program compilation process:
Lexical analysis--parsing--Intermediate code generation--code optimization--Target code generation
GCC compilers:
Preprocessing (preprocessing)--compile (compilation)--Assembly (assembly)--Connect
File Suffix Name Description:
. C:c Language Code
. A: library file consisting of target files
. C,.cc,.cpp:c++ Code
. h: Header files included in the program
. I: Pre-preprocessed C source files, typically intermediate code files
. II: Pre-processed C + + source files
. O: Compiled target file, intermediate target file generated by source file
. S: source code for assembly language
. S: After compiling with compilation source code
. O: After compiling the program target file, the target file is connected to the execution file
GCC: Compiling the program
-O: Specifies the compiled output file (default output to the current folder a.out)
GCC A.c-o test.out
-V: View the program compilation process and display the library that has been called
Gcc-v A.C
-X: Specifies the compilation language (used in extensions not recognized by the compiler)
Gcc-x ' C ' a.u
-asci: Specifies that the compiler uses the Ansic standard
-E: Only pre-compilation (. cxx) is done
-S: only to generate assembly files (. S)
-C: Generate only directory code and do not generate executable program (. O)
-G: Use GDB debugger with-o output xxx.debug file
Compile Process Control:
-e-s-C
SOURCE Files---> Preprocessing files---> assembly files---> Target files---> executables
GDB: Debug Program
GDB: Start the debugging environment
File xxx.debug: Loading debug files
List N: Show 10 rows starting with N
Break N: Add a breakpoint on n rows
Info breakpoint [n]: View breakpoints set in program/view n breakpoints
Next: The program runs to the next line to stop
Continue: The program will run to the next breakpoint stop
Step: Run one line at a line (same as next), but step can go inside the calling function
Print: Output variable current value
Delete N: Remove n Breakpoints
Q: Exit the Environment
gcc compiler C language