# OpenOCD's profile command on RISCV processor

**URL:** <https://forums.sifive.com/t/openocds-profile-command-on-riscv-processor/1538>\
**Category:** RISC-V\
**Created:** [August 23, 2018, 9:06pm UTC](https://forums.sifive.com/t/openocds-profile-command-on-riscv-processor/1538 "2018-08-23T21:06:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtosnerd](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@rtosnerd](https://forums.sifive.com/u/rtosnerd)\
**Post date:** [August 23, 2018, 9:06pm UTC](https://forums.sifive.com/t/openocds-profile-command-on-riscv-processor/1538/1 "2018-08-23T21:06:54Z")

</div>

Hello All,

OpenOCD comes with a profile feature found [here](http://openocd.org/doc/html/General-Commands.html):

> 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?

---

<div class="post-metadata">

**Author:** ![laanwj](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@laanwj](https://forums.sifive.com/u/laanwj)\
**Post date:** [August 25, 2018, 8:54pm UTC](https://forums.sifive.com/t/openocds-profile-command-on-riscv-processor/1538/2 "2018-08-25T20:54:42Z")

</div>

> [@rtosnerd](#):
>
> Do I need to compile my program with the -pg flags?

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