gem5  v22.0.0.2
insttracer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, 2017, 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2001-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __INSTRECORD_HH__
42 #define __INSTRECORD_HH__
43 
44 #include <memory>
45 
46 #include "arch/generic/pcstate.hh"
47 #include "arch/vecregs.hh"
48 #include "base/types.hh"
49 #include "config/the_isa.hh"
50 #include "cpu/inst_seq.hh"
51 #include "cpu/static_inst.hh"
52 #include "sim/sim_object.hh"
53 
54 namespace gem5
55 {
56 
57 class ThreadContext;
58 
59 namespace Trace {
60 
62 {
63  protected:
65 
66  // The following fields are initialized by the constructor and
67  // thus guaranteed to be valid.
69  // need to make this ref-counted so it doesn't go away before we
70  // dump the record
72  std::unique_ptr<PCStateBase> pc;
74 
75  // The remaining fields are only valid for particular instruction
76  // types (e.g, addresses for memory ops) or when particular
77  // options are enabled (e.g., tracing full register contents).
78  // Each data field has an associated valid flag to indicate
79  // whether the data field is valid.
80 
81  /*** @defgroup mem
82  * @{
83  * Memory request information in the instruction accessed memory.
84  * @see mem_valid
85  */
86  Addr addr = 0;
87  Addr size = 0;
88  unsigned flags = 0;
89 
100  union
101  {
102  uint64_t as_int;
103  double as_double;
106  } data = {0};
107 
113 
119 
124  {
126  DataInt8 = 1, // set to equal number of bytes
131  DataVec = 5,
134 
138  bool mem_valid = false;
139 
143  bool fetch_seq_valid = false;
147  bool cp_seq_valid = false;
148 
151  bool predicate = true;
152 
157  bool faulting = false;
158 
159  public:
160  InstRecord(Tick _when, ThreadContext *_thread,
161  const StaticInstPtr _staticInst, const PCStateBase &_pc,
162  const StaticInstPtr _macroStaticInst=nullptr)
163  : when(_when), thread(_thread), staticInst(_staticInst),
164  pc(_pc.clone()), macroStaticInst(_macroStaticInst)
165  {}
166 
167  virtual ~InstRecord()
168  {
169  if (data_status == DataVec) {
170  assert(data.as_vec);
171  delete data.as_vec;
172  } else if (data_status == DataVecPred) {
173  assert(data.as_pred);
174  delete data.as_pred;
175  }
176  }
177 
178  void setWhen(Tick new_when) { when = new_when; }
179  void
180  setMem(Addr a, Addr s, unsigned f)
181  {
182  addr = a;
183  size = s;
184  flags = f;
185  mem_valid = true;
186  }
187 
188  template <typename T, size_t N>
189  void
190  setData(std::array<T, N> d)
191  {
192  data.as_int = d[0];
193  data_status = (DataStatus)sizeof(T);
194  static_assert(sizeof(T) == DataInt8 || sizeof(T) == DataInt16 ||
195  sizeof(T) == DataInt32 || sizeof(T) == DataInt64,
196  "Type T has an unrecognized size.");
197  }
198 
199  void
200  setData(uint64_t d)
201  {
202  data.as_int = d;
204  }
205  void
206  setData(uint32_t d)
207  {
208  data.as_int = d;
210  }
211  void
212  setData(uint16_t d)
213  {
214  data.as_int = d;
216  }
217  void
218  setData(uint8_t d)
219  {
220  data.as_int = d;
222  }
223 
224  void setData(int64_t d) { setData((uint64_t)d); }
225  void setData(int32_t d) { setData((uint32_t)d); }
226  void setData(int16_t d) { setData((uint16_t)d); }
227  void setData(int8_t d) { setData((uint8_t)d); }
228 
229  void
230  setData(double d)
231  {
232  data.as_double = d;
234  }
235 
236  void
238  {
239  data.as_vec = new TheISA::VecRegContainer(d);
241  }
242 
243  void
245  {
246  data.as_pred = new TheISA::VecPredRegContainer(d);
248  }
249 
250  void
252  {
253  fetch_seq = seq;
254  fetch_seq_valid = true;
255  }
256 
257  void
259  {
260  cp_seq = seq;
261  cp_seq_valid = true;
262  }
263 
264  void setPredicate(bool val) { predicate = val; }
265 
266  void setFaulting(bool val) { faulting = val; }
267 
268  virtual void dump() = 0;
269 
270  public:
271  Tick getWhen() const { return when; }
272  ThreadContext *getThread() const { return thread; }
274  const PCStateBase &getPCState() const { return *pc; }
276 
277  Addr getAddr() const { return addr; }
278  Addr getSize() const { return size; }
279  unsigned getFlags() const { return flags; }
280  bool getMemValid() const { return mem_valid; }
281 
282  uint64_t getIntData() const { return data.as_int; }
283  double getFloatData() const { return data.as_double; }
284  int getDataStatus() const { return data_status; }
285 
286  InstSeqNum getFetchSeq() const { return fetch_seq; }
287  bool getFetchSeqValid() const { return fetch_seq_valid; }
288 
289  InstSeqNum getCpSeq() const { return cp_seq; }
290  bool getCpSeqValid() const { return cp_seq_valid; }
291 
292  bool getFaulting() const { return faulting; }
293 };
294 
295 class InstTracer : public SimObject
296 {
297  public:
298  InstTracer(const Params &p) : SimObject(p) {}
299 
300  virtual ~InstTracer() {}
301 
302  virtual InstRecord *
303  getInstRecord(Tick when, ThreadContext *tc,
304  const StaticInstPtr staticInst, const PCStateBase &pc,
305  const StaticInstPtr macroStaticInst=nullptr) = 0;
306 };
307 
308 } // namespace Trace
309 } // namespace gem5
310 
311 #endif // __INSTRECORD_HH__
gem5::VegaISA::s
Bitfield< 1 > s
Definition: pagetable.hh:64
gem5::Trace::InstRecord::setFaulting
void setFaulting(bool val)
Definition: insttracer.hh:266
gem5::VegaISA::f
Bitfield< 56 > f
Definition: pagetable.hh:53
gem5::Trace::InstRecord::getAddr
Addr getAddr() const
Definition: insttracer.hh:277
gem5::Trace::InstRecord::getPCState
const PCStateBase & getPCState() const
Definition: insttracer.hh:274
gem5::Trace::InstRecord::cp_seq_valid
bool cp_seq_valid
Definition: insttracer.hh:147
gem5::Trace::InstRecord::getFetchSeqValid
bool getFetchSeqValid() const
Definition: insttracer.hh:287
gem5::Trace::InstRecord::as_int
uint64_t as_int
Definition: insttracer.hh:102
gem5::ArmISA::VecPredRegContainer
VecPredReg::Container VecPredRegContainer
Definition: vec.hh:68
gem5::Trace::InstRecord::setMem
void setMem(Addr a, Addr s, unsigned f)
Definition: insttracer.hh:180
gem5::Trace::InstRecord::setWhen
void setWhen(Tick new_when)
Definition: insttracer.hh:178
gem5::Trace::InstRecord::as_vec
TheISA::VecRegContainer * as_vec
Definition: insttracer.hh:104
gem5::Trace::InstRecord::getFloatData
double getFloatData() const
Definition: insttracer.hh:283
gem5::Trace::InstRecord::InstRecord
InstRecord(Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, const PCStateBase &_pc, const StaticInstPtr _macroStaticInst=nullptr)
Definition: insttracer.hh:160
gem5::Trace::InstRecord::getSize
Addr getSize() const
Definition: insttracer.hh:278
gem5::Trace::InstRecord::setData
void setData(int32_t d)
Definition: insttracer.hh:225
gem5::Trace::InstRecord::data
union gem5::Trace::InstRecord::@336 data
gem5::Trace::InstRecord::as_double
double as_double
Definition: insttracer.hh:103
gem5::Trace::InstRecord::setData
void setData(double d)
Definition: insttracer.hh:230
gem5::Trace::InstRecord::setFetchSeq
void setFetchSeq(InstSeqNum seq)
Definition: insttracer.hh:251
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
gem5::ArmISA::a
Bitfield< 8 > a
Definition: misc_types.hh:66
gem5::Trace::InstRecord::setCPSeq
void setCPSeq(InstSeqNum seq)
Definition: insttracer.hh:258
gem5::Trace::InstRecord::setData
void setData(std::array< T, N > d)
Definition: insttracer.hh:190
gem5::Trace::InstRecord::getIntData
uint64_t getIntData() const
Definition: insttracer.hh:282
gem5::Trace::InstRecord::thread
ThreadContext * thread
Definition: insttracer.hh:68
gem5::Trace::InstRecord::~InstRecord
virtual ~InstRecord()
Definition: insttracer.hh:167
gem5::Trace::InstRecord::getStaticInst
StaticInstPtr getStaticInst() const
Definition: insttracer.hh:273
gem5::Trace::InstRecord::setPredicate
void setPredicate(bool val)
Definition: insttracer.hh:264
gem5::Trace::InstRecord::fetch_seq_valid
bool fetch_seq_valid
Definition: insttracer.hh:143
gem5::Trace::InstRecord::DataVecPred
@ DataVecPred
Definition: insttracer.hh:132
gem5::Trace::InstRecord::getCpSeqValid
bool getCpSeqValid() const
Definition: insttracer.hh:290
gem5::Trace::InstRecord::setData
void setData(int16_t d)
Definition: insttracer.hh:226
gem5::Trace::InstRecord::setData
void setData(int64_t d)
Definition: insttracer.hh:224
gem5::Trace::InstRecord::DataInt8
@ DataInt8
Definition: insttracer.hh:126
gem5::RefCountingPtr< StaticInst >
gem5::Trace::InstRecord::mem_valid
bool mem_valid
Definition: insttracer.hh:138
gem5::SimObject::Params
SimObjectParams Params
Definition: sim_object.hh:170
gem5::Trace::InstRecord::setData
void setData(int8_t d)
Definition: insttracer.hh:227
gem5::Trace::InstRecord::getFetchSeq
InstSeqNum getFetchSeq() const
Definition: insttracer.hh:286
inst_seq.hh
gem5::Trace::InstRecord::setData
void setData(TheISA::VecRegContainer &d)
Definition: insttracer.hh:237
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:94
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::Trace::InstRecord::getMemValid
bool getMemValid() const
Definition: insttracer.hh:280
gem5::Trace::InstTracer::getInstRecord
virtual InstRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, const PCStateBase &pc, const StaticInstPtr macroStaticInst=nullptr)=0
sim_object.hh
gem5::ArmISA::d
Bitfield< 9 > d
Definition: misc_types.hh:64
gem5::Trace::InstRecord::staticInst
StaticInstPtr staticInst
Definition: insttracer.hh:71
gem5::Trace::InstRecord::getMacroStaticInst
StaticInstPtr getMacroStaticInst() const
Definition: insttracer.hh:275
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Trace::InstRecord::setData
void setData(uint64_t d)
Definition: insttracer.hh:200
gem5::Trace::InstTracer
Definition: insttracer.hh:295
gem5::Trace::InstRecord::data_status
enum gem5::Trace::InstRecord::DataStatus data_status
gem5::Trace::InstRecord::DataInt32
@ DataInt32
Definition: insttracer.hh:128
gem5::Trace::InstRecord::getThread
ThreadContext * getThread() const
Definition: insttracer.hh:272
gem5::Trace::InstRecord::DataInvalid
@ DataInvalid
Definition: insttracer.hh:125
gem5::Trace::InstRecord::as_pred
TheISA::VecPredRegContainer * as_pred
Definition: insttracer.hh:105
gem5::ArmISA::VecRegContainer
gem5::VecRegContainer< NumVecElemPerVecReg *sizeof(VecElem)> VecRegContainer
Definition: vec.hh:62
static_inst.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Trace::InstRecord::fetch_seq
InstSeqNum fetch_seq
Definition: insttracer.hh:112
gem5::Trace::InstRecord::getCpSeq
InstSeqNum getCpSeq() const
Definition: insttracer.hh:289
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::Trace::InstRecord::DataStatus
DataStatus
Definition: insttracer.hh:123
gem5::Trace::InstRecord::DataInt16
@ DataInt16
Definition: insttracer.hh:127
gem5::Trace::InstRecord::setData
void setData(uint16_t d)
Definition: insttracer.hh:212
gem5::Trace::InstRecord::pc
std::unique_ptr< PCStateBase > pc
Definition: insttracer.hh:72
gem5::Trace::InstRecord::dump
virtual void dump()=0
gem5::Trace::InstRecord::DataInt64
@ DataInt64
Definition: insttracer.hh:129
pcstate.hh
gem5::Trace::InstRecord::setData
void setData(uint8_t d)
Definition: insttracer.hh:218
gem5::Trace::InstRecord::size
Addr size
The size of the memory request.
Definition: insttracer.hh:87
gem5::Trace::InstRecord::cp_seq
InstSeqNum cp_seq
Definition: insttracer.hh:118
gem5::Trace::InstRecord::DataVec
@ DataVec
Definition: insttracer.hh:131
gem5::Trace::InstRecord::setData
void setData(TheISA::VecPredRegContainer &d)
Definition: insttracer.hh:244
gem5::Trace::InstRecord::predicate
bool predicate
is the predicate for execution this inst true or false (not execed)?
Definition: insttracer.hh:151
types.hh
gem5::Trace::InstRecord::getFaulting
bool getFaulting() const
Definition: insttracer.hh:292
gem5::Trace::InstRecord::addr
Addr addr
The address that was accessed.
Definition: insttracer.hh:86
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::Trace::InstRecord::DataDouble
@ DataDouble
Definition: insttracer.hh:130
gem5::Trace::InstTracer::~InstTracer
virtual ~InstTracer()
Definition: insttracer.hh:300
gem5::Trace::InstRecord::setData
void setData(uint32_t d)
Definition: insttracer.hh:206
gem5::Trace::InstRecord
Definition: insttracer.hh:61
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::Trace::InstRecord::when
Tick when
Definition: insttracer.hh:64
gem5::Trace::InstRecord::macroStaticInst
StaticInstPtr macroStaticInst
Definition: insttracer.hh:73
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::Trace::InstRecord::faulting
bool faulting
Did the execution of this instruction fault? (requires ExecFaulting to be enabled)
Definition: insttracer.hh:157
gem5::Trace::InstRecord::flags
unsigned flags
The flags that were assigned to the request.
Definition: insttracer.hh:88
gem5::Trace::InstRecord::getDataStatus
int getDataStatus() const
Definition: insttracer.hh:284
gem5::Trace::InstTracer::InstTracer
InstTracer(const Params &p)
Definition: insttracer.hh:298
gem5::Trace::InstRecord::getFlags
unsigned getFlags() const
Definition: insttracer.hh:279
gem5::Trace::InstRecord::getWhen
Tick getWhen() const
Definition: insttracer.hh:271

Generated on Thu Jul 28 2022 13:32:36 for gem5 by doxygen 1.8.17