This is a created article in which the information may have evolved or changed.
Purpose: Use GDB to attach to a running process, then do some debugging and safely exit.
1. Modify the Ubuntu configuration to allow gdb to attach to the process, and how to modify the following:
Http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process
2. View the process ID #ps ax or #ps au
3. Start GDB
4. Use the file command to specify the program source code and symbol table that the process is contacting, for example:
File/home/yourihua/workplace/rhino/bin/console
5. Attach < process id>
6. Break point, as follows:
B/home/yourihua/workplace/rhino/src/github.com/yourihua/console/app/controllers/app.go:10
7. Enter C and the process continues to run.
8. Ctrl + C interrupts again, back to the GDB command line, and enter: Detach.
After you have finished debugging, you can use this command to disconnect the process from GDB (to end GDB's control of the process), after which the process you are debugging will continue to run.
Reference article:
Http://www.cnblogs.com/whiteyun/archive/2011/10/17/2215532.html
In the end, GDB is inseparable from Daniel, Yuhen's patient help.