From 43eda1f28516ca9534057691adf22df7c2911e44 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 2 Mar 2011 22:53:10 -0800 Subject: [PATCH] Statetrace: Get rid of explicit register name handling. --- util/statetrace/arch/tracechild_amd64.cc | 45 ------------------------ util/statetrace/arch/tracechild_amd64.hh | 24 ------------- util/statetrace/arch/tracechild_arm.cc | 13 ------- util/statetrace/arch/tracechild_arm.hh | 24 ------------- util/statetrace/arch/tracechild_i386.cc | 19 ---------- util/statetrace/arch/tracechild_i386.hh | 24 ------------- util/statetrace/arch/tracechild_sparc.cc | 24 ------------- util/statetrace/arch/tracechild_sparc.hh | 24 ------------- util/statetrace/regstate.hh | 13 ------- util/statetrace/statetrace.cc | 7 ---- util/statetrace/tracechild.hh | 7 ---- 11 files changed, 224 deletions(-) diff --git a/util/statetrace/arch/tracechild_amd64.cc b/util/statetrace/arch/tracechild_amd64.cc index 47bd6aa17..780bb75a5 100644 --- a/util/statetrace/arch/tracechild_amd64.cc +++ b/util/statetrace/arch/tracechild_amd64.cc @@ -39,44 +39,6 @@ using namespace std; -const char * AMD64TraceChild::regNames[numregs] = { - //GPRs - "rax", "rbx", "rcx", "rdx", - //Index registers - "rsi", "rdi", - //Base pointer and stack pointer - "rbp", "rsp", - //New 64 bit mode registers - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - //Segmentation registers - "cs", "ds", "es", "fs", "gs", "ss", "fs_base", "gs_base", - //PC - "rip", - //Flags - "eflags", - //MMX - "mmx0_0", "mmx0_1", "mmx1_0", "mmx1_1", - "mmx2_0", "mmx2_1", "mmx3_0", "mmx3_1", - "mmx4_0", "mmx4_1", "mmx5_0", "mmx5_1", - "mmx6_0", "mmx6_1", "mmx7_0", "mmx7_1", - //XMM - "xmm0_0", "xmm0_1", "xmm0_2", "xmm0_3", - "xmm1_0", "xmm1_1", "xmm1_2", "xmm1_3", - "xmm2_0", "xmm2_1", "xmm2_2", "xmm2_3", - "xmm3_0", "xmm3_1", "xmm3_2", "xmm3_3", - "xmm4_0", "xmm4_1", "xmm4_2", "xmm4_3", - "xmm5_0", "xmm5_1", "xmm5_2", "xmm5_3", - "xmm6_0", "xmm6_1", "xmm6_2", "xmm6_3", - "xmm7_0", "xmm7_1", "xmm7_2", "xmm7_3", - "xmm8_0", "xmm8_1", "xmm8_2", "xmm8_3", - "xmm9_0", "xmm9_1", "xmm9_2", "xmm9_3", - "xmm10_0", "xmm10_1", "xmm10_2", "xmm10_3", - "xmm11_0", "xmm11_1", "xmm11_2", "xmm11_3", - "xmm12_0", "xmm12_1", "xmm12_2", "xmm12_3", - "xmm13_0", "xmm13_1", "xmm13_2", "xmm13_3", - "xmm14_0", "xmm14_1", "xmm14_2", "xmm14_3", - "xmm15_0", "xmm15_1", "xmm15_2", "xmm15_3"}; - bool AMD64TraceChild::sendState(int socket) { @@ -278,13 +240,6 @@ AMD64TraceChild::getOldRegVal(int num) return getRegs(oldregs, oldfpregs, num); } -char * -AMD64TraceChild::printReg(int num) -{ - sprintf(printBuffer, "0x%016lX", getRegVal(num)); - return printBuffer; -} - ostream & AMD64TraceChild::outputStartState(ostream & os) { diff --git a/util/statetrace/arch/tracechild_amd64.hh b/util/statetrace/arch/tracechild_amd64.hh index 6ed90d292..256be5766 100644 --- a/util/statetrace/arch/tracechild_amd64.hh +++ b/util/statetrace/arch/tracechild_amd64.hh @@ -87,8 +87,6 @@ class AMD64TraceChild : public TraceChild numregs }; private: - char printBuffer [256]; - static const char * regNames[numregs]; int64_t getRegs(user_regs_struct & myregs, user_fpregs_struct &myfpregs,int num); user_regs_struct regs; @@ -108,34 +106,12 @@ class AMD64TraceChild : public TraceChild bool sendState(int socket); - int - getNumRegs() - { - return numregs; - } - - bool - diffSinceUpdate(int num) - { - assert(num < numregs && num >= 0); - return regDiffSinceUpdate[num]; - } - - std::string - getRegName(int num) - { - assert(num < numregs && num >= 0); - return regNames[num]; - } - int64_t getRegVal(int num); int64_t getOldRegVal(int num); uint64_t getPC() {return getRegVal(RIP);} uint64_t getSP() {return getRegVal(RSP);} std::ostream & outputStartState(std::ostream & output); - char * printReg(int num); - bool step(); }; diff --git a/util/statetrace/arch/tracechild_arm.cc b/util/statetrace/arch/tracechild_arm.cc index 2d38a9d00..bd4f4bd36 100644 --- a/util/statetrace/arch/tracechild_arm.cc +++ b/util/statetrace/arch/tracechild_arm.cc @@ -51,12 +51,6 @@ using namespace std; -const char* ARMTraceChild::regNames[numregs] = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "fp", "r12", "sp", "lr", "pc", - "cpsr" }; - - ARMTraceChild::ARMTraceChild() { foundMvn = false; @@ -132,13 +126,6 @@ ARMTraceChild::getOldRegVal(int num) return getRegs(oldregs, num); } -char * -ARMTraceChild::printReg(int num) -{ - sprintf(printBuffer, "0x%08X", (uint32_t)getRegVal(num)); - return printBuffer; -} - ostream & ARMTraceChild::outputStartState(ostream & os) { diff --git a/util/statetrace/arch/tracechild_arm.hh b/util/statetrace/arch/tracechild_arm.hh index cd998ddaa..0379885f1 100644 --- a/util/statetrace/arch/tracechild_arm.hh +++ b/util/statetrace/arch/tracechild_arm.hh @@ -69,8 +69,6 @@ class ARMTraceChild : public TraceChild numregs }; private: - char printBuffer[256]; - static const char *regNames[numregs]; uint32_t getRegs(user_regs& myregs, int num); user_regs regs; user_regs oldregs; @@ -84,26 +82,6 @@ class ARMTraceChild : public TraceChild ARMTraceChild(); bool sendState(int socket); - int - getNumRegs() - { - return numregs; - } - - bool - diffSinceUpdate(int num) - { - assert(num < numregs && num >= 0); - return regDiffSinceUpdate[num]; - } - - std::string - getRegName(int num) - { - assert(num < numregs && num >= 0); - return regNames[num]; - } - int64_t getRegVal(int num); int64_t getOldRegVal(int num); @@ -121,8 +99,6 @@ class ARMTraceChild : public TraceChild return getRegVal(SP); } - char * printReg(int num); - std::ostream & outputStartState(std::ostream & os); }; diff --git a/util/statetrace/arch/tracechild_i386.cc b/util/statetrace/arch/tracechild_i386.cc index 81264483a..2cdeb29fa 100644 --- a/util/statetrace/arch/tracechild_i386.cc +++ b/util/statetrace/arch/tracechild_i386.cc @@ -37,18 +37,6 @@ using namespace std; -char * I386TraceChild::regNames[numregs] = { - //GPRs - "eax", "ebx", "ecx", "edx", - //Index registers - "esi", "edi", - //Base pointer and stack pointer - "ebp", "esp", - //Segmentation registers - "cs", "ds", "es", "fs", "gs", "ss", - //PC - "eip"}; - int64_t I386TraceChild::getRegs(user_regs_struct & myregs, int num) { @@ -109,13 +97,6 @@ I386TraceChild::getOldRegVal(int num) return getRegs(oldregs, num); } -char * -I386TraceChild::printReg(int num) -{ - sprintf(printBuffer, "0x%08X", getRegVal(num)); - return printBuffer; -} - TraceChild * genTraceChild() { diff --git a/util/statetrace/arch/tracechild_i386.hh b/util/statetrace/arch/tracechild_i386.hh index ccdd87058..7f9f7499e 100644 --- a/util/statetrace/arch/tracechild_i386.hh +++ b/util/statetrace/arch/tracechild_i386.hh @@ -57,8 +57,6 @@ class I386TraceChild : public TraceChild numregs }; private: - char printBuffer [256]; - static char * regNames[numregs]; int64_t getRegs(user_regs_struct & myregs, int num); user_regs_struct regs; user_regs_struct oldregs; @@ -71,26 +69,6 @@ class I386TraceChild : public TraceChild I386TraceChild(); - int - getNumRegs() - { - return numregs; - } - - bool - diffSinceUpdate(int num) - { - assert(num < numregs && num >= 0); - return regDiffSinceUpdate[num]; - } - - std::string - getRegName(int num) - { - assert(num < numregs && num >= 0); - return regNames[num]; - } - int64_t getRegVal(int num); int64_t getOldRegVal(int num); uint64_t getPC() {return getRegVal(EIP);} @@ -102,8 +80,6 @@ class I386TraceChild : public TraceChild << std::endl; return output; } - - char * printReg(int num); }; #endif diff --git a/util/statetrace/arch/tracechild_sparc.cc b/util/statetrace/arch/tracechild_sparc.cc index 405c36cd7..dba8fa53d 100644 --- a/util/statetrace/arch/tracechild_sparc.cc +++ b/util/statetrace/arch/tracechild_sparc.cc @@ -37,23 +37,6 @@ using namespace std; -string SparcTraceChild::regNames[numregs] = { - //Global registers - "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", - //Output registers - "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", - //Local registers - "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", - //Input registers - "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", - //Floating point - "f0", "f2", "f4", "f6", "f8", "f10", "f12", "f14", - "f16", "f18", "f20", "f22", "f24", "f26", "f28", "f30", - "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", - "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", - //Miscelaneous - "fsr", "fprs", "pc", "npc", "y", "cwp", "pstate", "asi", "ccr"}; - bool SparcTraceChild::sendState(int socket) { @@ -385,13 +368,6 @@ SparcTraceChild::getOldRegVal(int num) return getRegs(oldregs, oldfpregs, oldLocals, oldInputs, num); } -char * -SparcTraceChild::printReg(int num) -{ - sprintf(printBuffer, "0x%016llx", getRegVal(num)); - return printBuffer; -} - ostream & SparcTraceChild::outputStartState(ostream & os) { diff --git a/util/statetrace/arch/tracechild_sparc.hh b/util/statetrace/arch/tracechild_sparc.hh index f88a51b69..e479fce55 100644 --- a/util/statetrace/arch/tracechild_sparc.hh +++ b/util/statetrace/arch/tracechild_sparc.hh @@ -66,8 +66,6 @@ class SparcTraceChild : public TraceChild numregs }; private: - char printBuffer[256]; - static std::string regNames[numregs]; regs theregs; regs oldregs; fpu thefpregs; @@ -92,26 +90,6 @@ class SparcTraceChild : public TraceChild bool sendState(int socket); - int - getNumRegs() - { - return numregs; - } - - bool - diffSinceUpdate(int num) - { - assert(num < numregs && num >= 0); - return regDiffSinceUpdate[num]; - } - - std::string - getRegName(int num) - { - assert(num < numregs && num >= 0); - return regNames[num]; - } - int64_t getRegVal(int num); int64_t getOldRegVal(int num); @@ -130,8 +108,6 @@ class SparcTraceChild : public TraceChild return getRegVal(O6); } - char * printReg(int num); - std::ostream & outputStartState(std::ostream & os); }; diff --git a/util/statetrace/regstate.hh b/util/statetrace/regstate.hh index ae23b58ca..bab3485c6 100644 --- a/util/statetrace/regstate.hh +++ b/util/statetrace/regstate.hh @@ -39,21 +39,8 @@ class RegState protected: virtual bool update(int pid) = 0; public: - virtual int getNumRegs() = 0; - virtual bool diffSinceUpdate(int num) = 0; - virtual std::string getRegName(int num) = 0; - virtual int - getRegNum(std::string name) - { - int numregs = getNumRegs(); - for (unsigned int x = 0; x < numregs; x++) - if(getRegName(x) == name) - return x; - return -1; - } virtual int64_t getRegVal(int num) = 0; virtual int64_t getOldRegVal(int num) = 0; - virtual char * printReg(int num) = 0; }; #endif diff --git a/util/statetrace/statetrace.cc b/util/statetrace/statetrace.cc index ff20625a1..ccc408fa7 100644 --- a/util/statetrace/statetrace.cc +++ b/util/statetrace/statetrace.cc @@ -53,7 +53,6 @@ printUsage(const char * execName) cout << "options:" << endl; cout << " -h print this help" << endl; cout << " --host remote m5 host to connect to" << endl; - cout << " -r print register names" << endl; cout << " -i print initial stack state" << endl; cout << " -nt don't print an instruction trace" << endl; } @@ -87,12 +86,6 @@ main(int argc, char * argv[], char * envp[]) return 1; } host = argv[x]; - } else if (!strcmp(argv[x], "-r")) { - cout << "Legal register names:" << endl; - int numRegs = child->getNumRegs(); - for (unsigned int x = 0; x < numRegs; x++) - cout << "\t" << child->getRegName(x) << endl; - return 0; } else if (!strcmp(argv[x], "-i")) { printInitial = true; } else if (!strcmp(argv[x], "-nt")) { diff --git a/util/statetrace/tracechild.hh b/util/statetrace/tracechild.hh index 247714111..ad7e60e06 100644 --- a/util/statetrace/tracechild.hh +++ b/util/statetrace/tracechild.hh @@ -46,14 +46,7 @@ class TraceChild : public RegState virtual bool startTracing(const char * pathToFile, char * const argv[]); virtual bool stopTracing(); virtual bool step(); - virtual uint64_t getPC() = 0; - virtual uint64_t getSP() = 0; virtual std::ostream & outputStartState(std::ostream & os) = 0; - int - getPid() - { - return pid; - } bool isTracing() { -- 2.30.2