vm: give factorbug a help command
Also change the prompt to "> _" instead of "READY\n_" since it's not 1970 anymoredb4
parent
2d5360778f
commit
23208e5697
36
vm/debug.cpp
36
vm/debug.cpp
|
@ -343,22 +343,18 @@ void factor_vm::dump_code_heap()
|
||||||
std::cout << printer.parameter_size << " bytes used by parameter tables" << std::endl;
|
std::cout << printer.parameter_size << " bytes used by parameter tables" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::factorbug()
|
void factor_vm::factorbug_usage()
|
||||||
{
|
{
|
||||||
if(fep_disabled)
|
|
||||||
{
|
|
||||||
std::cout << "Low level debugger disabled" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fep_p = true;
|
|
||||||
|
|
||||||
std::cout << "Starting low level debugger..." << std::endl;
|
|
||||||
std::cout << "Basic commands:" << std::endl;
|
std::cout << "Basic commands:" << std::endl;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
std::cout << " q ^Z -- quit Factor" << std::endl;
|
||||||
|
#else
|
||||||
std::cout << " q ^D -- quit Factor" << std::endl;
|
std::cout << " q ^D -- quit Factor" << std::endl;
|
||||||
|
#endif
|
||||||
std::cout << " c -- continue executing Factor - NOT SAFE" << std::endl;
|
std::cout << " c -- continue executing Factor - NOT SAFE" << std::endl;
|
||||||
std::cout << " t -- throw exception in Factor - NOT SAFE" << std::endl;
|
std::cout << " t -- throw exception in Factor - NOT SAFE" << std::endl;
|
||||||
std::cout << " .s .r .c -- print data, retain, call stacks" << std::endl;
|
std::cout << " .s .r .c -- print data, retain, call stacks" << std::endl;
|
||||||
|
std::cout << " help -- reprint this message" << std::endl;
|
||||||
std::cout << "Advanced commands:" << std::endl;
|
std::cout << "Advanced commands:" << std::endl;
|
||||||
std::cout << " e -- dump environment" << std::endl;
|
std::cout << " e -- dump environment" << std::endl;
|
||||||
std::cout << " d <addr> <count> -- dump memory" << std::endl;
|
std::cout << " d <addr> <count> -- dump memory" << std::endl;
|
||||||
|
@ -374,15 +370,29 @@ void factor_vm::factorbug()
|
||||||
std::cout << " push <addr> -- push object on data stack - NOT SAFE" << std::endl;
|
std::cout << " push <addr> -- push object on data stack - NOT SAFE" << std::endl;
|
||||||
std::cout << " gc -- trigger full GC - NOT SAFE" << std::endl;
|
std::cout << " gc -- trigger full GC - NOT SAFE" << std::endl;
|
||||||
std::cout << " code -- code heap dump" << std::endl;
|
std::cout << " code -- code heap dump" << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void factor_vm::factorbug()
|
||||||
|
{
|
||||||
|
if(fep_disabled)
|
||||||
|
{
|
||||||
|
std::cout << "Low level debugger disabled" << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fep_p = true;
|
||||||
|
|
||||||
|
std::cout << "Starting low level debugger..." << std::endl;
|
||||||
|
factorbug_usage();
|
||||||
bool seen_command = false;
|
bool seen_command = false;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
|
|
||||||
std::cout << "READY" << std::endl;
|
std::cout << "> " << std::flush;
|
||||||
std::cout.flush();
|
|
||||||
|
|
||||||
std::cin >> std::setw(1024) >> cmd >> std::setw(0);
|
std::cin >> std::setw(1024) >> cmd >> std::setw(0);
|
||||||
if(!std::cin.good())
|
if(!std::cin.good())
|
||||||
|
@ -481,6 +491,8 @@ void factor_vm::factorbug()
|
||||||
dump_code_heap();
|
dump_code_heap();
|
||||||
else if(strcmp(cmd,"gc") == 0)
|
else if(strcmp(cmd,"gc") == 0)
|
||||||
primitive_full_gc();
|
primitive_full_gc();
|
||||||
|
else if(strcmp(cmd,"help") == 0)
|
||||||
|
factorbug_usage();
|
||||||
else
|
else
|
||||||
std::cout << "unknown command" << std::endl;
|
std::cout << "unknown command" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,7 @@ struct factor_vm
|
||||||
void find_data_references_step(cell *scan);
|
void find_data_references_step(cell *scan);
|
||||||
void find_data_references(cell look_for_);
|
void find_data_references(cell look_for_);
|
||||||
void dump_code_heap();
|
void dump_code_heap();
|
||||||
|
void factorbug_usage();
|
||||||
void factorbug();
|
void factorbug();
|
||||||
void primitive_die();
|
void primitive_die();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue