3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
9 * \ingroup MSG_examples
10 * \brief Convenient debuging functions that should be used in combination with
11 * the perl-script tools/MSG_visualization/colorize.pl.
19 #include "msg/datatypes.h"
20 #include "xbt/error.h"
22 /** just like an assert.
23 * This function is used to ensure that a condition is true.
24 * If not, it prints an error message (with the virtual date and the
25 * PID of the #m_process_t that called it).
27 static void ASSERT(int value, const char *fmt, ...)
29 m_process_t self = MSG_process_self();
35 fprintf(stderr, "[%g] P%d | ", MSG_getClock(),
36 MSG_process_get_PID(self));
37 vfprintf(stderr, fmt, ap);
46 * Just like #ASSERT() except you already know that the condition does not hold
49 static void DIE(const char *fmt, ...)
51 m_process_t self = MSG_process_self();
56 fprintf(stderr, "[%g] P%d | ", MSG_getClock(),
57 MSG_process_get_PID(self));
58 vfprintf(stderr, fmt, ap);
66 * Print a one-line message with the virtual date and the PID of the #m_process_t
69 static void PRINT_MESSAGE(const char *fmt, ...)
72 m_process_t self = MSG_process_self();
77 fprintf(stderr, "[%g] P%d | (%s:%s) ", MSG_getClock(),
78 MSG_process_get_PID(self), MSG_host_self()->name, self->name);
79 vfprintf(stderr, fmt, ap);
86 * Just like #PRINT_MESSAGE() except that it prints DEBUG in front of the line.
88 static void PRINT_DEBUG_MESSAGE(const char *fmt, ...)
91 m_process_t self = MSG_process_self();
96 fprintf(stderr, "DEBUG [%g] P%d | (%s) ", MSG_getClock(),
97 MSG_process_get_PID(self), MSG_host_self()->name);
98 vfprintf(stderr, fmt, ap);