How does MCUXpresso debugger monitor heap and stack?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How does MCUXpresso debugger monitor heap and stack?

ソリューションへジャンプ
1,122件の閲覧回数
kackle123
Contributor IV

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?

0 件の賞賛
返信
1 解決策
1,095件の閲覧回数
ErichStyger
Specialist I

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/

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,080件の閲覧回数
kackle123
Contributor IV

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.

1,096件の閲覧回数
ErichStyger
Specialist I

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/

0 件の賞賛
返信