nativetrace.cc revision 6397
11689SN/A/* 28733Sgeoffrey.blake@arm.com * Copyright (c) 2006 The Regents of The University of Michigan 37598Sminkyu.jeong@arm.com * All rights reserved. 47598Sminkyu.jeong@arm.com * 57598Sminkyu.jeong@arm.com * Redistribution and use in source and binary forms, with or without 67598Sminkyu.jeong@arm.com * modification, are permitted provided that the following conditions are 77598Sminkyu.jeong@arm.com * met: redistributions of source code must retain the above copyright 87598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer; 97598Sminkyu.jeong@arm.com * redistributions in binary form must reproduce the above copyright 107598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer in the 117598Sminkyu.jeong@arm.com * documentation and/or other materials provided with the distribution; 127598Sminkyu.jeong@arm.com * neither the name of the copyright holders nor the names of its 137598Sminkyu.jeong@arm.com * contributors may be used to endorse or promote products derived from 142326SN/A * this software without specific prior written permission. 151689SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A * 281689SN/A * Authors: Gabe Black 291689SN/A */ 301689SN/A 311689SN/A#include "arch/arm/isa_traits.hh" 321689SN/A#include "arch/arm/miscregs.hh" 331689SN/A#include "arch/arm/nativetrace.hh" 341689SN/A#include "cpu/thread_context.hh" 351689SN/A#include "params/ArmNativeTrace.hh" 361689SN/A 371689SN/Anamespace Trace { 381689SN/A 392665Ssaidi@eecs.umich.edustatic const char *regNames[] = { 402665Ssaidi@eecs.umich.edu "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 411689SN/A "r8", "r9", "r10", "fp", "r12", "sp", "lr", "pc", 421689SN/A "cpsr" 431060SN/A}; 441060SN/A 451689SN/Avoid 461060SN/ATrace::ArmNativeTrace::check(NativeTraceRecord *record) 471060SN/A{ 481060SN/A ThreadContext *tc = record->getThread(); 498230Snate@binkert.org 506658Snate@binkert.org uint32_t regVal, realRegVal; 518733Sgeoffrey.blake@arm.com 522292SN/A const char **regName = regNames; 531717SN/A // Regular int regs 548229Snate@binkert.org for (int i = 0; i < 15; i++) { 558232Snate@binkert.org regVal = tc->readIntReg(i); 568232Snate@binkert.org read(&realRegVal, sizeof(realRegVal)); 578232Snate@binkert.org realRegVal = ArmISA::gtoh(realRegVal); 585529Snate@binkert.org checkReg(*(regName++), regVal, realRegVal); 591060SN/A } 608733Sgeoffrey.blake@arm.com 618733Sgeoffrey.blake@arm.com //R15, aliased with the PC 628733Sgeoffrey.blake@arm.com regVal = tc->readNextPC(); 638733Sgeoffrey.blake@arm.com read(&realRegVal, sizeof(realRegVal)); 646221Snate@binkert.org realRegVal = ArmISA::gtoh(realRegVal); 656221Snate@binkert.org checkReg(*(regName++), regVal, realRegVal); 661681SN/A 675529Snate@binkert.org //CPSR 682873Sktlim@umich.edu regVal = tc->readMiscReg(MISCREG_CPSR); 694329Sktlim@umich.edu read(&realRegVal, sizeof(realRegVal)); 704329Sktlim@umich.edu realRegVal = ArmISA::gtoh(realRegVal); 714329Sktlim@umich.edu checkReg(*(regName++), regVal, realRegVal); 722292SN/A} 732292SN/A 742292SN/A} /* namespace Trace */ 752292SN/A 762820Sktlim@umich.edu//////////////////////////////////////////////////////////////////////// 772292SN/A// 782820Sktlim@umich.edu// ExeTracer Simulation Object 792820Sktlim@umich.edu// 805529Snate@binkert.orgTrace::ArmNativeTrace * 812307SN/AArmNativeTraceParams::create() 821060SN/A{ 832292SN/A return new Trace::ArmNativeTrace(this); 842292SN/A}; 852292SN/A