SUMMARY
There are still three articles about introducing the way to analyse a program. But today, I’ll show you another member: callgrind. It’s a tool which belongs to valgrind.
WHY
Sometimes maybe you encounter the issue as same as me: I don’t want to re-compile the program and the oprofile cannot work in my system as well, so.. uh…. what should I do?
Don’t worry guys, the valgrind can save you :D. Why I say that? Because when you write a program in C/C++, you must choose a kernel which can support valgrind working well. As we know, valgrind can detect memory errors easily, it’s a great helper for us. So, if all profilers cannot work well, at least, we have the valgrind. :D
HOW
The way is simple:
- valgrind –tool=callgrind ./yourbin
- gprof2dot.py -f callgrind callgrind.out.xxx | dot -Tpng -o output.png
THE SAMPLE
Here is a sample of analysis mread program, which written by cloudwu.
GUI TOOL
There is GUI front end tool — kcachegrind, if you want to analyse the program more meticulous, you can try it :D
THE LAST
In the end, there are four articles for introducing how to analyse a C/C++ program:
Ok, I hope these articles can help you to increase your capability of analysing a program. :D for any questions, please feel free to reach me.