简体   繁体   中英

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM