Re: stack specific breakpoint
Doug Evans <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CADPb22SAsb5T3z1mG060ANZv=aQUVSvQzcX=juheWyjc_f4TzA@mail.gmail.com> |
On Sun, Feb 22, 2015 at 9:15 PM, kamaraju kusumanchi <[email protected]> wrote: > Is there a way to set a breakpoint in a function A only when it is > called from function B? In my case, I have > > funcB() > { > .... > funcA( funcD(), funcE()) > .... > } > > funcC() > { > .... > funcA(funcD(), funcE()) > .... > } > > where funcA is called by both funcB and funcC. funcC is called a lot > of times (the exact number is not known either at run time or compile > time) and funcB is called only a handful of times. The additional > twist is that the arguments passed to funcA are the return values from > other functions - funcD and funcE. > > I am interested in stepping into funcA only when it is called from > funcB. Is there a way to specify the function hierarchy when setting a > break point? > > I tried setting a break point where funcB calls funcA and then use the > "step" command. But this steps into funcD() instead of funcA(). > > Currently, my work around is to first set a breakpoint where funcB > calls funcA and when the code hits that set another break point in > funcA. Once code finishes funcA, I will disable it (since it could be > called by funcC afterwards). I will reenable it when it hits the funcA > line in funcB definition. But doing this enable/disable dance is > tiresome. Is there a better way to achiever this? (gdb) break funcA if $_caller_is("funcB") https://sourceware.org/gdb/current/onlinedocs/gdb/Convenience-Funs.html#Convenience-Funs This requires gdb 7.9 configured with python support.