Code heap debugging in FEP

slava 2006-09-28 00:53:54 +00:00
parent 06feb8ca68
commit 25e8988b86
3 changed files with 34 additions and 2 deletions

View File

@ -126,7 +126,7 @@ void free_unmarked(HEAP *heap)
if(scan->status == B_ALLOCATED)
{
/* merge blocks? */
if(next_block(heap,prev) == scan)
if(prev && next_block(heap,prev) == scan)
prev->size += scan->size;
else
{
@ -241,3 +241,32 @@ void primitive_code_gc(void)
{
garbage_collection(TENURED,true);
}
void dump_heap(HEAP *heap)
{
F_BLOCK *scan = (F_BLOCK *)heap->base;
while(scan)
{
char *status;
switch(scan->status)
{
case B_FREE:
status = "free";
break;
case B_ALLOCATED:
status = "allocated";
break;
case B_MARKED:
status = "marked";
break;
default:
status = "invalid";
break;
}
fprintf(stderr,"%lx %s\n",(CELL)scan,status);
scan = next_block(heap,scan);
}
}

View File

@ -77,3 +77,4 @@ void collect_literals(void);
void recursive_mark(CELL xt);
void primitive_code_room(void);
void primitive_code_gc(void);
void dump_heap(HEAP *heap);

View File

@ -165,7 +165,7 @@ void factorbug(void)
fprintf(stderr,"g -- dump generations\n");
fprintf(stderr,"card <addr> -- print card containing address\n");
fprintf(stderr,"addr <card> -- print address containing card\n");
fprintf(stderr,"c <gen> -- force garbage collection\n");
fprintf(stderr,"code -- code heap dump\n");
for(;;)
{
@ -243,6 +243,8 @@ void factorbug(void)
exit(1);
else if(strcmp(cmd,"im") == 0)
save_image("fep.image");
else if(strcmp(cmd,"code") == 0)
dump_heap(&compiling);
else
fprintf(stderr,"unknown command\n");
}