OpenOCD's profile command on RISCV processor


(Kevin) #1

Hello All,

OpenOCD comes with a profile feature found here:

Command: profile seconds filename [start end]

Profiling samples the CPU’s program counter as quickly as possible, which is useful for non-intrusive stochastic profiling. Saves up to 10000 samples in filename using “gmon.out” format. Optional start and end parameters allow to limit the address range. 

Which outputs a file formatted for gprof to interpret. I am able to execute the profile command and see that it gathers about 10 samples per second into the output file. However, if I do a hex dump on the file the contents are all 0’s except for a small header.

Here are my questions regarding this topic.
Has anyone had any luck using the profile functionality of openocd on a RISCV based processor?

Do I need to compile my program with the -pg flags?

Is there any deeper documentation outside of the general commands section of the manual?


(Wladimir van der Laan) #2

probably not—that flag adds instrumentation (on function entry/exit) to the generated code, which should be unnecessary when sampling is used