Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove old DEBUGx() for XBT_DEBUG
[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   xbt_die("deprecated");
19 }
20
21 char *instr_process_id (m_process_t proc, char *str, int len)
22 {
23   snprintf (str, len, "%s-%d", MSG_process_get_name(proc), MSG_process_get_PID(proc));
24   return str;
25 }
26
27 /*
28  * Instrumentation functions to trace MSG processes (m_process_t)
29  */
30 void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host)
31 {
32   if (TRACE_msg_process_is_enabled()){
33     static long long int counter = 0;
34     char key[INSTR_DEFAULT_STR_SIZE];
35     snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
36
37     int len = INSTR_DEFAULT_STR_SIZE;
38     char str[INSTR_DEFAULT_STR_SIZE];
39
40     //start link
41     container_t msg = getContainer(instr_process_id(process, str, len));
42     type_t type = getType ("MSG_PROCESS_LINK", getRootType());
43     new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
44
45     //destroy existing container of this process
46     destroyContainer(getContainer(instr_process_id(process, str, len)));
47
48     //create new container on the new_host location
49     msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, getContainer(new_host->name));
50
51     //set the state of this new container
52     type = getType ("MSG_PROCESS_STATE", msg->type);
53     val_t value = getValueByName ("executing", type);
54     new_pajeSetState (MSG_get_clock(), msg, type, value);
55
56     //end link
57     msg = getContainer(instr_process_id(process, str, len));
58     type = getType ("MSG_PROCESS_LINK", getRootType());
59     new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
60   }
61 }
62
63 void TRACE_msg_process_create (m_process_t process)
64 {
65   if (TRACE_msg_process_is_enabled()){
66     int len = INSTR_DEFAULT_STR_SIZE;
67     char str[INSTR_DEFAULT_STR_SIZE];
68
69     m_host_t host = MSG_process_get_host(process);
70     container_t host_container = getContainer(host->name);
71     container_t msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, host_container);
72
73     type_t type = getType ("MSG_PROCESS_STATE", msg->type);
74     val_t value = getValueByName ("executing", type);
75     new_pajeSetState (MSG_get_clock(), msg, type, value);
76   }
77 }
78
79 void TRACE_msg_process_kill(m_process_t process)
80 {
81   if (TRACE_msg_process_is_enabled()){
82     int len = INSTR_DEFAULT_STR_SIZE;
83     char str[INSTR_DEFAULT_STR_SIZE];
84
85     //kill means that this process no longer exists, let's destroy it
86     destroyContainer (getContainer(instr_process_id(process, str, len)));
87   }
88 }
89
90 void TRACE_msg_process_suspend(m_process_t process)
91 {
92   if (TRACE_msg_process_is_enabled()){
93     int len = INSTR_DEFAULT_STR_SIZE;
94     char str[INSTR_DEFAULT_STR_SIZE];
95
96     container_t process_container = getContainer (instr_process_id(process, str, len));
97     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
98     val_t value = getValueByName ("suspend", type);
99     new_pajePushState (MSG_get_clock(), process_container, type, value);
100   }
101 }
102
103 void TRACE_msg_process_resume(m_process_t process)
104 {
105   if (TRACE_msg_process_is_enabled()){
106     int len = INSTR_DEFAULT_STR_SIZE;
107     char str[INSTR_DEFAULT_STR_SIZE];
108
109     container_t process_container = getContainer (instr_process_id(process, str, len));
110     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
111     new_pajePopState (MSG_get_clock(), process_container, type);
112   }
113 }
114
115 void TRACE_msg_process_sleep_in(m_process_t process)
116 {
117   if (TRACE_msg_process_is_enabled()){
118     int len = INSTR_DEFAULT_STR_SIZE;
119     char str[INSTR_DEFAULT_STR_SIZE];
120
121     container_t process_container = getContainer (instr_process_id(process, str, len));
122     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
123     val_t value = getValueByName ("sleep", type);
124     new_pajePushState (MSG_get_clock(), process_container, type, value);
125   }
126 }
127
128 void TRACE_msg_process_sleep_out(m_process_t process)
129 {
130   if (TRACE_msg_process_is_enabled()){
131     int len = INSTR_DEFAULT_STR_SIZE;
132     char str[INSTR_DEFAULT_STR_SIZE];
133
134     container_t process_container = getContainer (instr_process_id(process, str, len));
135     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
136     new_pajePopState (MSG_get_clock(), process_container, type);
137   }
138 }
139
140 void TRACE_msg_process_end(m_process_t process)
141 {
142   if (TRACE_msg_process_is_enabled()) {
143     int len = INSTR_DEFAULT_STR_SIZE;
144     char str[INSTR_DEFAULT_STR_SIZE];
145
146     //that's the end, let's destroy it
147     destroyContainer (getContainer(instr_process_id(process, str, len)));
148   }
149 }
150
151 #endif /* HAVE_TRACING */