Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move the stack as field of SafetyChecker and CommDetChecker
[simgrid.git] / src / mc / mc_record.h
index 3257703..2c55598 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  *  passed to the application (without the MC specific arguments).
  */
 
-#ifndef MC_RECORD_H
-#define MC_RECORD_H
+#ifndef SIMGRID_MC_RECORD_H
+#define SIMGRID_MC_RECORD_H
 
-#include <stdbool.h>
+#include <string>
+#include <vector>
 
-#include "simgrid_config.h"
-#include "mc_record.h"
+#include <xbt/base.h>
+#include <xbt/dynar.h>
+#include <xbt/fifo.h>
 
-SG_BEGIN_DECL()
+namespace simgrid {
+namespace mc {
 
-/** Replay path (if any) in string representation
+/** An element in the recorded path
  *
- *  This is a path as generated by `MC_record_stack_to_string()`.
+ *  At each decision point, we need to record which process transition
+ *  is trigerred and potentially which value is associated with this
+ *  transition. The value is used to find which communication is triggerred
+ *  in things like waitany and for associating a given value of MC_random()
+ *  calls.
  */
-extern char* MC_record_path;
+struct RecordTraceElement {
+  int pid = 0;
+  int value = 0;
+  RecordTraceElement() {}
+  RecordTraceElement(int pid, int value) : pid(pid), value(value) {}
+};
 
-/** Whether the MC record mode is enabled
- *
- *  The behaviour is not changed. The only real difference is that
- *  the path is writtent in the log when an interesting path is found.
+typedef std::vector<RecordTraceElement> RecordTrace;
+
+/** Convert a string representation of the path into a array of `simgrid::mc::RecordTraceElement`
  */
-#define MC_record_is_active() _sg_do_model_check_record
+XBT_PRIVATE RecordTrace parseRecordTrace(const char* data);
+XBT_PRIVATE std::string traceToString(simgrid::mc::RecordTrace const& trace);
+XBT_PRIVATE void dumpRecordPath();
 
-/** Whether the replay mode is enabled */
-static inline bool MC_record_replay_is_active(void) {
-  return MC_record_path;
+XBT_PRIVATE void replay(RecordTrace const& trace);
+XBT_PRIVATE void replay(const char* trace);
+
+}
 }
 
-// **** Data conversion
+SG_BEGIN_DECL()
 
-/** An element in the recorded path
+/** Whether the MC record mode is enabled
  *
- *  At each decision point, we need to record which process transition
- *  is trigerred and potentially which value is associated with this
- *  transition. The value is used to find which communication is triggerred
- *  in things like waitany and for associating a given value of MC_random()
- *  calls.
+ *  The behaviour is not changed. The only real difference is that
+ *  the path is writtent in the log when an interesting path is found.
  */
-typedef struct s_mc_record_item {
-  int pid;
-  int value;
-} s_mc_record_item_t, *mc_record_item_t;
+#define MC_record_is_active() _sg_do_model_check_record
 
-/** Convert a string representation of the path into a array of `s_mc_record_item_t`
- */
-xbt_dynar_t MC_record_from_string(const char* data);
+// **** Data conversion
 
 /** Generate a string representation
 *
@@ -67,26 +73,7 @@ xbt_dynar_t MC_record_from_string(const char* data);
 * "pid0,value0;pid2,value2;pid3,value3". The value can be
 * omitted is it is null.
 */
-char* MC_record_stack_to_string(xbt_fifo_t stack);
-
-/** Dump the path represented by a given stack in the log
- */
-void MC_record_dump_path(xbt_fifo_t stack);
-
-// ***** Replay
-
-/** Replay a path represented by the record items
- *
- *  \param start Array of record item
- *  \item  count Number of record items
- */
-void MC_record_replay(mc_record_item_t start, size_t count);
-
-/** Replay a path represented by a string
- *
- *  \param data String representation of the path
- */
-void MC_record_replay_from_string(const char* data);
+XBT_PRIVATE char* MC_record_stack_to_string(xbt_fifo_t stack);
 
 SG_END_DECL()