Measure and report maximum stack usage. #175
Merged
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.
Adds code to measure the maximum excursion of the stack. Enabled only when doing a DEBUG build:
make -DDEBUG=1
.New debug-only module added:
ustack
. This provides:ustack.stack_size()
- return the maximum size of the stack.ustack.stack_usage()
- return how much stack is currently in use. Same asmicropython.stack_use()
, but duplicated here for convenience.ustack.max_stack_usage()
- return the maximum excursion of the stack so far since CircuitPython started.Related change: Debugging modules used to be enabled if if the general cpp flag
DEBUG
was defined. However, I created a new#define
calledMICROPY_DEBUG_MODULES
so they can be enabled/disabled separately.Also checked into why
NDEBUG
makes the code size a bit smaller (per @tannewt's TODO inatmel-samd/Makefile
.NDEBUG
is the standard way of disablingassert()
statements, so apparently that's the reason. Changed comment to reflect that.(This pull request improves on the previous request #150 and brings it up to date for master.)