- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
I'm looking for the details of how the debugger monitors the heap and stack.
Normally when using a memory-fill pattern/"high water" monitoring, code fills a memory space with a repeated byte (or series of bytes). I see that occur in memory when creating a new task when using FreeRTOS, but can't find where this is done to the standard stack and heap at start-up (such as when working with bare metal). That memory looks untouched, so how does the debugger know that X% of stack is used up?
解決済! 解決策の投稿を見る。
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
The linker provides special symbols for the heap and stack. For example it knows the base of the heap, and queries the 'top of heap' variable from the library, that way it knows the current heap usage (at least the level where it is up to).
Similar to the MSP: from the linker symbols it knows the stack start and end, and it can query the MSP register, and knows that way the current stack usage.
Note that this is the actual value, and not the 'max during runtime' you would get if you would use a stack fill pattern.
I hope this helps,
Erich
PS: https://mcuoneclipse.com/2023/02/19/avoiding-stack-overflows-application-monitoring-the-stack-usage/
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Ah, so the heap and main stack monitors don't use a memory-fill pattern, which is why I couldn't find that mechanism anywhere in the code. Thank you, Erich, for the umpteenth time.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
The linker provides special symbols for the heap and stack. For example it knows the base of the heap, and queries the 'top of heap' variable from the library, that way it knows the current heap usage (at least the level where it is up to).
Similar to the MSP: from the linker symbols it knows the stack start and end, and it can query the MSP register, and knows that way the current stack usage.
Note that this is the actual value, and not the 'max during runtime' you would get if you would use a stack fill pattern.
I hope this helps,
Erich
PS: https://mcuoneclipse.com/2023/02/19/avoiding-stack-overflows-application-monitoring-the-stack-usage/