exetrace.cc revision 6658
12SN/A/* 21762SN/A * Copyright (c) 2001-2005 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: Steve Reinhardt 292665Ssaidi@eecs.umich.edu * Lisa Hsu 302665Ssaidi@eecs.umich.edu * Nathan Binkert 312665Ssaidi@eecs.umich.edu * Steve Raasch 322SN/A */ 332SN/A 342SN/A#include <iomanip> 352SN/A 3656SN/A#include "base/loader/symtab.hh" 371717SN/A#include "cpu/base.hh" 382518SN/A#include "cpu/exetrace.hh" 3956SN/A#include "cpu/static_inst.hh" 404776Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 416658Snate@binkert.org#include "config/the_isa.hh" 424762Snate@binkert.org#include "enums/OpClass.hh" 433065Sgblack@eecs.umich.edu 442SN/Ausing namespace std; 452973Sgblack@eecs.umich.eduusing namespace TheISA; 462SN/A 473506Ssaidi@eecs.umich.edunamespace Trace { 484054Sbinkertn@umich.edu 494054Sbinkertn@umich.eduvoid 505866Sksewell@umich.eduExeTracerRecord::dumpTicks(ostream &outs) 515866Sksewell@umich.edu{ 525866Sksewell@umich.edu ccprintf(outs, "%7d: ", when); 535866Sksewell@umich.edu} 545866Sksewell@umich.edu 555866Sksewell@umich.eduvoid 565784Sgblack@eecs.umich.eduTrace::ExeTracerRecord::traceInst(StaticInstPtr inst, bool ran) 574054Sbinkertn@umich.edu{ 584776Sgblack@eecs.umich.edu ostream &outs = Trace::output(); 594054Sbinkertn@umich.edu 604776Sgblack@eecs.umich.edu if (IsOn(ExecTicks)) 615866Sksewell@umich.edu dumpTicks(outs); 624054Sbinkertn@umich.edu 634776Sgblack@eecs.umich.edu outs << thread->getCpuPtr()->name() << " "; 644054Sbinkertn@umich.edu 654776Sgblack@eecs.umich.edu if (IsOn(ExecSpeculative)) 664776Sgblack@eecs.umich.edu outs << (misspeculating ? "-" : "+") << " "; 674054Sbinkertn@umich.edu 684776Sgblack@eecs.umich.edu if (IsOn(ExecThread)) 695715Shsul@eecs.umich.edu outs << "T" << thread->threadId() << " : "; 704776Sgblack@eecs.umich.edu 714776Sgblack@eecs.umich.edu std::string sym_str; 724776Sgblack@eecs.umich.edu Addr sym_addr; 734776Sgblack@eecs.umich.edu if (debugSymbolTable 744776Sgblack@eecs.umich.edu && IsOn(ExecSymbol) 755947Sgblack@eecs.umich.edu#if FULL_SYSTEM 765947Sgblack@eecs.umich.edu && !inUserMode(thread) 775947Sgblack@eecs.umich.edu#endif 784776Sgblack@eecs.umich.edu && debugSymbolTable->findNearestSymbol(PC, sym_str, sym_addr)) { 794776Sgblack@eecs.umich.edu if (PC != sym_addr) 804776Sgblack@eecs.umich.edu sym_str += csprintf("+%d", PC - sym_addr); 815784Sgblack@eecs.umich.edu outs << "@" << sym_str; 824776Sgblack@eecs.umich.edu } 834776Sgblack@eecs.umich.edu else { 845784Sgblack@eecs.umich.edu outs << "0x" << hex << PC; 854776Sgblack@eecs.umich.edu } 864776Sgblack@eecs.umich.edu 875784Sgblack@eecs.umich.edu if (inst->isMicroop()) { 885784Sgblack@eecs.umich.edu outs << "." << setw(2) << dec << upc; 895784Sgblack@eecs.umich.edu } else { 905784Sgblack@eecs.umich.edu outs << " "; 915784Sgblack@eecs.umich.edu } 925784Sgblack@eecs.umich.edu 935784Sgblack@eecs.umich.edu outs << " : "; 945784Sgblack@eecs.umich.edu 954776Sgblack@eecs.umich.edu // 964776Sgblack@eecs.umich.edu // Print decoded instruction 974776Sgblack@eecs.umich.edu // 984776Sgblack@eecs.umich.edu 994776Sgblack@eecs.umich.edu outs << setw(26) << left; 1005784Sgblack@eecs.umich.edu outs << inst->disassemble(PC, debugSymbolTable); 1014776Sgblack@eecs.umich.edu 1025784Sgblack@eecs.umich.edu if (ran) { 1035784Sgblack@eecs.umich.edu outs << " : "; 1045784Sgblack@eecs.umich.edu 1055784Sgblack@eecs.umich.edu if (IsOn(ExecOpClass)) { 1065784Sgblack@eecs.umich.edu outs << Enums::OpClassStrings[inst->opClass()] << " : "; 1075784Sgblack@eecs.umich.edu } 1085784Sgblack@eecs.umich.edu 1095784Sgblack@eecs.umich.edu if (IsOn(ExecResult) && data_status != DataInvalid) { 1105784Sgblack@eecs.umich.edu ccprintf(outs, " D=%#018x", data.as_int); 1115784Sgblack@eecs.umich.edu } 1125784Sgblack@eecs.umich.edu 1135784Sgblack@eecs.umich.edu if (IsOn(ExecEffAddr) && addr_valid) 1145784Sgblack@eecs.umich.edu outs << " A=0x" << hex << addr; 1155784Sgblack@eecs.umich.edu 1165784Sgblack@eecs.umich.edu if (IsOn(ExecFetchSeq) && fetch_seq_valid) 1175784Sgblack@eecs.umich.edu outs << " FetchSeq=" << dec << fetch_seq; 1185784Sgblack@eecs.umich.edu 1195784Sgblack@eecs.umich.edu if (IsOn(ExecCPSeq) && cp_seq_valid) 1205784Sgblack@eecs.umich.edu outs << " CPSeq=" << dec << cp_seq; 1214776Sgblack@eecs.umich.edu } 1224776Sgblack@eecs.umich.edu 1234776Sgblack@eecs.umich.edu // 1244776Sgblack@eecs.umich.edu // End of line... 1254776Sgblack@eecs.umich.edu // 1264776Sgblack@eecs.umich.edu outs << endl; 1273506Ssaidi@eecs.umich.edu} 1283506Ssaidi@eecs.umich.edu 1295784Sgblack@eecs.umich.eduvoid 1305784Sgblack@eecs.umich.eduTrace::ExeTracerRecord::dump() 1315784Sgblack@eecs.umich.edu{ 1325784Sgblack@eecs.umich.edu /* 1335784Sgblack@eecs.umich.edu * The behavior this check tries to achieve is that if ExecMacro is on, 1345784Sgblack@eecs.umich.edu * the macroop will be printed. If it's on and microops are also on, it's 1355784Sgblack@eecs.umich.edu * printed before the microops start printing to give context. If the 1365784Sgblack@eecs.umich.edu * microops aren't printed, then it's printed only when the final microop 1375784Sgblack@eecs.umich.edu * finishes. Macroops then behave like regular instructions and don't 1385784Sgblack@eecs.umich.edu * complete/print when they fault. 1395784Sgblack@eecs.umich.edu */ 1405784Sgblack@eecs.umich.edu if (IsOn(ExecMacro) && staticInst->isMicroop() && 1415791Srstrong@cs.ucsd.edu ((IsOn(ExecMicro) && 1425784Sgblack@eecs.umich.edu macroStaticInst && staticInst->isFirstMicroop()) || 1435784Sgblack@eecs.umich.edu (!IsOn(ExecMicro) && 1445791Srstrong@cs.ucsd.edu macroStaticInst && staticInst->isLastMicroop()))) { 1455784Sgblack@eecs.umich.edu traceInst(macroStaticInst, false); 1465784Sgblack@eecs.umich.edu } 1475784Sgblack@eecs.umich.edu if (IsOn(ExecMicro) || !staticInst->isMicroop()) { 1485784Sgblack@eecs.umich.edu traceInst(staticInst, true); 1495784Sgblack@eecs.umich.edu } 1505784Sgblack@eecs.umich.edu} 1515784Sgblack@eecs.umich.edu 1524776Sgblack@eecs.umich.edu/* namespace Trace */ } 1534776Sgblack@eecs.umich.edu 1542SN/A//////////////////////////////////////////////////////////////////////// 1552SN/A// 1564776Sgblack@eecs.umich.edu// ExeTracer Simulation Object 1572SN/A// 1584776Sgblack@eecs.umich.eduTrace::ExeTracer * 1594776Sgblack@eecs.umich.eduExeTracerParams::create() 1603748Sgblack@eecs.umich.edu{ 1615034Smilesck@eecs.umich.edu return new Trace::ExeTracer(this); 1624776Sgblack@eecs.umich.edu}; 163