Fix reporting traps (faults) to GDB in SE mode (#166)
This addresses #123
This commit is contained in:
@@ -42,24 +42,28 @@ namespace PowerISA
|
||||
void
|
||||
UnimplementedOpcodeFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
panic_if(tc->getSystemPtr()->trapToGdb(GDBSignal::ILL, tc->contextId()),
|
||||
"Unimplemented opcode encountered at virtual address %#x\n",
|
||||
tc->pcState().instAddr());
|
||||
if (! tc->getSystemPtr()->trapToGdb(GDBSignal::ILL, tc->contextId()) ) {
|
||||
panic("Unimplemented opcode encountered at virtual address %#x\n",
|
||||
tc->pcState().instAddr());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AlignmentFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
panic_if(!tc->getSystemPtr()->trapToGdb(GDBSignal::BUS, tc->contextId()),
|
||||
"Alignment fault when accessing virtual address %#x\n", vaddr);
|
||||
if (! tc->getSystemPtr()->trapToGdb(GDBSignal::BUS, tc->contextId()) ) {
|
||||
panic("Alignment fault when accessing virtual address %#x\n",
|
||||
vaddr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TrapFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
panic_if(tc->getSystemPtr()->trapToGdb(GDBSignal::TRAP, tc->contextId()),
|
||||
"Trap encountered at virtual address %#x\n",
|
||||
tc->pcState().instAddr());
|
||||
if (! tc->getSystemPtr()->trapToGdb(GDBSignal::TRAP, tc->contextId()) ) {
|
||||
panic("Trap encountered at virtual address %#x\n",
|
||||
tc->pcState().instAddr());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace PowerISA
|
||||
|
||||
@@ -164,8 +164,6 @@ RiscvFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
pc_state.set(addr);
|
||||
tc->pcState(pc_state);
|
||||
} else {
|
||||
inst->advancePC(pc_state);
|
||||
tc->pcState(pc_state);
|
||||
invokeSE(tc, inst);
|
||||
}
|
||||
}
|
||||
@@ -207,9 +205,11 @@ UnknownInstFault::invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
void
|
||||
IllegalInstFault::invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
auto *rsi = static_cast<RiscvStaticInst *>(inst.get());
|
||||
panic("Illegal instruction 0x%08x at pc %s: %s", rsi->machInst,
|
||||
tc->pcState(), reason.c_str());
|
||||
if (! tc->getSystemPtr()->trapToGdb(GDBSignal::ILL, tc->contextId()) ) {
|
||||
auto *rsi = static_cast<RiscvStaticInst *>(inst.get());
|
||||
panic("Illegal instruction 0x%08x at pc %s: %s", rsi->machInst,
|
||||
tc->pcState(), reason.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -228,12 +228,20 @@ IllegalFrmFault::invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
void
|
||||
BreakpointFault::invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
schedRelBreak(0);
|
||||
if (! tc->getSystemPtr()->trapToGdb(GDBSignal::TRAP, tc->contextId()) ) {
|
||||
schedRelBreak(0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyscallFault::invokeSE(ThreadContext *tc, const StaticInstPtr &inst)
|
||||
{
|
||||
/* Advance the PC to next instruction so - once (simulated) syscall
|
||||
is executed - execution continues. */
|
||||
auto pc_state = tc->pcState().as<PCState>();
|
||||
inst->advancePC(pc_state);
|
||||
tc->pcState(pc_state);
|
||||
|
||||
tc->getSystemPtr()->workload->syscall(tc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user