0

I try to modify perf record to handle assembly code of target process/program. Therefore, I want to know where data structure does perf use to store assembly code and count position of target process/program?

Generally, perf record will write a 'perf.data' when finished and we can use perf record, press 'Enter' and choose 'annotate' to see assembly code of target process/program. By this way, we can get which code line is the reason for counting.

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
  • You really need to add more details to what you are trying to achieve. The question is very unclear. – Ajay Brahmakshatriya Dec 13 '17 at 04:19
  • Thanks. I try to modify `perf` source code to let 'perf record' command can output counter number and counter position of assembly code of target progress/program in real time, instead of rusult file `perf.data`. –  Dec 13 '17 at 05:50

1 Answers1

1

perf record does not handle assembly in any way, neither is any assembly or instructions stored in perf.data. perf record records events that contain instruction pointers. During perf report and other analysis tools, these are translated addresses within o DSOs using MMAP information. perf knows the file name to the corresponding binary - note that it may use copies of those binaries under .debug/.build-id to use the right version if it changed since recording. Perf runs objdump on the file to get the disassembly and show you the annotated view.

This answers your question, but without any further information, it is impossible to really help you achieve what you actually want to do. You can also build your own tool based on perf_event_open.

Zulan
  • 21,896
  • 6
  • 49
  • 109
  • Like you said that `perf record` record events that contain instruction pointers, so what data structure or where does perf use to store the instruction pointers' content, for example virtual address? –  Dec 17 '17 at 07:08