gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
insttracer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, 2017 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  * Authors: Steve Reinhardt
41  * Nathan Binkert
42  */
43 
44 #ifndef __INSTRECORD_HH__
45 #define __INSTRECORD_HH__
46 
48 #include "arch/generic/vec_reg.hh"
49 #include "base/types.hh"
50 #include "cpu/inst_seq.hh"
51 #include "cpu/static_inst.hh"
52 #include "sim/sim_object.hh"
53 
54 class ThreadContext;
55 
56 namespace Trace {
57 
59 {
60  protected:
62 
63  // The following fields are initialized by the constructor and
64  // thus guaranteed to be valid.
66  // need to make this ref-counted so it doesn't go away before we
67  // dump the record
71 
72  // The remaining fields are only valid for particular instruction
73  // types (e.g, addresses for memory ops) or when particular
74  // options are enabled (e.g., tracing full register contents).
75  // Each data field has an associated valid flag to indicate
76  // whether the data field is valid.
77 
78  /*** @defgroup mem
79  * @{
80  * Memory request information in the instruction accessed memory.
81  * @see mem_valid
82  */
85  unsigned flags;
86 
97  union {
98  uint64_t as_int;
99  double as_double;
103  } data;
104 
110 
116 
120  enum DataStatus {
122  DataInt8 = 1, // set to equal number of bytes
127  DataVec = 5,
129  } data_status;
130 
134  bool mem_valid;
135 
144 
147  bool predicate;
148 
149  public:
150  InstRecord(Tick _when, ThreadContext *_thread,
151  const StaticInstPtr _staticInst,
152  TheISA::PCState _pc,
153  const StaticInstPtr _macroStaticInst = NULL)
154  : when(_when), thread(_thread), staticInst(_staticInst), pc(_pc),
155  macroStaticInst(_macroStaticInst), addr(0), size(0), flags(0),
156  fetch_seq(0), cp_seq(0), data_status(DataInvalid), mem_valid(false),
157  fetch_seq_valid(false), cp_seq_valid(false), predicate(true)
158  { }
159 
160  virtual ~InstRecord()
161  {
162  if (data_status == DataVec) {
163  assert(data.as_vec);
164  delete data.as_vec;
165  } else if (data_status == DataVecPred) {
166  assert(data.as_pred);
167  delete data.as_pred;
168  }
169  }
170 
171  void setWhen(Tick new_when) { when = new_when; }
172  void setMem(Addr a, Addr s, unsigned f)
173  {
174  addr = a; size = s; flags = f; mem_valid = true;
175  }
176 
177  template <typename T, size_t N>
178  void
179  setData(std::array<T, N> d)
180  {
181  data.as_int = d[0];
182  data_status = (DataStatus)sizeof(T);
183  static_assert(sizeof(T) == DataInt8 || sizeof(T) == DataInt16 ||
184  sizeof(T) == DataInt32 || sizeof(T) == DataInt64,
185  "Type T has an unrecognized size.");
186  }
187 
188  void setData(uint64_t d) { data.as_int = d; data_status = DataInt64; }
189  void setData(uint32_t d) { data.as_int = d; data_status = DataInt32; }
190  void setData(uint16_t d) { data.as_int = d; data_status = DataInt16; }
191  void setData(uint8_t d) { data.as_int = d; data_status = DataInt8; }
192 
193  void setData(int64_t d) { setData((uint64_t)d); }
194  void setData(int32_t d) { setData((uint32_t)d); }
195  void setData(int16_t d) { setData((uint16_t)d); }
196  void setData(int8_t d) { setData((uint8_t)d); }
197 
198  void setData(double d) { data.as_double = d; data_status = DataDouble; }
199 
200  void
202  {
203  data.as_vec = new ::VecRegContainer<TheISA::VecRegSizeBytes>(d);
205  }
206 
207  void
210  {
214  }
215 
217  { fetch_seq = seq; fetch_seq_valid = true; }
218 
220  { cp_seq = seq; cp_seq_valid = true; }
221 
222  void setPredicate(bool val) { predicate = val; }
223 
224  virtual void dump() = 0;
225 
226  public:
227  Tick getWhen() const { return when; }
228  ThreadContext *getThread() const { return thread; }
230  TheISA::PCState getPCState() const { return pc; }
232 
233  Addr getAddr() const { return addr; }
234  Addr getSize() const { return size; }
235  unsigned getFlags() const { return flags; }
236  bool getMemValid() const { return mem_valid; }
237 
238  uint64_t getIntData() const { return data.as_int; }
239  double getFloatData() const { return data.as_double; }
240  int getDataStatus() const { return data_status; }
241 
242  InstSeqNum getFetchSeq() const { return fetch_seq; }
243  bool getFetchSeqValid() const { return fetch_seq_valid; }
244 
245  InstSeqNum getCpSeq() const { return cp_seq; }
246  bool getCpSeqValid() const { return cp_seq_valid; }
247 };
248 
249 class InstTracer : public SimObject
250 {
251  public:
253  {}
254 
255  virtual ~InstTracer()
256  {};
257 
258  virtual InstRecord *
259  getInstRecord(Tick when, ThreadContext *tc,
261  const StaticInstPtr macroStaticInst = NULL) = 0;
262 };
263 
264 
265 
266 } // namespace Trace
267 
268 #endif // __INSTRECORD_HH__
virtual void dump()=0
bool getFetchSeqValid() const
Definition: insttracer.hh:243
void setData(uint64_t d)
Definition: insttracer.hh:188
TheISA::PCState pc
Definition: insttracer.hh:69
StaticInstPtr getMacroStaticInst() const
Definition: insttracer.hh:231
void setFetchSeq(InstSeqNum seq)
Definition: insttracer.hh:216
bool predicate
is the predicate for execution this inst true or false (not execed)?
Definition: insttracer.hh:147
uint64_t getIntData() const
Definition: insttracer.hh:238
Addr getSize() const
Definition: insttracer.hh:234
InstRecord(Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, TheISA::PCState _pc, const StaticInstPtr _macroStaticInst=NULL)
Definition: insttracer.hh:150
void setData(int32_t d)
Definition: insttracer.hh:194
SimObjectParams Params
Definition: sim_object.hh:113
bool getCpSeqValid() const
Definition: insttracer.hh:246
void setData(int8_t d)
Definition: insttracer.hh:196
enum Trace::InstRecord::DataStatus data_status
Bitfield< 8 > a
InstTracer(const Params *p)
Definition: insttracer.hh:252
ThreadContext * thread
Definition: insttracer.hh:65
Addr size
The size of the memory request.
Definition: insttracer.hh:84
void setData(uint16_t d)
Definition: insttracer.hh:190
InstSeqNum getFetchSeq() const
Definition: insttracer.hh:242
unsigned getFlags() const
Definition: insttracer.hh:235
void setData(::VecRegContainer< TheISA::VecRegSizeBytes > &d)
Definition: insttracer.hh:201
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 63 > val
Definition: misc.hh:771
InstSeqNum getCpSeq() const
Definition: insttracer.hh:245
Bitfield< 6 > f
void setData(uint32_t d)
Definition: insttracer.hh:189
virtual ~InstRecord()
Definition: insttracer.hh:160
Bitfield< 4 > s
ThreadContext * getThread() const
Definition: insttracer.hh:228
::DummyVecPredRegContainer VecPredRegContainer
Definition: registers.hh:60
void setData(uint8_t d)
Definition: insttracer.hh:191
virtual ~InstTracer()
Definition: insttracer.hh:255
bool mem_valid
Are the memory fields in the record valid?
Definition: insttracer.hh:134
uint64_t Tick
Tick count type.
Definition: types.hh:63
TheISA::PCState getPCState() const
Definition: insttracer.hh:230
Bitfield< 9 > d
void setMem(Addr a, Addr s, unsigned f)
Definition: insttracer.hh:172
InstSeqNum fetch_seq
Definition: insttracer.hh:109
void setPredicate(bool val)
Definition: insttracer.hh:222
bool cp_seq_valid
Are the commit sequence number fields valid?
Definition: insttracer.hh:143
StaticInstPtr macroStaticInst
Definition: insttracer.hh:70
uint64_t InstSeqNum
Definition: inst_seq.hh:40
void setData(::VecPredRegContainer< TheISA::VecPredRegSizeBits, TheISA::VecPredRegHasPackedRepr > &d)
Definition: insttracer.hh:208
union Trace::InstRecord::@120 data
void setCPSeq(InstSeqNum seq)
Definition: insttracer.hh:219
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void setData(double d)
Definition: insttracer.hh:198
::VecRegContainer< TheISA::VecRegSizeBytes > * as_vec
Definition: insttracer.hh:100
constexpr size_t VecPredRegSizeBits
Definition: registers.hh:61
void setData(int16_t d)
Definition: insttracer.hh:195
::VecPredRegContainer< TheISA::VecPredRegSizeBits, TheISA::VecPredRegHasPackedRepr > * as_pred
Definition: insttracer.hh:102
DataStatus
What size of data was written?
Definition: insttracer.hh:120
unsigned flags
The flags that were assigned to the request.
Definition: insttracer.hh:85
double getFloatData() const
Definition: insttracer.hh:239
void setData(std::array< T, N > d)
Definition: insttracer.hh:179
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
Vector Registers layout specification.
int getDataStatus() const
Definition: insttracer.hh:240
Generic predicate register container.
Definition: vec_pred_reg.hh:51
Addr getAddr() const
Definition: insttracer.hh:233
bool getMemValid() const
Definition: insttracer.hh:236
StaticInstPtr staticInst
Definition: insttracer.hh:68
constexpr bool VecPredRegHasPackedRepr
Definition: registers.hh:62
bool fetch_seq_valid
Are the fetch sequence number fields valid?
Definition: insttracer.hh:139
InstSeqNum cp_seq
Definition: insttracer.hh:115
void setWhen(Tick new_when)
Definition: insttracer.hh:171
Tick getWhen() const
Definition: insttracer.hh:227
void setData(int64_t d)
Definition: insttracer.hh:193
Bitfield< 0 > p
Addr addr
The address that was accessed.
Definition: insttracer.hh:83
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
StaticInstPtr getStaticInst() const
Definition: insttracer.hh:229

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13