exetrace.hh revision 4776:8c8407243a2c
110448Snilay@cs.wisc.edu/*
210448Snilay@cs.wisc.edu * Copyright (c) 2001-2005 The Regents of The University of Michigan
310448Snilay@cs.wisc.edu * All rights reserved.
410448Snilay@cs.wisc.edu *
510448Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without
610448Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are
710448Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright
810448Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer;
910448Snilay@cs.wisc.edu * redistributions in binary form must reproduce the above copyright
1010448Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer in the
1110448Snilay@cs.wisc.edu * documentation and/or other materials provided with the distribution;
1210448Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its
1310448Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from
1410448Snilay@cs.wisc.edu * this software without specific prior written permission.
1510448Snilay@cs.wisc.edu *
1610448Snilay@cs.wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1710448Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1810448Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1910448Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2010448Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2110448Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2210447Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2310447Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2410447Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2510447Snilay@cs.wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2610447Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2710447Snilay@cs.wisc.edu *
2810447Snilay@cs.wisc.edu * Authors: Steve Reinhardt
2910447Snilay@cs.wisc.edu *          Nathan Binkert
3010447Snilay@cs.wisc.edu */
3110447Snilay@cs.wisc.edu
3210447Snilay@cs.wisc.edu#ifndef __EXETRACE_HH__
3310447Snilay@cs.wisc.edu#define __EXETRACE_HH__
3410447Snilay@cs.wisc.edu
3510447Snilay@cs.wisc.edu#include "base/trace.hh"
3610447Snilay@cs.wisc.edu#include "cpu/static_inst.hh"
3710447Snilay@cs.wisc.edu#include "sim/host.hh"
3810447Snilay@cs.wisc.edu#include "sim/insttracer.hh"
3910447Snilay@cs.wisc.edu
4010447Snilay@cs.wisc.educlass ThreadContext;
4110447Snilay@cs.wisc.edu
4210447Snilay@cs.wisc.edu
4310447Snilay@cs.wisc.edunamespace Trace {
4410447Snilay@cs.wisc.edu
4510447Snilay@cs.wisc.educlass ExeTracerRecord : public InstRecord
4610447Snilay@cs.wisc.edu{
4710447Snilay@cs.wisc.edu  public:
4810447Snilay@cs.wisc.edu    ExeTracerRecord(Tick _when, ThreadContext *_thread,
4910447Snilay@cs.wisc.edu               const StaticInstPtr &_staticInst, Addr _pc, bool spec)
5010447Snilay@cs.wisc.edu        : InstRecord(_when, _thread, _staticInst, _pc, spec)
5110447Snilay@cs.wisc.edu    {
5210447Snilay@cs.wisc.edu    }
5310447Snilay@cs.wisc.edu
5410447Snilay@cs.wisc.edu    void dump();
55};
56
57class ExeTracer : public InstTracer
58{
59  public:
60
61    ExeTracer(const std::string & name) : InstTracer(name)
62    {}
63
64    InstRecord *
65    getInstRecord(Tick when, ThreadContext *tc,
66            const StaticInstPtr staticInst, Addr pc)
67    {
68        if (!IsOn(ExecEnable))
69            return NULL;
70
71        if (!Trace::enabled)
72            return NULL;
73
74        if (!IsOn(ExecSpeculative) && tc->misspeculating())
75            return NULL;
76
77        return new ExeTracerRecord(when, tc,
78                staticInst, pc, tc->misspeculating());
79    }
80};
81
82/* namespace Trace */ }
83
84#endif // __EXETRACE_HH__
85