Skip to content

Fix Stack stats by running the test command with "-DMBED_HEAP_STATS_ENABLED=1" #3624

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

Merged
merged 1 commit into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
// <i> Initialize thread stack with watermark pattern for analyzing stack usage (current/maximum) in System and Thread Viewer.
// <i> Enabling this option increases significantly the execution time of osThreadCreate.
#ifndef OS_STKINIT
#define OS_STKINIT 0
#if (defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED)
#define OS_STKINIT 1
#else
#define OS_STKINIT 0
#endif
#endif

// <o>Processor mode for thread execution
Expand Down
25 changes: 21 additions & 4 deletions rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,27 @@ os_InRegs osEvent_type svcThreadGetInfo (osThreadId thread_id, osThreadInfo info
}

if (osThreadInfoStackMax == info) {
// Cortex-A RTX does not have stack init so
// the maximum stack usage cannot be obtained.
ret.status = osErrorResource;
return osEvent_ret_status;
uint32_t i;
uint32_t *stack_ptr;
uint32_t stack_size;
if (!(os_stackinfo & (1 << 28))) {
// Stack init must be turned on for max stack usage
ret.status = osErrorResource;
return osEvent_ret_status;
}
stack_ptr = (uint32_t*)ptcb->stack;
stack_size = ptcb->priv_stack;
if (0 == stack_size) {
// This is an OS task - always a fixed size
stack_size = os_stackinfo & 0x3FFFF;
}
for (i = 1; i <stack_size / 4; i++) {
if (stack_ptr[i] != MAGIC_PATTERN) {
break;
}
}
ret.value.v = stack_size - i * 4;
return osEvent_ret_value;
}

if (osThreadInfoEntry == info) {
Expand Down