Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix namespace for transition pattern code
[simgrid.git] / src / mc / mc_request.c
1 /* Copyright (c) 2008-2014. 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 "mc_request.h"
8 #include "mc_safety.h"
9 #include "mc_private.h"
10 #include "mc_smx.h"
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc,
13                                 "Logging specific to MC (request)");
14
15 static char *pointer_to_string(void *pointer);
16 static char *buff_size_to_string(size_t size);
17
18 int MC_request_depend(smx_simcall_t r1, smx_simcall_t r2)
19 {
20   if (mc_reduce_kind == e_mc_reduce_none)
21     return TRUE;
22
23   if (r1->issuer == r2->issuer)
24     return FALSE;
25
26   /* Wait with timeout transitions are not considered by the independance theorem, thus we consider them as dependant with all other transitions */
27   if ((r1->call == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(r1) > 0)
28       || (r2->call == SIMCALL_COMM_WAIT
29           && simcall_comm_wait__get__timeout(r2) > 0))
30     return TRUE;
31
32   if (r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_IRECV)
33     return FALSE;
34
35   if (r1->call == SIMCALL_COMM_IRECV && r2->call == SIMCALL_COMM_ISEND)
36     return FALSE;
37
38   if ((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
39       && r2->call == SIMCALL_COMM_WAIT) {
40
41     smx_rdv_t rdv =
42         r1->call ==
43         SIMCALL_COMM_ISEND ? simcall_comm_isend__get__rdv(r1) :
44         simcall_comm_irecv__get__rdv(r1);
45
46     // FIXME, remote access to comm object
47
48     if (rdv != simcall_comm_wait__get__comm(r2)->comm.rdv_cpy
49         && simcall_comm_wait__get__timeout(r2) <= 0)
50       return FALSE;
51
52     if ((r1->issuer != simcall_comm_wait__get__comm(r2)->comm.src_proc)
53         && (r1->issuer != simcall_comm_wait__get__comm(r2)->comm.dst_proc)
54         && simcall_comm_wait__get__timeout(r2) <= 0)
55       return FALSE;
56
57     if ((r1->call == SIMCALL_COMM_ISEND)
58         && (simcall_comm_wait__get__comm(r2)->comm.type == SIMIX_COMM_SEND)
59         && (simcall_comm_wait__get__comm(r2)->comm.src_buff !=
60             simcall_comm_isend__get__src_buff(r1))
61         && simcall_comm_wait__get__timeout(r2) <= 0)
62       return FALSE;
63
64     if ((r1->call == SIMCALL_COMM_IRECV)
65         && (simcall_comm_wait__get__comm(r2)->comm.type == SIMIX_COMM_RECEIVE)
66         && (simcall_comm_wait__get__comm(r2)->comm.dst_buff !=
67             simcall_comm_irecv__get__dst_buff(r1))
68         && simcall_comm_wait__get__timeout(r2) <= 0)
69       return FALSE;
70   }
71
72   if ((r2->call == SIMCALL_COMM_ISEND || r2->call == SIMCALL_COMM_IRECV)
73       && r1->call == SIMCALL_COMM_WAIT) {
74
75     smx_rdv_t rdv =
76         r2->call ==
77         SIMCALL_COMM_ISEND ? simcall_comm_isend__get__rdv(r2) :
78         simcall_comm_irecv__get__rdv(r2);
79
80     if (rdv != simcall_comm_wait__get__comm(r1)->comm.rdv_cpy
81         && simcall_comm_wait__get__timeout(r1) <= 0)
82       return FALSE;
83
84     if ((r2->issuer != simcall_comm_wait__get__comm(r1)->comm.src_proc)
85         && (r2->issuer != simcall_comm_wait__get__comm(r1)->comm.dst_proc)
86         && simcall_comm_wait__get__timeout(r1) <= 0)
87       return FALSE;
88
89     if ((r2->call == SIMCALL_COMM_ISEND)
90         && (simcall_comm_wait__get__comm(r1)->comm.type == SIMIX_COMM_SEND)
91         && (simcall_comm_wait__get__comm(r1)->comm.src_buff !=
92             simcall_comm_isend__get__src_buff(r2))
93         && simcall_comm_wait__get__timeout(r1) <= 0)
94       return FALSE;
95
96     if ((r2->call == SIMCALL_COMM_IRECV)
97         && (simcall_comm_wait__get__comm(r1)->comm.type == SIMIX_COMM_RECEIVE)
98         && (simcall_comm_wait__get__comm(r1)->comm.dst_buff !=
99             simcall_comm_irecv__get__dst_buff(r2))
100         && simcall_comm_wait__get__timeout(r1) <= 0)
101       return FALSE;
102   }
103
104   /* FIXME: the following rule assumes that the result of the
105    * isend/irecv call is not stored in a buffer used in the
106    * test call. */
107   /*if(   (r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
108      &&  r2->call == SIMCALL_COMM_TEST)
109      return FALSE; */
110
111   /* FIXME: the following rule assumes that the result of the
112    * isend/irecv call is not stored in a buffer used in the
113    * test call.*/
114   /*if(   (r2->call == SIMCALL_COMM_ISEND || r2->call == SIMCALL_COMM_IRECV)
115      && r1->call == SIMCALL_COMM_TEST)
116      return FALSE; */
117
118   if (r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_ISEND
119       && simcall_comm_isend__get__rdv(r1) != simcall_comm_isend__get__rdv(r2))
120     return FALSE;
121
122   if (r1->call == SIMCALL_COMM_IRECV && r2->call == SIMCALL_COMM_IRECV
123       && simcall_comm_irecv__get__rdv(r1) != simcall_comm_irecv__get__rdv(r2))
124     return FALSE;
125
126   if (r1->call == SIMCALL_COMM_WAIT
127       && (r2->call == SIMCALL_COMM_WAIT || r2->call == SIMCALL_COMM_TEST)
128       && (simcall_comm_wait__get__comm(r1)->comm.src_proc == NULL
129           || simcall_comm_wait__get__comm(r1)->comm.dst_proc == NULL))
130     return FALSE;
131
132   if (r2->call == SIMCALL_COMM_WAIT
133       && (r1->call == SIMCALL_COMM_WAIT || r1->call == SIMCALL_COMM_TEST)
134       && (simcall_comm_wait__get__comm(r2)->comm.src_proc == NULL
135           || simcall_comm_wait__get__comm(r2)->comm.dst_proc == NULL))
136     return FALSE;
137
138   if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_WAIT
139       && simcall_comm_wait__get__comm(r1)->comm.src_buff ==
140       simcall_comm_wait__get__comm(r2)->comm.src_buff
141       && simcall_comm_wait__get__comm(r1)->comm.dst_buff ==
142       simcall_comm_wait__get__comm(r2)->comm.dst_buff)
143     return FALSE;
144
145   if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_WAIT
146       && simcall_comm_wait__get__comm(r1)->comm.src_buff != NULL
147       && simcall_comm_wait__get__comm(r1)->comm.dst_buff != NULL
148       && simcall_comm_wait__get__comm(r2)->comm.src_buff != NULL
149       && simcall_comm_wait__get__comm(r2)->comm.dst_buff != NULL
150       && simcall_comm_wait__get__comm(r1)->comm.dst_buff !=
151       simcall_comm_wait__get__comm(r2)->comm.src_buff
152       && simcall_comm_wait__get__comm(r1)->comm.dst_buff !=
153       simcall_comm_wait__get__comm(r2)->comm.dst_buff
154       && simcall_comm_wait__get__comm(r2)->comm.dst_buff !=
155       simcall_comm_wait__get__comm(r1)->comm.src_buff)
156     return FALSE;
157
158   if (r1->call == SIMCALL_COMM_TEST &&
159       (simcall_comm_test__get__comm(r1) == NULL
160        || simcall_comm_test__get__comm(r1)->comm.src_buff == NULL
161        || simcall_comm_test__get__comm(r1)->comm.dst_buff == NULL))
162     return FALSE;
163
164   if (r2->call == SIMCALL_COMM_TEST &&
165       (simcall_comm_test__get__comm(r2) == NULL
166        || simcall_comm_test__get__comm(r2)->comm.src_buff == NULL
167        || simcall_comm_test__get__comm(r2)->comm.dst_buff == NULL))
168     return FALSE;
169
170   if (r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
171       && simcall_comm_test__get__comm(r1)->comm.src_buff ==
172       simcall_comm_wait__get__comm(r2)->comm.src_buff
173       && simcall_comm_test__get__comm(r1)->comm.dst_buff ==
174       simcall_comm_wait__get__comm(r2)->comm.dst_buff)
175     return FALSE;
176
177   if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
178       && simcall_comm_wait__get__comm(r1)->comm.src_buff ==
179       simcall_comm_test__get__comm(r2)->comm.src_buff
180       && simcall_comm_wait__get__comm(r1)->comm.dst_buff ==
181       simcall_comm_test__get__comm(r2)->comm.dst_buff)
182     return FALSE;
183
184   if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
185       && simcall_comm_wait__get__comm(r1)->comm.src_buff != NULL
186       && simcall_comm_wait__get__comm(r1)->comm.dst_buff != NULL
187       && simcall_comm_test__get__comm(r2)->comm.src_buff != NULL
188       && simcall_comm_test__get__comm(r2)->comm.dst_buff != NULL
189       && simcall_comm_wait__get__comm(r1)->comm.dst_buff !=
190       simcall_comm_test__get__comm(r2)->comm.src_buff
191       && simcall_comm_wait__get__comm(r1)->comm.dst_buff !=
192       simcall_comm_test__get__comm(r2)->comm.dst_buff
193       && simcall_comm_test__get__comm(r2)->comm.dst_buff !=
194       simcall_comm_wait__get__comm(r1)->comm.src_buff)
195     return FALSE;
196
197   if (r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
198       && simcall_comm_test__get__comm(r1)->comm.src_buff != NULL
199       && simcall_comm_test__get__comm(r1)->comm.dst_buff != NULL
200       && simcall_comm_wait__get__comm(r2)->comm.src_buff != NULL
201       && simcall_comm_wait__get__comm(r2)->comm.dst_buff != NULL
202       && simcall_comm_test__get__comm(r1)->comm.dst_buff !=
203       simcall_comm_wait__get__comm(r2)->comm.src_buff
204       && simcall_comm_test__get__comm(r1)->comm.dst_buff !=
205       simcall_comm_wait__get__comm(r2)->comm.dst_buff
206       && simcall_comm_wait__get__comm(r2)->comm.dst_buff !=
207       simcall_comm_test__get__comm(r1)->comm.src_buff)
208     return FALSE;
209
210
211   return TRUE;
212 }
213
214 static char *pointer_to_string(void *pointer)
215 {
216
217   if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))
218     return bprintf("%p", pointer);
219
220   return xbt_strdup("(verbose only)");
221 }
222
223 static char *buff_size_to_string(size_t buff_size)
224 {
225
226   if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))
227     return bprintf("%zu", buff_size);
228
229   return xbt_strdup("(verbose only)");
230 }
231
232
233 char *MC_request_to_string(smx_simcall_t req, int value)
234 {
235   char *type = NULL, *args = NULL, *str = NULL, *p = NULL, *bs = NULL;
236   smx_synchro_t act = NULL;
237   smx_mutex_t mutex = NULL;
238   size_t size = 0;
239
240   smx_process_t issuer = MC_smx_simcall_get_issuer(req);
241
242   switch (req->call) {
243   case SIMCALL_COMM_ISEND:
244     type = xbt_strdup("iSend");
245     p = pointer_to_string(simcall_comm_isend__get__src_buff(req));
246     bs = buff_size_to_string(simcall_comm_isend__get__src_buff_size(req));
247     if (issuer->smx_host)
248       args =
249           bprintf("src=(%lu)%s (%s), buff=%s, size=%s", issuer->pid,
250                   MC_smx_process_get_host_name(issuer),
251                   MC_smx_process_get_name(issuer),
252                   p, bs);
253     else
254       args =
255           bprintf("src=(%lu)%s, buff=%s, size=%s", issuer->pid,
256                   MC_smx_process_get_name(issuer), p, bs);
257     break;
258   case SIMCALL_COMM_IRECV:
259     size =
260         simcall_comm_irecv__get__dst_buff_size(req) ?
261         *simcall_comm_irecv__get__dst_buff_size(req) : 0;
262     type = xbt_strdup("iRecv");
263     p = pointer_to_string(simcall_comm_irecv__get__dst_buff(req));
264     bs = buff_size_to_string(size);
265     if (issuer->smx_host)
266       args =
267           bprintf("dst=(%lu)%s (%s), buff=%s, size=%s", issuer->pid,
268                   MC_smx_process_get_host_name(issuer),
269                   MC_smx_process_get_name(issuer),
270                   p, bs);
271     else
272       args =
273           bprintf("dst=(%lu)%s, buff=%s, size=%s", issuer->pid,
274                   MC_smx_process_get_name(issuer),
275                   p, bs);
276     break;
277   case SIMCALL_COMM_WAIT:
278     act = simcall_comm_wait__get__comm(req);
279     if (value == -1) {
280       type = xbt_strdup("WaitTimeout");
281       p = pointer_to_string(act);
282       args = bprintf("comm=%s", p);
283     } else {
284       type = xbt_strdup("Wait");
285       p = pointer_to_string(act);
286       // TODO, fix remote access to comm
287       smx_process_t src_proc = MC_smx_resolve_process(act->comm.src_proc);
288       smx_process_t dst_proc = MC_smx_resolve_process(act->comm.dst_proc);
289       args = bprintf("comm=%s [(%lu)%s (%s)-> (%lu)%s (%s)]", p,
290                      src_proc ? src_proc->pid : 0,
291                      src_proc ? MC_smx_process_get_host_name(src_proc) : "",
292                      src_proc ? MC_smx_process_get_name(src_proc) : "",
293                      dst_proc ? dst_proc->pid : 0,
294                      dst_proc ? MC_smx_process_get_host_name(dst_proc) : "",
295                      dst_proc ? MC_smx_process_get_name(dst_proc) : "");
296     }
297     break;
298   case SIMCALL_COMM_TEST:
299     act = simcall_comm_test__get__comm(req);
300     if (act->comm.src_proc == NULL || act->comm.dst_proc == NULL) {
301       type = xbt_strdup("Test FALSE");
302       p = pointer_to_string(act);
303       args = bprintf("comm=%s", p);
304     } else {
305       type = xbt_strdup("Test TRUE");
306       p = pointer_to_string(act);
307       // TODO, get process, get process name
308       smx_process_t src_proc = MC_smx_resolve_process(act->comm.src_proc);
309       smx_process_t dst_proc = MC_smx_resolve_process(act->comm.dst_proc);
310       args = bprintf("comm=%s [(%lu)%s (%s) -> (%lu)%s (%s)]", p,
311                      src_proc->pid,
312                      MC_smx_process_get_name(src_proc),
313                      MC_smx_process_get_host_name(src_proc),
314                      dst_proc->pid,
315                      MC_smx_process_get_name(dst_proc),
316                      MC_smx_process_get_host_name(dst_proc));
317     }
318     break;
319
320   case SIMCALL_COMM_WAITANY:
321     type = xbt_strdup("WaitAny");
322     if (!xbt_dynar_is_empty(simcall_comm_waitany__get__comms(req))) {
323       p = pointer_to_string(xbt_dynar_get_as
324                             (simcall_comm_waitany__get__comms(req), value,
325                              smx_synchro_t));
326       args =
327           bprintf("comm=%s (%d of %lu)", p, value + 1,
328                   xbt_dynar_length(simcall_comm_waitany__get__comms(req)));
329     } else {
330       args = bprintf("comm at idx %d", value);
331     }
332     break;
333
334   case SIMCALL_COMM_TESTANY:
335     if (value == -1) {
336       type = xbt_strdup("TestAny FALSE");
337       args = xbt_strdup("-");
338     } else {
339       type = xbt_strdup("TestAny");
340       args =
341           bprintf("(%d of %lu)", value + 1,
342                   xbt_dynar_length(simcall_comm_testany__get__comms(req)));
343     }
344     break;
345
346   case SIMCALL_MUTEX_LOCK:
347     mutex = simcall_mutex_lock__get__mutex(req);
348     type = xbt_strdup("Mutex LOCK");
349     args = bprintf("locked = %d, owner = %d, sleeping = %d", mutex->locked, mutex->owner != NULL ? (int)mutex->owner->pid : -1, xbt_swag_size(mutex->sleeping));
350     break;
351
352   case SIMCALL_MC_SNAPSHOT:
353     type = xbt_strdup("MC_SNAPSHOT");
354     args = NULL;
355     break;
356
357   case SIMCALL_MC_COMPARE_SNAPSHOTS:
358     type = xbt_strdup("MC_COMPARE_SNAPSHOTS");
359     args = NULL;
360     break;
361
362   case SIMCALL_MC_RANDOM:
363     type = xbt_strdup("MC_RANDOM");
364     args = bprintf("%d", value);
365     break;
366
367   default:
368     THROW_UNIMPLEMENTED;
369   }
370
371   if (args != NULL) {
372     // FIXME, get process name
373     str =
374         bprintf("[(%lu)%s (%s)] %s(%s)", issuer->pid,
375                 MC_smx_process_get_host_name(issuer),
376                 MC_smx_process_get_name(issuer),
377                 type, args);
378   } else {
379     // FIXME, get process name
380     str =
381         bprintf("[(%lu)%s (%s)] %s ", issuer->pid,
382                 MC_smx_process_get_host_name(issuer),
383                 MC_smx_process_get_name(issuer),
384                 type);
385   }
386
387   xbt_free(args);
388   xbt_free(type);
389   xbt_free(p);
390   xbt_free(bs);
391   return str;
392 }
393
394 unsigned int MC_request_testany_fail(smx_simcall_t req)
395 {
396   unsigned int cursor;
397   smx_synchro_t action;
398
399   xbt_dynar_foreach(simcall_comm_testany__get__comms(req), cursor, action) {
400     // FIXME, remote access to comm object
401     if (action->comm.src_proc && action->comm.dst_proc)
402       return FALSE;
403   }
404
405   return TRUE;
406 }
407
408 int MC_request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
409 {
410   smx_synchro_t act;
411
412   // FIXME, remote access to comm object
413
414   switch (req->call) {
415
416   case SIMCALL_COMM_WAIT:
417     /* FIXME: check also that src and dst processes are not suspended */
418     act = simcall_comm_wait__get__comm(req);
419     return (act->comm.src_proc && act->comm.dst_proc);
420     break;
421
422   case SIMCALL_COMM_WAITANY:
423     act =
424         xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), idx,
425                          smx_synchro_t);
426     return (act->comm.src_proc && act->comm.dst_proc);
427     break;
428
429   case SIMCALL_COMM_TESTANY:
430     act =
431         xbt_dynar_get_as(simcall_comm_testany__get__comms(req), idx,
432                          smx_synchro_t);
433     return (act->comm.src_proc && act->comm.dst_proc);
434     break;
435
436   default:
437     return TRUE;
438   }
439 }
440
441 int MC_process_is_enabled(smx_process_t process)
442 {
443   return MC_request_is_enabled(&process->simcall);
444 }
445
446 char *MC_request_get_dot_output(smx_simcall_t req, int value)
447 {
448   char *str = NULL, *label = NULL;
449   smx_synchro_t act = NULL;
450
451   const smx_process_t issuer = MC_smx_simcall_get_issuer(req);
452
453   switch (req->call) {
454   case SIMCALL_COMM_ISEND:
455     if (issuer->smx_host)
456       label =
457           bprintf("[(%lu)%s] iSend", issuer->pid,
458                   MC_smx_process_get_host_name(issuer));
459     else
460       label = bprintf("[(%lu)] iSend", issuer->pid);
461     break;
462
463   case SIMCALL_COMM_IRECV:
464     if (issuer->smx_host)
465       label =
466           bprintf("[(%lu)%s] iRecv", issuer->pid,
467                   MC_smx_process_get_host_name(issuer));
468     else
469       label = bprintf("[(%lu)] iRecv", issuer->pid);
470     break;
471
472   case SIMCALL_COMM_WAIT:
473     act = simcall_comm_wait__get__comm(req);
474     if (value == -1) {
475       if (issuer->smx_host)
476         label =
477             bprintf("[(%lu)%s] WaitTimeout", issuer->pid,
478                     MC_smx_process_get_host_name(issuer));
479       else
480         label = bprintf("[(%lu)] WaitTimeout", issuer->pid);
481     } else {
482       // FIXME, remote access to act->comm
483       smx_process_t src_proc = MC_smx_resolve_process(act->comm.src_proc);
484       smx_process_t dst_proc = MC_smx_resolve_process(act->comm.dst_proc);
485       if (issuer->smx_host)
486         label =
487             bprintf("[(%lu)%s] Wait [(%lu)->(%lu)]", issuer->pid,
488                     MC_smx_process_get_host_name(issuer),
489                     src_proc ? src_proc->pid : 0,
490                     dst_proc ? dst_proc->pid : 0);
491       else
492         label =
493             bprintf("[(%lu)] Wait [(%lu)->(%lu)]", issuer->pid,
494                     src_proc ? src_proc->pid : 0,
495                     dst_proc ? dst_proc->pid : 0);
496     }
497     break;
498
499   case SIMCALL_COMM_TEST:
500     act = simcall_comm_test__get__comm(req);
501     if (act->comm.src_proc == NULL || act->comm.dst_proc == NULL) {
502       if (issuer->smx_host)
503         label =
504             bprintf("[(%lu)%s] Test FALSE", issuer->pid,
505                     MC_smx_process_get_host_name(issuer));
506       else
507         label = bprintf("[(%lu)] Test FALSE", issuer->pid);
508     } else {
509       if (issuer->smx_host)
510         label =
511             bprintf("[(%lu)%s] Test TRUE", issuer->pid,
512                     MC_smx_process_get_host_name(issuer));
513       else
514         label = bprintf("[(%lu)] Test TRUE", issuer->pid);
515     }
516     break;
517
518   case SIMCALL_COMM_WAITANY:
519     if (issuer->smx_host)
520       label =
521           bprintf("[(%lu)%s] WaitAny [%d of %lu]", issuer->pid,
522                   MC_smx_process_get_host_name(issuer), value + 1,
523                   xbt_dynar_length(simcall_comm_waitany__get__comms(req)));
524     else
525       label =
526           bprintf("[(%lu)] WaitAny [%d of %lu]", issuer->pid, value + 1,
527                   xbt_dynar_length(simcall_comm_waitany__get__comms(req)));
528     break;
529
530   case SIMCALL_COMM_TESTANY:
531     if (value == -1) {
532       if (issuer->smx_host)
533         label =
534             bprintf("[(%lu)%s] TestAny FALSE", issuer->pid,
535                     MC_smx_process_get_host_name(issuer));
536       else
537         label = bprintf("[(%lu)] TestAny FALSE", issuer->pid);
538     } else {
539       if (issuer->smx_host)
540         label =
541             bprintf("[(%lu)%s] TestAny TRUE [%d of %lu]", issuer->pid,
542                     MC_smx_process_get_host_name(issuer), value + 1,
543                     xbt_dynar_length(simcall_comm_testany__get__comms(req)));
544       else
545         label =
546             bprintf("[(%lu)] TestAny TRUE [%d of %lu]", issuer->pid,
547                     value + 1,
548                     xbt_dynar_length(simcall_comm_testany__get__comms(req)));
549     }
550     break;
551
552   case SIMCALL_MUTEX_LOCK:
553     label = bprintf("[(%lu)] Mutex LOCK", req->issuer->pid);
554     break;
555
556   case SIMCALL_MC_RANDOM:
557     if (issuer->smx_host)
558       label =
559           bprintf("[(%lu)%s] MC_RANDOM (%d)", issuer->pid,
560                   MC_smx_process_get_host_name(issuer), value);
561     else
562       label = bprintf("[(%lu)] MC_RANDOM (%d)", issuer->pid, value);
563     break;
564
565   case SIMCALL_MC_SNAPSHOT:
566     if (issuer->smx_host)
567       label =
568           bprintf("[(%lu)%s] MC_SNAPSHOT", issuer->pid,
569                   MC_smx_process_get_host_name(issuer));
570     else
571       label = bprintf("[(%lu)] MC_SNAPSHOT", issuer->pid);
572     break;
573
574   case SIMCALL_MC_COMPARE_SNAPSHOTS:
575     if (issuer->smx_host)
576       label =
577           bprintf("[(%lu)%s] MC_COMPARE_SNAPSHOTS", issuer->pid,
578                   MC_smx_process_get_host_name(issuer));
579     else
580       label = bprintf("[(%lu)] MC_COMPARE_SNAPSHOTS", issuer->pid);
581     break;
582
583   default:
584     THROW_UNIMPLEMENTED;
585   }
586
587   str =
588       bprintf("label = \"%s\", color = %s, fontcolor = %s", label,
589               colors[issuer->pid - 1], colors[issuer->pid - 1]);
590   xbt_free(label);
591   return str;
592
593 }