@@ -481,8 +481,8 @@ static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
481481//
482482// Otherwise, you can inspect word 0 of the block to likely get the Python object type of the memory
483483// that should have been collected. Compare that pointer to those in the matching firmware.elf.map.
484- static bool debug_collect = false ;
485- static void * target_ptr = (void * )0x1101b8d0 ;
484+ static bool debug_collect = true ;
485+ static void * target_ptr = (void * )0x7ffff7ec00d0 ;
486486
487487#if MICROPY_ENABLE_SELECTIVE_COLLECT
488488static uint32_t target_count = 100 ;
@@ -548,13 +548,13 @@ static void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(size_t block)
548548 #endif
549549 if (!should_scan ) {
550550 if (!found_collect_candidate ) {
551- console_uart_printf ( "should have scanned %p\n" , block_ptr );
551+ mp_printf ( & mp_plat_print , "should have scanned %p\n" , block_ptr );
552552 // This is often the pointer to the Python type in RAM.
553553 // It is helpful to know the allocation path that should use mp_obj_malloc.
554- console_uart_printf ( " [0] = %p\n" , block_ptr [0 ]);
555- console_uart_printf ( " [1] = %p\n" , block_ptr [1 ]);
554+ mp_printf ( & mp_plat_print , " [0] = %p\n" , block_ptr [0 ]);
555+ mp_printf ( & mp_plat_print , " [1] = %p\n" , block_ptr [1 ]);
556556 }
557- console_uart_printf ( " [%d] = %p\n" , i , ptr );
557+ mp_printf ( & mp_plat_print , " [%d] = %p\n" , i , ptr );
558558 found_collect_candidate = true;
559559 ptr = NULL ;
560560 continue ;
@@ -1064,14 +1064,14 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
10641064 if (debug_collect ) {
10651065 if (ret_ptr == target_ptr ) {
10661066 if (current_count == target_count && do_not_collect ) {
1067- asm ( "bkpt" );
1067+ __builtin_trap ( );
10681068 }
1069- console_uart_printf ( "target_count = %d\n" , current_count );
1069+ mp_printf ( & mp_plat_print , "target_count = %d\n" , current_count );
10701070 current_count ++ ;
10711071 }
10721072
10731073 if (target_ptr != NULL && ret_ptr == target_ptr ) {
1074- console_uart_printf ( "gc_alloc(%d, %01x) = %p\n" , n_bytes , alloc_flags , ret_ptr );
1074+ mp_printf ( & mp_plat_print , "gc_alloc(%d, %01x) = %p\n" , n_bytes , alloc_flags , ret_ptr );
10751075 }
10761076 }
10771077 #endif
@@ -1110,7 +1110,7 @@ void gc_free(void *ptr) {
11101110 }
11111111
11121112 if (debug_collect && target_ptr != NULL && ptr == target_ptr ) {
1113- console_uart_printf ( "gc_free(%p)\n" , ptr );
1113+ mp_printf ( & mp_plat_print , "gc_free(%p)\n" , ptr );
11141114 }
11151115
11161116 // get the GC block number corresponding to this pointer
@@ -1399,7 +1399,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
13991399 void * ptr_out = gc_alloc (n_bytes , alloc_flags );
14001400
14011401 if (debug_collect && target_ptr != NULL && (ptr_out == target_ptr || ptr_in == target_ptr )) {
1402- console_uart_printf ( "gc_realloc: moving %p -> %p, %d -> %d bytes\n" , ptr_in , ptr_out , n_blocks * BYTES_PER_BLOCK , n_bytes );
1402+ mp_printf ( & mp_plat_print , "gc_realloc: moving %p -> %p, %d -> %d bytes\n" , ptr_in , ptr_out , n_blocks * BYTES_PER_BLOCK , n_bytes );
14031403 }
14041404 // check that the alloc succeeded
14051405 if (ptr_out == NULL ) {
0 commit comments