Skip to content

Commit 1545531

Browse files
committed
py/gc: Differentiate between root and subtree pointers for debug log.
This is more informative when debugging possible gc issues. Signed-off-by: stijn <stijn@ignitron.net>
1 parent c39d10a commit 1545531

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

py/gc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,12 @@ static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
385385

386386
#ifndef TRACE_MARK
387387
#if DEBUG_PRINT
388-
#define TRACE_MARK(block, ptr) DEBUG_printf("gc_mark(%p)\n", ptr)
388+
// R for root pointer, S for subtree.
389+
#define TRACE_MARK_R(block, ptr) DEBUG_printf("gc_mark_r(%p)\n", ptr)
390+
#define TRACE_MARK_S(block, ptr) DEBUG_printf("gc_mark_s(%p)\n", ptr)
389391
#else
390-
#define TRACE_MARK(block, ptr)
392+
#define TRACE_MARK_R(block, ptr)
393+
#define TRACE_MARK_S(block, ptr)
391394
#endif
392395
#endif
393396

@@ -439,7 +442,7 @@ void gc_collect_root(void **ptrs, size_t len) {
439442
size_t block = BLOCK_FROM_PTR(area, ptr);
440443
if (ATB_GET_KIND(area, block) == AT_HEAD) {
441444
// An unmarked head: mark it, and mark all its children
442-
TRACE_MARK(ptr_block, ptr);
445+
TRACE_MARK_R(ptr_block, ptr);
443446
ATB_HEAD_TO_MARK(area, block);
444447
#if MICROPY_GC_SPLIT_HEAP
445448
gc_mark_subtree(area, block);
@@ -501,7 +504,7 @@ static void gc_mark_subtree(size_t block)
501504
continue;
502505
}
503506
// An unmarked head. Mark it, and push it on gc stack.
504-
TRACE_MARK(ptr_block, ptr);
507+
TRACE_MARK_S(ptr_block, ptr);
505508
ATB_HEAD_TO_MARK(ptr_area, ptr_block);
506509
if (sp < MICROPY_ALLOC_GC_STACK_SIZE) {
507510
MP_STATE_MEM(gc_block_stack)[sp] = ptr_block;

0 commit comments

Comments
 (0)