Does perf have the ability to produce a self-contained perf.data file with symbol information in addition to offsets?
By default, perf report seems to reconstruct the symbol information based on having the file available.
Suppose we have a file hello.cpp in /tmp/perftest:
#include <cstdio>
int store = 0;
int add_to_store(int x) {
store += x;
}
int main() {
for (int i = 0; i < 1000000; ++i) {
add_to_store(i);
}
printf("%d\n", store);
}
If you compile it (with optimization disabled) and run it you get some number
$ g++ -O0 hello.cpp
$ ./a.out
1783293664
If we want to record where it spends most of its time ... we can use perf.
$ perf record ./a.out
1783293664
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.007 MB perf.data (15 samples) ]
And we get the following output inside a pager-ish program when we run perf report
40.00% a.out a.out [.] add_to_store
40.00% a.out a.out [.] main
13.33% a.out ld-2.17.so [.] do_lookup_x
6.67% a.out ld-2.17.so [.] calloc
However, the symbol data does not actually live in perf.data, e.g.
$ strings perf.data | grep add_to_store
Exit 1
And if we rm ./a.out, then we see the following for our perf report output:
20.00% a.out a.out [.] 0x0000000000000608
20.00% a.out a.out [.] 0x000000000000062f
13.33% a.out a.out [.] 0x000000000000060e
13.33% a.out a.out [.] 0x0000000000000626
13.33% a.out ld-2.17.so [.] do_lookup_x
6.67% a.out a.out [.] 0x0000000000000603
6.67% a.out a.out [.] 0x0000000000000636
6.67% a.out ld-2.17.so [.] calloc
Is there a way to direct perf to collect symbol information and put it in perf.data? Or, failing that, does the perf.data format allow for the possibility of storing symbol information in it? I'm okay with writing a script to munge the data file if I have to.