exetrace.cc (3743:2061715f68d1) exetrace.cc (3748:35d3c2e37b58)
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;

--- 52 unchanged lines hidden (view full) ---

61SharedData *shared_data = NULL;
62}
63
64////////////////////////////////////////////////////////////////////////
65//
66// Methods for the InstRecord object
67//
68
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;

--- 52 unchanged lines hidden (view full) ---

61SharedData *shared_data = NULL;
62}
63
64////////////////////////////////////////////////////////////////////////
65//
66// Methods for the InstRecord object
67//
68
69#if THE_ISA == SPARC_ISA
69
70
71inline char * genCenteredLabel(int length, char * buffer, char * label)
72{
73 int labelLength = strlen(label);
74 assert(labelLength <= length);
75 int leftPad = (length - labelLength) / 2;
76 int rightPad = length - leftPad - labelLength;
77 char format[64];
78 sprintf(format, "%%%ds%%s%%%ds", leftPad, rightPad);
79 sprintf(buffer, format, "", label, "");
80 return buffer;
81}
82
83inline void printRegPair(ostream & os, char const * title, uint64_t a, uint64_t b)
84{
85 ccprintf(os, " %16s | %#018x %s %#-018x \n",
86 title, a, (a == b) ? "|" : "X", b);
87}
88
89inline void printColumnLabels(ostream & os)
90{
91 static char * regLabel = genCenteredLabel(16, new char[17], "Register");
92 static char * m5Label = genCenteredLabel(18, new char[18], "M5");
93 static char * legionLabel = genCenteredLabel(18, new char[18], "Legion");
94 ccprintf(os, " %s | %s | %s \n", regLabel, m5Label, legionLabel);
95 ccprintf(os, "--------------------+-----------------------+-----------------------\n");
96}
97
98inline void printSectionHeader(ostream & os, char * name)
99{
100 char sectionString[70];
101 genCenteredLabel(69, sectionString, name);
102 ccprintf(os, "====================================================================\n");
103 ccprintf(os, "%69s\n", sectionString);
104 ccprintf(os, "====================================================================\n");
105}
106
107inline void printLevelHeader(ostream & os, int level)
108{
109 char sectionString[70];
110 char levelName[70];
111 sprintf(levelName, "Trap stack level %d", level);
112 genCenteredLabel(69, sectionString, levelName);
113 ccprintf(os, "====================================================================\n");
114 ccprintf(os, "%69s\n", sectionString);
115 ccprintf(os, "====================================================================\n");
116}
117
118#endif
119
70void
71Trace::InstRecord::dump(ostream &outs)
72{
73 if (flags[PRINT_REG_DELTA])
74 {
75#if THE_ISA == SPARC_ISA
76 //Don't print what happens for each micro-op, just print out
77 //once at the last op, and for regular instructions.

--- 154 unchanged lines hidden (view full) ---

232#if THE_ISA == SPARC_ISA
233 // Compare
234 if (flags[LEGION_LOCKSTEP])
235 {
236 bool compared = false;
237 bool diffPC = false;
238 bool diffInst = false;
239 bool diffRegs = false;
120void
121Trace::InstRecord::dump(ostream &outs)
122{
123 if (flags[PRINT_REG_DELTA])
124 {
125#if THE_ISA == SPARC_ISA
126 //Don't print what happens for each micro-op, just print out
127 //once at the last op, and for regular instructions.

--- 154 unchanged lines hidden (view full) ---

282#if THE_ISA == SPARC_ISA
283 // Compare
284 if (flags[LEGION_LOCKSTEP])
285 {
286 bool compared = false;
287 bool diffPC = false;
288 bool diffInst = false;
289 bool diffRegs = false;
290 bool diffTpc = false;
291 bool diffTnpc = false;
292 bool diffTstate = false;
293 bool diffTt = false;
294 bool diffTba = false;
295 bool diffHpstate = false;
296 bool diffHtstate = false;
297 bool diffHtba = false;
298 bool diffPstate = false;
299 bool diffY = false;
300 bool diffCcr = false;
301 bool diffTl = false;
302 bool diffGl = false;
303 bool diffAsi = false;
304 bool diffPil = false;
305 bool diffCwp = false;
306 bool diffCansave = false;
307 bool diffCanrestore = false;
308 bool diffOtherwin = false;
309 bool diffCleanwin = false;
240 Addr m5Pc, lgnPc;
241
242
243 if(!staticInst->isMicroOp() || staticInst->isLastMicroOp()) {
244 while (!compared) {
310 Addr m5Pc, lgnPc;
311
312
313 if(!staticInst->isMicroOp() || staticInst->isLastMicroOp()) {
314 while (!compared) {
245 m5Pc = PC & TheISA::PAddrImplMask;
246 lgnPc = shared_data->pc & TheISA::PAddrImplMask;
247 if (shared_data->flags == OWN_M5) {
315 if (shared_data->flags == OWN_M5) {
316 m5Pc = PC & TheISA::PAddrImplMask;
317 lgnPc = shared_data->pc & TheISA::PAddrImplMask;
248 if (lgnPc != m5Pc)
249 diffPC = true;
250 if (shared_data->instruction !=
251 (SparcISA::MachInst)staticInst->machInst) {
252 diffInst = true;
253 }
254 for (int i = 0; i < TheISA::NumRegularIntRegs; i++) {
255 if (thread->readIntReg(i) != shared_data->intregs[i]) {
256 diffRegs = true;
257 }
258 }
318 if (lgnPc != m5Pc)
319 diffPC = true;
320 if (shared_data->instruction !=
321 (SparcISA::MachInst)staticInst->machInst) {
322 diffInst = true;
323 }
324 for (int i = 0; i < TheISA::NumRegularIntRegs; i++) {
325 if (thread->readIntReg(i) != shared_data->intregs[i]) {
326 diffRegs = true;
327 }
328 }
329 uint64_t oldTl = thread->readMiscReg(MISCREG_TL);
330 if (oldTl != shared_data->tl)
331 diffTl = true;
332 for (int i = 1; i <= MaxTL; i++) {
333 thread->setMiscReg(MISCREG_TL, i);
334 if (thread->readMiscReg(MISCREG_TPC) !=
335 shared_data->tpc[i])
336 diffTpc = true;
337 if (thread->readMiscReg(MISCREG_TNPC) !=
338 shared_data->tnpc[i])
339 diffTnpc = true;
340 if (thread->readMiscReg(MISCREG_TSTATE) !=
341 shared_data->tstate[i])
342 diffTstate = true;
343 if (thread->readMiscReg(MISCREG_TT) !=
344 shared_data->tt[i])
345 diffTt = true;
346 if (thread->readMiscReg(MISCREG_HTSTATE) !=
347 shared_data->htstate[i])
348 diffHtstate = true;
349 }
350 thread->setMiscReg(MISCREG_TL, oldTl);
259
351
260 if (diffPC || diffInst || diffRegs ) {
352 if(shared_data->tba != thread->readMiscReg(MISCREG_TBA))
353 diffTba = true;
354 //When the hpstate register is read by an instruction,
355 //legion has bit 11 set. When it's in storage, it doesn't.
356 //Since we don't directly support seperate interpretations
357 //of the registers like that, the bit is always set to 1 and
358 //we just don't compare it. It's not supposed to matter
359 //anyway.
360 if((shared_data->hpstate | (1 << 11)) != thread->readMiscReg(MISCREG_HPSTATE))
361 diffHpstate = true;
362 if(shared_data->htba != thread->readMiscReg(MISCREG_HTBA))
363 diffHtba = true;
364 if(shared_data->pstate != thread->readMiscReg(MISCREG_PSTATE))
365 diffPstate = true;
366 if(shared_data->y != thread->readMiscReg(MISCREG_Y))
367 diffY = true;
368 if(shared_data->ccr != thread->readMiscReg(MISCREG_CCR))
369 diffCcr = true;
370 if(shared_data->gl != thread->readMiscReg(MISCREG_GL))
371 diffGl = true;
372 if(shared_data->asi != thread->readMiscReg(MISCREG_ASI))
373 diffAsi = true;
374 if(shared_data->pil != thread->readMiscReg(MISCREG_PIL))
375 diffPil = true;
376 if(shared_data->cwp != thread->readMiscReg(MISCREG_CWP))
377 diffCwp = true;
378 if(shared_data->cansave != thread->readMiscReg(MISCREG_CANSAVE))
379 diffCansave = true;
380 if(shared_data->canrestore !=
381 thread->readMiscReg(MISCREG_CANRESTORE))
382 diffCanrestore = true;
383 if(shared_data->otherwin != thread->readMiscReg(MISCREG_OTHERWIN))
384 diffOtherwin = true;
385 if(shared_data->cleanwin != thread->readMiscReg(MISCREG_CLEANWIN))
386 diffCleanwin = true;
387
388 if (diffPC || diffInst || diffRegs || diffTpc || diffTnpc ||
389 diffTstate || diffTt || diffHpstate ||
390 diffHtstate || diffHtba || diffPstate || diffY ||
391 diffCcr || diffTl || diffGl || diffAsi || diffPil ||
392 diffCwp || diffCansave || diffCanrestore ||
393 diffOtherwin || diffCleanwin) {
261 outs << "Differences found between M5 and Legion:";
262 if (diffPC)
263 outs << " [PC]";
264 if (diffInst)
265 outs << " [Instruction]";
266 if (diffRegs)
267 outs << " [IntRegs]";
394 outs << "Differences found between M5 and Legion:";
395 if (diffPC)
396 outs << " [PC]";
397 if (diffInst)
398 outs << " [Instruction]";
399 if (diffRegs)
400 outs << " [IntRegs]";
401 if (diffTpc)
402 outs << " [Tpc]";
403 if (diffTnpc)
404 outs << " [Tnpc]";
405 if (diffTstate)
406 outs << " [Tstate]";
407 if (diffTt)
408 outs << " [Tt]";
409 if (diffHpstate)
410 outs << " [Hpstate]";
411 if (diffHtstate)
412 outs << " [Htstate]";
413 if (diffHtba)
414 outs << " [Htba]";
415 if (diffPstate)
416 outs << " [Pstate]";
417 if (diffY)
418 outs << " [Y]";
419 if (diffCcr)
420 outs << " [Ccr]";
421 if (diffTl)
422 outs << " [Tl]";
423 if (diffGl)
424 outs << " [Gl]";
425 if (diffAsi)
426 outs << " [Asi]";
427 if (diffPil)
428 outs << " [Pil]";
429 if (diffCwp)
430 outs << " [Cwp]";
431 if (diffCansave)
432 outs << " [Cansave]";
433 if (diffCanrestore)
434 outs << " [Canrestore]";
435 if (diffOtherwin)
436 outs << " [Otherwin]";
437 if (diffCleanwin)
438 outs << " [Cleanwin]";
268 outs << endl << endl;
269
270 outs << right << setfill(' ') << setw(15)
271 << "M5 PC: " << "0x"<< setw(16) << setfill('0')
272 << hex << m5Pc << endl;
273 outs << setfill(' ') << setw(15)
274 << "Legion PC: " << "0x"<< setw(16) << setfill('0') << hex
275 << lgnPc << endl << endl;
276
277 outs << setfill(' ') << setw(15)
278 << "M5 Inst: " << "0x"<< setw(8)
279 << setfill('0') << hex << staticInst->machInst
280 << staticInst->disassemble(m5Pc, debugSymbolTable)
281 << endl;
282
439 outs << endl << endl;
440
441 outs << right << setfill(' ') << setw(15)
442 << "M5 PC: " << "0x"<< setw(16) << setfill('0')
443 << hex << m5Pc << endl;
444 outs << setfill(' ') << setw(15)
445 << "Legion PC: " << "0x"<< setw(16) << setfill('0') << hex
446 << lgnPc << endl << endl;
447
448 outs << setfill(' ') << setw(15)
449 << "M5 Inst: " << "0x"<< setw(8)
450 << setfill('0') << hex << staticInst->machInst
451 << staticInst->disassemble(m5Pc, debugSymbolTable)
452 << endl;
453
283 StaticInstPtr legionInst = StaticInst::decode(makeExtMI(shared_data->instruction, thread));
454 StaticInstPtr legionInst =
455 StaticInst::decode(makeExtMI(shared_data->instruction,
456 thread));
284 outs << setfill(' ') << setw(15)
285 << " Legion Inst: "
286 << "0x" << setw(8) << setfill('0') << hex
287 << shared_data->instruction
288 << legionInst->disassemble(lgnPc, debugSymbolTable)
457 outs << setfill(' ') << setw(15)
458 << " Legion Inst: "
459 << "0x" << setw(8) << setfill('0') << hex
460 << shared_data->instruction
461 << legionInst->disassemble(lgnPc, debugSymbolTable)
289 << endl;
462 << endl << endl;
290
463
464 printSectionHeader(outs, "General State");
465 printColumnLabels(outs);
466 printRegPair(outs, "HPstate",
467 thread->readMiscReg(MISCREG_HPSTATE),
468 shared_data->hpstate | (1 << 11));
469 printRegPair(outs, "Htba",
470 thread->readMiscReg(MISCREG_HTBA),
471 shared_data->htba);
472 printRegPair(outs, "Pstate",
473 thread->readMiscReg(MISCREG_PSTATE),
474 shared_data->pstate);
475 printRegPair(outs, "Y",
476 thread->readMiscReg(MISCREG_Y),
477 shared_data->y);
478 printRegPair(outs, "Ccr",
479 thread->readMiscReg(MISCREG_CCR),
480 shared_data->ccr);
481 printRegPair(outs, "Tl",
482 thread->readMiscReg(MISCREG_TL),
483 shared_data->tl);
484 printRegPair(outs, "Gl",
485 thread->readMiscReg(MISCREG_GL),
486 shared_data->gl);
487 printRegPair(outs, "Asi",
488 thread->readMiscReg(MISCREG_ASI),
489 shared_data->asi);
490 printRegPair(outs, "Pil",
491 thread->readMiscReg(MISCREG_PIL),
492 shared_data->pil);
493 printRegPair(outs, "Cwp",
494 thread->readMiscReg(MISCREG_CWP),
495 shared_data->cwp);
496 printRegPair(outs, "Cansave",
497 thread->readMiscReg(MISCREG_CANSAVE),
498 shared_data->cansave);
499 printRegPair(outs, "Canrestore",
500 thread->readMiscReg(MISCREG_CANRESTORE),
501 shared_data->canrestore);
502 printRegPair(outs, "Otherwin",
503 thread->readMiscReg(MISCREG_OTHERWIN),
504 shared_data->otherwin);
505 printRegPair(outs, "Cleanwin",
506 thread->readMiscReg(MISCREG_CLEANWIN),
507 shared_data->cleanwin);
291 outs << endl;
508 outs << endl;
509 for (int i = 1; i <= MaxTL; i++) {
510 printLevelHeader(outs, i);
511 printColumnLabels(outs);
512 thread->setMiscReg(MISCREG_TL, i);
513 printRegPair(outs, "Tpc",
514 thread->readMiscReg(MISCREG_TPC),
515 shared_data->tpc[i]);
516 printRegPair(outs, "Tnpc",
517 thread->readMiscReg(MISCREG_TNPC),
518 shared_data->tnpc[i]);
519 printRegPair(outs, "Tstate",
520 thread->readMiscReg(MISCREG_TSTATE),
521 shared_data->tstate[i]);
522 printRegPair(outs, "Tt",
523 thread->readMiscReg(MISCREG_TT),
524 shared_data->tt[i]);
525 printRegPair(outs, "Htstate",
526 thread->readMiscReg(MISCREG_HTSTATE),
527 shared_data->htstate[i]);
528 }
529 thread->setMiscReg(MISCREG_TL, oldTl);
530 outs << endl;
292
531
532 printSectionHeader(outs, "General Purpose Registers");
293 static const char * regtypes[4] = {"%g", "%o", "%l", "%i"};
294 for(int y = 0; y < 4; y++)
295 {
296 for(int x = 0; x < 8; x++)
297 {
533 static const char * regtypes[4] = {"%g", "%o", "%l", "%i"};
534 for(int y = 0; y < 4; y++)
535 {
536 for(int x = 0; x < 8; x++)
537 {
298 outs << regtypes[y] << x << " " ;
299 outs << "0x" << hex << setw(16) << thread->readIntReg(y*8+x);
300 if (thread->readIntReg(y*8 + x) != shared_data->intregs[y*8+x])
538 char label[8];
539 sprintf(label, "%s%d", regtypes[y], x);
540 printRegPair(outs, label,
541 thread->readIntReg(y*8+x),
542 shared_data->intregs[y*8+x]);
543 /*outs << regtypes[y] << x << " " ;
544 outs << "0x" << hex << setw(16)
545 << thread->readIntReg(y*8+x);
546 if (thread->readIntReg(y*8 + x)
547 != shared_data->intregs[y*8+x])
301 outs << " X ";
302 else
303 outs << " | ";
548 outs << " X ";
549 else
550 outs << " | ";
304 outs << "0x" << setw(16) << hex << shared_data->intregs[y*8+x]
305 << endl;
551 outs << "0x" << setw(16) << hex
552 << shared_data->intregs[y*8+x]
553 << endl;*/
306 }
307 }
308 fatal("Differences found between Legion and M5\n");
309 }
310
311 compared = true;
312 shared_data->flags = OWN_LEGION;
313 }

--- 113 unchanged lines hidden ---
554 }
555 }
556 fatal("Differences found between Legion and M5\n");
557 }
558
559 compared = true;
560 shared_data->flags = OWN_LEGION;
561 }

--- 113 unchanged lines hidden ---