Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] update on --cfg=tracing/msg/task:1, now works with new tracing system
[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   if (category == NULL) {
32     //if user provides a NULL category, process is no longer traced
33     xbt_free (process->category);
34     process->category = NULL;
35     return;
36   }
37
38   //set process category
39   process->category = xbt_strdup(category);
40   DEBUG3("MSG process %p(%s), category %s", process, process->name, process->category);
41
42   m_host_t host = MSG_process_get_host(process);
43   container_t host_container = getContainer(host->name);
44   container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, host_container);
45   type_t type = getType (category);
46   if (!type){
47     type = newVariableType(category, TYPE_VARIABLE, color, msg->type);
48   }
49   pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
50 }
51
52 /*
53  * Instrumentation functions to trace MSG processes (m_process_t)
54  */
55 void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host)
56 {
57   if (!(TRACE_is_enabled() &&
58       TRACE_msg_process_is_enabled() &&
59       process->category)) return;
60
61   //destroy existing container of this process
62   destroyContainer(getContainer(process->name));
63
64   //create new container on the new_host location
65   container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, getContainer(new_host->name));
66   type_t type = getType (process->category);
67   pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
68 }
69
70 void TRACE_msg_process_kill(m_process_t process)
71 {
72   if (!(TRACE_is_enabled() &&
73       TRACE_msg_process_is_enabled() &&
74       process->category)) return;
75
76   //kill means that this process no longer exists, let's destroy it
77   destroyContainer (getContainer(process->name));
78 }
79
80 void TRACE_msg_process_suspend(m_process_t process)
81 {
82   if (!(TRACE_is_enabled() &&
83       TRACE_msg_process_is_enabled() &&
84       process->category)) return;
85
86   //FIXME
87   //pajeSetState(MSG_get_clock(), "process-state", name, "suspend");
88 }
89
90 void TRACE_msg_process_resume(m_process_t process)
91 {
92   if (!(TRACE_is_enabled() &&
93       TRACE_msg_process_is_enabled() &&
94       process->category)) return;
95
96   //FIXME
97   //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
98 }
99
100 void TRACE_msg_process_sleep_in(m_process_t process)
101 {
102   if (!(TRACE_is_enabled() &&
103       TRACE_msg_process_is_enabled() &&
104       process->category)) return;
105
106   //FIXME
107   //pajeSetState(MSG_get_clock(), "process-state", name, "sleep");
108 }
109
110 void TRACE_msg_process_sleep_out(m_process_t process)
111 {
112   if (!(TRACE_is_enabled() &&
113       TRACE_msg_process_is_enabled() &&
114       process->category)) return;
115
116   //FIXME
117   //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
118 }
119
120 void TRACE_msg_process_end(m_process_t process)
121 {
122   if (!(TRACE_is_enabled() &&
123       TRACE_msg_process_is_enabled() &&
124       process->category)) return;
125
126   //that's the end, let's destroy it
127   destroyContainer (getContainer(process->name));
128 }
129
130 #endif /* HAVE_TRACING */