40
40
#endif
41
41
#include <inttypes.h>
42
42
43
+ #ifndef MAX
44
+ #define MAX (a , b ) ((a) > (b) ? (a) : (b))
45
+ #endif
46
+
43
47
#ifndef NDEBUG
44
48
#define ERROR_REPORT (ctx , error_msg , error_filename , error_line ) print_error_report(ctx, error_msg, error_filename, error_line)
45
49
static void print_error_report (const mbed_error_ctx * ctx , const char * , const char * error_filename , int error_line );
@@ -473,6 +477,7 @@ mbed_error_status_t mbed_clear_all_errors(void)
473
477
return status ;
474
478
}
475
479
480
+ #ifdef MBED_CONF_RTOS_PRESENT
476
481
static inline const char * name_or_unnamed (const osRtxThread_t * thread )
477
482
{
478
483
const char * unnamed = "<unnamed>" ;
@@ -484,7 +489,9 @@ static inline const char *name_or_unnamed(const osRtxThread_t *thread)
484
489
const char * name = thread -> name ;
485
490
return name ? name : unnamed ;
486
491
}
492
+ #endif // MBED_CONF_RTOS_PRESENT
487
493
494
+ #if MBED_STACK_DUMP_ENABLED
488
495
/** Prints stack dump from given stack information.
489
496
* The arguments should be given in address raw value to check alignment.
490
497
* @param stack_start The address of stack start.
@@ -515,7 +522,6 @@ static void print_stack_dump_core(uint32_t stack_start, uint32_t stack_size, uin
515
522
516
523
static void print_stack_dump (uint32_t stack_start , uint32_t stack_size , uint32_t stack_sp , const mbed_error_ctx * ctx )
517
524
{
518
- #if MBED_STACK_DUMP_ENABLED
519
525
if (ctx && mbed_error_is_handler (ctx )) {
520
526
// Stack dump extra for handler stack which may have accessed MSP.
521
527
mbed_fault_context_t * mfc = (mbed_fault_context_t * )ctx -> error_value ;
@@ -536,8 +542,8 @@ static void print_stack_dump(uint32_t stack_start, uint32_t stack_size, uint32_t
536
542
}
537
543
538
544
print_stack_dump_core (stack_start , stack_size , stack_sp , "PSP" );
539
- #endif // MBED_STACK_DUMP_ENABLED
540
545
}
546
+ #endif // MBED_STACK_DUMP_ENABLED
541
547
542
548
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT )
543
549
/* Prints info of a thread(using osRtxThread_t struct)*/
@@ -546,7 +552,9 @@ static void print_thread(const osRtxThread_t *thread)
546
552
uint32_t stack_mem = (uint32_t )thread -> stack_mem ;
547
553
mbed_error_printf ("\n%s State: 0x%" PRIX8 " Entry: 0x%08" PRIX32 " Stack Size: 0x%08" PRIX32 " Mem: 0x%08" PRIX32 " SP: 0x%08" PRIX32 , name_or_unnamed (thread ), thread -> state , thread -> thread_addr , thread -> stack_size , stack_mem , thread -> sp );
548
554
555
+ #if MBED_STACK_DUMP_ENABLED
549
556
print_stack_dump (stack_mem , thread -> stack_size , thread -> sp , NULL );
557
+ #endif
550
558
}
551
559
552
560
/* Prints thread info from a list */
@@ -628,14 +636,16 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
628
636
}
629
637
630
638
mbed_error_printf ("\nError Value: 0x%" PRIX32 , ctx -> error_value );
631
- bool is_handler = mbed_error_is_handler (ctx );
632
639
#ifdef MBED_CONF_RTOS_PRESENT
640
+ bool is_handler = mbed_error_is_handler (ctx );
633
641
mbed_error_printf ("\nCurrent Thread: %s%s Id: 0x%" PRIX32 " Entry: 0x%" PRIX32 " StackSize: 0x%" PRIX32 " StackMem: 0x%" PRIX32 " SP: 0x%" PRIX32 " " ,
634
642
name_or_unnamed ((osRtxThread_t * )ctx -> thread_id ), is_handler ? " <handler>" : "" ,
635
643
ctx -> thread_id , ctx -> thread_entry_address , ctx -> thread_stack_size , ctx -> thread_stack_mem , ctx -> thread_current_sp );
636
644
#endif
637
645
646
+ #if MBED_STACK_DUMP_ENABLED
638
647
print_stack_dump (ctx -> thread_stack_mem , ctx -> thread_stack_size , ctx -> thread_current_sp , ctx );
648
+ #endif
639
649
640
650
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT )
641
651
mbed_error_printf ("\nNext:" );
0 commit comments