Today, using GDB to debug the whole day, in a lot of key places to add the breakpoint, near work, because to close the remote connection, in order to facilitate the test tomorrow, I would like to save all the breakpoints. However, because there are too many breakpoints, use "info B" Although you can see the breakpoint, but the location of the breakpoint to find out, and then save, feel a little trouble.
(GDB) Info bnum Type Disp Enb Address What1 breakpoint keep y 0x000000000040336d in main (int, char**) at recvmain.cpp:290 Breakpoint already hits 1 time2 breakpoint keep y 0x00002aaab049c7ef in Crealcrediteventab::loopeventcreditctrl (int) ...
On the internet to see if GDB has a way to save breakpoints, but the value of the "Python Save Breakpoint" method, see the use of "Save Breakpoints" command, so I came to the GDB debugging environment to see if GDB has the parameter "save", as follows:
See the "Save breakpoints", can't help but to see the meaning of this command:
(GDB) Help save breakpoints Save breakpoint definitions as a script. This includes all types of breakpoints (breakpoints, watchpoints,catchpoints, tracepoints).
Look at the explanation, sure enough to meet my requirements--to save all the breakpoints, save to "Gdb.cfg", as follows:
(GDB) Save breakpoints gdb.cfgsaved to file ' gdb.cfg '. (gdb) ^z[1]+ Stopped gdb recvmain[[email protected] creditctl] $vi gdb.cfg 1 break main 2 break Crealcrediteventab::loopeventcreditctrl 3 Break Assignstoptask ...
The first is the line number that appears, and as you can see, my breakpoint is actually saved.
I took a closer look at the comment above for "save breakpoints", in another GDB session you can use the "source" command to restore (restore, restore) them (breakpoints). Test: Delete all breakpoints first, then use source to recover all saved breakpoints as follows:
(GDB) D #删除所有断点Delete all breakpoints? (Y or N) y (gdb) Info b #查看断点No breakpoints or watchpoints. ( GDB) Source Gdb.cfg #加载断点Breakpoint 9 at 0x40336d:file RecvMain.cpp, line 290.Breakpoint at 0x2aaab049c7ef:file C RealCreditEventAb.cpp, line 80 ..... (GDB) Info b #查看断点Num Type Disp Enb Address What9 breakpoint keep y 0x000000000040336d In Main (int., char**) at recvmain.cpp:29010 Breakpoint keep y 0x00002aaab049c7ef in Crealcrediteventab: : Loopeventcreditctrl (int) at crealcrediteventab.cpp:80 ...
Take a look at the document, and learn a new skill, record it, hope to be helpful to everyone.
Extended reading: http://ccshell.com/archives/92.html python save Breakpoint