Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove useless condition check
[simgrid.git] / src / mc / mc_record.h
1 /* Copyright (c) 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 /** \file
8  *  This file contains the MC replay/record functionnality.
9  *  A MC path may be recorded by using ``-cfg=model-check/record:1`'`.
10  *  The path is written in the log output and an be replayed with MC disabled
11  *  (even with an non-LC build) with `--cfg=model-check/replay:$replayPath`.
12  *
13  *  The same version of Simgrid should be used and the same arguments should be
14  *  passed to the application (without the MC specific arguments).
15  */
16
17 #ifndef MC_RECORD_H
18 #define MC_RECORD_H
19
20 #include <stdbool.h>
21
22 #include "simgrid_config.h"
23 #include "mc_record.h"
24
25 SG_BEGIN_DECL()
26
27 /** Replay path (if any) in string representation
28  *
29  *  This is a path as generated by `MC_record_stack_to_string()`.
30  */
31 extern char* MC_record_path;
32
33 /** Whether the MC record mode is enabled
34  *
35  *  The behaviour is not changed. The only real difference is that
36  *  the path is writtent in the log when an interesting path is found.
37  */
38 #define MC_record_is_active() _sg_do_model_check_record
39
40 /** Whether the replay mode is enabled */
41 static inline bool MC_record_replay_is_active(void) {
42   return MC_record_path;
43 }
44
45 // **** Data conversion
46
47 /** An element in the recorded path
48  *
49  *  At each decision point, we need to record which process transition
50  *  is trigerred and potentially which value is associated with this
51  *  transition. The value is used to find which communication is triggerred
52  *  in things like waitany and for associating a given value of MC_random()
53  *  calls.
54  */
55 typedef struct s_mc_record_item {
56   int pid;
57   int value;
58 } s_mc_record_item_t, *mc_record_item_t;
59
60 /** Convert a string representation of the path into a array of `s_mc_record_item_t`
61  */
62 xbt_dynar_t MC_record_from_string(const char* data);
63
64 /** Generate a string representation
65 *
66 * The current format is a ";"-delimited list of pairs:
67 * "pid0,value0;pid2,value2;pid3,value3". The value can be
68 * omitted is it is null.
69 */
70 char* MC_record_stack_to_string(xbt_fifo_t stack);
71
72 /** Dump the path represented by a given stack in the log
73  */
74 void MC_record_dump_path(xbt_fifo_t stack);
75
76 // ***** Replay
77
78 /** Replay a path represented by the record items
79  *
80  *  \param start Array of record item
81  *  \item  count Number of record items
82  */
83 void MC_record_replay(mc_record_item_t start, size_t count);
84
85 /** Replay a path represented by a string
86  *
87  *  \param data String representation of the path
88  */
89 void MC_record_replay_from_string(const char* data);
90
91 SG_END_DECL()
92
93 #endif