Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[XBT] Remove a new/delete pair from xbt-replay code
[simgrid.git] / src / msg / msg_actions.cpp
1 /* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/msg/msg_private.hpp"
7 #include "xbt/replay.hpp"
8
9 #include <cerrno>
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg, "MSG actions for trace driven simulation");
12
13 void MSG_action_init()
14 {
15   MSG_function_register_default(simgrid::xbt::replay_runner);
16 }
17
18 void MSG_action_exit()
19 {
20   // Nothing to do anymore here
21 }
22
23 /** \ingroup msg_trace_driven
24  * \brief A trace loader
25  *
26  *  If path!=nullptr, load a trace file containing actions, and execute them.
27  *  Else, assume that each process gets the path in its deployment file
28  */
29 msg_error_t MSG_action_trace_run(char *path)
30 {
31   if (path) {
32     simgrid::xbt::action_fs = new std::ifstream(path, std::ifstream::in);
33   }
34
35   msg_error_t res = MSG_main();
36
37   if (not simgrid::xbt::action_queues.empty()) {
38     XBT_WARN("Not all actions got consumed. If the simulation ended successfully (without deadlock),"
39              " you may want to add new processes to your deployment file.");
40
41     for (auto const& actions_of : simgrid::xbt::action_queues) {
42       XBT_WARN("Still %zu actions for %s", actions_of.second->size(), actions_of.first.c_str());
43     }
44   }
45
46   if (path) {
47     delete simgrid::xbt::action_fs;
48     simgrid::xbt::action_fs = nullptr;
49   }
50
51   return res;
52 }