Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ba1faf6428060f1c494b954784bd06ecd5dca59e
[simgrid.git] / src / instr / instr_msg_process.c
1 /* Copyright (c) 2010. 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 #include "instr/instr_private.h"
8
9 #ifdef HAVE_TRACING
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
12
13 /*
14  * TRACE_msg_set_process_category: tracing interface function
15  */
16 void TRACE_msg_set_process_category(m_process_t process, const char *category, const char *color)
17 {
18   if (!(TRACE_is_enabled() &&
19       TRACE_msg_process_is_enabled())) return;
20
21   xbt_assert3(process->category == NULL,
22       "Process %p(%s) already has a category (%s).",
23       process, process->name, process->category);
24   xbt_assert2(process->name != NULL,
25       "Process %p(%s) must have a unique name in order to be traced.",
26       process, process->name);
27   xbt_assert3(getContainer(process->name)==NULL,
28       "Process %p(%s). Tracing already knows a process with name %s."
29       "The name of each process must be unique.", process, process->name, process->name);
30
31   //set process category
32   process->category = xbt_strdup(category);
33   DEBUG3("MSG process %p(%s), category %s", process, process->name, process->category);
34
35   m_host_t host = MSG_process_get_host(process);
36   container_t host_container = getContainer(host->name);
37   container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, host_container);
38   type_t type = getType (category);
39   if (!type){
40     type = newVariableType(category, TYPE_VARIABLE, color, msg->type);
41   }
42   pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
43 }
44
45 /*
46  * Instrumentation functions to trace MSG processes (m_process_t)
47  */
48 void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host)
49 {
50   if (!(TRACE_is_enabled() &&
51       TRACE_msg_process_is_enabled() &&
52       process->category)) return;
53
54   //destroy existing container of this process
55   destroyContainer(getContainer(process->name));
56
57   //create new container on the new_host location
58   container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, getContainer(new_host->name));
59   type_t type = getType (process->category);
60   pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
61 }
62
63 void TRACE_msg_process_kill(m_process_t process)
64 {
65   if (!(TRACE_is_enabled() &&
66       TRACE_msg_process_is_enabled() &&
67       process->category)) return;
68
69   //kill means that this process no longer exists, let's destroy it
70   destroyContainer (getContainer(process->name));
71 }
72
73 void TRACE_msg_process_suspend(m_process_t process)
74 {
75   if (!(TRACE_is_enabled() &&
76       TRACE_msg_process_is_enabled() &&
77       process->category)) return;
78
79   //FIXME
80   //pajeSetState(MSG_get_clock(), "process-state", name, "suspend");
81 }
82
83 void TRACE_msg_process_resume(m_process_t process)
84 {
85   if (!(TRACE_is_enabled() &&
86       TRACE_msg_process_is_enabled() &&
87       process->category)) return;
88
89   //FIXME
90   //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
91 }
92
93 void TRACE_msg_process_sleep_in(m_process_t process)
94 {
95   if (!(TRACE_is_enabled() &&
96       TRACE_msg_process_is_enabled() &&
97       process->category)) return;
98
99   //FIXME
100   //pajeSetState(MSG_get_clock(), "process-state", name, "sleep");
101 }
102
103 void TRACE_msg_process_sleep_out(m_process_t process)
104 {
105   if (!(TRACE_is_enabled() &&
106       TRACE_msg_process_is_enabled() &&
107       process->category)) return;
108
109   //FIXME
110   //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
111 }
112
113 void TRACE_msg_process_end(m_process_t process)
114 {
115   if (!(TRACE_is_enabled() &&
116       TRACE_msg_process_is_enabled() &&
117       process->category)) return;
118
119   //that's the end, let's destroy it
120   destroyContainer (getContainer(process->name));
121 }
122
123 #endif /* HAVE_TRACING */