//==============================================
//
// 23-Jul-2007 SANGORRIN: create this file for debugging functions
+// 31-Jul-2007 TELLERIA: Change "debug" for "trace"
// -----------------------------------------------------------------------
+#ifndef FRSH_DEBUG_H
+#define FRSH_DEBUG_H
+
#include <stdio.h> // for vprintf
#include <stdbool.h> // for bool
#include <stdarg.h> // for va_list, va_start and va_end
+#include "timespec_operations.h"
+#include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
+#include "fosa_clocks_and_timers.h"
// Tune the following FLAGS to select the debugging messages to be generated
-#define FRSH_DEBUG_CALLBACKS true
-#define FRSH_DEBUG_WATCHDOG true
-#define FRSH_DEBUG_TIMEDWAIT true
-#define FRSH_DEBUG_SERVICE_TH true
+#define FRSH_TRACE_CALLBACKS false
+#define FRSH_TRACE_SERVICE_TH false
+#define FRSH_TRACE_WATCHDOG false
+#define FRSH_TRACE_SPORADIC_SERVER false
+#define FRSH_TRACE_ROUND_ROBIN false
+#define FRSH_TRACE_BOUNDED_JOB false
+
+#define FRSH_TRACE_ADMISSION_TEST false
+#define FRSH_TRACE_ADMISSION_RESULT false
+
+#define FRSH_TRACE_THREAD_INDEX false
+#define FRSH_TRACE_VRES_INDEX false
+
+#define FRSH_TRACE_DISTRIBUTED false
+
+#define FRSH_TRACE_TS_MSECS
+
+/* These variables live defined in frsh_error.c */
+/************************************************/
+extern struct timespec frsh_trace_init_timespec;
+extern long frsh_trace_init_timemsec;
+
+extern int global_error_condition; /* Used to propagate error
+ * conditions in debugging */
+
+static inline long int FRSH_GET_TIMESTAMP_MSECS()
+{
+ int terror = -1;
+ struct timespec current_time = {-1, -1};
+ long int current_time_msec = -1;
+ long int result = -1;
+
+ PRW( fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t_time) );
+ current_time_msec = timespec2msec(¤t_time);
+
+ result = current_time_msec - frsh_trace_init_timemsec;
-static void inline DEBUG(bool is_active, const char *format, ...)
+ return result;
+}
+
+static inline long int FRSH_TIMESPEC_TO_RELATIVE_MSECS(const struct timespec *tspec)
+{
+ long int time_msecs = -1;
+
+ time_msecs = timespec2msec(tspec);
+
+ return time_msecs - frsh_trace_init_timemsec;
+}
+
+static void inline FRSH_TRACE(bool is_active, const char *format, ...)
{
va_list args;
+#ifdef FRSH_TRACE_TS_MSECS
+ const int TS_LENGTH_MSECS = 10; /* Room for LONG_MAX 2147483648 */
+#endif
+
if (is_active) {
+
va_start(args, format);
+
+#ifdef FRSH_TRACE_TS_MSECS
+ printf("%*ld: ", TS_LENGTH_MSECS, FRSH_GET_TIMESTAMP_MSECS());
+#endif
vprintf(format, args);
va_end(args);
}
}
+
+#endif