Go to the documentation of this file.
65 using namespace ArmISA;
70 const int TarmacParserRecord::MaxLineLength;
71 int8_t TarmacParserRecord::maxVectorLength = 0;
73 TarmacParserRecord::ParserInstEntry TarmacParserRecord::instRecord;
74 TarmacParserRecord::ParserRegEntry TarmacParserRecord::regRecord;
75 TarmacParserRecord::ParserMemEntry TarmacParserRecord::memRecord;
76 TarmacBaseRecord::TarmacRecordType TarmacParserRecord::currRecordType;
79 TarmacParserRecord::destRegRecords;
80 char TarmacParserRecord::buf[TarmacParserRecord::MaxLineLength];
81 TarmacParserRecord::MiscRegMap TarmacParserRecord::miscRegMap = {
746 TarmacParserRecord::TarmacParserRecordEvent::process()
751 end = destRegRecords.end();
755 for (; it != end; ++it) {
760 values.push_back(thread->getReg(
intRegClass[it->index]));
763 if (instRecord.isetstate == ISET_A64) {
766 auto vv = vc.
as<uint32_t>();
767 values.push_back(vv[0]);
770 values.push_back(elem);
774 if (instRecord.isetstate == ISET_A64) {
777 auto vv = vc.
as<uint64_t>();
778 values.push_back(vv[0]);
783 values.push_back((uint64_t)(w1) << 32 | w0);
790 auto pv =
pc.as<uint8_t>();
792 for (
int i = maxVectorLength * 8;
i > 0; ) {
793 p = (
p << 1) | pv[--
i];
799 if (instRecord.isetstate == ISET_A64) {
802 auto vv = vc.
as<uint64_t>();
803 values.push_back(vv[0]);
804 values.push_back(vv[1]);
811 values.push_back((uint64_t)(w1) << 32 | w0);
812 values.push_back((uint64_t)(w3) << 32 | w2);
817 int8_t
i = maxVectorLength;
820 auto vv = vc.
as<uint64_t>();
822 values.push_back(vv[--
i]);
829 CPSR cpsr = thread->readMiscRegNoEffect(it->index);
834 values.push_back(cpsr);
840 values.push_back(cpsr);
844 const uint32_t ones = (uint32_t)(-1);
853 fpcrMask.stride = ones;
854 fpcrMask.rMode = ones;
858 values.push_back(fpscr & fpcrMask);
862 const uint32_t ones = (uint32_t)(-1);
875 values.push_back(fpscr & fpsrMask);
877 values.push_back(thread->readMiscRegNoEffect(it->index));
881 panic(
"Unknown TARMAC trace record type!");
885 if (values.size() != it->values.size()) same =
false;
887 uint32_t size = values.size();
888 if (size > it->values.size())
889 size = it->values.size();
892 for (
int i = 0;
i < size; ++
i) {
893 if (values[
i] != it->values[
i]) {
902 TarmacParserRecord::printMismatchHeader(inst, *
pc);
905 outs <<
"diff> [" << it->repr <<
"] gem5: 0x" << std::hex;
906 for (
auto v : values)
907 outs << std::setw(16) << std::setfill(
'0') <<
v;
909 outs <<
", TARMAC: 0x" << std::hex;
910 for (
auto v : it->values)
911 outs << std::setw(16) << std::setfill(
'0') <<
v;
915 destRegRecords.clear();
917 if (mismatchOnPcOrOpcode && (parent.exitOnDiff ||
918 parent.exitOnInsnDiff))
919 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
920 "on PC or opcode", 1);
921 if (mismatch && parent.exitOnDiff)
922 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
927 TarmacParserRecord::TarmacParserRecordEvent::description()
const
929 return "TARMAC parser record event";
938 outs <<
"\nMismatch between gem5 and TARMAC trace @ " << std::dec
940 <<
"[seq_num: " << std::dec << instRecord.seq_num
941 <<
", opcode: 0x" << std::hex << (staticInst->
getEMI() & 0xffffffff)
942 <<
", PC: 0x" <<
pc.instAddr()
943 <<
", disasm: " << staticInst->
disassemble(
pc.instAddr()) <<
"]"
953 _pc, _macroStaticInst),
954 parsingStarted(false), mismatch(false),
955 mismatchOnPcOrOpcode(false), parent(_parent)
957 memReq = std::make_shared<Request>();
968 uint64_t written_data = 0;
995 outs <<
"diff> [PC] gem5: 0x" << std::hex <<
pc->instAddr()
996 <<
", TARMAC: 0x" <<
instRecord.addr << std::endl;
1001 if (arm_inst->encoding() !=
instRecord.opcode) {
1004 outs <<
"diff> [opcode] gem5: 0x" << std::hex
1005 << arm_inst->encoding()
1006 <<
", TARMAC: 0x" <<
instRecord.opcode << std::endl;
1018 outs <<
"diff> [iset_state] gem5: "
1040 <<
")] gem5: 0x" << written_data
1050 panic(
"Unknown TARMAC trace record type!");
1062 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
1063 "on PC or opcode", 1);
1076 if (
buf[0] !=
'I') {
1082 assert((
buf[0] ==
'c') && (
buf[1] ==
'p') && (
buf[2] ==
'u'));
1090 if (
buf[0] ==
'I') {
1099 char c = trace.peek();
1117 warn(
"Invalid TARMAC trace record (seq_num: %lld)",
1125 }
else if (
buf[0] ==
'R') {
1131 if (std::tolower(
buf[0]) ==
'r' && isdigit(
buf[1])) {
1134 int base_index = atoi(&
buf[1]);
1135 char* pch = strchr(
buf,
'_');
1140 if (strncmp(pch,
"usr", 3) == 0)
1142 else if (strncmp(pch,
"fiq", 3) == 0)
1144 else if (strncmp(pch,
"irq", 3) == 0)
1146 else if (strncmp(pch,
"svc", 3) == 0)
1148 else if (strncmp(pch,
"mon", 3) == 0)
1150 else if (strncmp(pch,
"abt", 3) == 0)
1152 else if (strncmp(pch,
"und", 3) == 0)
1154 else if (strncmp(pch,
"hyp", 3) == 0)
1157 }
else if (std::tolower(
buf[0]) ==
'x' && isdigit(
buf[1])) {
1161 }
else if (std::tolower(
buf[0]) ==
's' && isdigit(
buf[1])) {
1165 }
else if (std::tolower(
buf[0]) ==
'd' && isdigit(
buf[1])) {
1169 }
else if (std::tolower(
buf[0]) ==
'q' && isdigit(
buf[1])) {
1173 }
else if (std::tolower(
buf[0]) ==
'z' && isdigit(
buf[1])) {
1177 }
else if (std::tolower(
buf[0]) ==
'p' && isdigit(
buf[1])) {
1181 }
else if (strncmp(
buf,
"SP_EL", 5) == 0) {
1191 std::string reg_name =
buf;
1192 std::transform(reg_name.begin(), reg_name.end(), reg_name.begin(),
1198 warn(
"Unknown register in TARMAC trace (%s).\n",
buf);
1208 uint64_t hi = strtoull(
buf, NULL, 16);
1210 uint64_t
lo = strtoull(
buf, NULL, 16);
1224 v = (
v << 32) | lsw;
1232 char c = trace.peek();
1233 if ((
c ==
':') || (
c ==
'_')) {
1237 v = (
v << 32) | lsw;
1247 char c = trace.peek();
1293 if (req->isLLSC() || req->isLocalAccess())
1324 saved_offset =
trace.tellg();
1325 trace >> buf >> buf >> buf;
1328 if (buf[0] ==
'I') {
1332 trace.seekg(saved_offset, std::ios::beg);
1341 panic(
"End of TARMAC trace reached before start PC\n");
1348 switch (isetstate) {
1352 return "Thumb (A32)";
1356 return "UNSUPPORTED";
Tick curTick()
The universal simulation clock.
@ funcRequestorId
This requestor id is used for functional requests that don't come from a particular device.
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
constexpr decltype(nullptr) NoFault
Tarmac Parser: this tracer parses an existing Tarmac trace and it diffs it with gem5 simulation statu...
Addr size
The size of the memory request.
@ MISCREG_TLBI_VAAE1IS_Xt
VecPredReg::Container VecPredRegContainer
Event triggered to check the value of the destination registers.
bool cpuId
If true, the trace format includes the CPU id.
@ MISCREG_TLBI_IPAS2E1IS_Xt
static ParserMemEntry memRecord
Buffer for memory access trace records (stores only).
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
bool macroopInProgress
True if a macroop is currently in progress.
bool contains(const Addr &a) const
Determine if the range contains an address.
virtual BaseMMU * getMMUPtr()=0
virtual const PCStateBase & pcState() const =0
static int8_t maxVectorLength
Max.
@ MISCREG_TLBI_IPAS2LE1IS_Xt
bool readMemNoEffect(Addr addr, uint8_t *data, unsigned size, unsigned flags)
Performs a memory access to read the value written by a previous write.
@ MISCREG_TLBI_VMALLS12E1IS
bool exitOnDiff
If true, the simulation is stopped as the first mismatch is detected.
@ MISCREG_TLBI_VALE2IS_Xt
@ MISCREG_TLBI_VALE1IS_Xt
@ MISCREG_ID_AA64AFR1_EL1
bool exitOnInsnDiff
If true, the simulation is stopped as the first mismatch is detected on PC or opcode.
@ MISCREG_ID_AA64MMFR0_EL1
static const RegId & mon(unsigned index)
T * get() const
Directly access the pointer itself without taking a reference.
@ MISCREG_ID_AA64DFR1_EL1
@ MISCREG_TLBI_VALE3IS_Xt
bool memWrCheck
If true, memory write accesses are checked.
static MiscRegMap miscRegMap
@ MISCREG_TLBI_VMALLS12E1
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
@ MISCREG_DBGCLAIMCLR_EL1
This proxy attempts to translate virtual addresses using the TLBs.
static const RegId & und(unsigned index)
@ MISCREG_DBGAUTHSTATUS_EL1
static ParserInstEntry instRecord
Buffer for instruction trace records.
@ MISCREG_DBGCLAIMSET_EL1
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
std::ifstream trace
TARMAC trace file.
std::vector< uint64_t > values
@ MISCREG_ID_AA64PFR1_EL1
ThreadContext is the external interface to all thread state for anything outside of the CPU.
@ MISCREG_ID_AA64MMFR2_EL1
std::shared_ptr< FaultBase > Fault
VecElem * as()
View interposers.
@ MISCREG_ID_AA64AFR0_EL1
uint64_t Tick
Tick count type.
bool mismatchOnPcOrOpcode
True if a mismatch has been detected for this instruction on PC or opcode.
static const RegId & svc(unsigned index)
std::shared_ptr< Request > RequestPtr
AddrRange ignoredAddrRange
Ignored addresses (ignored if empty).
unsigned flags
The flags that were assigned to the request.
This object is a proxy for a port or other object which implements the functional response protocol,...
Addr startPc
Tracing starts when the PC gets this value for the first time (ignored if 0x0).
constexpr RegClass intRegClass
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
static std::list< ParserRegEntry > destRegRecords
List of records of destination registers.
@ MISCREG_TLBI_ASIDE1IS_Xt
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
bool mismatch
True if a mismatch has been detected for this instruction.
bool parsingStarted
True if a TARMAC instruction record has already been parsed for this instruction.
@ MISCREG_ID_AA64DFR0_EL1
@ MISCREG_ID_AA64MMFR1_EL1
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool isLastMicroop() const
static void printMismatchHeader(const StaticInstPtr inst, const PCStateBase &pc)
Print a mismatch header containing the instruction fields as reported by gem5.
@ MISCREG_ID_AA64ISAR1_EL1
RequestPtr memReq
Request for memory write checks.
constexpr RegClass vecRegClass
void advanceTraceToStartPc()
Helper function to advance the trace up to startPc.
@ MISCREG_TLBI_IPAS2LE1_Xt
@ MISCREG_TLBI_VAALE1IS_Xt
union gem5::trace::InstRecord::Data data
std::ostream & output()
Get the ostream from the current global logger.
static TarmacRecordType currRecordType
Type of last parsed record.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
virtual uint64_t getEMI() const
static ISetState pcToISetState(const PCStateBase &pc)
Returns the Instruction Set State according to the current PCState.
const char * iSetStateToStr(ISetState isetstate) const
Returns the string representation of an instruction set state.
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
constexpr RegClass vecElemClass
static char buf[MaxLineLength]
Buffer used for trace file parsing.
bool advanceTrace()
Advances the TARMAC trace up to the next instruction, register, or memory access record.
std::unique_ptr< PCStateBase > pc
static const RegId & hyp(unsigned index)
Addr addr
The address that was accessed.
constexpr RegClass vecPredRegClass
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
@ MISCREG_ID_AA64PFR0_EL1
static ParserRegEntry regRecord
Buffer for register trace records.
@ MISCREG_TLBI_IPAS2E1_Xt
@ NO_ACCESS
The request should not cause a memory access.
@ MISCREG_ID_AA64ISAR0_EL1
static const RegId & abt(unsigned index)
static const int MaxLineLength
ISetState
ARM instruction set state.
#define panic(...)
This implements a cprintf based panic() function.
Generated on Sun Jul 30 2023 01:56:50 for gem5 by doxygen 1.8.17