vm: add factorbug command to throw exception
Also rename "q" to "c" because it "c"ontinues, remove the useless "im" command, and rename the less useful "t" to "trim" so we can use "t" to mean "throw"db4
parent
a374c2da05
commit
b0b0905460
|
@ -134,11 +134,14 @@ HOOK: signal-error. os ( obj -- )
|
|||
: fp-trap-error. ( error -- )
|
||||
"Floating point trap" print drop ;
|
||||
|
||||
: interrupt-error. ( error -- )
|
||||
"Interrupt" print drop ;
|
||||
|
||||
PREDICATE: vm-error < array
|
||||
{
|
||||
{ [ dup empty? ] [ drop f ] }
|
||||
{ [ dup first "kernel-error" = not ] [ drop f ] }
|
||||
[ second 0 17 between? ]
|
||||
[ second 0 18 between? ]
|
||||
} cond ;
|
||||
|
||||
: vm-errors ( error -- n errors )
|
||||
|
@ -161,6 +164,7 @@ PREDICATE: vm-error < array
|
|||
{ 15 [ callstack-overflow. ] }
|
||||
{ 16 [ memory-error. ] }
|
||||
{ 17 [ fp-trap-error. ] }
|
||||
{ 18 [ interrupt-error. ] }
|
||||
} ; inline
|
||||
|
||||
M: vm-error summary drop "VM error" ;
|
||||
|
|
19
vm/debug.cpp
19
vm/debug.cpp
|
@ -351,23 +351,22 @@ void factor_vm::factorbug()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* open_console(); */
|
||||
fep_p = true;
|
||||
|
||||
std::cout << "Starting low level debugger...\n";
|
||||
std::cout << " Basic commands:\n";
|
||||
std::cout << "q -- continue executing Factor - NOT SAFE\n";
|
||||
std::cout << "im -- save image to fep.image\n";
|
||||
std::cout << "c -- continue executing Factor - NOT SAFE\n";
|
||||
std::cout << "t -- throw exception in Factor - NOT SAFE\n";
|
||||
std::cout << "x -- exit Factor\n";
|
||||
std::cout << " Advanced commands:\n";
|
||||
std::cout << "d <addr> <count> -- dump memory\n";
|
||||
std::cout << "u <addr> -- dump object at tagged <addr>\n";
|
||||
std::cout << ". <addr> -- print object at tagged <addr>\n";
|
||||
std::cout << "t -- toggle output trimming\n";
|
||||
std::cout << "s r -- dump data, retain stacks\n";
|
||||
std::cout << ".s .r .c -- print data, retain, call stacks\n";
|
||||
std::cout << "e -- dump environment\n";
|
||||
std::cout << "g -- dump generations\n";
|
||||
std::cout << "trim -- toggle output trimming\n";
|
||||
std::cout << "data -- data heap dump\n";
|
||||
std::cout << "words -- words dump\n";
|
||||
std::cout << "tuples -- tuples dump\n";
|
||||
|
@ -427,7 +426,7 @@ void factor_vm::factorbug()
|
|||
print_obj(addr);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
else if(strcmp(cmd,"t") == 0)
|
||||
else if(strcmp(cmd,"trim") == 0)
|
||||
full_output = !full_output;
|
||||
else if(strcmp(cmd,"s") == 0)
|
||||
dump_memory(ctx->datastack_seg->start,ctx->datastack);
|
||||
|
@ -446,15 +445,19 @@ void factor_vm::factorbug()
|
|||
}
|
||||
else if(strcmp(cmd,"g") == 0)
|
||||
dump_generations();
|
||||
else if(strcmp(cmd,"q") == 0)
|
||||
else if(strcmp(cmd,"q") == 0 || strcmp(cmd,"c") == 0)
|
||||
{
|
||||
fep_p = false;
|
||||
return;
|
||||
}
|
||||
else if(strcmp(cmd,"t") == 0)
|
||||
{
|
||||
fep_p = false;
|
||||
general_error(ERROR_INTERRUPT,false_object,false_object);
|
||||
assert(false);
|
||||
}
|
||||
else if(strcmp(cmd,"x") == 0)
|
||||
exit(1);
|
||||
else if(strcmp(cmd,"im") == 0)
|
||||
save_image(STRING_LITERAL("fep.image.saving"),STRING_LITERAL("fep.image"));
|
||||
else if(strcmp(cmd,"data") == 0)
|
||||
dump_objects(TYPE_COUNT);
|
||||
else if(strcmp(cmd,"refs") == 0)
|
||||
|
|
|
@ -182,10 +182,10 @@ void factor_vm::handle_safepoint()
|
|||
if (signal_from_leaf)
|
||||
std::cout << "XXX SIGNALED FROM LEAF\n";
|
||||
|
||||
code->unguard_safepoint();
|
||||
if (safepoint_fep) {
|
||||
std::cout << "Interrupted\n";
|
||||
factorbug();
|
||||
code->unguard_safepoint();
|
||||
safepoint_fep = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ enum vm_error_type
|
|||
ERROR_CALLSTACK_OVERFLOW,
|
||||
ERROR_MEMORY,
|
||||
ERROR_FP_TRAP,
|
||||
ERROR_INTERRUPT,
|
||||
};
|
||||
|
||||
void fatal_error(const char *msg, cell tagged);
|
||||
|
|
Loading…
Reference in New Issue