diff --git a/components/freertos/include/freertos/task.h b/components/freertos/include/freertos/task.h index cfea1f0a77..982c6bfe69 100644 --- a/components/freertos/include/freertos/task.h +++ b/components/freertos/include/freertos/task.h @@ -199,6 +199,7 @@ typedef struct xTASK_SNAPSHOT StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ + eTaskState eState; /*!< Current state of the task. Can be running or suspended */ } TaskSnapshot_t; /** diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 5290168542..d09e36e56e 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -5057,6 +5057,7 @@ TickType_t uxReturn; } pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB; pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack; + pxTaskSnapshotArray[ *uxTask ].eState = eTaskGetState(pxTCB); #if( portSTACK_GROWTH < 0 ) { pxTaskSnapshotArray[ *uxTask ].pxEndOfStack = pxTCB->pxEndOfStack; diff --git a/components/freertos/test/test_tasks_snapshot.c b/components/freertos/test/test_tasks_snapshot.c index bc42e1a90c..f02c04332e 100644 --- a/components/freertos/test/test_tasks_snapshot.c +++ b/components/freertos/test/test_tasks_snapshot.c @@ -27,6 +27,9 @@ TEST_CASE("Tasks snapshot", "[freertos]") esp_cpu_stall(other_core_id); #endif UBaseType_t task_num = uxTaskGetSnapshotAll(tasks, TEST_MAX_TASKS_NUM, &tcb_sz); + for (uint32_t i = 0; i < task_num; i++) { + TEST_ASSERT_EQUAL(tasks[i].eState, eTaskGetState(tasks[i].pxTCB)); + } #ifndef CONFIG_FREERTOS_UNICORE esp_cpu_unstall(other_core_id); #endif