File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -696,6 +696,34 @@ void gc_dump_alloc_table(void) {
696696 switch (ATB_GET_KIND (bl )) {
697697 case AT_FREE : c = '.' ; break ;
698698 case AT_HEAD : c = 'h' ; break ;
699+ /* this prints out if the object is reachable from BSS or STACK (for unix only)
700+ case AT_HEAD: {
701+ extern char __bss_start, _end;
702+ extern char *stack_top;
703+ c = 'h';
704+ void **ptrs = (void**)&__bss_start;
705+ mp_uint_t len = ((mp_uint_t)&_end - (mp_uint_t)&__bss_start) / sizeof(mp_uint_t);
706+ for (mp_uint_t i = 0; i < len; i++) {
707+ mp_uint_t ptr = (mp_uint_t)ptrs[i];
708+ if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
709+ c = 'B';
710+ break;
711+ }
712+ }
713+ if (c == 'h') {
714+ ptrs = (void**)&c;
715+ len = ((mp_uint_t)stack_top - (mp_uint_t)&c) / sizeof(mp_uint_t);
716+ for (mp_uint_t i = 0; i < len; i++) {
717+ mp_uint_t ptr = (mp_uint_t)ptrs[i];
718+ if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
719+ c = 'S';
720+ break;
721+ }
722+ }
723+ }
724+ break;
725+ }
726+ */
699727 /* this prints the uPy object type of the head block
700728 case AT_HEAD: {
701729 mp_uint_t *ptr = gc_pool_start + bl * WORDS_PER_BLOCK;
You can’t perform that action at this time.
0 commit comments