exetrace.cc (3380:382e21bc32f3) | exetrace.cc (3506:99f86646ba5c) |
---|---|
1/* 2 * Copyright (c) 2001-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 19 unchanged lines hidden (view full) --- 28 * Authors: Steve Reinhardt 29 * Lisa Hsu 30 * Nathan Binkert 31 * Steve Raasch 32 */ 33 34#include <fstream> 35#include <iomanip> | 1/* 2 * Copyright (c) 2001-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 19 unchanged lines hidden (view full) --- 28 * Authors: Steve Reinhardt 29 * Lisa Hsu 30 * Nathan Binkert 31 * Steve Raasch 32 */ 33 34#include <fstream> 35#include <iomanip> |
36#include <sys/ipc.h> 37#include <sys/shm.h> |
|
36 37#include "arch/regfile.hh" 38#include "base/loader/symtab.hh" 39#include "cpu/base.hh" 40#include "cpu/exetrace.hh" 41#include "cpu/static_inst.hh" 42#include "sim/param.hh" 43#include "sim/system.hh" 44 45//XXX This is temporary 46#include "arch/isa_specific.hh" | 38 39#include "arch/regfile.hh" 40#include "base/loader/symtab.hh" 41#include "cpu/base.hh" 42#include "cpu/exetrace.hh" 43#include "cpu/static_inst.hh" 44#include "sim/param.hh" 45#include "sim/system.hh" 46 47//XXX This is temporary 48#include "arch/isa_specific.hh" |
49#include "cpu/m5legion_interface.h" |
|
47 48using namespace std; 49using namespace TheISA; 50 | 50 51using namespace std; 52using namespace TheISA; 53 |
54namespace Trace { 55SharedData *shared_data = NULL; 56} 57 |
|
51//////////////////////////////////////////////////////////////////////// 52// 53// Methods for the InstRecord object 54// 55 56 57void 58Trace::InstRecord::dump(ostream &outs) 59{ 60 if (flags[PRINT_REG_DELTA]) 61 { 62#if THE_ISA == SPARC_ISA | 58//////////////////////////////////////////////////////////////////////// 59// 60// Methods for the InstRecord object 61// 62 63 64void 65Trace::InstRecord::dump(ostream &outs) 66{ 67 if (flags[PRINT_REG_DELTA]) 68 { 69#if THE_ISA == SPARC_ISA |
70#if 0 |
|
63 //Don't print what happens for each micro-op, just print out 64 //once at the last op, and for regular instructions. 65 if(!staticInst->isMicroOp() || staticInst->isLastMicroOp()) 66 { 67 static uint64_t regs[32] = { 68 0, 0, 0, 0, 0, 0, 0, 0, 69 0, 0, 0, 0, 0, 0, 0, 0, 70 0, 0, 0, 0, 0, 0, 0, 0, --- 45 unchanged lines hidden (view full) --- 116 sprintf(buf, " F%d = 0x%016llx", 2 * y, newVal); 117 outs << buf; 118 floats[y] = newVal; 119 } 120 } 121 outs << endl; 122 } 123#endif | 71 //Don't print what happens for each micro-op, just print out 72 //once at the last op, and for regular instructions. 73 if(!staticInst->isMicroOp() || staticInst->isLastMicroOp()) 74 { 75 static uint64_t regs[32] = { 76 0, 0, 0, 0, 0, 0, 0, 0, 77 0, 0, 0, 0, 0, 0, 0, 0, 78 0, 0, 0, 0, 0, 0, 0, 0, --- 45 unchanged lines hidden (view full) --- 124 sprintf(buf, " F%d = 0x%016llx", 2 * y, newVal); 125 outs << buf; 126 floats[y] = newVal; 127 } 128 } 129 outs << endl; 130 } 131#endif |
132#endif |
|
124 } 125 else if (flags[INTEL_FORMAT]) { 126#if FULL_SYSTEM 127 bool is_trace_system = (thread->getCpuPtr()->system->name() == trace_system); 128#else 129 bool is_trace_system = true; 130#endif 131 if (is_trace_system) { --- 85 unchanged lines hidden (view full) --- 217 if (flags[PRINT_CP_SEQ] && cp_seq_valid) 218 outs << " CPSeq=" << dec << cp_seq; 219 220 // 221 // End of line... 222 // 223 outs << endl; 224 } | 133 } 134 else if (flags[INTEL_FORMAT]) { 135#if FULL_SYSTEM 136 bool is_trace_system = (thread->getCpuPtr()->system->name() == trace_system); 137#else 138 bool is_trace_system = true; 139#endif 140 if (is_trace_system) { --- 85 unchanged lines hidden (view full) --- 226 if (flags[PRINT_CP_SEQ] && cp_seq_valid) 227 outs << " CPSeq=" << dec << cp_seq; 228 229 // 230 // End of line... 231 // 232 outs << endl; 233 } |
234 // Compare 235 if (flags[LEGION_LOCKSTEP]) 236 { 237 bool compared = false; 238 bool diffPC = false; 239 bool diffInst = false; 240 bool diffRegs = false; 241 242 while (!compared) { 243 if (shared_data->flags == OWN_M5) { 244 if (shared_data->pc != PC) 245 diffPC = true; 246 if (shared_data->instruction != staticInst->machInst) 247 diffInst = true; 248 for (int i = 0; i < TheISA::NumIntRegs; i++) { 249 if (thread->readIntReg(i) != shared_data->intregs[i]) 250 diffRegs = true; 251 } 252 253 if (diffPC || diffInst || diffRegs ) { 254 outs << "Differences found between M5 and Legion:"; 255 if (diffPC) 256 outs << " PC"; 257 if (diffInst) 258 outs << " Instruction"; 259 if (diffRegs) 260 outs << " IntRegs"; 261 outs << endl; 262 263 outs << "M5 PC: " << setw(20) << "0x" << hex << PC; 264 outs << "Legion PC: " << setw(20) << "0x" << hex << 265 shared_data->pc << endl; 266 267 268 269 outs << "M5 Instruction: " << staticInst->machInst << "(" 270 << staticInst->disassemble(PC, debugSymbolTable) 271 << ")" << "Legion Instruction: " << 272 shared_data->instruction << "(" 273 /*<< legionInst->disassemble(shared_data->pc, 274 debugSymbolTable)*/ 275 << ")" << endl; 276 277 for (int i = 0; i < TheISA::NumIntRegs; i++) { 278 outs << setw(16) << "0x" << hex << thread->readIntReg(i) 279 << setw(16) << "0x" << hex << shared_data->intregs[i]; 280 281 if (thread->readIntReg(i) != shared_data->intregs[i]) 282 outs << "<--- Different"; 283 outs << endl; 284 } 285 } 286 287 compared = true; 288 shared_data->flags = OWN_LEGION; 289 } 290 } 291 292 } |
|
225} 226 227 228vector<bool> Trace::InstRecord::flags(NUM_BITS); 229string Trace::InstRecord::trace_system; 230 231//////////////////////////////////////////////////////////////////////// 232// --- 33 unchanged lines hidden (view full) --- 266Param<bool> exe_trace_print_cp_seq(&exeTraceParams, "print_cpseq", 267 "print correct-path sequence number", false); 268Param<bool> exe_trace_print_reg_delta(&exeTraceParams, "print_reg_delta", 269 "print which registers changed to what", false); 270Param<bool> exe_trace_pc_symbol(&exeTraceParams, "pc_symbol", 271 "Use symbols for the PC if available", true); 272Param<bool> exe_trace_intel_format(&exeTraceParams, "intel_format", 273 "print trace in intel compatible format", false); | 293} 294 295 296vector<bool> Trace::InstRecord::flags(NUM_BITS); 297string Trace::InstRecord::trace_system; 298 299//////////////////////////////////////////////////////////////////////// 300// --- 33 unchanged lines hidden (view full) --- 334Param<bool> exe_trace_print_cp_seq(&exeTraceParams, "print_cpseq", 335 "print correct-path sequence number", false); 336Param<bool> exe_trace_print_reg_delta(&exeTraceParams, "print_reg_delta", 337 "print which registers changed to what", false); 338Param<bool> exe_trace_pc_symbol(&exeTraceParams, "pc_symbol", 339 "Use symbols for the PC if available", true); 340Param<bool> exe_trace_intel_format(&exeTraceParams, "intel_format", 341 "print trace in intel compatible format", false); |
342Param<bool> exe_trace_legion_lockstep(&exeTraceParams, "legion_lockstep", 343 "Compare sim state to legion state every cycle", 344 false); |
|
274Param<string> exe_trace_system(&exeTraceParams, "trace_system", 275 "print trace of which system (client or server)", 276 "client"); 277 278 279// 280// Helper function for ExecutionTraceParamContext::checkParams() just 281// to get us into the InstRecord namespace --- 9 unchanged lines hidden (view full) --- 291 flags[PRINT_RESULT_DATA] = exe_trace_print_effaddr; 292 flags[PRINT_EFF_ADDR] = exe_trace_print_data; 293 flags[PRINT_INT_REGS] = exe_trace_print_iregs; 294 flags[PRINT_FETCH_SEQ] = exe_trace_print_fetchseq; 295 flags[PRINT_CP_SEQ] = exe_trace_print_cp_seq; 296 flags[PRINT_REG_DELTA] = exe_trace_print_reg_delta; 297 flags[PC_SYMBOL] = exe_trace_pc_symbol; 298 flags[INTEL_FORMAT] = exe_trace_intel_format; | 345Param<string> exe_trace_system(&exeTraceParams, "trace_system", 346 "print trace of which system (client or server)", 347 "client"); 348 349 350// 351// Helper function for ExecutionTraceParamContext::checkParams() just 352// to get us into the InstRecord namespace --- 9 unchanged lines hidden (view full) --- 362 flags[PRINT_RESULT_DATA] = exe_trace_print_effaddr; 363 flags[PRINT_EFF_ADDR] = exe_trace_print_data; 364 flags[PRINT_INT_REGS] = exe_trace_print_iregs; 365 flags[PRINT_FETCH_SEQ] = exe_trace_print_fetchseq; 366 flags[PRINT_CP_SEQ] = exe_trace_print_cp_seq; 367 flags[PRINT_REG_DELTA] = exe_trace_print_reg_delta; 368 flags[PC_SYMBOL] = exe_trace_pc_symbol; 369 flags[INTEL_FORMAT] = exe_trace_intel_format; |
370 flags[LEGION_LOCKSTEP] = exe_trace_legion_lockstep; |
|
299 trace_system = exe_trace_system; | 371 trace_system = exe_trace_system; |
372 373 // If were going to be in lockstep with Legion 374 // Setup shared memory, and get otherwise ready 375 if (flags[LEGION_LOCKSTEP]) { 376 int shmfd = shmget(getuid(), sizeof(SharedData), 0777); 377 if (shmfd < 0) 378 fatal("Couldn't get shared memory fd. Is Legion running?"); 379 380 shared_data = (SharedData*)shmat(shmfd, NULL, SHM_RND); 381 if (shared_data == (SharedData*)-1) 382 fatal("Couldn't allocate shared memory"); 383 384 if (shared_data->flags != OWN_M5) 385 fatal("Shared memory has invalid owner"); 386 387 if (shared_data->version != VERSION) 388 fatal("Shared Data is wrong version! M5: %d Legion: %d", VERSION, 389 shared_data->version); 390 391 } |
|
300} 301 302void 303ExecutionTraceParamContext::checkParams() 304{ 305 Trace::InstRecord::setParams(); 306} 307 | 392} 393 394void 395ExecutionTraceParamContext::checkParams() 396{ 397 Trace::InstRecord::setParams(); 398} 399 |