In my project, I have my_malloc() that will call malloc().
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().
Is it possible?
The goal is to id all that code that is calling malloc() directly and didn't go thru my_malloc().
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().
In other words, you want to break on malloc
when it is not called by my_malloc
.
One way to do that is to set three breakpoints: one on malloc
, one on my_malloc
entry, and one on my_malloc
return. Then (assuming the breakpoints are 1, 2 and 3 respectively).
(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
This technique only works for single-threaded applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With