Skip to content

Commit ec21405

Browse files
committed
py: Add (commented out) code to gc_dump_alloc_table for qstr info.
1 parent 56e1f99 commit ec21405

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

py/gc.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,26 @@ void gc_dump_alloc_table(void) {
730730
#endif
731731
else if (*ptr == (mp_uint_t)&mp_type_fun_bc) { c = 'B'; }
732732
else if (*ptr == (mp_uint_t)&mp_type_module) { c = 'M'; }
733-
else { c = 'h'; }
733+
else {
734+
c = 'h';
735+
#if 0
736+
// This code prints "Q" for qstr-pool data, and "q" for qstr-str
737+
// data. It can be useful to see how qstrs are being allocated,
738+
// but is disabled by default because it is very slow.
739+
for (qstr_pool_t *pool = MP_STATE_VM(last_pool); c == 'h' && pool != NULL; pool = pool->prev) {
740+
if ((qstr_pool_t*)ptr == pool) {
741+
c = 'Q';
742+
break;
743+
}
744+
for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) {
745+
if ((const byte*)ptr == *q) {
746+
c = 'q';
747+
break;
748+
}
749+
}
750+
}
751+
#endif
752+
}
734753
break;
735754
}
736755
case AT_TAIL: c = 't'; break;

0 commit comments

Comments
 (0)