test(espcoredump): fix test for corrupted TCB handling in coredump

This commit is contained in:
Erhan Kurubas
2026-01-21 08:12:02 +03:00
parent ea36d9b437
commit b95bbc34c3
3 changed files with 29 additions and 21 deletions
+14 -5
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -382,10 +382,19 @@ void test_coredump_summary(void)
void test_tcb_corrupted(void)
{
uint32_t *tcb_ptr = (uint32_t *)xTaskGetIdleTaskHandleForCore(0);
for (size_t i = 0; i < sizeof(StaticTask_t) / sizeof(uint32_t); ++i) {
tcb_ptr[i] = 0xDEADBEE0;
}
StaticTask_t *tcb = (StaticTask_t *)xTaskGetIdleTaskHandleForCore(0);
// Corrupt critical fields that are read by xTaskGetNext() and vTaskGetSnapshot().
tcb->pxDummy1 = (void *)0xDEADBEE0; // pxTopOfStack
tcb->xDummy3[0].pvDummy3[0] = (void *)0xDEADBEE1; // xStateListItem.pxNext
tcb->xDummy3[0].pvDummy3[1] = (void *)0xDEADBEE2; // xStateListItem.pxPrevious
tcb->xDummy3[0].pvDummy3[2] = (void *)0xDEADBEE3; // xStateListItem.pvOwner
tcb->pxDummy6 = (void *)0xDEADBEE6; // pxStack
#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
tcb->pxDummy8 = (void *)0xDEADBEE8; // pxEndOfStack
#endif
// Trigger a context switch.
vTaskDelay(2);
}