exetrace.cc revision 5034
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"
414762Snate@binkert.org#include "enums/OpClass.hh"
423065Sgblack@eecs.umich.edu
432SN/Ausing namespace std;
442973Sgblack@eecs.umich.eduusing namespace TheISA;
452SN/A
463506Ssaidi@eecs.umich.edunamespace Trace {
474054Sbinkertn@umich.edu
484054Sbinkertn@umich.eduvoid
494776Sgblack@eecs.umich.eduTrace::ExeTracerRecord::dump()
504054Sbinkertn@umich.edu{
514776Sgblack@eecs.umich.edu    ostream &outs = Trace::output();
524054Sbinkertn@umich.edu
534776Sgblack@eecs.umich.edu    if (IsOn(ExecTicks))
544776Sgblack@eecs.umich.edu        ccprintf(outs, "%7d: ", when);
554054Sbinkertn@umich.edu
564776Sgblack@eecs.umich.edu    outs << thread->getCpuPtr()->name() << " ";
574054Sbinkertn@umich.edu
584776Sgblack@eecs.umich.edu    if (IsOn(ExecSpeculative))
594776Sgblack@eecs.umich.edu        outs << (misspeculating ? "-" : "+") << " ";
604054Sbinkertn@umich.edu
614776Sgblack@eecs.umich.edu    if (IsOn(ExecThread))
624776Sgblack@eecs.umich.edu        outs << "T" << thread->getThreadNum() << " : ";
634776Sgblack@eecs.umich.edu
644776Sgblack@eecs.umich.edu
654776Sgblack@eecs.umich.edu    std::string sym_str;
664776Sgblack@eecs.umich.edu    Addr sym_addr;
674776Sgblack@eecs.umich.edu    if (debugSymbolTable
684776Sgblack@eecs.umich.edu        && IsOn(ExecSymbol)
694776Sgblack@eecs.umich.edu        && debugSymbolTable->findNearestSymbol(PC, sym_str, sym_addr)) {
704776Sgblack@eecs.umich.edu        if (PC != sym_addr)
714776Sgblack@eecs.umich.edu            sym_str += csprintf("+%d", PC - sym_addr);
724776Sgblack@eecs.umich.edu        outs << "@" << sym_str << " : ";
734776Sgblack@eecs.umich.edu    }
744776Sgblack@eecs.umich.edu    else {
754776Sgblack@eecs.umich.edu        outs << "0x" << hex << PC << " : ";
764776Sgblack@eecs.umich.edu    }
774776Sgblack@eecs.umich.edu
784776Sgblack@eecs.umich.edu    //
794776Sgblack@eecs.umich.edu    //  Print decoded instruction
804776Sgblack@eecs.umich.edu    //
814776Sgblack@eecs.umich.edu
824776Sgblack@eecs.umich.edu    outs << setw(26) << left;
834776Sgblack@eecs.umich.edu    outs << staticInst->disassemble(PC, debugSymbolTable);
844776Sgblack@eecs.umich.edu    outs << " : ";
854776Sgblack@eecs.umich.edu
864776Sgblack@eecs.umich.edu    if (IsOn(ExecOpClass)) {
874776Sgblack@eecs.umich.edu        outs << Enums::OpClassStrings[staticInst->opClass()] << " : ";
884776Sgblack@eecs.umich.edu    }
894776Sgblack@eecs.umich.edu
904776Sgblack@eecs.umich.edu    if (IsOn(ExecResult) && data_status != DataInvalid) {
914776Sgblack@eecs.umich.edu        ccprintf(outs, " D=%#018x", data.as_int);
924776Sgblack@eecs.umich.edu    }
934776Sgblack@eecs.umich.edu
944776Sgblack@eecs.umich.edu    if (IsOn(ExecEffAddr) && addr_valid)
954776Sgblack@eecs.umich.edu        outs << " A=0x" << hex << addr;
964776Sgblack@eecs.umich.edu
974776Sgblack@eecs.umich.edu    if (IsOn(ExecFetchSeq) && fetch_seq_valid)
984776Sgblack@eecs.umich.edu        outs << "  FetchSeq=" << dec << fetch_seq;
994776Sgblack@eecs.umich.edu
1004776Sgblack@eecs.umich.edu    if (IsOn(ExecCPSeq) && cp_seq_valid)
1014776Sgblack@eecs.umich.edu        outs << "  CPSeq=" << dec << cp_seq;
1024776Sgblack@eecs.umich.edu
1034776Sgblack@eecs.umich.edu    //
1044776Sgblack@eecs.umich.edu    //  End of line...
1054776Sgblack@eecs.umich.edu    //
1064776Sgblack@eecs.umich.edu    outs << endl;
1073506Ssaidi@eecs.umich.edu}
1083506Ssaidi@eecs.umich.edu
1094776Sgblack@eecs.umich.edu/* namespace Trace */ }
1104776Sgblack@eecs.umich.edu
1112SN/A////////////////////////////////////////////////////////////////////////
1122SN/A//
1134776Sgblack@eecs.umich.edu//  ExeTracer Simulation Object
1142SN/A//
1154776Sgblack@eecs.umich.eduTrace::ExeTracer *
1164776Sgblack@eecs.umich.eduExeTracerParams::create()
1173748Sgblack@eecs.umich.edu{
1185034Smilesck@eecs.umich.edu    return new Trace::ExeTracer(this);
1194776Sgblack@eecs.umich.edu};
120