VM: Refactor debug.cpp to Factor style

db4
Erik Charlebois 2013-05-11 21:57:14 -04:00
parent 7a05bf1993
commit 6955dd8565
1 changed files with 461 additions and 522 deletions

View File

@ -1,51 +1,42 @@
#include "master.hpp" #include "master.hpp"
namespace factor namespace factor {
{
std::ostream &operator<<(std::ostream &out, const string *str) std::ostream& operator<<(std::ostream& out, const string* str) {
{
for (cell i = 0; i < string_capacity(str); i++) for (cell i = 0; i < string_capacity(str); i++)
out << (char) str->data()[i]; out << (char) str->data()[i];
return out; return out;
} }
void factor_vm::print_word(word *word, cell nesting) void factor_vm::print_word(word* word, cell nesting) {
{
if (tagged<object>(word->vocabulary).type_p(STRING_TYPE)) if (tagged<object>(word->vocabulary).type_p(STRING_TYPE))
std::cout << untag<string>(word->vocabulary) << ":"; std::cout << untag<string>(word->vocabulary) << ":";
if (tagged<object>(word->name).type_p(STRING_TYPE)) if (tagged<object>(word->name).type_p(STRING_TYPE))
std::cout << untag<string>(word->name); std::cout << untag<string>(word->name);
else else {
{
std::cout << "#<not a string: "; std::cout << "#<not a string: ";
print_nested_obj(word->name, nesting); print_nested_obj(word->name, nesting);
std::cout << ">"; std::cout << ">";
} }
} }
void factor_vm::print_factor_string(string *str) void factor_vm::print_factor_string(string* str) {
{
std::cout << '"' << str << '"'; std::cout << '"' << str << '"';
} }
void factor_vm::print_array(array *array, cell nesting) void factor_vm::print_array(array* array, cell nesting) {
{
cell length = array_capacity(array); cell length = array_capacity(array);
cell i; cell i;
bool trimmed; bool trimmed;
if(length > 10 && !full_output) if (length > 10 && !full_output) {
{
trimmed = true; trimmed = true;
length = 10; length = 10;
} } else
else
trimmed = false; trimmed = false;
for(i = 0; i < length; i++) for (i = 0; i < length; i++) {
{
std::cout << " "; std::cout << " ";
print_nested_obj(array_nth(array, i), nesting); print_nested_obj(array_nth(array, i), nesting);
} }
@ -54,39 +45,31 @@ void factor_vm::print_array(array *array, cell nesting)
std::cout << "..."; std::cout << "...";
} }
void factor_vm::print_alien(alien *alien, cell nesting) void factor_vm::print_alien(alien* alien, cell nesting) {
{
if (to_boolean(alien->expired)) if (to_boolean(alien->expired))
std::cout << "#<expired alien>"; std::cout << "#<expired alien>";
else if (to_boolean(alien->base)) else if (to_boolean(alien->base)) {
{
std::cout << "#<displaced alien " << alien->displacement << "+"; std::cout << "#<displaced alien " << alien->displacement << "+";
print_nested_obj(alien->base, nesting); print_nested_obj(alien->base, nesting);
std::cout << ">"; std::cout << ">";
} } else {
else
{
std::cout << "#<alien " << (void*)alien->address << ">"; std::cout << "#<alien " << (void*)alien->address << ">";
} }
} }
void factor_vm::print_byte_array(byte_array *array, cell nesting) void factor_vm::print_byte_array(byte_array* array, cell nesting) {
{
cell length = array->capacity; cell length = array->capacity;
cell i; cell i;
bool trimmed; bool trimmed;
unsigned char* data = array->data<unsigned char>(); unsigned char* data = array->data<unsigned char>();
if(length > 16 && !full_output) if (length > 16 && !full_output) {
{
trimmed = true; trimmed = true;
length = 16; length = 16;
} } else
else
trimmed = false; trimmed = false;
for(i = 0; i < length; i++) for (i = 0; i < length; i++) {
{
std::cout << " " << (unsigned) data[i]; std::cout << " " << (unsigned) data[i];
} }
@ -94,8 +77,7 @@ void factor_vm::print_byte_array(byte_array *array, cell nesting)
std::cout << "..."; std::cout << "...";
} }
void factor_vm::print_tuple(tuple *tuple, cell nesting) void factor_vm::print_tuple(tuple* tuple, cell nesting) {
{
tuple_layout* layout = untag<tuple_layout>(tuple->layout); tuple_layout* layout = untag<tuple_layout>(tuple->layout);
cell length = to_fixnum(layout->size); cell length = to_fixnum(layout->size);
@ -103,16 +85,13 @@ void factor_vm::print_tuple(tuple *tuple, cell nesting)
print_nested_obj(layout->klass, nesting); print_nested_obj(layout->klass, nesting);
bool trimmed; bool trimmed;
if(length > 10 && !full_output) if (length > 10 && !full_output) {
{
trimmed = true; trimmed = true;
length = 10; length = 10;
} } else
else
trimmed = false; trimmed = false;
for(cell i = 0; i < length; i++) for (cell i = 0; i < length; i++) {
{
std::cout << " "; std::cout << " ";
print_nested_obj(tuple->data()[i], nesting); print_nested_obj(tuple->data()[i], nesting);
} }
@ -121,18 +100,15 @@ void factor_vm::print_tuple(tuple *tuple, cell nesting)
std::cout << "..."; std::cout << "...";
} }
void factor_vm::print_nested_obj(cell obj, fixnum nesting) void factor_vm::print_nested_obj(cell obj, fixnum nesting) {
{ if (nesting <= 0 && !full_output) {
if(nesting <= 0 && !full_output)
{
std::cout << " ... "; std::cout << " ... ";
return; return;
} }
quotation* quot; quotation* quot;
switch(tagged<object>(obj).type()) switch (tagged<object>(obj).type()) {
{
case FIXNUM_TYPE: case FIXNUM_TYPE:
std::cout << untag_fixnum(obj); std::cout << untag_fixnum(obj);
break; break;
@ -185,22 +161,16 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting)
std::cout << std::flush; std::cout << std::flush;
} }
void factor_vm::print_obj(cell obj) void factor_vm::print_obj(cell obj) { print_nested_obj(obj, 10); }
{
print_nested_obj(obj,10);
}
void factor_vm::print_objects(cell *start, cell *end) void factor_vm::print_objects(cell* start, cell* end) {
{ for (; start <= end; start++) {
for(; start <= end; start++)
{
print_obj(*start); print_obj(*start);
std::cout << std::endl; std::cout << std::endl;
} }
} }
void factor_vm::print_datastack() void factor_vm::print_datastack() {
{
std::cout << "==== DATA STACK:" << std::endl; std::cout << "==== DATA STACK:" << std::endl;
if (ctx) if (ctx)
print_objects((cell*)ctx->datastack_seg->start, (cell*)ctx->datastack); print_objects((cell*)ctx->datastack_seg->start, (cell*)ctx->datastack);
@ -208,8 +178,7 @@ void factor_vm::print_datastack()
std::cout << "*** Context not initialized" << std::endl; std::cout << "*** Context not initialized" << std::endl;
} }
void factor_vm::print_retainstack() void factor_vm::print_retainstack() {
{
std::cout << "==== RETAIN STACK:" << std::endl; std::cout << "==== RETAIN STACK:" << std::endl;
if (ctx) if (ctx)
print_objects((cell*)ctx->retainstack_seg->start, (cell*)ctx->retainstack); print_objects((cell*)ctx->retainstack_seg->start, (cell*)ctx->retainstack);
@ -221,8 +190,8 @@ struct stack_frame_printer {
factor_vm* parent; factor_vm* parent;
explicit stack_frame_printer(factor_vm* parent_) : parent(parent_) {} explicit stack_frame_printer(factor_vm* parent_) : parent(parent_) {}
void operator()(void *frame_top, cell frame_size, code_block *owner, void *addr) void operator()(void* frame_top, cell frame_size, code_block* owner,
{ void* addr) {
std::cout << std::endl; std::cout << std::endl;
std::cout << "frame: " << frame_top << " size " << frame_size << std::endl; std::cout << "frame: " << frame_top << " size " << frame_size << std::endl;
std::cout << "executing: "; std::cout << "executing: ";
@ -243,20 +212,16 @@ struct stack_frame_printer {
} }
}; };
void factor_vm::print_callstack() void factor_vm::print_callstack() {
{
std::cout << "==== CALL STACK:" << std::endl; std::cout << "==== CALL STACK:" << std::endl;
if (ctx) if (ctx) {
{
stack_frame_printer printer(this); stack_frame_printer printer(this);
iterate_callstack(ctx, printer); iterate_callstack(ctx, printer);
} } else
else
std::cout << "*** Context not initialized" << std::endl; std::cout << "*** Context not initialized" << std::endl;
} }
void factor_vm::print_callstack_object(callstack *obj) void factor_vm::print_callstack_object(callstack* obj) {
{
stack_frame_printer printer(this); stack_frame_printer printer(this);
iterate_callstack_object(obj, printer); iterate_callstack_object(obj, printer);
} }
@ -267,8 +232,7 @@ struct padded_address {
explicit padded_address(cell value_) : value(value_) {} explicit padded_address(cell value_) : value(value_) {}
}; };
std::ostream &operator<<(std::ostream &out, const padded_address &value) std::ostream& operator<<(std::ostream& out, const padded_address& value) {
{
char prev = out.fill('0'); char prev = out.fill('0');
out.width(sizeof(cell) * 2); out.width(sizeof(cell) * 2);
out << std::hex << value.value << std::dec; out << std::hex << value.value << std::dec;
@ -276,15 +240,13 @@ std::ostream &operator<<(std::ostream &out, const padded_address &value)
return out; return out;
} }
void factor_vm::dump_cell(cell x) void factor_vm::dump_cell(cell x) {
{
std::cout << padded_address(x) << ": "; std::cout << padded_address(x) << ": ";
x = *(cell*)x; x = *(cell*)x;
std::cout << padded_address(x) << " tag " << TAG(x) << std::endl; std::cout << padded_address(x) << " tag " << TAG(x) << std::endl;
} }
void factor_vm::dump_memory(cell from, cell to) void factor_vm::dump_memory(cell from, cell to) {
{
from = UNTAG(from); from = UNTAG(from);
for (; from <= to; from += sizeof(cell)) for (; from <= to; from += sizeof(cell))
@ -292,8 +254,7 @@ void factor_vm::dump_memory(cell from, cell to)
} }
template <typename Generation> template <typename Generation>
void factor_vm::dump_generation(const char *name, Generation *gen) void factor_vm::dump_generation(const char* name, Generation* gen) {
{
std::cout << name << ": "; std::cout << name << ": ";
std::cout << "Start=" << gen->start; std::cout << "Start=" << gen->start;
std::cout << ", size=" << gen->size; std::cout << ", size=" << gen->size;
@ -301,8 +262,7 @@ void factor_vm::dump_generation(const char *name, Generation *gen)
std::cout << std::endl; std::cout << std::endl;
} }
void factor_vm::dump_generations() void factor_vm::dump_generations() {
{
std::cout << std::hex; std::cout << std::hex;
dump_generation("Nursery", &nursery); dump_generation("Nursery", &nursery);
@ -320,13 +280,11 @@ struct object_dumper {
factor_vm* parent; factor_vm* parent;
cell type; cell type;
explicit object_dumper(factor_vm *parent_, cell type_) : explicit object_dumper(factor_vm* parent_, cell type_)
parent(parent_), type(type_) {} : parent(parent_), type(type_) {}
void operator()(object *obj) void operator()(object* obj) {
{ if (type == TYPE_COUNT || obj->type() == type) {
if(type == TYPE_COUNT || obj->type() == type)
{
std::cout << padded_address((cell) obj) << " "; std::cout << padded_address((cell) obj) << " ";
parent->print_nested_obj(tag_dynamic(obj), 2); parent->print_nested_obj(tag_dynamic(obj), 2);
std::cout << std::endl; std::cout << std::endl;
@ -334,8 +292,7 @@ struct object_dumper {
} }
}; };
void factor_vm::dump_objects(cell type) void factor_vm::dump_objects(cell type) {
{
primitive_full_gc(); primitive_full_gc();
object_dumper dumper(this, type); object_dumper dumper(this, type);
each_object(dumper); each_object(dumper);
@ -346,13 +303,12 @@ struct find_data_reference_slot_visitor {
object* obj; object* obj;
factor_vm* parent; factor_vm* parent;
explicit find_data_reference_slot_visitor(cell look_for_, object *obj_, factor_vm *parent_) : explicit find_data_reference_slot_visitor(cell look_for_, object* obj_,
look_for(look_for_), obj(obj_), parent(parent_) { } factor_vm* parent_)
: look_for(look_for_), obj(obj_), parent(parent_) {}
void operator()(cell *scan) void operator()(cell* scan) {
{ if (look_for == *scan) {
if(look_for == *scan)
{
std::cout << padded_address((cell) obj) << " "; std::cout << padded_address((cell) obj) << " ";
parent->print_nested_obj(tag_dynamic(obj), 2); parent->print_nested_obj(tag_dynamic(obj), 2);
std::cout << std::endl; std::cout << std::endl;
@ -364,39 +320,36 @@ struct dump_edges_slot_visitor {
object* obj; object* obj;
factor_vm* parent; factor_vm* parent;
explicit dump_edges_slot_visitor(cell, object *obj_, factor_vm *parent_) : explicit dump_edges_slot_visitor(cell, object* obj_, factor_vm* parent_)
obj(obj_), parent(parent_) { } : obj(obj_), parent(parent_) {}
void operator()(cell *scan) void operator()(cell* scan) {
{
if (TAG(*scan) > F_TYPE) if (TAG(*scan) > F_TYPE)
std::cout << (void*)tag_dynamic(obj) << " ==> " << (void*)*scan << std::endl; std::cout << (void*)tag_dynamic(obj) << " ==> " << (void*)*scan
<< std::endl;
} }
}; };
template <typename SlotVisitor> template <typename SlotVisitor> struct data_reference_object_visitor {
struct data_reference_object_visitor {
cell look_for; cell look_for;
factor_vm* parent; factor_vm* parent;
explicit data_reference_object_visitor(cell look_for_, factor_vm *parent_) : explicit data_reference_object_visitor(cell look_for_, factor_vm* parent_)
look_for(look_for_), parent(parent_) {} : look_for(look_for_), parent(parent_) {}
void operator()(object *obj) void operator()(object* obj) {
{
SlotVisitor visitor(look_for, obj, parent); SlotVisitor visitor(look_for, obj, parent);
obj->each_slot(visitor); obj->each_slot(visitor);
} }
}; };
void factor_vm::find_data_references(cell look_for) void factor_vm::find_data_references(cell look_for) {
{ data_reference_object_visitor<find_data_reference_slot_visitor> visitor(
data_reference_object_visitor<find_data_reference_slot_visitor> visitor(look_for,this); look_for, this);
each_object(visitor); each_object(visitor);
} }
void factor_vm::dump_edges() void factor_vm::dump_edges() {
{
data_reference_object_visitor<dump_edges_slot_visitor> visitor(0, this); data_reference_object_visitor<dump_edges_slot_visitor> visitor(0, this);
each_object(visitor); each_object(visitor);
} }
@ -405,16 +358,14 @@ struct code_block_printer {
factor_vm* parent; factor_vm* parent;
cell reloc_size, parameter_size; cell reloc_size, parameter_size;
explicit code_block_printer(factor_vm *parent_) : explicit code_block_printer(factor_vm* parent_)
parent(parent_), reloc_size(0), parameter_size(0) {} : parent(parent_), reloc_size(0), parameter_size(0) {}
void operator()(code_block *scan, cell size) void operator()(code_block* scan, cell size) {
{
const char* status; const char* status;
if (scan->free_p()) if (scan->free_p())
status = "free"; status = "free";
else else {
{
reloc_size += parent->object_size(scan->relocation); reloc_size += parent->object_size(scan->relocation);
parameter_size += parent->object_size(scan->parameters); parameter_size += parent->object_size(scan->parameters);
@ -433,68 +384,73 @@ struct code_block_printer {
}; };
/* Dump all code blocks for debugging */ /* Dump all code blocks for debugging */
void factor_vm::dump_code_heap() void factor_vm::dump_code_heap() {
{
code_block_printer printer(this); code_block_printer printer(this);
code->allocator->iterate(printer); code->allocator->iterate(printer);
std::cout << printer.reloc_size << " bytes used by relocation tables" << std::endl; std::cout << printer.reloc_size << " bytes used by relocation tables"
std::cout << printer.parameter_size << " bytes used by parameter tables" << std::endl; << std::endl;
std::cout << printer.parameter_size << " bytes used by parameter tables"
<< std::endl;
} }
void factor_vm::factorbug_usage(bool advanced_p) void factor_vm::factorbug_usage(bool advanced_p) {
{
std::cout << "Basic commands:" << std::endl; std::cout << "Basic commands:" << std::endl;
#ifdef WINDOWS #ifdef WINDOWS
std::cout << " q ^Z -- quit Factor" << std::endl; std::cout << " q ^Z -- quit Factor" << std::endl;
#else #else
std::cout << " q ^D -- quit Factor" << std::endl; std::cout << " q ^D -- quit Factor" << std::endl;
#endif #endif
std::cout << " c -- continue executing Factor - NOT SAFE" << std::endl; std::cout << " c -- continue executing Factor - NOT SAFE"
std::cout << " t -- throw exception in Factor - NOT SAFE" << std::endl; << std::endl;
std::cout << " .s .r .c -- print data, retain, call stacks" << std::endl; std::cout << " t -- throw exception in Factor - NOT SAFE"
if (advanced_p) << std::endl;
{ std::cout << " .s .r .c -- print data, retain, call stacks"
<< std::endl;
if (advanced_p) {
std::cout << " help -- reprint this message" << 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;
std::cout << " u <addr> -- dump object at tagged <addr>" << std::endl; std::cout << " u <addr> -- dump object at tagged <addr>"
std::cout << " . <addr> -- print object at tagged <addr>" << std::endl; << std::endl;
std::cout << " . <addr> -- print object at tagged <addr>"
<< std::endl;
std::cout << " g -- dump generations" << std::endl; std::cout << " g -- dump generations" << std::endl;
std::cout << " ds dr -- dump data, retain stacks" << std::endl; std::cout << " ds dr -- dump data, retain stacks" << std::endl;
std::cout << " trim -- toggle output trimming" << std::endl; std::cout << " trim -- toggle output trimming" << std::endl;
std::cout << " data -- data heap dump" << std::endl; std::cout << " data -- data heap dump" << std::endl;
std::cout << " words -- words dump" << std::endl; std::cout << " words -- words dump" << std::endl;
std::cout << " tuples -- tuples dump" << std::endl; std::cout << " tuples -- tuples dump" << std::endl;
std::cout << " edges -- print all object-to-object references" << std::endl; std::cout << " edges -- print all object-to-object references"
std::cout << " refs <addr> -- find data heap references to object" << std::endl; << std::endl;
std::cout << " push <addr> -- push object on data stack - NOT SAFE" << std::endl; std::cout << " refs <addr> -- find data heap references to object"
std::cout << " gc -- trigger full GC - NOT SAFE" << std::endl; << std::endl;
std::cout << " compact-gc -- trigger compacting GC - 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 << " compact-gc -- trigger compacting GC - NOT SAFE"
<< std::endl;
std::cout << " code -- code heap dump" << std::endl; std::cout << " code -- code heap dump" << std::endl;
std::cout << " abort -- call abort()" << std::endl; std::cout << " abort -- call abort()" << std::endl;
std::cout << " breakpoint -- trigger system breakpoint" << std::endl; std::cout << " breakpoint -- trigger system breakpoint" << std::endl;
} } else {
else std::cout << " help -- full help, including advanced commands"
{ << std::endl;
std::cout << " help -- full help, including advanced commands" << std::endl;
} }
std::cout << std::endl; std::cout << std::endl;
} }
static void exit_fep(factor_vm *vm) static void exit_fep(factor_vm* vm) {
{
vm->unlock_console(); vm->unlock_console();
vm->handle_ctrl_c(); vm->handle_ctrl_c();
vm->fep_p = false; vm->fep_p = false;
} }
void factor_vm::factorbug() void factor_vm::factorbug() {
{ if (fep_disabled) {
if(fep_disabled)
{
std::cout << "Low level debugger disabled" << std::endl; std::cout << "Low level debugger disabled" << std::endl;
exit(1); exit(1);
} }
@ -518,17 +474,14 @@ void factor_vm::factorbug()
} }
bool seen_command = false; bool seen_command = false;
for(;;) for (;;) {
{
char cmd[1024]; char cmd[1024];
std::cout << "> " << std::flush; std::cout << "> " << std::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()) {
{ if (!seen_command) {
if(!seen_command)
{
/* If we exit with an EOF immediately, then /* If we exit with an EOF immediately, then
dump stacks. This is useful for builder and dump stacks. This is useful for builder and
other cases where Factor is run with stdin other cases where Factor is run with stdin
@ -547,29 +500,24 @@ void factor_vm::factorbug()
if (strcmp(cmd, "q") == 0) if (strcmp(cmd, "q") == 0)
exit(1); exit(1);
if(strcmp(cmd,"d") == 0) if (strcmp(cmd, "d") == 0) {
{
cell addr = read_cell_hex(); cell addr = read_cell_hex();
if (std::cin.peek() == ' ') if (std::cin.peek() == ' ')
std::cin.ignore(); std::cin.ignore();
if(!std::cin.good()) break; if (!std::cin.good())
break;
cell count = read_cell_hex(); cell count = read_cell_hex();
dump_memory(addr, addr + count); dump_memory(addr, addr + count);
} } else if (strcmp(cmd, "u") == 0) {
else if(strcmp(cmd,"u") == 0)
{
cell addr = read_cell_hex(); cell addr = read_cell_hex();
cell count = object_size(addr); cell count = object_size(addr);
dump_memory(addr, addr + count); dump_memory(addr, addr + count);
} } else if (strcmp(cmd, ".") == 0) {
else if(strcmp(cmd,".") == 0)
{
cell addr = read_cell_hex(); cell addr = read_cell_hex();
print_obj(addr); print_obj(addr);
std::cout << std::endl; std::cout << std::endl;
} } else if (strcmp(cmd, "trim") == 0)
else if(strcmp(cmd,"trim") == 0)
full_output = !full_output; full_output = !full_output;
else if (strcmp(cmd, "ds") == 0) else if (strcmp(cmd, "ds") == 0)
dump_memory(ctx->datastack_seg->start, ctx->datastack); dump_memory(ctx->datastack_seg->start, ctx->datastack);
@ -581,45 +529,35 @@ void factor_vm::factorbug()
print_retainstack(); print_retainstack();
else if (strcmp(cmd, ".c") == 0) else if (strcmp(cmd, ".c") == 0)
print_callstack(); print_callstack();
else if(strcmp(cmd,"e") == 0) else if (strcmp(cmd, "e") == 0) {
{
for (cell i = 0; i < special_object_count; i++) for (cell i = 0; i < special_object_count; i++)
dump_cell((cell) & special_objects[i]); dump_cell((cell) & special_objects[i]);
} } else if (strcmp(cmd, "g") == 0)
else if(strcmp(cmd,"g") == 0)
dump_generations(); dump_generations();
else if(strcmp(cmd,"c") == 0) else if (strcmp(cmd, "c") == 0) {
{
exit_fep(this); exit_fep(this);
return; return;
} } else if (strcmp(cmd, "t") == 0) {
else if(strcmp(cmd,"t") == 0)
{
exit_fep(this); exit_fep(this);
general_error(ERROR_INTERRUPT, false_object, false_object); general_error(ERROR_INTERRUPT, false_object, false_object);
FACTOR_ASSERT(false); FACTOR_ASSERT(false);
} } else if (strcmp(cmd, "data") == 0)
else if(strcmp(cmd,"data") == 0)
dump_objects(TYPE_COUNT); dump_objects(TYPE_COUNT);
else if (strcmp(cmd, "edges") == 0) else if (strcmp(cmd, "edges") == 0)
dump_edges(); dump_edges();
else if(strcmp(cmd,"refs") == 0) else if (strcmp(cmd, "refs") == 0) {
{
cell addr = read_cell_hex(); cell addr = read_cell_hex();
std::cout << "Data heap references:" << std::endl; std::cout << "Data heap references:" << std::endl;
find_data_references(addr); find_data_references(addr);
std::cout << std::endl; std::cout << std::endl;
} } else if (strcmp(cmd, "words") == 0)
else if(strcmp(cmd,"words") == 0)
dump_objects(WORD_TYPE); dump_objects(WORD_TYPE);
else if (strcmp(cmd, "tuples") == 0) else if (strcmp(cmd, "tuples") == 0)
dump_objects(TUPLE_TYPE); dump_objects(TUPLE_TYPE);
else if(strcmp(cmd,"push") == 0) else if (strcmp(cmd, "push") == 0) {
{
cell addr = read_cell_hex(); cell addr = read_cell_hex();
ctx->push(addr); ctx->push(addr);
} } else if (strcmp(cmd, "code") == 0)
else if(strcmp(cmd,"code") == 0)
dump_code_heap(); dump_code_heap();
else if (strcmp(cmd, "compact-gc") == 0) else if (strcmp(cmd, "compact-gc") == 0)
primitive_compact_gc(); primitive_compact_gc();
@ -638,10 +576,11 @@ void factor_vm::factorbug()
} }
} }
void factor_vm::primitive_die() void factor_vm::primitive_die() {
{ std::cout << "The die word was called by the library. Unless you called it "
std::cout << "The die word was called by the library. Unless you called it yourself," << std::endl; "yourself," << std::endl;
std::cout << "you have triggered a bug in Factor. Please report." << std::endl; std::cout << "you have triggered a bug in Factor. Please report."
<< std::endl;
factorbug(); factorbug();
} }