nativetrace.cc revision 7811
14776SN/A/* 26365Sgblack@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan 34776SN/A * All rights reserved. 44776SN/A * 54776SN/A * Redistribution and use in source and binary forms, with or without 64776SN/A * modification, are permitted provided that the following conditions are 74776SN/A * met: redistributions of source code must retain the above copyright 84776SN/A * notice, this list of conditions and the following disclaimer; 94776SN/A * redistributions in binary form must reproduce the above copyright 104776SN/A * notice, this list of conditions and the following disclaimer in the 114776SN/A * documentation and/or other materials provided with the distribution; 124776SN/A * neither the name of the copyright holders nor the names of its 134776SN/A * contributors may be used to endorse or promote products derived from 144776SN/A * this software without specific prior written permission. 154776SN/A * 164776SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174776SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184776SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194776SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204776SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214776SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224776SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234776SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244776SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254776SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264776SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274776SN/A * 286365Sgblack@eecs.umich.edu * Authors: Gabe Black 294776SN/A */ 304776SN/A 316365Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh" 326365Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh" 336365Sgblack@eecs.umich.edu#include "arch/sparc/nativetrace.hh" 344776SN/A#include "cpu/thread_context.hh" 356365Sgblack@eecs.umich.edu#include "params/SparcNativeTrace.hh" 367678Sgblack@eecs.umich.edu#include "sim/byteswap.hh" 374776SN/A 384776SN/Anamespace Trace { 394776SN/A 406388Sgblack@eecs.umich.edustatic const char *intRegNames[SparcISA::NumIntArchRegs] = { 417741Sgblack@eecs.umich.edu // Global registers 426365Sgblack@eecs.umich.edu "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", 437741Sgblack@eecs.umich.edu // Output registers 446365Sgblack@eecs.umich.edu "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", 457741Sgblack@eecs.umich.edu // Local registers 466365Sgblack@eecs.umich.edu "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", 477741Sgblack@eecs.umich.edu // Input registers 486365Sgblack@eecs.umich.edu "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", 496365Sgblack@eecs.umich.edu}; 506365Sgblack@eecs.umich.edu 516365Sgblack@eecs.umich.eduvoid 526365Sgblack@eecs.umich.eduTrace::SparcNativeTrace::check(NativeTraceRecord *record) 534776SN/A{ 546365Sgblack@eecs.umich.edu ThreadContext *tc = record->getThread(); 555523SN/A 566365Sgblack@eecs.umich.edu uint64_t regVal, realRegVal; 576365Sgblack@eecs.umich.edu 586365Sgblack@eecs.umich.edu // Integer registers 596365Sgblack@eecs.umich.edu 606365Sgblack@eecs.umich.edu // I doubt a real SPARC will describe more integer registers than this. 616365Sgblack@eecs.umich.edu assert(SparcISA::NumIntArchRegs == 32); 626388Sgblack@eecs.umich.edu const char **regName = intRegNames; 636365Sgblack@eecs.umich.edu for (int i = 0; i < SparcISA::NumIntArchRegs; i++) { 646365Sgblack@eecs.umich.edu regVal = tc->readIntReg(i); 656365Sgblack@eecs.umich.edu read(&realRegVal, sizeof(realRegVal)); 666365Sgblack@eecs.umich.edu realRegVal = SparcISA::gtoh(realRegVal); 676365Sgblack@eecs.umich.edu checkReg(*(regName++), regVal, realRegVal); 684776SN/A } 696365Sgblack@eecs.umich.edu 707720Sgblack@eecs.umich.edu SparcISA::PCState pc = tc->pcState(); 716365Sgblack@eecs.umich.edu // PC 726365Sgblack@eecs.umich.edu read(&realRegVal, sizeof(realRegVal)); 736365Sgblack@eecs.umich.edu realRegVal = SparcISA::gtoh(realRegVal); 747720Sgblack@eecs.umich.edu regVal = pc.npc(); 756365Sgblack@eecs.umich.edu checkReg("pc", regVal, realRegVal); 766365Sgblack@eecs.umich.edu 776365Sgblack@eecs.umich.edu // NPC 786365Sgblack@eecs.umich.edu read(&realRegVal, sizeof(realRegVal)); 796365Sgblack@eecs.umich.edu realRegVal = SparcISA::gtoh(realRegVal); 807720Sgblack@eecs.umich.edu pc.nnpc(); 816365Sgblack@eecs.umich.edu checkReg("npc", regVal, realRegVal); 826365Sgblack@eecs.umich.edu 836365Sgblack@eecs.umich.edu // CCR 846365Sgblack@eecs.umich.edu read(&realRegVal, sizeof(realRegVal)); 856365Sgblack@eecs.umich.edu realRegVal = SparcISA::gtoh(realRegVal); 866365Sgblack@eecs.umich.edu regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2); 876365Sgblack@eecs.umich.edu checkReg("ccr", regVal, realRegVal); 884776SN/A} 894776SN/A 907811Ssteve.reinhardt@amd.com} // namespace Trace 914776SN/A 924776SN/A//////////////////////////////////////////////////////////////////////// 934776SN/A// 944776SN/A// ExeTracer Simulation Object 954776SN/A// 966365Sgblack@eecs.umich.eduTrace::SparcNativeTrace * 976365Sgblack@eecs.umich.eduSparcNativeTraceParams::create() 984776SN/A{ 996365Sgblack@eecs.umich.edu return new Trace::SparcNativeTrace(this); 1004776SN/A}; 101