Appendix E. gprof helper

In this appendix

gprof helper Module for Multithreaded Applications

gprof, when used with multithreaded applications on certain kernels (such as Linux), profiles only the main thread. To work around this situation, we include the gprof helper module from http://sam.zoy.org/writings/programming/gprof.html. Basically, gprof uses the internal ITIMER_PROF timer, which makes the kernel deliver a signal to the application whenever it expires. This module passes this timer data to all spawned threads.

To use the module, compile the following:

$ gcc -shared -fPIC gprof-helper.c -o gprof-helper.so -lpthread -ldl

Type the following in the command line:

$ LD_PRELOAD=./gprof-helper.so ...

Get UNIX to Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.