@@ -534,25 +534,6 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
534
534
mbed_error_printf ("\nCurrent Thread: %s Id: 0x%" PRIX32 " Entry: 0x%" PRIX32 " StackSize: 0x%" PRIX32 " StackMem: 0x%" PRIX32 " SP: 0x%" PRIX32 " " ,
535
535
name_or_unnamed (((osRtxThread_t * )ctx -> thread_id )-> name ),
536
536
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
- }
556
537
#endif
557
538
558
539
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT )
@@ -575,6 +556,51 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
575
556
mbed_stats_sys_get (& sys_stats );
576
557
mbed_error_printf ("\nFor more info, visit: https://mbed.com/s/error?error=0x%08X&osver=%" PRId32 "&core=0x%08" PRIX32 "&comp=%d&ver=%" PRIu32 "&tgt=" GET_TARGET_NAME (TARGET_NAME ), ctx -> error_status , sys_stats .os_version , sys_stats .cpu_id , sys_stats .compiler_id , sys_stats .compiler_version );
577
558
#endif
559
+
560
+ #if MBED_STACK_DUMP_ENABLED && defined(MBED_CONF_RTOS_PRESENT )
561
+ #define STACK_END_MARK 0xCCCCCCCC
562
+ #define STACK_END_MARK_CNT 3
563
+ #define STACK_DUMP_WIDTH 8
564
+ mbed_error_printf ("\n\nStack Dump:" );
565
+ // Find the stack end.
566
+ int stack_end_cnt = 0 ;
567
+ uint32_t st_end = ctx -> thread_current_sp ;
568
+ for ( ; st_end >= ctx -> thread_stack_mem ; st_end -= sizeof (int ))
569
+ {
570
+ uint32_t st_val = * ((uint32_t * )st_end );
571
+ if (st_val == STACK_END_MARK )
572
+ {
573
+ stack_end_cnt ++ ;
574
+ }
575
+ else
576
+ {
577
+ stack_end_cnt = 0 ;
578
+ }
579
+ if (stack_end_cnt >= STACK_END_MARK_CNT )
580
+ {
581
+ st_end += (STACK_END_MARK_CNT - 1 ) * sizeof (int );
582
+ break ;
583
+ }
584
+ }
585
+ for (uint32_t st = st_end ; st <= ctx -> thread_current_sp ; st += sizeof (int ) * STACK_DUMP_WIDTH )
586
+ {
587
+ mbed_error_printf ("\n0x%08" PRIX32 ":" , st );
588
+ for (int i = 0 ; i < STACK_DUMP_WIDTH ; i ++ )
589
+ {
590
+ uint32_t st_cur = st + i * sizeof (int );
591
+ if (st_cur > ctx -> thread_current_sp )
592
+ break ;
593
+ uint32_t st_val = * ((uint32_t * )st_cur );
594
+ mbed_error_printf ("0x%08" PRIX32 " " , st_val );
595
+ if (st_val == STACK_END_MARK )
596
+ stack_end_cnt ++ ;
597
+ else
598
+ stack_end_cnt = 0 ;
599
+ }
600
+ }
601
+ mbed_error_printf ("\n" );
602
+ #endif // MBED_STACK_DUMP_ENABLED
603
+
578
604
mbed_error_printf ("\n-- MbedOS Error Info --\n" );
579
605
}
580
606
#endif //ifndef NDEBUG
0 commit comments