czwartek, 29 września 2011

Profiling

Basic profiling tool - gprof

Required '-pg' added for compilation and linking.

Profile results are stored in file 'gmon.out'. Default place for the file is working directory of the program being profiled. Important - process has to be closed with normal termination - exit() or end of main() function - profile file is saved on process termination.

Potentially interesting - environmental variables for gprof (not sure if working):
GMON_OUT_PREFIX, PROFDIR, PROFFLAGS.

sources:
http://sourceware.org/binutils/docs/gprof/
http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html
http://sourceware.org/gdb/onlinedocs/gdb/


Other:
Tool from Intel - Pin
GNU cflow analyzes a collection of C source files and prints a graph, charting control flow within the program.
ltrace, ptrace, etrace, ftrace
SystemTap - http://sourceware.org/systemtap/examples/general/para-callgraph.stp - Observe, systemtap and oprofile updates
-finstrument-functions gcc
http://blog.superadditive.com/2007/12/01/call-graphs-using-the-gnu-project-debugger/