GDB (GNU Source-Level Debugger is the tool for debugging the program under Linux. It can observe the status of another program during execution and error. We usually compile the program with a command similar to% gcc -o test test.c, now we plus the -ggdb parameter option to generate debugging information. After generating Test, we can use%. / Test. Of course, the result is either in the expected result, or it is an abnormal result. Of course, we now say how to use GDB to check the error in the case of exceptions. We can use% GDB Test to debug TEST. This way we entered the GDB debug state entry (GDB) this command prompt. Here we type RUN to perform Test's programs, of course, this is not our purpose, but it does provide a convenience of running the program without exiting GDB. The most basic of the debug is of course the breakpoint, observe the variable and see how the variable changes. Suppose now knows the results of a certain place may have problems, then use the Break plus code line number to set up breakpoints. To know the exact line number, as long as you enter the command list, you can see all programs with the line number. Then run with a breakpoint, you can observe the variable when stopped at the breakpoint, and you can see its value with the WATCH donor name. Then it is stepped, of course, NEXT, is it very simple. There is also the GDB also provides the function of executing the shell command, as long as the format of the shell command string is followed. One of them can be executed for the Make command even if you don't need to type. There are still a lot of commands in GDB, just as other tools you can see commands and their descriptions. GDB can also connect an running process into GDB for debugging. Use the file to specify the source code contacted by the process, then use the attach process-id to connect a running process, with Continue to continue the process. Similarly, DETACH can be disconnected. It is just a common function of GDB, which has a powerful function used in all debugging, and it is necessary to discover and use in practice.