gem5  v21.1.0.2
nativetrace.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006-2009 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
29 #ifndef __CPU_NATIVETRACE_HH__
30 #define __CPU_NATIVETRACE_HH__
31 
32 #include <unistd.h>
33 
34 #include <cerrno>
35 
36 #include "base/socket.hh"
37 #include "base/trace.hh"
38 #include "base/types.hh"
39 #include "cpu/exetrace.hh"
40 #include "cpu/static_inst.hh"
41 
42 namespace gem5
43 {
44 
45 class ThreadContext;
46 
47 namespace Trace {
48 
49 class NativeTrace;
50 
52 {
53  protected:
55 
56  public:
58  Tick _when, ThreadContext *_thread,
59  const StaticInstPtr _staticInst, TheISA::PCState _pc,
60  const StaticInstPtr _macroStaticInst = NULL)
61  : ExeTracerRecord(_when, _thread, _staticInst, _pc, _macroStaticInst),
62  parent(_parent)
63  {
64  }
65 
66  void dump();
67 };
68 
69 class NativeTrace : public ExeTracer
70 {
71  protected:
72  int fd;
73 
75 
76  public:
77 
78  NativeTrace(const Params &p);
79  virtual ~NativeTrace() {}
80 
83  const StaticInstPtr staticInst, TheISA::PCState pc,
84  const StaticInstPtr macroStaticInst = NULL)
85  {
86  return new NativeTraceRecord(this, when, tc,
87  staticInst, pc, macroStaticInst);
88  }
89 
90  template<class T>
91  bool
92  checkReg(const char * regName, T &val, T &realVal)
93  {
94  if (val != realVal)
95  {
96  DPRINTFN("Register %s should be %#x but is %#x.\n",
97  regName, realVal, val);
98  return false;
99  }
100  return true;
101  }
102 
103  void
104  read(void *ptr, size_t size)
105  {
106  size_t soFar = 0;
107  while (soFar < size) {
108  ssize_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
109  if (res < 0)
110  panic("Read call failed! %s\n", strerror(errno));
111  else
112  soFar += res;
113  }
114  }
115 
116  virtual void
117  check(NativeTraceRecord *record) = 0;
118 };
119 
120 } // namespace Trace
121 } // namespace gem5
122 
123 #endif // __CPU_NATIVETRACE_HH__
socket.hh
gem5::Trace::NativeTrace::fd
int fd
Definition: nativetrace.hh:72
gem5::Trace::NativeTraceRecord::dump
void dump()
Definition: nativetrace.cc:58
gem5::Trace::ExeTracer::Params
ExeTracerParams Params
Definition: exetrace.hh:65
gem5::Trace::NativeTrace::NativeTrace
NativeTrace(const Params &p)
Definition: nativetrace.cc:41
gem5::Trace::NativeTrace::read
void read(void *ptr, size_t size)
Definition: nativetrace.hh:104
gem5::Trace::NativeTrace
Definition: nativetrace.hh:69
gem5::ListenSocket
Definition: socket.hh:35
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:775
exetrace.hh
gem5::Trace::NativeTraceRecord::NativeTraceRecord
NativeTraceRecord(NativeTrace *_parent, Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, TheISA::PCState _pc, const StaticInstPtr _macroStaticInst=NULL)
Definition: nativetrace.hh:57
gem5::RefCountingPtr< StaticInst >
gem5::Trace::NativeTrace::check
virtual void check(NativeTraceRecord *record)=0
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:93
gem5::MipsISA::PCState
GenericISA::DelaySlotPCState< 4 > PCState
Definition: pcstate.hh:40
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Trace::NativeTraceRecord::parent
NativeTrace * parent
Definition: nativetrace.hh:54
static_inst.hh
gem5::Trace::NativeTrace::native_listener
ListenSocket native_listener
Definition: nativetrace.hh:74
gem5::Trace::NativeTrace::checkReg
bool checkReg(const char *regName, T &val, T &realVal)
Definition: nativetrace.hh:92
types.hh
gem5::Trace::NativeTrace::~NativeTrace
virtual ~NativeTrace()
Definition: nativetrace.hh:79
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::Trace::ExeTracer
Definition: exetrace.hh:62
gem5::Trace::NativeTrace::getInstRecord
NativeTraceRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, TheISA::PCState pc, const StaticInstPtr macroStaticInst=NULL)
Definition: nativetrace.hh:82
gem5::Trace::ExeTracerRecord
Definition: exetrace.hh:47
trace.hh
DPRINTFN
#define DPRINTFN(...)
Definition: trace.hh:214
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::Trace::NativeTraceRecord
Definition: nativetrace.hh:51
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

Generated on Tue Sep 21 2021 12:24:37 for gem5 by doxygen 1.8.17