/*
- * Copyright (c) 2001-2005 The Regents of The University of Michigan
+ * Copyright (c) 2006-2009 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Authors: Steve Reinhardt
- * Nathan Binkert
+ * Authors: Gabe Black
*/
-#ifndef __NATIVETRACE_HH__
-#define __NATIVETRACE_HH__
+#ifndef __CPU_NATIVETRACE_HH__
+#define __CPU_NATIVETRACE_HH__
+#include <unistd.h>
+
+#include <cerrno>
+
+#include "base/socket.hh"
#include "base/trace.hh"
+#include "base/types.hh"
+#include "cpu/exetrace.hh"
#include "cpu/static_inst.hh"
-#include "sim/host.hh"
-#include "sim/insttracer.hh"
class ThreadContext;
-
namespace Trace {
class NativeTrace;
-class NativeTraceRecord : public InstRecord
+class NativeTraceRecord : public ExeTracerRecord
{
protected:
NativeTrace * parent;
- bool
- checkIntReg(const char * regName, int index, int size);
-
- bool
- checkPC(const char * regName, int size);
-
public:
NativeTraceRecord(NativeTrace * _parent,
Tick _when, ThreadContext *_thread,
- const StaticInstPtr &_staticInst, Addr _pc, bool spec)
- : InstRecord(_when, _thread, _staticInst, _pc, spec), parent(_parent)
+ const StaticInstPtr _staticInst, TheISA::PCState _pc,
+ bool spec, const StaticInstPtr _macroStaticInst = NULL)
+ : ExeTracerRecord(_when, _thread, _staticInst, _pc, spec,
+ _macroStaticInst),
+ parent(_parent)
{
}
void dump();
};
-class NativeTrace : public InstTracer
+class NativeTrace : public ExeTracer
{
protected:
int fd;
public:
- NativeTrace(const std::string & name);
+ NativeTrace(const Params *p);
+ virtual ~NativeTrace() {}
NativeTraceRecord *
getInstRecord(Tick when, ThreadContext *tc,
- const StaticInstPtr staticInst, Addr pc)
+ const StaticInstPtr staticInst, TheISA::PCState pc,
+ const StaticInstPtr macroStaticInst = NULL)
{
if (tc->misspeculating())
return NULL;
return new NativeTraceRecord(this, when, tc,
- staticInst, pc, tc->misspeculating());
+ staticInst, pc, tc->misspeculating(), macroStaticInst);
+ }
+
+ template<class T>
+ bool
+ checkReg(const char * regName, T &val, T &realVal)
+ {
+ if(val != realVal)
+ {
+ DPRINTFN("Register %s should be %#x but is %#x.\n",
+ regName, realVal, val);
+ return false;
+ }
+ return true;
+ }
+
+ void
+ read(void *ptr, size_t size)
+ {
+ size_t soFar = 0;
+ while (soFar < size) {
+ ssize_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
+ if (res < 0)
+ panic("Read call failed! %s\n", strerror(errno));
+ else
+ soFar += res;
+ }
}
- friend class NativeTraceRecord;
+ virtual void
+ check(NativeTraceRecord *record) = 0;
};
-/* namespace Trace */ }
+} // namespace Trace
-#endif // __EXETRACE_HH__
+#endif // __CPU_NATIVETRACE_HH__