nativetrace.cc revision 6365
12SN/A/* 24039Sbinkertn@umich.edu * Copyright (c) 2006 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu */ 302SN/A 312SN/A#include "arch/sparc/isa_traits.hh" 324039Sbinkertn@umich.edu#include "arch/sparc/registers.hh" 334039Sbinkertn@umich.edu#include "arch/sparc/nativetrace.hh" 342SN/A#include "cpu/thread_context.hh" 354039Sbinkertn@umich.edu#include "params/SparcNativeTrace.hh" 362SN/A 372SN/Anamespace Trace { 382SN/A 392SN/Astatic char *intRegNames[SparcISA::NumIntArchRegs] = { 408229Snate@binkert.org //Global registers 414039Sbinkertn@umich.edu "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", 422621SN/A //Output registers 432SN/A "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", 442SN/A //Local registers 454039Sbinkertn@umich.edu "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", 464039Sbinkertn@umich.edu //Input registers 474039Sbinkertn@umich.edu "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", 484039Sbinkertn@umich.edu}; 492SN/A 504039Sbinkertn@umich.eduvoid 514039Sbinkertn@umich.eduTrace::SparcNativeTrace::check(NativeTraceRecord *record) 524039Sbinkertn@umich.edu{ 534039Sbinkertn@umich.edu ThreadContext *tc = record->getThread(); 545756Snate@binkert.org 554039Sbinkertn@umich.edu uint64_t regVal, realRegVal; 564039Sbinkertn@umich.edu 574039Sbinkertn@umich.edu // Integer registers 584039Sbinkertn@umich.edu 594039Sbinkertn@umich.edu // I doubt a real SPARC will describe more integer registers than this. 605756Snate@binkert.org assert(SparcISA::NumIntArchRegs == 32); 615756Snate@binkert.org char **regName = intRegNames; 624039Sbinkertn@umich.edu for (int i = 0; i < SparcISA::NumIntArchRegs; i++) { 634039Sbinkertn@umich.edu regVal = tc->readIntReg(i); 644039Sbinkertn@umich.edu read(&realRegVal, sizeof(realRegVal)); 654039Sbinkertn@umich.edu realRegVal = SparcISA::gtoh(realRegVal); 664039Sbinkertn@umich.edu checkReg(*(regName++), regVal, realRegVal); 672SN/A } 685756Snate@binkert.org 695756Snate@binkert.org // PC 705756Snate@binkert.org read(&realRegVal, sizeof(realRegVal)); 715756Snate@binkert.org realRegVal = SparcISA::gtoh(realRegVal); 725756Snate@binkert.org regVal = tc->readNextPC(); 735756Snate@binkert.org checkReg("pc", regVal, realRegVal); 745756Snate@binkert.org 755756Snate@binkert.org // NPC 765756Snate@binkert.org read(&realRegVal, sizeof(realRegVal)); 775756Snate@binkert.org realRegVal = SparcISA::gtoh(realRegVal); 785756Snate@binkert.org regVal = tc->readNextNPC(); 795756Snate@binkert.org checkReg("npc", regVal, realRegVal); 805756Snate@binkert.org 812SN/A // CCR 824039Sbinkertn@umich.edu read(&realRegVal, sizeof(realRegVal)); 834039Sbinkertn@umich.edu realRegVal = SparcISA::gtoh(realRegVal); 842SN/A regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2); 855756Snate@binkert.org checkReg("ccr", regVal, realRegVal); 865756Snate@binkert.org} 875756Snate@binkert.org 885756Snate@binkert.org} /* namespace Trace */ 895756Snate@binkert.org 905756Snate@binkert.org//////////////////////////////////////////////////////////////////////// 915756Snate@binkert.org// 925756Snate@binkert.org// ExeTracer Simulation Object 935756Snate@binkert.org// 945756Snate@binkert.orgTrace::SparcNativeTrace * 955756Snate@binkert.orgSparcNativeTraceParams::create() 965756Snate@binkert.org{ 975756Snate@binkert.org return new Trace::SparcNativeTrace(this); 985756Snate@binkert.org}; 995756Snate@binkert.org