Changes to add tracing and replaying command-line options
authorPolina Dudnik <pdudnik@gmail.com>
Mon, 13 Jul 2009 17:50:10 +0000 (12:50 -0500)
committerPolina Dudnik <pdudnik@gmail.com>
Mon, 13 Jul 2009 17:50:10 +0000 (12:50 -0500)
Trace is automatically ended upon a manual checkpoint

src/mem/ruby/libruby.cc
src/mem/ruby/libruby.hh
src/mem/ruby/recorder/Tracer.cc
src/mem/ruby/system/System.hh

index d356009609f528641da1f0cb7c4cdc412c0eabbb..185797f593166ff1826eb6e172df548a75f29179 100644 (file)
@@ -9,6 +9,7 @@
 #include "mem/ruby/eventqueue/RubyEventQueue.hh"
 #include "mem/ruby/system/MemoryVector.hh"
 #include "mem/ruby/common/Address.hh"
+#include "mem/ruby/recorder/Tracer.hh"
 
 string RubyRequestType_to_string(const RubyRequestType& obj)
 {
@@ -204,6 +205,20 @@ void libruby_print_stats(std::ostream & out)
 {
   RubySystem::printStats(out);
 }
+void libruby_playback_trace(char * trace_filename) 
+{
+  RubySystem::getTracer()->playbackTrace(trace_filename);
+}
+
+void libruby_start_tracing(char * record_filename) {
+  // start the trace
+  RubySystem::getTracer()->startTrace(record_filename);
+}
+
+void libruby_stop_tracing() {
+  // start the trace
+  RubySystem::getTracer()->stopTrace();
+}
 
 uint64_t libruby_get_time() {
   return RubySystem::getCycleCount(0);
index 85de794f1e52aca7aac786688eaf890a7ebd8d84..5eb5e965c2fdfff9de4e3191e583cbc865cb4c5e 100644 (file)
@@ -102,6 +102,20 @@ void libruby_print_config(std::ostream & out);
  */
 void libruby_print_stats(std::ostream & out);
 
+/**
+ * does not return until done
+ */  
+void libruby_playback_trace(char * trace_filename);
+
+/*
+ * enables the tracer and opens the trace file
+ */ 
+void libruby_start_tracing(char * record_filename);
+
+/*
+ * closes the trace file
+ */ 
+void libruby_stop_tracing();
 
 /**
  * get time
index d2df544d8b61156a9cbab471c0ab77f8b90c7846..5b1e4274be28e9e4236d5f5995e311744514b184 100644 (file)
@@ -92,10 +92,11 @@ void Tracer::startTrace(string filename)
 
 void Tracer::stopTrace()
 {
-  assert(m_enabled == true);
-  m_trace_file.close();
-  cout << "Request trace file closed." << endl;
-  m_enabled = false;
+  if (m_enabled == true) {
+    m_trace_file.close();
+    cout << "Request trace file closed." << endl;
+    m_enabled = false;
+  }
 }
 
 void Tracer::traceRequest(const string & sequencer_name, const Address& data_addr, const Address& pc_addr, RubyRequestType type, Time time)
index 40c425ad78f3c7d3f3014cfeeef1577f1ed24bea..8cbeb2b0e390572c9965d0c8bc2f84f957bc06a3 100644 (file)
@@ -106,7 +106,7 @@ public:
   static int getNumberOfSequencers() { return m_sequencers.size(); }
 
   Profiler* getProfiler() {assert(m_profiler_ptr != NULL); return m_profiler_ptr; }
-  Tracer* getTracer() { assert(m_tracer_ptr != NULL); return m_tracer_ptr; }
+  static Tracer* getTracer() { assert(m_tracer_ptr != NULL); return m_tracer_ptr; }
   static MemoryVector* getMemoryVector() { assert(m_mem_vec_ptr != NULL); return m_mem_vec_ptr;}
 
   void recordCacheContents(CacheRecorder& tr) const;