GDB: Is there a command that allows you to see how many times a function has been called?

I currently have to write malloc () and free () implementations, and I am provided with a driver program that will run my two implementations.

But I'm currently segfaulting because free () is trying to free up a payload size that is good in billions of bytes (which is wrong). I have a line and line number from running GDB, but I need to know if the malloc () and free () calls have been more than once to confirm that there really is at least one case where it runs smoothly.

+5
source share
3 answers

(gdb) help break
.
break [LOCATION] [thread THREADNUM] [if CONDITION]
LOCATION , "*" .
, .
, .
, .
LOCATION .
.

0

malloc . "" , . GDB , . " ", GDB .

+7

To complete the Martin info, run gdb and then at the gdb command prompt:

b <file:line_number or function name>
ignore <breakpoint identifier> 100000

Then you run the executable (or you resume it), and then when you want to check the number of hits of the breakpoint, at the gdb prompt:

info breakpoints
+2
source

All Articles