1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2008 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 // As a special exception, if you include this header file into source
55 // files to be compiled, this header file does not by itself cause
56 // the resulting executable to be covered by the GNU General Public
57 // License. This exception does not however invalidate any other
58 // reasons why the executable file might be covered by the GNU General
60 // -----------------------------------------------------------------------
61 //==============================================
62 // ******** ******* ******** ** **
63 // **///// /**////** **////// /** /**
64 // ** /** /** /** /** /**
65 // ******* /******* /********* /**********
66 // **//// /**///** ////////** /**//////**
67 // ** /** //** /** /** /**
68 // ** /** //** ******** /** /**
69 // // // // //////// // //
71 // FRSH(FRescor ScHeduler), pronounced "fresh"
72 //==============================================
74 // 23-Jul-2007 SANGORRIN: create this file for debugging functions
75 // 31-Jul-2007 TELLERIA: Change "debug" for "trace"
76 // -----------------------------------------------------------------------
80 #include <stdio.h> // for vprintf
81 #include <stdbool.h> // for bool
82 #include <stdarg.h> // for va_list, va_start and va_end
84 #include "frsh_debug_and_trace_types.h"
85 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
86 #include "fosa_clocks_and_timers.h"
90 // Tune the following FLAGS to select the debugging messages to be generated
91 #define FRSH_TRACE_CALLBACKS false
92 #define FRSH_TRACE_SERVICE_TH false
93 #define FRSH_TRACE_WATCHDOG false
94 #define FRSH_TRACE_SPORADIC_SERVER false
95 #define FRSH_TRACE_ROUND_ROBIN false
96 #define FRSH_TRACE_BOUNDED_JOB false
98 #define FRSH_TRACE_ADMISSION_TEST false
99 #define FRSH_TRACE_ADMISSION_RESULT false
101 #define FRSH_TRACE_THREAD_INDEX false
102 #define FRSH_TRACE_VRES_INDEX false
104 #define FRSH_TRACE_DISTRIBUTED false
107 * frsh_trace_point_insert()
109 * Insert an application-defined trace-point identifier together with
110 * a timestamp into the trace log, if tracing is enabled; the
111 * identifier is an integer that must be between two configurable
112 * values defined in the FRSH API as constants; if tracing is not
113 * enabled, this function has no effect.
115 int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
117 /** If FRSH_TRACE_TS_MSECS is defined, each trace line is prefixed
118 with a msec counter **/
119 #define FRSH_TRACE_TS_MSECS
121 /* These variables live defined in frsh_error.c */
122 /************************************************/
123 extern fosa_abs_time_t frsh_trace_init_timespec;
124 extern long frsh_trace_init_timemsec;
126 extern int global_error_condition; /* Used to propagate error
127 * conditions in debugging */
129 static inline long int FRSH_GET_TIMESTAMP_MSECS()
132 fosa_abs_time_t current_time;
133 long int current_time_msec = -1;
134 long int result = -1;
136 PRW( fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t_time) );
137 current_time_msec = fosa_abs_time_to_msec(current_time);
139 result = current_time_msec - frsh_trace_init_timemsec;
144 static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
146 long int time_msecs = -1;
148 time_msecs = fosa_abs_time_to_msec(*timestamp);
150 return time_msecs - frsh_trace_init_timemsec;
156 * If the boolean value is true, print the format line optionally
157 * preceded by a timestamp in ms relative to the start of the
160 * Due to the "..." argument passing, this function cannot be
163 void FRSH_TRACE(bool is_active, const char *format, ...);