nativetrace.cc revision 11793
17405SAli.Saidi@ARM.com/*
212667Schuan.zhu@arm.com * Copyright (c) 2006 The Regents of The University of Michigan
37405SAli.Saidi@ARM.com * All rights reserved.
47405SAli.Saidi@ARM.com *
57405SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
67405SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are
77405SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright
87405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer;
97405SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright
107405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the
117405SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution;
127405SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its
137405SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from
147405SAli.Saidi@ARM.com * this software without specific prior written permission.
157405SAli.Saidi@ARM.com *
167405SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177405SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187405SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197405SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207405SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217405SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227405SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237405SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247405SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257405SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267405SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277405SAli.Saidi@ARM.com *
287405SAli.Saidi@ARM.com * Authors: Gabe Black
297405SAli.Saidi@ARM.com */
307405SAli.Saidi@ARM.com
317405SAli.Saidi@ARM.com#include "arch/sparc/nativetrace.hh"
327405SAli.Saidi@ARM.com
337405SAli.Saidi@ARM.com#include "arch/sparc/isa_traits.hh"
347405SAli.Saidi@ARM.com#include "arch/sparc/registers.hh"
357405SAli.Saidi@ARM.com#include "cpu/thread_context.hh"
367405SAli.Saidi@ARM.com#include "params/SparcNativeTrace.hh"
377405SAli.Saidi@ARM.com#include "sim/byteswap.hh"
387405SAli.Saidi@ARM.com
397405SAli.Saidi@ARM.comnamespace Trace {
407405SAli.Saidi@ARM.com
417405SAli.Saidi@ARM.comstatic const char *intRegNames[SparcISA::NumIntArchRegs] = {
4210461SAndreas.Sandberg@ARM.com    // Global registers
439050Schander.sudanthi@arm.com    "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
4412406Sgabeblack@google.com    // Output registers
4512605Sgiacomo.travaglini@arm.com    "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7",
4611793Sbrandon.potter@amd.com    // Local registers
478887Sgeoffrey.blake@arm.com    "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
488232Snate@binkert.org    // Input registers
498232Snate@binkert.org    "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
5010844Sandreas.sandberg@arm.com};
519384SAndreas.Sandberg@arm.com
527678Sgblack@eecs.umich.eduvoid
538059SAli.Saidi@ARM.comTrace::SparcNativeTrace::check(NativeTraceRecord *record)
548284SAli.Saidi@ARM.com{
557405SAli.Saidi@ARM.com    ThreadContext *tc = record->getThread();
567405SAli.Saidi@ARM.com
577405SAli.Saidi@ARM.com    uint64_t regVal, realRegVal;
587405SAli.Saidi@ARM.com
599384SAndreas.Sandberg@arm.com    // Integer registers
6010461SAndreas.Sandberg@ARM.com
6110461SAndreas.Sandberg@ARM.com    // I doubt a real SPARC will describe more integer registers than this.
6211165SRekai.GonzalezAlberquilla@arm.com    assert(SparcISA::NumIntArchRegs == 32);
6312109SRekai.GonzalezAlberquilla@arm.com    const char **regName = intRegNames;
6412714Sgiacomo.travaglini@arm.com    for (int i = 0; i < SparcISA::NumIntArchRegs; i++) {
6512714Sgiacomo.travaglini@arm.com        regVal = tc->readIntReg(i);
669384SAndreas.Sandberg@arm.com        read(&realRegVal, sizeof(realRegVal));
6711770SCurtis.Dunham@arm.com        realRegVal = SparcISA::gtoh(realRegVal);
6810037SARM gem5 Developers        checkReg(*(regName++), regVal, realRegVal);
6910461SAndreas.Sandberg@ARM.com    }
7010461SAndreas.Sandberg@ARM.com
7110461SAndreas.Sandberg@ARM.com    SparcISA::PCState pc = tc->pcState();
7210461SAndreas.Sandberg@ARM.com    // PC
7310461SAndreas.Sandberg@ARM.com    read(&realRegVal, sizeof(realRegVal));
7410461SAndreas.Sandberg@ARM.com    realRegVal = SparcISA::gtoh(realRegVal);
7510609Sandreas.sandberg@arm.com    regVal = pc.npc();
7610609Sandreas.sandberg@arm.com    checkReg("pc", regVal, realRegVal);
7710609Sandreas.sandberg@arm.com
7810037SARM gem5 Developers    // NPC
7910037SARM gem5 Developers    read(&realRegVal, sizeof(realRegVal));
8010037SARM gem5 Developers    realRegVal = SparcISA::gtoh(realRegVal);
8110037SARM gem5 Developers    pc.nnpc();
8211771SCurtis.Dunham@arm.com    checkReg("npc", regVal, realRegVal);
8310037SARM gem5 Developers
8410037SARM gem5 Developers    // CCR
8513173Sgiacomo.travaglini@arm.com    read(&realRegVal, sizeof(realRegVal));
8610037SARM gem5 Developers    realRegVal = SparcISA::gtoh(realRegVal);
8710037SARM gem5 Developers    regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2);
8813114Sgiacomo.travaglini@arm.com    checkReg("ccr", regVal, realRegVal);
8910037SARM gem5 Developers}
9011771SCurtis.Dunham@arm.com
9110037SARM gem5 Developers} // namespace Trace
9213499Sgiacomo.travaglini@arm.com
9310037SARM gem5 Developers////////////////////////////////////////////////////////////////////////
9413114Sgiacomo.travaglini@arm.com//
9510037SARM gem5 Developers//  ExeTracer Simulation Object
9610037SARM gem5 Developers//
9712477SCurtis.Dunham@arm.comTrace::SparcNativeTrace *
9810037SARM gem5 DevelopersSparcNativeTraceParams::create()
9910037SARM gem5 Developers{
1009384SAndreas.Sandberg@arm.com    return new Trace::SparcNativeTrace(this);
1019384SAndreas.Sandberg@arm.com};
1029384SAndreas.Sandberg@arm.com