X86: Add a trace flag for tracing faults.

This commit is contained in:
Gabe Black 2009-02-25 10:17:59 -08:00
parent eec3f49a57
commit 1cedc748d4
3 changed files with 31 additions and 2 deletions

View file

@ -113,6 +113,7 @@ if env['TARGET_ISA'] == 'x86':
TraceFlag('LocalApic', "Local APIC debugging")
TraceFlag('PageTableWalker', \
"Page table walker state machine debugging")
TraceFlag('Faults', "Trace all faults/exceptions/traps")
SimObject('X86LocalApic.py')
SimObject('X86System.py')

View file

@ -103,6 +103,8 @@ namespace X86ISA
#if FULL_SYSTEM
void X86FaultBase::invoke(ThreadContext * tc)
{
Addr pc = tc->readPC();
DPRINTF(Faults, "RIP %#x: vector %d: %s\n", pc, vector, describe());
using namespace X86ISAInst::RomLabels;
HandyM5Reg m5reg = tc->readMiscRegNoEffect(MISCREG_M5_REG);
MicroPC entry;
@ -116,7 +118,7 @@ namespace X86ISA
entry = extern_label_legacyModeInterrupt;
}
tc->setIntReg(INTREG_MICRO(1), vector);
tc->setIntReg(INTREG_MICRO(7), tc->readPC());
tc->setIntReg(INTREG_MICRO(7), pc);
if (errorCode != (uint64_t)(-1)) {
if (m5reg.mode == LongMode) {
entry = extern_label_longModeInterruptWithError;
@ -132,6 +134,18 @@ namespace X86ISA
tc->setMicroPC(romMicroPC(entry));
tc->setNextMicroPC(romMicroPC(entry) + 1);
}
std::string
X86FaultBase::describe() const
{
std::stringstream ss;
ccprintf(ss, "%s", mnemonic());
if (errorCode != (uint64_t)(-1)) {
ccprintf(ss, "(%#x)", errorCode);
}
return ss.str();
}
void X86Trap::invoke(ThreadContext * tc)
{
@ -163,6 +177,14 @@ namespace X86ISA
}
}
std::string
PageFault::describe() const
{
std::stringstream ss;
ccprintf(ss, "%s at %#x", X86FaultBase::describe(), addr);
return ss.str();
}
#endif
} // namespace X86ISA

View file

@ -62,6 +62,8 @@
#include "base/misc.hh"
#include "sim/faults.hh"
#include <string>
namespace X86ISA
{
// Base class for all x86 "faults" where faults is in the m5 sense
@ -102,6 +104,8 @@ namespace X86ISA
#if FULL_SYSTEM
void invoke(ThreadContext * tc);
virtual std::string describe() const;
#endif
};
@ -342,6 +346,8 @@ namespace X86ISA
#if FULL_SYSTEM
void invoke(ThreadContext * tc);
virtual std::string describe() const;
#endif
};
@ -414,7 +420,7 @@ namespace X86ISA
{
public:
SoftwareInterrupt(uint8_t _vector) :
X86Interrupt("Software Interrupt", "INTn", _vector)
X86Interrupt("Software Interrupt", "#INTR", _vector)
{}
bool isSoft()