nativetrace.cc revision 6397
14776SN/A/* 26365SN/A * 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 * 286365SN/A * Authors: Gabe Black 294776SN/A */ 304776SN/A 316397Sgblack@eecs.umich.edu#include "arch/arm/isa_traits.hh" 326397Sgblack@eecs.umich.edu#include "arch/arm/miscregs.hh" 336397Sgblack@eecs.umich.edu#include "arch/arm/nativetrace.hh" 344776SN/A#include "cpu/thread_context.hh" 356397Sgblack@eecs.umich.edu#include "params/ArmNativeTrace.hh" 364776SN/A 374776SN/Anamespace Trace { 384776SN/A 396397Sgblack@eecs.umich.edustatic const char *regNames[] = { 406397Sgblack@eecs.umich.edu "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 416397Sgblack@eecs.umich.edu "r8", "r9", "r10", "fp", "r12", "sp", "lr", "pc", 426397Sgblack@eecs.umich.edu "cpsr" 436365SN/A}; 446365SN/A 456365SN/Avoid 466397Sgblack@eecs.umich.eduTrace::ArmNativeTrace::check(NativeTraceRecord *record) 474776SN/A{ 486365SN/A ThreadContext *tc = record->getThread(); 495523SN/A 506397Sgblack@eecs.umich.edu uint32_t regVal, realRegVal; 516365SN/A 526397Sgblack@eecs.umich.edu const char **regName = regNames; 536397Sgblack@eecs.umich.edu // Regular int regs 546397Sgblack@eecs.umich.edu for (int i = 0; i < 15; i++) { 556365SN/A regVal = tc->readIntReg(i); 566365SN/A read(&realRegVal, sizeof(realRegVal)); 576397Sgblack@eecs.umich.edu realRegVal = ArmISA::gtoh(realRegVal); 586365SN/A checkReg(*(regName++), regVal, realRegVal); 594776SN/A } 606365SN/A 616397Sgblack@eecs.umich.edu //R15, aliased with the PC 626397Sgblack@eecs.umich.edu regVal = tc->readNextPC(); 636365SN/A read(&realRegVal, sizeof(realRegVal)); 646397Sgblack@eecs.umich.edu realRegVal = ArmISA::gtoh(realRegVal); 656397Sgblack@eecs.umich.edu checkReg(*(regName++), regVal, realRegVal); 666365SN/A 676397Sgblack@eecs.umich.edu //CPSR 686397Sgblack@eecs.umich.edu regVal = tc->readMiscReg(MISCREG_CPSR); 696365SN/A read(&realRegVal, sizeof(realRegVal)); 706397Sgblack@eecs.umich.edu realRegVal = ArmISA::gtoh(realRegVal); 716397Sgblack@eecs.umich.edu checkReg(*(regName++), regVal, realRegVal); 724776SN/A} 734776SN/A 746365SN/A} /* namespace Trace */ 754776SN/A 764776SN/A//////////////////////////////////////////////////////////////////////// 774776SN/A// 784776SN/A// ExeTracer Simulation Object 794776SN/A// 806397Sgblack@eecs.umich.eduTrace::ArmNativeTrace * 816397Sgblack@eecs.umich.eduArmNativeTraceParams::create() 824776SN/A{ 836397Sgblack@eecs.umich.edu return new Trace::ArmNativeTrace(this); 844776SN/A}; 85