1 /* Copyright (c) 2010-2019. The SimGrid Team.
2 * All rights reserved. */
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. */
8 #include "src/instr/instr_private.hpp"
9 #include "src/msg/msg_private.hpp"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_msg, instr, "MSG instrumentation");
15 void TRACE_msg_set_task_category(msg_task_t task, const char *category)
17 xbt_assert(task->category == nullptr, "Task %p(%s) already has a category (%s).",
18 task, task->name, task->category);
20 //if user provides a nullptr category, task is no longer traced
21 if (category == nullptr) {
22 xbt_free (task->category);
23 task->category = nullptr;
24 XBT_DEBUG("MSG task %p(%s), category removed", task, task->name);
27 task->category = xbt_strdup(category);
28 XBT_DEBUG("MSG task %p(%s), category %s", task, task->name, task->category);
32 void TRACE_msg_task_get_end(msg_task_t task)
34 XBT_DEBUG("GET,out %p, %lld, %s", task, task->counter, task->category);
36 if (TRACE_actor_is_enabled()) {
37 container_t process_container = simgrid::instr::Container::by_name(instr_pid(MSG_process_self()));
39 std::string key = std::string("p") + std::to_string(task->counter);
40 simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->end_event(process_container, "SR", key);
44 /* MSG_task_put related functions */
45 void TRACE_msg_task_put_start(msg_task_t task)
47 XBT_DEBUG("PUT,in %p, %lld, %s", task, task->counter, task->category);
49 if (TRACE_actor_is_enabled()) {
50 container_t process_container = simgrid::instr::Container::by_name(instr_pid(MSG_process_self()));
51 std::string key = std::string("p") + std::to_string(task->counter);
52 simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->start_event(process_container, "SR", key);