From ae5a434f7617fcab607a5406b8928e07693a4871 Mon Sep 17 00:00:00 2001 From: Stephen Casner Date: Mon, 8 Jan 2018 12:57:47 -0800 Subject: [PATCH] Return stack block size and current free space in TaskStatus For some reason, the pxStackBase member is not set in the TaskStatus_t struct as returned by uxTaskGetSystemState(), so we are expanding its function by returning the total size of the stack block in the high 16 bits and the current amount of free stack space in the low 16 bits. --- components/freertos/tasks.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index e95a8b04b..f94c76376 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -87,6 +87,7 @@ task.h is included from an application file. */ #include "StackMacros.h" #include "portmacro.h" #include "semphr.h" +#include "multi_heap_poisoning.h" /* Lint e961 and e750 are suppressed as a MISRA exception justified because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the @@ -3749,6 +3750,12 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber; pxTaskStatusArray[ uxTask ].eCurrentState = eState; pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority; +#ifndef CONFIG_HEAP_POISONING_DISABLED + poison_head_t* stackblk = (poison_head_t*)(pxNextTCB->pxStack - sizeof(poison_head_t)); + uint32_t stackinfo = stackblk->alloc_size << 16; + stackinfo |= pxNextTCB->pxTopOfStack - pxNextTCB->pxStack; + pxTaskStatusArray[ uxTask ].pxStackBase = (StackType_t*)stackinfo; +#endif #if ( INCLUDE_vTaskSuspend == 1 ) {