exetrace.cc revision 8229:78bf55f23338
12817Sksewell@umich.edu/* 213610Sgiacomo.gabrielli@arm.com * Copyright (c) 2001-2005 The Regents of The University of Michigan 39920Syasuko.eckert@amd.com * All rights reserved. 48733Sgeoffrey.blake@arm.com * 58733Sgeoffrey.blake@arm.com * Redistribution and use in source and binary forms, with or without 68733Sgeoffrey.blake@arm.com * modification, are permitted provided that the following conditions are 78733Sgeoffrey.blake@arm.com * met: redistributions of source code must retain the above copyright 88733Sgeoffrey.blake@arm.com * notice, this list of conditions and the following disclaimer; 98733Sgeoffrey.blake@arm.com * redistributions in binary form must reproduce the above copyright 108733Sgeoffrey.blake@arm.com * notice, this list of conditions and the following disclaimer in the 118733Sgeoffrey.blake@arm.com * documentation and/or other materials provided with the distribution; 128733Sgeoffrey.blake@arm.com * neither the name of the copyright holders nor the names of its 138733Sgeoffrey.blake@arm.com * contributors may be used to endorse or promote products derived from 148733Sgeoffrey.blake@arm.com * this software without specific prior written permission. 152817Sksewell@umich.edu * 162817Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172817Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182817Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192817Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202817Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212817Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222817Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232817Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242817Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252817Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262817Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272817Sksewell@umich.edu * 282817Sksewell@umich.edu * Authors: Steve Reinhardt 292817Sksewell@umich.edu * Lisa Hsu 302817Sksewell@umich.edu * Nathan Binkert 312817Sksewell@umich.edu * Steve Raasch 322817Sksewell@umich.edu */ 332817Sksewell@umich.edu 342817Sksewell@umich.edu#include <iomanip> 352817Sksewell@umich.edu 362817Sksewell@umich.edu#include "arch/isa_traits.hh" 372817Sksewell@umich.edu#include "arch/utility.hh" 382817Sksewell@umich.edu#include "base/loader/symtab.hh" 392817Sksewell@umich.edu#include "config/the_isa.hh" 402817Sksewell@umich.edu#include "cpu/base.hh" 412817Sksewell@umich.edu#include "cpu/exetrace.hh" 422817Sksewell@umich.edu#include "cpu/static_inst.hh" 432817Sksewell@umich.edu#include "cpu/thread_context.hh" 442817Sksewell@umich.edu#include "enums/OpClass.hh" 452817Sksewell@umich.edu 462817Sksewell@umich.eduusing namespace std; 476658Snate@binkert.orgusing namespace TheISA; 488229Snate@binkert.org 492935Sksewell@umich.edunamespace Trace { 502817Sksewell@umich.edu 512834Sksewell@umich.eduvoid 522834Sksewell@umich.eduExeTracerRecord::dumpTicks(ostream &outs) 532834Sksewell@umich.edu{ 548902Sandreas.hansson@arm.com ccprintf(outs, "%7d: ", when); 552834Sksewell@umich.edu} 562817Sksewell@umich.edu 572817Sksewell@umich.eduvoid 582817Sksewell@umich.eduTrace::ExeTracerRecord::traceInst(StaticInstPtr inst, bool ran) 592817Sksewell@umich.edu{ 602817Sksewell@umich.edu ostream &outs = Trace::output(); 612817Sksewell@umich.edu 622817Sksewell@umich.edu if (IsOn(ExecTicks)) 632817Sksewell@umich.edu dumpTicks(outs); 642817Sksewell@umich.edu 652817Sksewell@umich.edu outs << thread->getCpuPtr()->name() << " "; 662817Sksewell@umich.edu 672817Sksewell@umich.edu if (IsOn(ExecSpeculative)) 682817Sksewell@umich.edu outs << (misspeculating ? "-" : "+") << " "; 692817Sksewell@umich.edu 702817Sksewell@umich.edu if (IsOn(ExecThread)) 712817Sksewell@umich.edu outs << "T" << thread->threadId() << " : "; 722817Sksewell@umich.edu 732817Sksewell@umich.edu std::string sym_str; 742817Sksewell@umich.edu Addr sym_addr; 752817Sksewell@umich.edu Addr cur_pc = pc.instAddr(); 762817Sksewell@umich.edu if (debugSymbolTable 772817Sksewell@umich.edu && IsOn(ExecSymbol) 782817Sksewell@umich.edu#if FULL_SYSTEM 792817Sksewell@umich.edu && !inUserMode(thread) 802817Sksewell@umich.edu#endif 813784Sgblack@eecs.umich.edu && debugSymbolTable->findNearestSymbol(cur_pc, sym_str, sym_addr)) { 8212406Sgabeblack@google.com if (cur_pc != sym_addr) 833784Sgblack@eecs.umich.edu sym_str += csprintf("+%d",cur_pc - sym_addr); 843784Sgblack@eecs.umich.edu outs << "@" << sym_str; 8512406Sgabeblack@google.com } else { 863784Sgblack@eecs.umich.edu outs << "0x" << hex << cur_pc; 878887Sgeoffrey.blake@arm.com } 888733Sgeoffrey.blake@arm.com 899023Sgblack@eecs.umich.edu if (inst->isMicroop()) { 909023Sgblack@eecs.umich.edu outs << "." << setw(2) << dec << pc.microPC(); 919023Sgblack@eecs.umich.edu } else { 929023Sgblack@eecs.umich.edu outs << " "; 939023Sgblack@eecs.umich.edu } 948541Sgblack@eecs.umich.edu 952817Sksewell@umich.edu outs << " : "; 962817Sksewell@umich.edu 972817Sksewell@umich.edu // 982817Sksewell@umich.edu // Print decoded instruction 9910110Sandreas.hansson@arm.com // 1002817Sksewell@umich.edu 10110190Sakash.bagdia@arm.com outs << setw(26) << left; 10210190Sakash.bagdia@arm.com outs << inst->disassemble(cur_pc, debugSymbolTable); 10310190Sakash.bagdia@arm.com 10411005Sandreas.sandberg@arm.com if (ran) { 1055714Shsul@eecs.umich.edu outs << " : "; 1065714Shsul@eecs.umich.edu 1075714Shsul@eecs.umich.edu if (IsOn(ExecOpClass)) { 1085715Shsul@eecs.umich.edu outs << Enums::OpClassStrings[inst->opClass()] << " : "; 10910110Sandreas.hansson@arm.com } 1105715Shsul@eecs.umich.edu 1115715Shsul@eecs.umich.edu if (IsOn(ExecResult) && predicate == false) { 1122817Sksewell@umich.edu outs << "Predicated False"; 1132817Sksewell@umich.edu } 1142817Sksewell@umich.edu 1152817Sksewell@umich.edu if (IsOn(ExecResult) && data_status != DataInvalid) { 1163548Sgblack@eecs.umich.edu ccprintf(outs, " D=%#018x", data.as_int); 1172817Sksewell@umich.edu } 1182817Sksewell@umich.edu 1198541Sgblack@eecs.umich.edu if (IsOn(ExecEffAddr) && addr_valid) 1208541Sgblack@eecs.umich.edu outs << " A=0x" << hex << addr; 1218754Sgblack@eecs.umich.edu 12211886Sbrandon.potter@amd.com if (IsOn(ExecFetchSeq) && fetch_seq_valid) 12311886Sbrandon.potter@amd.com outs << " FetchSeq=" << dec << fetch_seq; 1248852Sandreas.hansson@arm.com 1252817Sksewell@umich.edu if (IsOn(ExecCPSeq) && cp_seq_valid) 1268852Sandreas.hansson@arm.com outs << " CPSeq=" << dec << cp_seq; 1273675Sktlim@umich.edu } 1288706Sandreas.hansson@arm.com 1298706Sandreas.hansson@arm.com // 1308799Sgblack@eecs.umich.edu // End of line... 1318852Sandreas.hansson@arm.com // 1328706Sandreas.hansson@arm.com outs << endl; 1332817Sksewell@umich.edu} 1342817Sksewell@umich.edu 1352817Sksewell@umich.eduvoid 1362817Sksewell@umich.eduTrace::ExeTracerRecord::dump() 1372817Sksewell@umich.edu{ 1382817Sksewell@umich.edu /* 1392817Sksewell@umich.edu * The behavior this check tries to achieve is that if ExecMacro is on, 1402817Sksewell@umich.edu * the macroop will be printed. If it's on and microops are also on, it's 14110407Smitch.hayenga@arm.com * printed before the microops start printing to give context. If the 14210407Smitch.hayenga@arm.com * microops aren't printed, then it's printed only when the final microop 1432817Sksewell@umich.edu * finishes. Macroops then behave like regular instructions and don't 1442817Sksewell@umich.edu * complete/print when they fault. 14510407Smitch.hayenga@arm.com */ 1462817Sksewell@umich.edu if (IsOn(ExecMacro) && staticInst->isMicroop() && 1472817Sksewell@umich.edu ((IsOn(ExecMicro) && 14810407Smitch.hayenga@arm.com macroStaticInst && staticInst->isFirstMicroop()) || 1492817Sksewell@umich.edu (!IsOn(ExecMicro) && 1502817Sksewell@umich.edu macroStaticInst && staticInst->isLastMicroop()))) { 1512817Sksewell@umich.edu traceInst(macroStaticInst, false); 1522817Sksewell@umich.edu } 1532817Sksewell@umich.edu if (IsOn(ExecMicro) || !staticInst->isMicroop()) { 1548777Sgblack@eecs.umich.edu traceInst(staticInst, true); 1552817Sksewell@umich.edu } 1562817Sksewell@umich.edu} 1572817Sksewell@umich.edu 1582817Sksewell@umich.edu} // namespace Trace 1592817Sksewell@umich.edu 1602817Sksewell@umich.edu//////////////////////////////////////////////////////////////////////// 1612817Sksewell@umich.edu// 1622817Sksewell@umich.edu// ExeTracer Simulation Object 1632817Sksewell@umich.edu// 1642817Sksewell@umich.eduTrace::ExeTracer * 1652817Sksewell@umich.eduExeTracerParams::create() 1662817Sksewell@umich.edu{ 1672817Sksewell@umich.edu return new Trace::ExeTracer(this); 1682817Sksewell@umich.edu}; 1692817Sksewell@umich.edu