From c4f9e27c28c018c85b9d23e5ac7470ada508bdb8 Mon Sep 17 00:00:00 2001 From: Joseph Julicher Date: Thu, 6 Jan 2022 12:03:56 -0700 Subject: [PATCH] Feature: Add task top/end of stack to task info report (#436) uncrustify Co-authored-by: Shreyas Balakrishna Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- include/task.h | 4 ++++ tasks.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/task.h b/include/task.h index 4045f107a..007900f2a 100644 --- a/include/task.h +++ b/include/task.h @@ -161,6 +161,10 @@ typedef struct xTASK_STATUS UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */ + #if ( ( portSTACK_GROWTH > 0 ) && ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + StackType_t * pxTopOfStack; /* Points to the top address of the task's stack area. */ + StackType_t * pxEndOfStack; /* Points to the end address of the task's stack area. */ + #endif configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; diff --git a/tasks.c b/tasks.c index de70417f6..88e699ca6 100644 --- a/tasks.c +++ b/tasks.c @@ -3712,6 +3712,10 @@ static void prvCheckTasksWaitingTermination( void ) pxTaskStatus->pcTaskName = ( const char * ) &( pxTCB->pcTaskName[ 0 ] ); pxTaskStatus->uxCurrentPriority = pxTCB->uxPriority; pxTaskStatus->pxStackBase = pxTCB->pxStack; + #if ( ( portSTACK_GROWTH > 0 ) && ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + pxTaskStatus->pxTopOfStack = pxTCB->pxTopOfStack; + pxTaskStatus->pxEndOfStack = pxTCB->pxEndOfStack; + #endif pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber; #if ( configUSE_MUTEXES == 1 )