35a36,37
> #include <sys/ipc.h>
> #include <sys/shm.h>
46a49
> #include "cpu/m5legion_interface.h"
50a54,57
> namespace Trace {
> SharedData *shared_data = NULL;
> }
>
62a70
> #if 0
123a132
> #endif
224a234,292
> // Compare
> if (flags[LEGION_LOCKSTEP])
> {
> bool compared = false;
> bool diffPC = false;
> bool diffInst = false;
> bool diffRegs = false;
>
> while (!compared) {
> if (shared_data->flags == OWN_M5) {
> if (shared_data->pc != PC)
> diffPC = true;
> if (shared_data->instruction != staticInst->machInst)
> diffInst = true;
> for (int i = 0; i < TheISA::NumIntRegs; i++) {
> if (thread->readIntReg(i) != shared_data->intregs[i])
> diffRegs = true;
> }
>
> if (diffPC || diffInst || diffRegs ) {
> outs << "Differences found between M5 and Legion:";
> if (diffPC)
> outs << " PC";
> if (diffInst)
> outs << " Instruction";
> if (diffRegs)
> outs << " IntRegs";
> outs << endl;
>
> outs << "M5 PC: " << setw(20) << "0x" << hex << PC;
> outs << "Legion PC: " << setw(20) << "0x" << hex <<
> shared_data->pc << endl;
>
>
>
> outs << "M5 Instruction: " << staticInst->machInst << "("
> << staticInst->disassemble(PC, debugSymbolTable)
> << ")" << "Legion Instruction: " <<
> shared_data->instruction << "("
> /*<< legionInst->disassemble(shared_data->pc,
> debugSymbolTable)*/
> << ")" << endl;
>
> for (int i = 0; i < TheISA::NumIntRegs; i++) {
> outs << setw(16) << "0x" << hex << thread->readIntReg(i)
> << setw(16) << "0x" << hex << shared_data->intregs[i];
>
> if (thread->readIntReg(i) != shared_data->intregs[i])
> outs << "<--- Different";
> outs << endl;
> }
> }
>
> compared = true;
> shared_data->flags = OWN_LEGION;
> }
> }
>
> }
273a342,344
> Param<bool> exe_trace_legion_lockstep(&exeTraceParams, "legion_lockstep",
> "Compare sim state to legion state every cycle",
> false);
298a370
> flags[LEGION_LOCKSTEP] = exe_trace_legion_lockstep;
299a372,391
>
> // If were going to be in lockstep with Legion
> // Setup shared memory, and get otherwise ready
> if (flags[LEGION_LOCKSTEP]) {
> int shmfd = shmget(getuid(), sizeof(SharedData), 0777);
> if (shmfd < 0)
> fatal("Couldn't get shared memory fd. Is Legion running?");
>
> shared_data = (SharedData*)shmat(shmfd, NULL, SHM_RND);
> if (shared_data == (SharedData*)-1)
> fatal("Couldn't allocate shared memory");
>
> if (shared_data->flags != OWN_M5)
> fatal("Shared memory has invalid owner");
>
> if (shared_data->version != VERSION)
> fatal("Shared Data is wrong version! M5: %d Legion: %d", VERSION,
> shared_data->version);
>
> }