Add stack high watermark tracking to thread analyzer #299
+265
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements peak stack usage tracking for thread analyzer to identify worst-case stack requirements over thread lifetime. Stack painting (0xaa initialization via
CONFIG_INIT_STACKS) already exists but only showed current usage, not historical peak.Changes
Core Implementation
_thread_stack_info: Addedhigh_watermarkfield to persist peak usage across analyzer runsthread_analyzer_info: Addedstack_high_watermarkto pass data to callbacksthread_analyze_cb(): Updates watermark when current usage exceeds stored maximumthread_print_cb(): Displays watermark in both runtime/non-runtime stat modesConfiguration
CONFIG_THREAD_ANALYZER_STACK_HIGH_WATERMARK: New Kconfig option (default: y)Documentation
thread_analyzer.hexplaining stack painting mechanismthread-analyzer.rstwith watermark usage and example outputTesting
debug.thread_analyzer.high_watermarktest caseExample Output
Watermark shows thread peaked at 412 bytes despite current 376 byte usage—useful for identifying undersized stacks or optimization opportunities.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.