dump_cell(out, from);
}
-template <typename Generation>
-void factor_vm::dump_generation(ostream& out, const char* name, Generation* gen) {
- out << name << ": ";
- out << "Start=" << gen->start;
- out << ", size=" << gen->size;
- out << ", end=" << gen->end;
- out << endl;
+void dump_memory_range(ostream& out, const char* name, cell name_w,
+ cell start, cell end) {
+ out << setw(name_w) << left << name << ": ";
+
+ out << "[" << (void*)start << " -> " << (void*)end << "] ";
+ out << setw(10) << right << (end - start) << " bytes" << endl;
}
-void factor_vm::dump_generations(ostream& out) {
- out << hex;
+template <typename Generation>
+void dump_generation(ostream& out, const char* name, Generation* gen) {
+ dump_memory_range(out, name, 10, gen->start, gen->end);
+}
- dump_generation(out, "Nursery", &nursery);
+void factor_vm::dump_memory_layout(ostream& out) {
+ dump_generation(out, "Nursery", data->nursery);
dump_generation(out, "Aging", data->aging);
dump_generation(out, "Tenured", data->tenured);
-
- out << "Cards:";
- out << "base=" << (cell)data->cards << ", ";
- out << "size=" << (cell)(data->cards_end - data->cards) << endl;
- out << dec;
+ dump_memory_range(out, "Cards", 10, (cell)data->cards, (cell)data->cards_end);
+
+ out << endl << "Contexts:" << endl << endl;
+ FACTOR_FOR_EACH(active_contexts) {
+ context* the_ctx = *iter;
+ segment* ds = the_ctx->datastack_seg;
+ segment* rs = the_ctx->retainstack_seg;
+ segment* cs = the_ctx->callstack_seg;
+ if (the_ctx == ctx) {
+ out << " Active:" << endl;
+ }
+ dump_memory_range(out, " Datastack", 14, ds->start, ds->end);
+ dump_memory_range(out, " Retainstack", 14, rs->start, rs->end);
+ dump_memory_range(out, " Callstack", 14, cs->start, cs->end);
+ out << endl;
+ }
}
void factor_vm::dump_objects(ostream& out, cell type) {
<< endl;
cout << " . <addr> -- print object at tagged <addr>"
<< endl;
- cout << " g -- dump generations" << endl;
+ cout << " g -- dump memory layout" << endl;
cout << " ds dr -- dump data, retain stacks" << endl;
cout << " trim -- toggle output trimming" << endl;
cout << " data -- data heap dump" << endl;
for (cell i = 0; i < special_object_count; i++)
dump_cell(cout, (cell)&special_objects[i]);
} else if (cmd == "g")
- dump_generations(cout);
+ dump_memory_layout(cout);
else if (cmd == "c") {
exit_fep(this);
return;
}
void factor_vm::primitive_die() {
- cout << "The die word was called by the library. Unless you called it "
- "yourself," << endl;
- cout << "you have triggered a bug in Factor. Please report."
- << endl;
- factorbug();
+ critical_error("The die word was called by the library.", 0);
}
}
void print_callstack_object(ostream& out, callstack* obj);
void dump_cell(ostream& out, cell x);
void dump_memory(ostream& out, cell from, cell to);
- template <typename Generation>
- void dump_generation(ostream& out, const char* name, Generation* gen);
- void dump_generations(ostream& out);
+ void dump_memory_layout(ostream& out);
void dump_objects(ostream& out, cell type);
void dump_edges(ostream& out);
void find_data_references(ostream& out, cell look_for_);