Skip to content

Commit deeda9a

Browse files
committed
Fix trap interactive output
1 parent 398101b commit deeda9a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

riscv/interactive.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ void sim_t::interactive()
342342
(this->*funcs[cmd])(cmd, args);
343343
else
344344
out << "Unknown command " << cmd << std::endl;
345-
} catch(trap_t& t) {
345+
} catch(trap_interactive& t) {
346346
out << "Bad or missing arguments for command " << cmd << std::endl;
347+
} catch(trap_t& t){
348+
out << "Received trap: " << t.name() << std::endl;
347349
}
348350
#ifdef HAVE_BOOST_ASIO
349351
if (socketif)
@@ -473,15 +475,9 @@ void sim_t::interactive_insn(const std::string& cmd, const std::vector<std::stri
473475
int max_xlen = p->get_isa().get_max_xlen();
474476

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

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

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

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

0 commit comments

Comments
 (0)