Go to the documentation of this file.
63 using namespace ArmISA;
68 const int TarmacParserRecord::MaxLineLength;
69 int8_t TarmacParserRecord::maxVectorLength = 0;
71 TarmacParserRecord::ParserInstEntry TarmacParserRecord::instRecord;
72 TarmacParserRecord::ParserRegEntry TarmacParserRecord::regRecord;
73 TarmacParserRecord::ParserMemEntry TarmacParserRecord::memRecord;
74 TarmacBaseRecord::TarmacRecordType TarmacParserRecord::currRecordType;
77 TarmacParserRecord::destRegRecords;
78 char TarmacParserRecord::buf[TarmacParserRecord::MaxLineLength];
79 TarmacParserRecord::MiscRegMap TarmacParserRecord::miscRegMap = {
744 TarmacParserRecord::TarmacParserRecordEvent::process()
749 end = destRegRecords.end();
753 for (; it != end; ++it) {
761 if (instRecord.isetstate == ISET_A64) {
764 auto vv = vc.
as<uint32_t>();
765 values.push_back(vv[0]);
767 const VecElem elem = thread->getReg(
769 values.push_back(elem);
773 if (instRecord.isetstate == ISET_A64) {
776 auto vv = vc.
as<uint64_t>();
777 values.push_back(vv[0]);
779 const VecElem w0 = thread->getReg(
781 const VecElem w1 = thread->getReg(
784 values.push_back((uint64_t)(w1) << 32 | w0);
791 auto pv =
pc.as<uint8_t>();
793 for (
int i = maxVectorLength * 8;
i > 0; ) {
794 p = (
p << 1) | pv[--
i];
800 if (instRecord.isetstate == ISET_A64) {
803 auto vv = vc.
as<uint64_t>();
804 values.push_back(vv[0]);
805 values.push_back(vv[1]);
807 const VecElem w0 = thread->getReg(
809 const VecElem w1 = thread->getReg(
811 const VecElem w2 = thread->getReg(
813 const VecElem w3 = thread->getReg(
816 values.push_back((uint64_t)(w1) << 32 | w0);
817 values.push_back((uint64_t)(w3) << 32 | w2);
822 int8_t
i = maxVectorLength;
825 auto vv = vc.
as<uint64_t>();
827 values.push_back(vv[--
i]);
834 CPSR cpsr = thread->readMiscRegNoEffect(it->index);
839 values.push_back(cpsr);
845 values.push_back(cpsr);
849 const uint32_t ones = (uint32_t)(-1);
858 fpcrMask.stride = ones;
859 fpcrMask.rMode = ones;
863 values.push_back(fpscr & fpcrMask);
867 const uint32_t ones = (uint32_t)(-1);
880 values.push_back(fpscr & fpsrMask);
882 values.push_back(thread->readMiscRegNoEffect(it->index));
886 panic(
"Unknown TARMAC trace record type!");
890 if (values.size() != it->values.size()) same =
false;
892 uint32_t size = values.size();
893 if (size > it->values.size())
894 size = it->values.size();
897 for (
int i = 0;
i < size; ++
i) {
898 if (values[
i] != it->values[
i]) {
907 TarmacParserRecord::printMismatchHeader(inst, *
pc);
910 outs <<
"diff> [" << it->repr <<
"] gem5: 0x" << std::hex;
911 for (
auto v : values)
912 outs << std::setw(16) << std::setfill(
'0') <<
v;
914 outs <<
", TARMAC: 0x" << std::hex;
915 for (
auto v : it->values)
916 outs << std::setw(16) << std::setfill(
'0') <<
v;
920 destRegRecords.clear();
922 if (mismatchOnPcOrOpcode && (parent.exitOnDiff ||
923 parent.exitOnInsnDiff))
924 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
925 "on PC or opcode", 1);
926 if (mismatch && parent.exitOnDiff)
927 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
932 TarmacParserRecord::TarmacParserRecordEvent::description()
const
934 return "TARMAC parser record event";
943 outs <<
"\nMismatch between gem5 and TARMAC trace @ " << std::dec
945 <<
"[seq_num: " << std::dec << instRecord.seq_num
946 <<
", opcode: 0x" << std::hex << (staticInst->
getEMI() & 0xffffffff)
947 <<
", PC: 0x" <<
pc.instAddr()
948 <<
", disasm: " << staticInst->
disassemble(
pc.instAddr()) <<
"]"
958 _pc, _macroStaticInst),
959 parsingStarted(false), mismatch(false),
960 mismatchOnPcOrOpcode(false), parent(_parent)
962 memReq = std::make_shared<Request>();
973 uint64_t written_data = 0;
1000 outs <<
"diff> [PC] gem5: 0x" << std::hex <<
pc->instAddr()
1009 outs <<
"diff> [opcode] gem5: 0x" << std::hex
1010 << arm_inst->encoding()
1023 outs <<
"diff> [iset_state] gem5: "
1044 outs <<
"diff> [mem(0x" << std::hex <<
memRecord.addr
1045 <<
")] gem5: 0x" << written_data
1055 panic(
"Unknown TARMAC trace record type!");
1067 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
1068 "on PC or opcode", 1);
1081 if (
buf[0] !=
'I') {
1087 assert((
buf[0] ==
'c') && (
buf[1] ==
'p') && (
buf[2] ==
'u'));
1095 if (
buf[0] ==
'I') {
1104 char c = trace.peek();
1122 warn(
"Invalid TARMAC trace record (seq_num: %lld)",
1130 }
else if (
buf[0] ==
'R') {
1136 if (std::tolower(
buf[0]) ==
'r' && isdigit(
buf[1])) {
1139 int base_index = atoi(&
buf[1]);
1140 char* pch = strchr(
buf,
'_');
1145 if (strncmp(pch,
"usr", 3) == 0)
1147 else if (strncmp(pch,
"fiq", 3) == 0)
1149 else if (strncmp(pch,
"irq", 3) == 0)
1151 else if (strncmp(pch,
"svc", 3) == 0)
1153 else if (strncmp(pch,
"mon", 3) == 0)
1155 else if (strncmp(pch,
"abt", 3) == 0)
1157 else if (strncmp(pch,
"und", 3) == 0)
1159 else if (strncmp(pch,
"hyp", 3) == 0)
1162 }
else if (std::tolower(
buf[0]) ==
'x' && isdigit(
buf[1])) {
1166 }
else if (std::tolower(
buf[0]) ==
's' && isdigit(
buf[1])) {
1170 }
else if (std::tolower(
buf[0]) ==
'd' && isdigit(
buf[1])) {
1174 }
else if (std::tolower(
buf[0]) ==
'q' && isdigit(
buf[1])) {
1178 }
else if (std::tolower(
buf[0]) ==
'z' && isdigit(
buf[1])) {
1182 }
else if (std::tolower(
buf[0]) ==
'p' && isdigit(
buf[1])) {
1186 }
else if (strncmp(
buf,
"SP_EL", 5) == 0) {
1196 std::string reg_name =
buf;
1197 std::transform(reg_name.begin(), reg_name.end(), reg_name.begin(),
1203 warn(
"Unknown register in TARMAC trace (%s).\n",
buf);
1213 uint64_t hi = strtoull(
buf, NULL, 16);
1215 uint64_t
lo = strtoull(
buf, NULL, 16);
1229 v = (
v << 32) | lsw;
1237 char c = trace.peek();
1238 if ((
c ==
':') || (
c ==
'_')) {
1242 v = (
v << 32) | lsw;
1252 char c = trace.peek();
1298 if (req->isLLSC() || req->isLocalAccess())
1326 saved_offset =
trace.tellg();
1327 trace >> buf >> buf >> buf;
1330 if (buf[0] ==
'I') {
1334 trace.seekg(saved_offset, std::ios::beg);
1343 panic(
"End of TARMAC trace reached before start PC\n");
1350 switch (isetstate) {
1354 return "Thumb (A32)";
1358 return "UNSUPPORTED";
Tick curTick()
The universal simulation clock.
bool mismatch
True if a mismatch has been detected for this instruction.
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
static char buf[MaxLineLength]
Buffer used for trace file parsing.
bool memWrCheck
If true, memory write accesses are checked.
constexpr decltype(nullptr) NoFault
@ MISCREG_TLBI_VAAE1IS_Xt
VecPredReg::Container VecPredRegContainer
static std::list< ParserRegEntry > destRegRecords
List of records of destination registers.
@ VecElemClass
Vector Register Native Elem lane.
static int8_t maxVectorLength
Max.
@ MISCREG_TLBI_IPAS2E1IS_Xt
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
bool contains(const Addr &a) const
Determine if the range contains an address.
@ NO_ACCESS
The request should not cause a memory access.
virtual BaseMMU * getMMUPtr()=0
virtual const PCStateBase & pcState() const =0
@ MISCREG_TLBI_IPAS2LE1IS_Xt
@ MISCREG_TLBI_VMALLS12E1IS
union gem5::Trace::InstRecord::@336 data
@ MISCREG_TLBI_VALE2IS_Xt
@ MISCREG_TLBI_VALE1IS_Xt
@ MISCREG_ID_AA64AFR1_EL1
@ MISCREG_ID_AA64MMFR0_EL1
std::ifstream trace
TARMAC trace file.
T * get() const
Directly access the pointer itself without taking a reference.
@ MISCREG_ID_AA64DFR1_EL1
@ MISCREG_TLBI_VALE3IS_Xt
@ MISCREG_TLBI_VMALLS12E1
bool cpuId
If true, the trace format includes the CPU id.
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
AddrRange ignoredAddrRange
Ignored addresses (ignored if empty).
This proxy attempts to translate virtual addresses using the TLBs.
bool macroopInProgress
True if a macroop is currently in progress.
const char * iSetStateToStr(ISetState isetstate) const
Returns the string representation of an instruction set state.
constexpr RegId Nz(CCRegClass, _NzIdx)
Event triggered to check the value of the destination registers.
@ MISCREG_DBGAUTHSTATUS_EL1
static ParserInstEntry instRecord
Buffer for instruction trace records.
bool mismatchOnPcOrOpcode
True if a mismatch has been detected for this instruction on PC or opcode.
std::vector< uint64_t > values
@ MISCREG_DBGCLAIMSET_EL1
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
ISetState
ARM instruction set state.
static ParserMemEntry memRecord
Buffer for memory access trace records (stores only).
@ 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.
constexpr RegId V(CCRegClass, _VIdx)
static const int MaxLineLength
@ MISCREG_ID_AA64AFR0_EL1
uint64_t Tick
Tick count type.
std::shared_ptr< Request > RequestPtr
static ParserRegEntry regRecord
Buffer for register trace records.
bool exitOnDiff
If true, the simulation is stopped as the first mismatch is detected.
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
@ MISCREG_TLBI_ASIDE1IS_Xt
std::ostream & output()
Get the ostream from the current global logger.
@ MISCREG_ID_AA64DFR0_EL1
@ MISCREG_ID_AA64MMFR1_EL1
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
constexpr RegId C(CCRegClass, _CIdx)
bool isLastMicroop() const
RequestPtr memReq
Request for memory write checks.
@ MISCREG_ID_AA64ISAR1_EL1
@ MISCREG_TLBI_IPAS2LE1_Xt
std::unique_ptr< PCStateBase > pc
@ funcRequestorId
This requestor id is used for functional requests that don't come from a particular device.
@ MISCREG_TLBI_VAALE1IS_Xt
constexpr RegId Ge(CCRegClass, _GeIdx)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
bool readMemNoEffect(Addr addr, uint8_t *data, unsigned size, unsigned flags)
Performs a memory access to read the value written by a previous write.
@ IntRegClass
Integer register.
Tarmac Parser: this tracer parses an existing Tarmac trace and it diffs it with gem5 simulation statu...
virtual uint64_t getEMI() const
Addr size
The size of the memory request.
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
static MiscRegMap miscRegMap
static ISetState pcToISetState(const PCStateBase &pc)
Returns the Instruction Set State according to the current PCState.
bool parsingStarted
True if a TARMAC instruction record has already been parsed for this instruction.
Addr addr
The address that was accessed.
Addr startPc
Tracing starts when the PC gets this value for the first time (ignored if 0x0).
void advanceTraceToStartPc()
Helper function to advance the trace up to startPc.
@ VecRegClass
Vector Register.
bool exitOnInsnDiff
If true, the simulation is stopped as the first mismatch is detected on PC or opcode.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
@ MISCREG_ID_AA64PFR0_EL1
bool advanceTrace()
Advances the TARMAC trace up to the next instruction, register, or memory access record.
@ MISCREG_TLBI_IPAS2E1_Xt
static TarmacRecordType currRecordType
Type of last parsed record.
unsigned flags
The flags that were assigned to the request.
@ MISCREG_ID_AA64ISAR0_EL1
Register ID: describe an architectural register with its class and index.
#define panic(...)
This implements a cprintf based panic() function.
static void printMismatchHeader(const StaticInstPtr inst, const PCStateBase &pc)
Print a mismatch header containing the instruction fields as reported by gem5.
Generated on Wed Jul 13 2022 10:39:12 for gem5 by doxygen 1.8.17