Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute and display stack high water mark in 'freertos task' (GCC-312) #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danc86
Copy link

@danc86 danc86 commented Apr 26, 2023

Essentially follows the same logic as in the FreeRTOS uxTaskGetStackHighWaterMark() function, except we also need to guess the stack growth direction (portSTACK_GROWTH macro).

Example output:

(gdb) freertos task
CPU	 - Processing on CPU number
ID	 - TCB_t task memory address
PRI	 - Task priority
B_PRI	 - Base priority.
SL	 - Free/unused stack size.
SHW	 - Stack high water mark (amount of stack space that has not been touched).

 CPU                            ID    NAME    STATUS PRI B_PRI MUTEXES_HELD   SL SHW
---- ----------------------------- ------- --------- --- ----- ------------ ---- ---
CPU0  0x1043f0 <xIdleTaskTCB.4917>    IDLE     ready   0     0            0  120 120
     0x104448 <xTimerTaskTCB.4924> Tmr Svc suspended   6     6            0  304 304
           0x10292c <xAppsTaskObj>    main suspended   5     5            0 1012 404
        0x108e38 <dmem_heap+18840> evtloop delayed_1   3     3            0 8384 368

I only have RISC-V targets (stack grows downwards) so I haven't actually tested the code path for handling stack growing upwards. But I think it will work... :-)

Essentially follows the same logic as in the FreeRTOS
uxTaskGetStackHighWaterMark() function, except we also need to
guess the stack growth direction (portSTACK_GROWTH macro).
@Lapshin
Copy link
Collaborator

Lapshin commented Apr 26, 2023

@danc86, thanks for the contribution!

That's a pretty nice implementation. Only one thing I would like to ask you to improve:

Could you please check the stack growth direction with frame addresses from the backtrace?
  • This requires having a task with more than one frame. I think this is not going to be a problem

This will give us the right direction without guessing...

This could be done once if the direction is unknown, not needed to check the direction every time

@github-actions github-actions bot changed the title compute and display stack high water mark in 'freertos task' compute and display stack high water mark in 'freertos task' (GCC-312) Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants