Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / mc / mc_record.h
1 /* Copyright (c) 2014-2015. 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 SIMGRID_MC_RECORD_H
18 #define SIMGRID_MC_RECORD_H
19
20 #include <xbt/base.h>
21
22 SG_BEGIN_DECL()
23
24 /** Whether the MC record mode is enabled
25  *
26  *  The behaviour is not changed. The only real difference is that
27  *  the path is writtent in the log when an interesting path is found.
28  */
29 #define MC_record_is_active() _sg_do_model_check_record
30
31 // **** Data conversion
32
33 /** An element in the recorded path
34  *
35  *  At each decision point, we need to record which process transition
36  *  is trigerred and potentially which value is associated with this
37  *  transition. The value is used to find which communication is triggerred
38  *  in things like waitany and for associating a given value of MC_random()
39  *  calls.
40  */
41 typedef struct s_mc_record_item {
42   int pid;
43   int value;
44 } s_mc_record_item_t, *mc_record_item_t;
45
46 /** Convert a string representation of the path into a array of `s_mc_record_item_t`
47  */
48 XBT_PRIVATE xbt_dynar_t MC_record_from_string(const char* data);
49
50 /** Generate a string representation
51 *
52 * The current format is a ";"-delimited list of pairs:
53 * "pid0,value0;pid2,value2;pid3,value3". The value can be
54 * omitted is it is null.
55 */
56 XBT_PRIVATE char* MC_record_stack_to_string(xbt_fifo_t stack);
57
58 /** Dump the path represented by a given stack in the log
59  */
60 XBT_PRIVATE void MC_record_dump_path(xbt_fifo_t stack);
61
62 // ***** Replay
63
64 /** Replay a path represented by the record items
65  *
66  *  \param start Array of record item
67  *  \item  count Number of record items
68  */
69 XBT_PRIVATE void MC_record_replay(mc_record_item_t start, size_t count);
70
71 /** Replay a path represented by a string
72  *
73  *  \param data String representation of the path
74  */
75 XBT_PRIVATE void MC_record_replay_from_string(const char* data);
76
77 XBT_PRIVATE void MC_record_replay_init(void);
78
79 SG_END_DECL()
80
81 #endif