Hans Müller, as I understand, gprof format is not so easy to generate (https://sourceware.org/binutils/docs/gprof/File-Format.html - "new file format is defined in header file gmon_out.h. It consists of a header containing the magic cookie and a version number, ... Histogram records consist of a header that is followed by an array of bins...")
I can recommend generation of
Easier way (for flat) is to use some awk
/perl
/python
scripting and addr2line
tool from binutils (you need addr2line with support of target architecture). This tool will give you function names from address (if you correctly map PC samples to virtual addresses of elf binary), and your script should sum samples for every function, then sort. It is harder to handle callgraph in small scripts.
gpreftools's pprof
is just script which can run addr2line for you (you still need right variant of addr2line). It is capable of summing samples for functions and sorting, and even may call objdump
to get annotated disassembly.
Both formats may be used for flat profiles, but they support callgraphs to some level. pprof allows you to save full backtrace in every event; while callgrind.out format stores only pairs caller-callee (cfn), and kcachegrind may incorrectly guess pathes to hot code.