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)
{
return getRegs(oldregs, oldfpregs, num);
}
-char *
-AMD64TraceChild::printReg(int num)
-{
- sprintf(printBuffer, "0x%016lX", getRegVal(num));
- return printBuffer;
-}
-
ostream &
AMD64TraceChild::outputStartState(ostream & os)
{
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;
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();
};
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;
return getRegs(oldregs, num);
}
-char *
-ARMTraceChild::printReg(int num)
-{
- sprintf(printBuffer, "0x%08X", (uint32_t)getRegVal(num));
- return printBuffer;
-}
-
ostream &
ARMTraceChild::outputStartState(ostream & os)
{
numregs
};
private:
- char printBuffer[256];
- static const char *regNames[numregs];
uint32_t getRegs(user_regs& myregs, int num);
user_regs regs;
user_regs oldregs;
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);
return getRegVal(SP);
}
- char * printReg(int num);
-
std::ostream & outputStartState(std::ostream & os);
};
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)
{
return getRegs(oldregs, num);
}
-char *
-I386TraceChild::printReg(int num)
-{
- sprintf(printBuffer, "0x%08X", getRegVal(num));
- return printBuffer;
-}
-
TraceChild *
genTraceChild()
{
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;
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);}
<< std::endl;
return output;
}
-
- char * printReg(int num);
};
#endif
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)
{
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)
{
numregs
};
private:
- char printBuffer[256];
- static std::string regNames[numregs];
regs theregs;
regs oldregs;
fpu thefpregs;
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);
return getRegVal(O6);
}
- char * printReg(int num);
-
std::ostream & outputStartState(std::ostream & os);
};
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
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;
}
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")) {
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()
{