summaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-17 14:12:57 +0000
committerDamien George <damien.p.george@gmail.com>2014-10-17 14:12:57 +0000
commitc30595eb1b8245da4ce1b9e9c32cb238bcf899de (patch)
treee685e60724b986c04d7f935aec3ac6cb99381837 /py/gc.c
parent090c9236e8b1c213dd147fc46dabd8106cd421ad (diff)
py: Add more debug printing code in gc_dump_alloc_table.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index f808eef33..68b70ba18 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -696,6 +696,34 @@ void gc_dump_alloc_table(void) {
switch (ATB_GET_KIND(bl)) {
case AT_FREE: c = '.'; break;
case AT_HEAD: c = 'h'; break;
+ /* this prints out if the object is reachable from BSS or STACK (for unix only)
+ case AT_HEAD: {
+ extern char __bss_start, _end;
+ extern char *stack_top;
+ c = 'h';
+ void **ptrs = (void**)&__bss_start;
+ mp_uint_t len = ((mp_uint_t)&_end - (mp_uint_t)&__bss_start) / sizeof(mp_uint_t);
+ for (mp_uint_t i = 0; i < len; i++) {
+ mp_uint_t ptr = (mp_uint_t)ptrs[i];
+ if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
+ c = 'B';
+ break;
+ }
+ }
+ if (c == 'h') {
+ ptrs = (void**)&c;
+ len = ((mp_uint_t)stack_top - (mp_uint_t)&c) / sizeof(mp_uint_t);
+ for (mp_uint_t i = 0; i < len; i++) {
+ mp_uint_t ptr = (mp_uint_t)ptrs[i];
+ if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
+ c = 'S';
+ break;
+ }
+ }
+ }
+ break;
+ }
+ */
/* this prints the uPy object type of the head block
case AT_HEAD: {
mp_uint_t *ptr = gc_pool_start + bl * WORDS_PER_BLOCK;