As the saying goes, Emacs is the editor of God, and Vim is the god of the editor. Master programmers are using these two artifacts to develop. I think, Emacs is very strong, because many in other editors must use the mouse to click a lot of steps, under Emacs can be done by the keyboard. It greatly saves you the time to find the button on the monitor. Emacs runs more smoothly on Linux than Windows, and when you use Emacs to edit a program, your hands don't have to leave the keyboard to do all the work. So today let's see how to use Emacs to debug C + + programs.
First, install Emacs and GCC
: emacs:http://www.gnu.org/software/emacs/
gcc:http://gcc.gnu.org/
Ii. configuring Emacs and GCC
Emacs recommends that you open the display line number. The specific operation is: there is an. emacs file under C:\Users\maple\AppData\Roaming, open it, add (Global-linum-mode t) and save, note that the brackets should also be written.
GCC adds paths to the PATH environment variable, ensuring that the g++ command executes correctly under CMD.
Third, write the program, edit
We create a new file, and then open with Emacs (Emacs operation Mode has time to introduce, you can follow the inside of the tutorial to learn).
Let's save it first. Then use Emacs to invoke GCC and press s-m-1
Appears to let you enter the shell command, which is the console command. We enter g++ testdbg.cpp-g-o testdbg.exe
Compiled correctly. When we opened the TOOLS->GDB for debugging, we found that Emacs had several more buttons. Such as:
Four, commissioning
1. Set breakpoints
Entering break 5 indicates that a breakpoint is set on line fifth, and we find a little red dot on the left. That's where the breakpoint is.
2. Running the program
Enter run to execute the program and stop at the breakpoint when the program executes.
3. Single Step execution
Input step can be executed in one step, in GdB, directly press ENTER can repeat the previous step of the action.
4. Print variables
Using the print variable, you can print out the value of the current variable.
V. Summary
Using Emacs, get rid of a variety of IDE constraints, can be very fast development of small modules, Emacs also with the ability to view hex file, on Linux, replace the work of Winhex, can be compared to the file, these later have time to talk about. GDB is a powerful debugger attached to the GCC, by the majority of programmers love, in which information about GDB, you can check the manual.
Debugging C + + program with Emacs Tutorial