gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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, const PCStateBase &_pc,
60  const StaticInstPtr _macroStaticInst=nullptr)
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, const PCStateBase &pc,
84  const StaticInstPtr macroStaticInst=nullptr) override
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__
gem5::trace::NativeTrace::NativeTrace
NativeTrace(const Params &p)
Definition: nativetrace.cc:41
socket.hh
gem5::trace::ExeTracer
Definition: exetrace.hh:62
gem5::trace::NativeTrace::fd
int fd
Definition: nativetrace.hh:72
gem5::trace::NativeTraceRecord::parent
NativeTrace * parent
Definition: nativetrace.hh:54
gem5::trace::NativeTrace::getInstRecord
NativeTraceRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, const PCStateBase &pc, const StaticInstPtr macroStaticInst=nullptr) override
Definition: nativetrace.hh:82
gem5::trace::NativeTrace
Definition: nativetrace.hh:69
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
exetrace.hh
gem5::trace::NativeTrace::check
virtual void check(NativeTraceRecord *record)=0
gem5::trace::NativeTraceRecord::NativeTraceRecord
NativeTraceRecord(NativeTrace *_parent, Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, const PCStateBase &_pc, const StaticInstPtr _macroStaticInst=nullptr)
Definition: nativetrace.hh:57
gem5::trace::NativeTrace::read
void read(void *ptr, size_t size)
Definition: nativetrace.hh:104
gem5::RefCountingPtr< StaticInst >
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::trace::NativeTraceRecord::dump
void dump()
Definition: nativetrace.cc:53
static_inst.hh
gem5::trace::NativeTrace::checkReg
bool checkReg(const char *regName, T &val, T &realVal)
Definition: nativetrace.hh:92
gem5::trace::NativeTrace::native_listener
ListenSocketPtr native_listener
Definition: nativetrace.hh:74
gem5::trace::ExeTracerRecord
Definition: exetrace.hh:47
gem5::trace::ExeTracer::Params
ExeTracerParams Params
Definition: exetrace.hh:65
gem5::trace::NativeTrace::~NativeTrace
virtual ~NativeTrace()
Definition: nativetrace.hh:79
types.hh
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
trace.hh
DPRINTFN
#define DPRINTFN(...)
Definition: trace.hh:238
gem5::PCStateBase
Definition: pcstate.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::trace::NativeTraceRecord
Definition: nativetrace.hh:51
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::ListenSocketPtr
std::unique_ptr< ListenSocket > ListenSocketPtr
Definition: socket.hh:112

Generated on Sun Jul 30 2023 01:56:49 for gem5 by doxygen 1.8.17