当前位置:网站首页>Explanation of vim, makefile and GDB tools

Explanation of vim, makefile and GDB tools

2022-06-21 13:36:00 Longbow dog learning C

One .vim

1.vim What is it? ?

We are beginning to learn c Language , Most of them have to learn vs(visual studio) Tools , In this tool, we can edit code or debug code in this software , It is a versatile software .

and Linux We need to learn several tools to implement the whole process ,vim Is a tool for editing code .

2.vim Multimodal ?

vim There are multiple patterns in the tool , common 10 Several patterns , In order to realize code editing in different scenarios , The most common one we use is normal ( command ) Pattern , Insert mode and last line mode .

In normal mode, we can delete the existing code , Copy move (yy Copy dd Clip p Paste )

Input i Enter insertion mode , Before data input

Use shift and ; Enter last line mode , Used to save and exit files

Two .makefile

Study makefile We need to learn the compilation process first

1.gcc/g++ Use

The original code file needs a series of processing ( compile ) To generate a processable file . and gcc yes c Language code file implementation processing compiler ,g++ yes c++ Implemented compiler .

The whole process can be roughly divided into four parts , Preprocessing , compile , assembly , link

2. What has been done in the four processes

  • Preprocessing : Mainly for macro replacement , To comment and other operations

gcc -E hello.c -o hello.i here E It means to stop compiling after preprocessing ,o After that is the generated object file ,(.c) The file is preprocessed to generate (.i) file

  • compile : Check for syntax errors , Code normalization , Generate assembly language after no error

gcc –S hello.i –o hello.s  S Description stop after compilation ,(.i) The file is compiled and generated (.s) file

  • assembly : Generating machine recognizable code

gcc –c hello.s –o hello.o  C Description stop after the assembly process ,(.s) Files are generated after assembly (.o) file

  • link : Generate executable files

gcc hello.o -o hello Same as above

Finally, I can just talk about the following

3. What is? makefile

The implementation of a project is inseparable from numerous source files , How to compile these files has become a problem , and makefile and make Defines the Compilation Rules of the file .

Write well makefile after , Just one make You can make the project compile automatically .

makefile It's a document ,make It's an order , Use both together .

Let's go straight to one makefile

g++ It shows that the language we use is c++, In the figure g++ After [email protected] Represents the left of the colon in the previous line parser  $^ It stands for the one to the right of the colon parser.cc $(FLAG) Represents the first line of code

amount to    g++ -o parser parser.cc ( first line ) 

according to ( rely on )parser.cc File generation target parser Executable file

among clean After represents input make clean It will delete parser file

3、 ... and .gdb

1. What is? gdb

gdb It's a debugging tool , There are two modes of program release ,debug and release, Only the former can be debugged

and Linux gcc/g++ The default generation is the offending pattern , To debug compile time +g

after gdb The executable is just

 r function ,break n Give it to n Line break point ,delete breakpoint n Delete the first n Line breakpoint .

info break View breakpoint information n Run the next step .

原网站

版权声明
本文为[Longbow dog learning C]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221438094445.html