M new/include/viua/vm/ins.h => new/include/viua/vm/ins.h +1 -0
@@ 129,6 129,7 @@ auto execute(viua::vm::Stack&, viua::arch::instruction_type const* const)
auto print_backtrace(viua::vm::Stack const&,
std::optional<size_t> const = std::nullopt) -> void;
auto dump_registers(std::vector<Value> const&, std::string_view const) -> void;
+auto dump_memory(std::vector<std::array<uint8_t, Process::MEM_PAGE_SIZE>> const&) -> void;
} // namespace viua::vm::ins
#endif
M new/src/tools/exec/repl.cpp => new/src/tools/exec/repl.cpp +1 -0
@@ 549,6 549,7 @@ auto repl_eval(std::vector<std::string_view> const parts) -> bool
viua::vm::ins::dump_registers(frame.parameters, "p");
viua::vm::ins::dump_registers(frame.registers, "l");
viua::vm::ins::dump_registers(proc->stack.args, "a");
+ viua::vm::ins::dump_memory(proc->memory);
} else if (p(1).value_or("") == "ip") {
if (not REPL_STATE->selected_pid) {
std::cerr << esc(2, COLOR_FG_RED) << "error"
M new/src/vm/ins.cpp => new/src/vm/ins.cpp +22 -19
@@ 2025,28 2025,10 @@ auto print_backtrace(Stack const& stack, std::optional<size_t> const only_for)
}
}
}
-auto execute(EBREAK const, Stack& stack, ip_type const) -> void
+auto dump_memory(std::vector<std::array<uint8_t, Process::MEM_PAGE_SIZE>> const& memory) -> void
{
- viua::TRACE_STREAM << "begin ebreak in process "
- << stack.proc->pid.to_string() << viua::TRACE_STREAM.endl;
-
- viua::TRACE_STREAM << " backtrace:" << viua::TRACE_STREAM.endl;
- print_backtrace(stack);
-
- viua::TRACE_STREAM << " register contents:" << viua::TRACE_STREAM.endl;
- for (auto i = size_t{0}; i < stack.frames.size(); ++i) {
- auto const& each = stack.frames.at(i);
-
- viua::TRACE_STREAM << " of #" << i << viua::TRACE_STREAM.endl;
-
- dump_registers(each.parameters, "p");
- dump_registers(each.registers, "l");
- }
- dump_registers(stack.args, "a");
-
viua::TRACE_STREAM << " memory:" << viua::TRACE_STREAM.endl;
constexpr auto MEMORY_LINE_SIZE = size_t{16};
- auto const& memory = stack.proc->memory;
viua::TRACE_STREAM << std::hex << std::setfill('0');
for (auto line = size_t{0}; line < (memory.front().size() / MEMORY_LINE_SIZE); ++line) {
@@ 2065,6 2047,27 @@ auto execute(EBREAK const, Stack& stack, ip_type const) -> void
}
viua::TRACE_STREAM << viua::TRACE_STREAM.endl;
}
+}
+auto execute(EBREAK const, Stack& stack, ip_type const) -> void
+{
+ viua::TRACE_STREAM << "begin ebreak in process "
+ << stack.proc->pid.to_string() << viua::TRACE_STREAM.endl;
+
+ viua::TRACE_STREAM << " backtrace:" << viua::TRACE_STREAM.endl;
+ print_backtrace(stack);
+
+ viua::TRACE_STREAM << " register contents:" << viua::TRACE_STREAM.endl;
+ for (auto i = size_t{0}; i < stack.frames.size(); ++i) {
+ auto const& each = stack.frames.at(i);
+
+ viua::TRACE_STREAM << " of #" << i << viua::TRACE_STREAM.endl;
+
+ dump_registers(each.parameters, "p");
+ dump_registers(each.registers, "l");
+ }
+ dump_registers(stack.args, "a");
+
+ dump_memory(stack.proc->memory);
viua::TRACE_STREAM << "end ebreak in process " << stack.proc->pid.to_string()
<< viua::TRACE_STREAM.endl;