1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2009 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH (FRescor ScHeduler)
36 // FRSH is free software; you can redistribute it and/or modify it
37 // under terms of the GNU General Public License as published by the
38 // Free Software Foundation; either version 2, or (at your option) any
39 // later version. FRSH is distributed in the hope that it will be
40 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
41 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 // General Public License for more details. You should have received a
43 // copy of the GNU General Public License along with FRSH; see file
44 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
45 // Cambridge, MA 02139, USA.
47 // As a special exception, including FRSH header files in a file,
48 // instantiating FRSH generics or templates, or linking other files
49 // with FRSH objects to produce an executable application, does not
50 // by itself cause the resulting executable application to be covered
51 // by the GNU General Public License. This exception does not
52 // however invalidate any other reasons why the executable file might be
53 // covered by the GNU Public License.
54 // -----------------------------------------------------------------------
55 //==============================================
56 // ******** ******* ******** ** **
57 // **///// /**////** **////// /** /**
58 // ** /** /** /** /** /**
59 // ******* /******* /********* /**********
60 // **//// /**///** ////////** /**//////**
61 // ** /** //** /** /** /**
62 // ** /** //** ******** /** /**
63 // // // // //////// // //
65 // FRSH(FRescor ScHeduler), pronounced "fresh"
66 //==============================================
68 // 23-Jul-2007 SANGORRIN: create this file for debugging functions
69 // 31-Jul-2007 TELLERIA: Change "debug" for "trace"
70 // -----------------------------------------------------------------------
74 #include <stdio.h> // for vprintf
75 #include <stdbool.h> // for bool
76 #include <stdarg.h> // for va_list, va_start and va_end
78 #include "frsh_debug_and_trace_types.h"
79 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
80 #include "fosa_clocks_and_timers.h"
84 // Tune the following FLAGS to select the debugging messages to be generated
85 #define FRSH_TRACE_CALLBACKS false
86 #define FRSH_TRACE_SERVICE_TH false
87 #define FRSH_TRACE_WATCHDOG false
88 #define FRSH_TRACE_SPORADIC_SERVER false
89 #define FRSH_TRACE_REPLENISHMENTS false
90 #define FRSH_TRACE_ROUND_ROBIN false
91 #define FRSH_TRACE_BOUNDED_JOB false
92 #define FRSH_TRACE_SYNCHRONIZE_WORKLOAD false
93 #define FRSH_TRACE_ADMISSION_TEST false
94 #define FRSH_TRACE_ADMISSION_RESULT false
96 #define FRSH_TRACE_THREAD_INDEX false
97 #define FRSH_TRACE_VRES_INDEX false
99 #define FRSH_TRACE_DISTRIBUTED false
101 #define QUICK_AND_DIRTY_FIX_JLDEMO true
105 * frsh_trace_point_insert()
107 * Insert an application-defined trace-point identifier together with
108 * a timestamp into the trace log, if tracing is enabled; the
109 * identifier is an integer that must be between two configurable
110 * values defined in the FRSH API as constants; if tracing is not
111 * enabled, this function has no effect.
113 int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
115 /** If FRSH_TRACE_TS_MSECS is defined, each trace line is prefixed
116 with a msec counter **/
117 #define FRSH_TRACE_TS_MSECS
119 /* These variables live defined in frsh_error.c */
120 /************************************************/
121 extern fosa_abs_time_t frsh_trace_init_timespec;
122 extern long frsh_trace_init_timemsec;
124 extern int global_error_condition; /* Used to propagate error
125 * conditions in debugging */
127 static inline long int FRSH_GET_TIMESTAMP_MSECS()
130 fosa_abs_time_t current_time;
131 long int current_time_msec = -1;
132 long int result = -1;
134 PRW( fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t_time) );
135 current_time_msec = fosa_abs_time_to_msec(current_time);
137 result = current_time_msec - frsh_trace_init_timemsec;
142 static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
144 long int time_msecs = -1;
146 time_msecs = fosa_abs_time_to_msec(*timestamp);
148 return time_msecs - frsh_trace_init_timemsec;
154 * If the boolean value is true, print the format line optionally
155 * preceded by a timestamp in ms relative to the start of the
158 * Due to the "..." argument passing, this function cannot be
161 void FRSH_TRACE(bool is_active, const char *format, ...);