Skip to content

Commit 9ddd9bf

Browse files
committed
Now stack printing is done.
1 parent 363ad8a commit 9ddd9bf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

platform/mbed_error.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,25 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
534534
mbed_error_printf("\nCurrent Thread: %s Id: 0x%" PRIX32 " Entry: 0x%" PRIX32 " StackSize: 0x%" PRIX32 " StackMem: 0x%" PRIX32 " SP: 0x%" PRIX32 " ",
535535
name_or_unnamed(((osRtxThread_t *)ctx->thread_id)->name),
536536
ctx->thread_id, ctx->thread_entry_address, ctx->thread_stack_size, ctx->thread_stack_mem, ctx->thread_current_sp);
537+
538+
#define STACK_END 0xCCCCCCCC
539+
mbed_error_printf("\nPrinting Stack");
540+
int stack_end_cnt = 0;
541+
for (uint32_t st = ctx->thread_current_sp; st >= ctx->thread_stack_mem; st -= sizeof(int))
542+
{
543+
uint32_t st_val = *((uint32_t*)st);
544+
mbed_error_printf("\n0x%" PRIX32 ": 0x%" PRIX32, st, st_val);
545+
if (st_val == STACK_END)
546+
{
547+
stack_end_cnt++;
548+
}
549+
else
550+
{
551+
stack_end_cnt = 0;
552+
}
553+
if (stack_end_cnt > 2)
554+
break;
555+
}
537556
#endif
538557

539558
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT)

0 commit comments

Comments
 (0)