sumpfralle opened a new issue, #16740:
URL: https://github.com/apache/nuttx/issues/16740

   ### Description
   
   I followed the NuttX [documentation for 
gprof](https://nuttx.apache.org/docs/latest/applications/system/gprof/index.html)
 in order to analyze the timing of one part of my embedded firmware (for 
`rp2040`).
   
   I did this:
   
   1. Configure the necessary Kconfig settings:
       ```
       CONFIG_SYSLOG_TIMESTAMP=n
       CONFIG_DEBUG_ERROR=y
       CONFIG_DEBUG_FEATURES=y
       CONFIG_DEBUG_SCHED=y
       CONFIG_DEBUG_SCHED_ERROR=y
       CONFIG_PROFILE_MINI=y
       CONFIG_FRAME_POINTER=y
       CONFIG_SYSTEM_GPROF=y
       ```
   1. Adjust some constants in `libs/libbuiltin/libgcc/profile.c`:
       * `HISTFRACTION`: 16
       * `HASHFRACTION`: 16
       * `ARCDENSITY`: 1.2
       * Without the above changes, I ran into memory allocation issues when 
starting `gprof` (for 300 kB text and 256 kB RAM).
   1. Connect to NuttX shell.
   1. Run `gprof start`.
   1. Trigger some interesting actions to be profiled.
   1. Run `gprof dump /remote/gmon.out`.
   1. Transfer the file to my local Linux host (via NFS, compiled into the 
NuttX firmware).
   1. Run `gprof` locally:
       ```shell
       arm-none-eabi-gprof external/nuttx/nuttx gmon.out
       ```
   
   The output refers to all timings as zero:
   
   ```
   Flat profile:
   
   Each sample counts as 0.001 seconds.
    no time accumulated
   
     %   cumulative   self              self     total
    time   seconds   seconds    calls  Ts/call  Ts/call  name
     0.00      0.00     0.00     1307     0.00     0.00  foo
     0.00      0.00     0.00     1306     0.00     0.00  bar
     0.00      0.00     0.00      654     0.00     0.00  baz
     0.00      0.00     0.00      654     0.00     0.00  bat
   ```
   Instead I exepected non-zero durations in the table above.
   
   Is this the expected result of the gprof profiling in NuttX?
   
   The [NuttX documentation for 
gprof](https://nuttx.apache.org/docs/latest/applications/system/gprof/index.html)
 contains an example containing non-zero numbers (at the end of the section). 
Maybe this only works in a simulator build?
   
   I am willing to prepare a documentation update, if someone can help me 
clarifying the usage.
   
   Thank you for your time!
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to