Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix debug + trace
authordegomme <adegomme@users.noreply.github.com>
Thu, 28 Mar 2019 11:04:52 +0000 (12:04 +0100)
committerdegomme <adegomme@users.noreply.github.com>
Thu, 28 Mar 2019 17:35:56 +0000 (18:35 +0100)
- print might be called several times when debug is on, leading to double frees.
- actually emove the calls to buffer_debug, printing the whole buffer twice at each tracing event is a tiny bit too much (and it ruins the output trace).

The helper function is still there, I don't know whether to remove it or not.

src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/instr/instr_paje_trace.cpp

index 0870bf0..ed016d8 100644 (file)
@@ -83,6 +83,10 @@ void VariableEvent::print()
   tracing_file << stream_.str() << std::endl;
 }
 
   tracing_file << stream_.str() << std::endl;
 }
 
+StateEvent::~StateEvent(){
+  delete extra_;
+}
+
 void StateEvent::print()
 {
   if (trace_format == simgrid::instr::TraceFormat::Paje) {
 void StateEvent::print()
 {
   if (trace_format == simgrid::instr::TraceFormat::Paje) {
@@ -119,7 +123,6 @@ void StateEvent::print()
     THROW_IMPOSSIBLE;
   }
 
     THROW_IMPOSSIBLE;
   }
 
-  delete extra_;
 }
 }
 }
 }
 }
 }
index 71dd4c7..d57c644 100644 (file)
@@ -74,6 +74,7 @@ class StateEvent : public PajeEvent {
 
 public:
   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
 
 public:
   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
+  ~StateEvent();
   void print() override;
 };
 
   void print() override;
 };
 
index 2a440d1..f880887 100644 (file)
@@ -85,8 +85,6 @@ static void buffer_debug(std::vector<simgrid::instr::PajeEvent*>* buf)
 /* internal do the instrumentation module */
 void simgrid::instr::PajeEvent::insert_into_buffer()
 {
 /* internal do the instrumentation module */
 void simgrid::instr::PajeEvent::insert_into_buffer()
 {
-  buffer_debug(&buffer);
-
   XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size());
   std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
   for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
   XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size());
   std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
   for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
@@ -102,6 +100,4 @@ void simgrid::instr::PajeEvent::insert_into_buffer()
   else
     XBT_DEBUG("%s: inserted at pos= %zd from its end", __func__, std::distance(buffer.rbegin(), i));
   buffer.insert(i.base(), this);
   else
     XBT_DEBUG("%s: inserted at pos= %zd from its end", __func__, std::distance(buffer.rbegin(), i));
   buffer.insert(i.base(), this);
-
-  buffer_debug(&buffer);
 }
 }