Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perf annotate, display only source code

I'm using Perf to perform some profiling experiments.

However, I would like to know results for a specific code region and for this case seeing the results (percentages) for each line of source code (C/C++ in this case) would ease the task.

perf annotate has a view where it displays ASM+Source Code and also has the option to turn off showing source code. I would like to know how to accomplish the other end of this option, that is, showing only Source Code + its percentages of events per line and hide ASM output. Is this possible with perf?

Suggestion of other tool to do that? I'm also using Vtune however the analysis I want to do not is working. Valgrind is out of question, too slow.

I'm on an x64 running Ubuntu 13.04.

like image 571
JohnTortugo Avatar asked Sep 02 '13 15:09

JohnTortugo


1 Answers

Unfortunately perf-annotate uses objdump under the hood which doesn't seem to be able to show only source (-S implies -d).

If you know the way to make objdump behave, see symbol__annotate() at tools/perf/util/annotate.c.

snprintf(command, sizeof(command),
         "%s %s%s --start-address=0x%016" PRIx64
         " --stop-address=0x%016" PRIx64
         " -d %s %s -C %s|grep -v %s|expand",
         objdump_path ? objdump_path : "objdump",
         disassembler_style ? "-M " : "",
         disassembler_style ? disassembler_style : "",
         map__rip_2objdump(map, sym->start),
         map__rip_2objdump(map, sym->end+1),
         symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
         symbol_conf.annotate_src ? "-S" : "",
         symfs_filename, filename);
like image 93
adobriyan Avatar answered Nov 14 '22 15:11

adobriyan