gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  * Authors: Gabe Black
29  */
30 
31 #ifndef __CPU_NATIVETRACE_HH__
32 #define __CPU_NATIVETRACE_HH__
33 
34 #include <unistd.h>
35 
36 #include <cerrno>
37 
38 #include "base/socket.hh"
39 #include "base/trace.hh"
40 #include "base/types.hh"
41 #include "cpu/exetrace.hh"
42 #include "cpu/static_inst.hh"
43 
44 class ThreadContext;
45 
46 namespace Trace {
47 
48 class NativeTrace;
49 
51 {
52  protected:
54 
55  public:
57  Tick _when, ThreadContext *_thread,
58  const StaticInstPtr _staticInst, TheISA::PCState _pc,
59  const StaticInstPtr _macroStaticInst = NULL)
60  : ExeTracerRecord(_when, _thread, _staticInst, _pc, _macroStaticInst),
61  parent(_parent)
62  {
63  }
64 
65  void dump();
66 };
67 
68 class NativeTrace : public ExeTracer
69 {
70  protected:
71  int fd;
72 
74 
75  public:
76 
77  NativeTrace(const Params *p);
78  virtual ~NativeTrace() {}
79 
82  const StaticInstPtr staticInst, TheISA::PCState pc,
83  const StaticInstPtr macroStaticInst = NULL)
84  {
85  return new NativeTraceRecord(this, when, tc,
86  staticInst, pc, macroStaticInst);
87  }
88 
89  template<class T>
90  bool
91  checkReg(const char * regName, T &val, T &realVal)
92  {
93  if (val != realVal)
94  {
95  DPRINTFN("Register %s should be %#x but is %#x.\n",
96  regName, realVal, val);
97  return false;
98  }
99  return true;
100  }
101 
102  void
103  read(void *ptr, size_t size)
104  {
105  size_t soFar = 0;
106  while (soFar < size) {
107  ssize_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
108  if (res < 0)
109  panic("Read call failed! %s\n", strerror(errno));
110  else
111  soFar += res;
112  }
113  }
114 
115  virtual void
116  check(NativeTraceRecord *record) = 0;
117 };
118 
119 } // namespace Trace
120 
121 #endif // __CPU_NATIVETRACE_HH__
NativeTraceRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, TheISA::PCState pc, const StaticInstPtr macroStaticInst=NULL)
Definition: nativetrace.hh:81
#define panic(...)
Definition: misc.hh:153
NativeTraceRecord(NativeTrace *_parent, Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, TheISA::PCState _pc, const StaticInstPtr _macroStaticInst=NULL)
Definition: nativetrace.hh:56
bool checkReg(const char *regName, T &val, T &realVal)
Definition: nativetrace.hh:91
ThreadContext is the external interface to all thread state for anything outside of the CPU...
#define DPRINTFN(...)
Definition: trace.hh:216
Bitfield< 63 > val
Definition: misc.hh:770
uint64_t Tick
Tick count type.
Definition: types.hh:63
virtual void check(NativeTraceRecord *record)=0
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
int size()
Definition: pagetable.hh:146
NativeTrace(const Params *p)
Definition: nativetrace.cc:42
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
ListenSocket native_listener
Definition: nativetrace.hh:73
void read(void *ptr, size_t size)
Definition: nativetrace.hh:103
IntReg pc
Definition: remote_gdb.hh:91
ExeTracerParams Params
Definition: exetrace.hh:66
virtual ~NativeTrace()
Definition: nativetrace.hh:78
Bitfield< 0 > p

Generated on Fri Jun 9 2017 13:03:39 for gem5 by doxygen 1.8.6