Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to figure out the top callers of a C function?

Say I have function that is called a LOT from many different places. So I would like to find out who calls this functions the most. For example, top 5 callers or who ever calls this function more than N times.

I am using AS3 Linux, gcc 3.4.

For now I just put a breakpoint and then stop there after every 300 times, thus brute-forcing it...

Does anyone know of tools that can help me?

Thanks

like image 545
vehomzzz Avatar asked Sep 24 '09 20:09

vehomzzz


1 Answers

Compile with -pg option, run the program for a while and then use gprof. Running a program compiled with -pg option will generate gmon.out file with execution profile. gprof can read this file and present it in readable form.

like image 98
danadam Avatar answered Nov 15 '22 10:11

danadam