Skip to content

Commit 23208e5

Browse files
committed
vm: give factorbug a help command
Also change the prompt to "> _" instead of "READY\n_" since it's not 1970 anymore
1 parent 2d53607 commit 23208e5

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

vm/debug.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,22 +343,18 @@ void factor_vm::dump_code_heap()
343343
std::cout << printer.parameter_size << " bytes used by parameter tables" << std::endl;
344344
}
345345

346-
void factor_vm::factorbug()
346+
void factor_vm::factorbug_usage()
347347
{
348-
if(fep_disabled)
349-
{
350-
std::cout << "Low level debugger disabled" << std::endl;
351-
exit(1);
352-
}
353-
354-
fep_p = true;
355-
356-
std::cout << "Starting low level debugger..." << std::endl;
357348
std::cout << "Basic commands:" << std::endl;
349+
#ifdef WINDOWS
350+
std::cout << " q ^Z -- quit Factor" << std::endl;
351+
#else
358352
std::cout << " q ^D -- quit Factor" << std::endl;
353+
#endif
359354
std::cout << " c -- continue executing Factor - NOT SAFE" << std::endl;
360355
std::cout << " t -- throw exception in Factor - NOT SAFE" << std::endl;
361356
std::cout << " .s .r .c -- print data, retain, call stacks" << std::endl;
357+
std::cout << " help -- reprint this message" << std::endl;
362358
std::cout << "Advanced commands:" << std::endl;
363359
std::cout << " e -- dump environment" << std::endl;
364360
std::cout << " d <addr> <count> -- dump memory" << std::endl;
@@ -374,15 +370,29 @@ void factor_vm::factorbug()
374370
std::cout << " push <addr> -- push object on data stack - NOT SAFE" << std::endl;
375371
std::cout << " gc -- trigger full GC - NOT SAFE" << std::endl;
376372
std::cout << " code -- code heap dump" << std::endl;
373+
std::cout << std::endl;
374+
375+
}
376+
377+
void factor_vm::factorbug()
378+
{
379+
if(fep_disabled)
380+
{
381+
std::cout << "Low level debugger disabled" << std::endl;
382+
exit(1);
383+
}
377384

385+
fep_p = true;
386+
387+
std::cout << "Starting low level debugger..." << std::endl;
388+
factorbug_usage();
378389
bool seen_command = false;
379390

380391
for(;;)
381392
{
382393
char cmd[1024];
383394

384-
std::cout << "READY" << std::endl;
385-
std::cout.flush();
395+
std::cout << "> " << std::flush;
386396

387397
std::cin >> std::setw(1024) >> cmd >> std::setw(0);
388398
if(!std::cin.good())
@@ -481,6 +491,8 @@ void factor_vm::factorbug()
481491
dump_code_heap();
482492
else if(strcmp(cmd,"gc") == 0)
483493
primitive_full_gc();
494+
else if(strcmp(cmd,"help") == 0)
495+
factorbug_usage();
484496
else
485497
std::cout << "unknown command" << std::endl;
486498
}

vm/vm.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ struct factor_vm
383383
void find_data_references_step(cell *scan);
384384
void find_data_references(cell look_for_);
385385
void dump_code_heap();
386+
void factorbug_usage();
386387
void factorbug();
387388
void primitive_die();
388389

0 commit comments

Comments
 (0)