1 /* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved. */
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. */
6 #include "src/kernel/actor/ActorImpl.hpp"
9 #if SIMGRID_HAVE_STATEFUL_MC
10 #include "src/mc/api/RemoteApp.hpp"
11 #include "src/mc/explo/Exploration.hpp"
12 #include "src/mc/inspect/mc_unw.hpp"
13 #include "src/mc/mc_config.hpp"
14 #include "src/mc/mc_private.hpp"
15 #include "src/mc/remote/AppSide.hpp"
16 #include "src/mc/sosp/Snapshot.hpp"
19 #include <boost/core/demangle.hpp>
22 #include <libunwind.h>
29 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc, "Logging specific to MC (global)");
31 namespace simgrid::mc {
33 std::vector<double> processes_time;
37 #if SIMGRID_HAVE_STATEFUL_MC
39 namespace simgrid::mc {
41 /******************************* Core of MC *******************************/
42 /**************************************************************************/
43 void dumpStack(FILE* file, unw_cursor_t* cursor)
46 std::array<char, 100> buffer;
50 const char* name = not unw_get_proc_name(cursor, buffer.data(), buffer.size(), &off) ? buffer.data() : "?";
51 // Unmangle C++ names:
52 std::string realname = boost::core::demangle(name);
54 #if defined(__x86_64__)
57 unw_get_reg(cursor, UNW_X86_64_RIP, &rip);
58 unw_get_reg(cursor, UNW_X86_64_RSP, &rsp);
59 fprintf(file, " %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n", nframe, realname.c_str(), (std::uint64_t)rip,
62 fprintf(file, " %i: %s\n", nframe, realname.c_str());
66 } while (unw_step(cursor));
69 } // namespace simgrid::mc
72 double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl* process)
75 auto pid = static_cast<size_t>(process->get_pid());
76 if (pid < simgrid::mc::processes_time.size())
77 return simgrid::mc::processes_time[pid];
82 void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl* process, double amount)
84 simgrid::mc::processes_time.at(process->get_pid()) += amount;