nativetrace.cc revision 6365
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 2006 The Regents of The University of Michigan 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org * 286145Snate@binkert.org * Authors: Gabe Black 296145Snate@binkert.org */ 306845Sdrh5@cs.wisc.edu 316154Snate@binkert.org#include "arch/sparc/isa_traits.hh" 326154Snate@binkert.org#include "arch/sparc/registers.hh" 336154Snate@binkert.org#include "arch/sparc/nativetrace.hh" 346154Snate@binkert.org#include "cpu/thread_context.hh" 356154Snate@binkert.org#include "params/SparcNativeTrace.hh" 366154Snate@binkert.org 376285Snate@binkert.orgnamespace Trace { 386285Snate@binkert.org 396154Snate@binkert.orgstatic char *intRegNames[SparcISA::NumIntArchRegs] = { 406154Snate@binkert.org //Global registers 416154Snate@binkert.org "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", 426285Snate@binkert.org //Output registers 436285Snate@binkert.org "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", 446899SBrad.Beckmann@amd.com //Local registers 456145Snate@binkert.org "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", 466876Ssteve.reinhardt@amd.com //Input registers 476876Ssteve.reinhardt@amd.com "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", 486285Snate@binkert.org}; 496145Snate@binkert.org 506355Spdudnik@gmail.comvoid 516850Spdudnik@gmail.comTrace::SparcNativeTrace::check(NativeTraceRecord *record) 526876Ssteve.reinhardt@amd.com{ 536876Ssteve.reinhardt@amd.com ThreadContext *tc = record->getThread(); 546876Ssteve.reinhardt@amd.com 556285Snate@binkert.org uint64_t regVal, realRegVal; 566876Ssteve.reinhardt@amd.com 576285Snate@binkert.org // Integer registers 586876Ssteve.reinhardt@amd.com 596876Ssteve.reinhardt@amd.com // I doubt a real SPARC will describe more integer registers than this. 606886SBrad.Beckmann@amd.com assert(SparcISA::NumIntArchRegs == 32); 616876Ssteve.reinhardt@amd.com char **regName = intRegNames; 626876Ssteve.reinhardt@amd.com for (int i = 0; i < SparcISA::NumIntArchRegs; i++) { 636876Ssteve.reinhardt@amd.com regVal = tc->readIntReg(i); 646876Ssteve.reinhardt@amd.com read(&realRegVal, sizeof(realRegVal)); 656876Ssteve.reinhardt@amd.com realRegVal = SparcISA::gtoh(realRegVal); 666876Ssteve.reinhardt@amd.com checkReg(*(regName++), regVal, realRegVal); 676876Ssteve.reinhardt@amd.com } 686285Snate@binkert.org 696876Ssteve.reinhardt@amd.com // PC 706876Ssteve.reinhardt@amd.com read(&realRegVal, sizeof(realRegVal)); 716876Ssteve.reinhardt@amd.com realRegVal = SparcISA::gtoh(realRegVal); 726876Ssteve.reinhardt@amd.com regVal = tc->readNextPC(); 736145Snate@binkert.org checkReg("pc", regVal, realRegVal); 746876Ssteve.reinhardt@amd.com 756876Ssteve.reinhardt@amd.com // NPC 766876Ssteve.reinhardt@amd.com read(&realRegVal, sizeof(realRegVal)); 776876Ssteve.reinhardt@amd.com realRegVal = SparcISA::gtoh(realRegVal); 786899SBrad.Beckmann@amd.com regVal = tc->readNextNPC(); 796899SBrad.Beckmann@amd.com checkReg("npc", regVal, realRegVal); 806876Ssteve.reinhardt@amd.com 816876Ssteve.reinhardt@amd.com // CCR 826876Ssteve.reinhardt@amd.com read(&realRegVal, sizeof(realRegVal)); 836876Ssteve.reinhardt@amd.com realRegVal = SparcISA::gtoh(realRegVal); 846145Snate@binkert.org regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2); 856145Snate@binkert.org checkReg("ccr", regVal, realRegVal); 866145Snate@binkert.org} 876285Snate@binkert.org 886145Snate@binkert.org} /* namespace Trace */ 896145Snate@binkert.org 906145Snate@binkert.org//////////////////////////////////////////////////////////////////////// 916145Snate@binkert.org// 926145Snate@binkert.org// ExeTracer Simulation Object 936145Snate@binkert.org// 946145Snate@binkert.orgTrace::SparcNativeTrace * 956145Snate@binkert.orgSparcNativeTraceParams::create() 966285Snate@binkert.org{ 976285Snate@binkert.org return new Trace::SparcNativeTrace(this); 986285Snate@binkert.org}; 996285Snate@binkert.org