esp32: Fixes crash during core dump.

Removes piece of debugging code introduced by 8d43859b.
This commit is contained in:
Alexey Gerenkov 2017-09-10 19:17:46 +03:00
parent 050ae50e83
commit 4e0c3a0415
3 changed files with 60 additions and 29 deletions

View file

@ -269,9 +269,7 @@ extern void vPortCleanUpTCB ( void *pxTCB );
#define configXT_BOARD 1 /* Board mode */ #define configXT_BOARD 1 /* Board mode */
#define configXT_SIMULATOR 0 #define configXT_SIMULATOR 0
#if CONFIG_ESP32_ENABLE_COREDUMP
#define configENABLE_TASK_SNAPSHOT 1 #define configENABLE_TASK_SNAPSHOT 1
#endif
#if CONFIG_SYSVIEW_ENABLE #if CONFIG_SYSVIEW_ENABLE
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__

View file

@ -4991,9 +4991,11 @@ TickType_t uxReturn;
#endif /* configUSE_TASK_NOTIFICATIONS */ #endif /* configUSE_TASK_NOTIFICATIONS */
#if ( configENABLE_TASK_SNAPSHOT == 1 ) #if ( configENABLE_TASK_SNAPSHOT == 1 )
static void prvTaskGetSnapshot( TaskSnapshot_t *pxTaskSnapshotArray, UBaseType_t *uxTask, TCB_t *pxTCB ) static void prvTaskGetSnapshot( TaskSnapshot_t *pxTaskSnapshotArray, UBaseType_t *uxTask, TCB_t *pxTCB )
{ {
if (pxTCB == NULL) {
return;
}
pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB; pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB;
pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack; pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack;
#if( portSTACK_GROWTH < 0 ) #if( portSTACK_GROWTH < 0 )
@ -5017,11 +5019,10 @@ TickType_t uxReturn;
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
do do
{ {
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
if( *uxTask >= uxArraySize ) if( *uxTask >= uxArraySize )
break; break;
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
prvTaskGetSnapshot( pxTaskSnapshotArray, uxTask, pxNextTCB ); prvTaskGetSnapshot( pxTaskSnapshotArray, uxTask, pxNextTCB );
} while( pxNextTCB != pxFirstTCB ); } while( pxNextTCB != pxFirstTCB );
} }
@ -5035,8 +5036,6 @@ TickType_t uxReturn;
{ {
UBaseType_t uxTask = 0, i = 0; UBaseType_t uxTask = 0, i = 0;
PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB[ portNUM_PROCESSORS ] = { NULL };
*pxTcbSz = sizeof(TCB_t); *pxTcbSz = sizeof(TCB_t);
/* Fill in an TaskStatus_t structure with information on each /* Fill in an TaskStatus_t structure with information on each
@ -5055,7 +5054,6 @@ PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB[ portNUM_PROCESSORS ] = { NULL };
for (i = 0; i < portNUM_PROCESSORS; i++) { for (i = 0; i < portNUM_PROCESSORS; i++) {
if( uxTask >= uxArraySize ) if( uxTask >= uxArraySize )
break; break;
prvTaskGetSnapshot( pxTaskSnapshotArray, &uxTask, pxCurrentTCB[ i ] );
prvTaskGetSnapshotsFromList( pxTaskSnapshotArray, &uxTask, uxArraySize, &( xPendingReadyList[ i ] ) ); prvTaskGetSnapshotsFromList( pxTaskSnapshotArray, &uxTask, uxArraySize, &( xPendingReadyList[ i ] ) );
} }

View file

@ -0,0 +1,35 @@
/*
Test FreeRTOS support for core dump.
*/
#include <stdio.h>
#include "soc/cpu.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
#define TEST_MAX_TASKS_NUM 32
/* simple test to check that in normal conditions uxTaskGetSnapshotAll does not generate exception */
TEST_CASE("Tasks snapshot", "[freertos]")
{
TaskSnapshot_t tasks[TEST_MAX_TASKS_NUM];
UBaseType_t tcb_sz;
int other_core_id = xPortGetCoreID() == 0 ? 1 : 0;
// uxTaskGetSnapshotAll is supposed to be called when all tasks on both CPUs are
// inactive and can not alter FreeRTOS internal tasks lists, e.g. from panic handler
unsigned state = portENTER_CRITICAL_NESTED();
#if CONFIG_FREERTOS_UNICORE == 0
esp_cpu_stall(other_core_id);
#endif
UBaseType_t task_num = uxTaskGetSnapshotAll(tasks, TEST_MAX_TASKS_NUM, &tcb_sz);
#if CONFIG_FREERTOS_UNICORE == 0
esp_cpu_unstall(other_core_id);
#endif
portEXIT_CRITICAL_NESTED(state);
printf("Dumped %d tasks. TCB size %d\n", task_num, tcb_sz);
TEST_ASSERT_NOT_EQUAL(0, task_num);
TEST_ASSERT_NOT_EQUAL(0, tcb_sz);
}