2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Steve Reinhardt
32 #ifndef __INSTRECORD_HH__
33 #define __INSTRECORD_HH__
35 #include "base/bigint.hh"
36 #include "base/trace.hh"
37 #include "cpu/inst_seq.hh" // for InstSeqNum
38 #include "cpu/static_inst.hh"
39 #include "sim/host.hh"
40 #include "sim/sim_object.hh"
51 // The following fields are initialized by the constructor and
52 // thus guaranteed to be valid.
53 ThreadContext *thread;
54 // need to make this ref-counted so it doesn't go away before we
56 StaticInstPtr staticInst;
60 // The remaining fields are only valid for particular instruction
61 // types (e.g, addresses for memory ops) or when particular
62 // options are enabled (e.g., tracing full register contents).
63 // Each data field has an associated valid flag to indicate
64 // whether the data field is valid.
74 DataInt8 = 1, // set to equal number of bytes
88 InstRecord(Tick _when, ThreadContext *_thread,
89 const StaticInstPtr &_staticInst,
91 : when(_when), thread(_thread),
92 staticInst(_staticInst), PC(_pc),
95 data_status = DataInvalid;
98 fetch_seq_valid = false;
102 virtual ~InstRecord() { }
104 void setAddr(Addr a) { addr = a; addr_valid = true; }
106 void setData(Twin64_t d) { data.as_int = d.a; data_status = DataInt64; }
107 void setData(Twin32_t d) { data.as_int = d.a; data_status = DataInt32; }
108 void setData(uint64_t d) { data.as_int = d; data_status = DataInt64; }
109 void setData(uint32_t d) { data.as_int = d; data_status = DataInt32; }
110 void setData(uint16_t d) { data.as_int = d; data_status = DataInt16; }
111 void setData(uint8_t d) { data.as_int = d; data_status = DataInt8; }
113 void setData(int64_t d) { setData((uint64_t)d); }
114 void setData(int32_t d) { setData((uint32_t)d); }
115 void setData(int16_t d) { setData((uint16_t)d); }
116 void setData(int8_t d) { setData((uint8_t)d); }
118 void setData(double d) { data.as_double = d; data_status = DataDouble; }
120 void setFetchSeq(InstSeqNum seq)
121 { fetch_seq = seq; fetch_seq_valid = true; }
123 void setCPSeq(InstSeqNum seq)
124 { cp_seq = seq; cp_seq_valid = true; }
126 virtual void dump() = 0;
129 class InstTracer : public SimObject
132 InstTracer(const std::string & name) : SimObject(name)
135 virtual ~InstTracer()
139 getInstRecord(Tick when, ThreadContext *tc,
140 const StaticInstPtr staticInst, Addr pc) = 0;
145 }; // namespace Trace
147 #endif // __INSTRECORD_HH__