mbed_error: Print thread names

As part of this, don't show empty current thread info in non-RTOS
build.
pull/8441/head
Kevin Bracey 2018-10-16 13:15:50 +03:00
parent c3d0e2c2ef
commit 10fe32277d
1 changed files with 10 additions and 2 deletions

View File

@ -270,11 +270,16 @@ mbed_error_status_t mbed_clear_all_errors(void)
return status;
}
static const char *name_or_unnamed(const char *name)
{
return name ? name : "<unnamed>";
}
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT)
/* Prints info of a thread(using osRtxThread_t struct)*/
static void print_thread(const osRtxThread_t *thread)
{
mbed_error_printf("\nState: 0x%08X Entry: 0x%08X Stack Size: 0x%08X Mem: 0x%08X SP: 0x%08X", thread->state, thread->thread_addr, thread->stack_size, (uint32_t)thread->stack_mem, thread->sp);
mbed_error_printf("\n%s State: 0x%X Entry: 0x%08X Stack Size: 0x%08X Mem: 0x%08X SP: 0x%08X", name_or_unnamed(thread->name), thread->state, thread->thread_addr, thread->stack_size, (uint32_t)thread->stack_mem, thread->sp);
}
/* Prints thread info from a list */
@ -348,8 +353,11 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
#endif
mbed_error_printf("\nError Value: 0x%X", ctx->error_value);
mbed_error_printf("\nCurrent Thread: Id: 0x%X Entry: 0x%X StackSize: 0x%X StackMem: 0x%X SP: 0x%X ",
#ifdef MBED_CONF_RTOS_PRESENT
mbed_error_printf("\nCurrent Thread: %s Id: 0x%X Entry: 0x%X StackSize: 0x%X StackMem: 0x%X SP: 0x%X ",
name_or_unnamed(((osRtxThread_t *)ctx->thread_id)->name),
ctx->thread_id, ctx->thread_entry_address, ctx->thread_stack_size, ctx->thread_stack_mem, ctx->thread_current_sp);
#endif
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT)
mbed_error_printf("\nNext:");