在我的项目中,我有my_malloc(),它将调用malloc().
我喜欢在gdb中设置条件断点,这样gdb就会分成“gdb>”仅当malloc()的调用函数不等于my_mallc()时.
可能吗?
@R_502_323@
I like to set up the conditional breakpoint in gdb such that gdb will break into “gdb>” only when the caller function of malloc() is not equal to my_mallc().
换句话说,当my_malloc未调用malloc时,您希望在malloc上中断.
一种方法是设置三个断点:一个在malloc上,一个在my_malloc上,一个在my_malloc上.然后(假设断点分别为1,2和3).
(gdb) commands 2 silent # don't announce hitting breakpoint #2 disable 1 # don't stop when malloc is called within my_malloc continue # continue execution when BP#2 is hit end (gdb) commands 3 silent enable 1 # re-enable malloc breakpoint continue end
此技术仅适用于单线程应用程序.