Skip to content

Commit

Permalink
Fix trap interactive output
Browse files Browse the repository at this point in the history
  • Loading branch information
abejgonzalez committed Jul 29, 2024
1 parent ceb2d15 commit f3e7fa8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions riscv/interactive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ void sim_t::interactive()
(this->*funcs[cmd])(cmd, args);
else
out << "Unknown command " << cmd << std::endl;
} catch(trap_t& t) {
} catch(trap_interactive& t) {
out << "Bad or missing arguments for command " << cmd << std::endl;
} catch(trap_t& t){
out << "Received trap: " << t.name() << std::endl;
}
#ifdef HAVE_BOOST_ASIO
if (socketif)
Expand Down Expand Up @@ -473,15 +475,9 @@ void sim_t::interactive_insn(const std::string& cmd, const std::vector<std::stri
int max_xlen = p->get_isa().get_max_xlen();

std::ostream out(sout_.rdbuf());
try
{
insn_t insn(get_insn(args));
out << std::hex << std::setfill('0') << "0x" << std::setw(max_xlen/4)
<< zext(insn.bits(), max_xlen) << " " << p->get_disassembler()->disassemble(insn) << std::endl;
}
catch (trap_t& t) {
out << "Unable to obtain insn due to " << t.name() << std::endl;
}
insn_t insn(get_insn(args)); // ensure this is outside of ostream to not pollute output on non-interactive trap
out << std::hex << std::setfill('0') << "0x" << std::setw(max_xlen/4)
<< zext(insn.bits(), max_xlen) << " " << p->get_disassembler()->disassemble(insn) << std::endl;
}

void sim_t::interactive_priv(const std::string& cmd, const std::vector<std::string>& args)
Expand Down Expand Up @@ -717,8 +713,9 @@ void sim_t::interactive_mem(const std::string& cmd, const std::vector<std::strin
int max_xlen = procs[0]->get_isa().get_max_xlen();

std::ostream out(sout_.rdbuf());
reg_t mem_val = get_mem(args); // ensure this is outside of ostream to not pollute output on non-interactive trap
out << std::hex << "0x" << std::setfill('0') << std::setw(max_xlen/4)
<< zext(get_mem(args), max_xlen) << std::endl;
<< zext(mem_val, max_xlen) << std::endl;
}

void sim_t::interactive_str(const std::string& cmd, const std::vector<std::string>& args)
Expand Down

0 comments on commit f3e7fa8

Please sign in to comment.