]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_debug_and_trace.h
frsh_configuration_parameters.h is now generated OMK
[frescor/frsh-include.git] / frsh_debug_and_trace.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
3 //
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
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //
16 //    See http://www.frescor.org for a link to partners' websites
17 //
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
21 //        made of this code.
22 //
23 //
24 //  based on previous work (FSF) done in the FIRST project
25 //
26 //   Copyright (C) 2005  Mälardalen University, SWEDEN
27 //                       Scuola Superiore S.Anna, ITALY
28 //                       Universidad de Cantabria, SPAIN
29 //                       University of York, UK
30 //
31 //   FSF API web pages: http://marte.unican.es/fsf/docs
32 //                      http://shark.sssup.it/contrib/first/docs/
33 //
34 //   This file is part of FRSH (FRescor ScHeduler)
35 //
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.
46 //
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 //  //       //     // ////////   //      //
64 //
65 // FRSH(FRescor ScHeduler), pronounced "fresh"
66 //==============================================
67 //
68 // 23-Jul-2007 SANGORRIN: create this file for debugging functions
69 // 31-Jul-2007 TELLERIA:  Change "debug" for "trace"
70 // -----------------------------------------------------------------------
71 #ifndef FRSH_DEBUG_H
72 #define FRSH_DEBUG_H
73
74 #include <stdio.h> // for vprintf
75 #include <stdbool.h> // for bool
76 #include <stdarg.h> // for va_list, va_start and va_end
77 #include "fosa.h"
78 #include "frsh_debug_and_trace_types.h"
79 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
80 #include "fosa_clocks_and_timers.h"
81
82 FRSH_CPP_BEGIN_DECLS
83
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
93 #define FRSH_TRACE_ADMISSION_TEST false
94 #define FRSH_TRACE_ADMISSION_RESULT false
95
96 #define FRSH_TRACE_THREAD_INDEX false
97 #define FRSH_TRACE_VRES_INDEX false
98
99 #define FRSH_TRACE_DISTRIBUTED false
100
101 /**
102  * frsh_trace_point_insert()
103  *
104  * Insert an application-defined trace-point identifier together with
105  * a timestamp into the trace log, if tracing is enabled; the
106  * identifier is an integer that must be between two configurable
107  * values defined in the FRSH API as constants; if tracing is not
108  * enabled, this function has no effect.
109  */
110 int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
111
112 /** If FRSH_TRACE_TS_MSECS is defined, each trace line is prefixed
113     with a msec counter **/
114 #define FRSH_TRACE_TS_MSECS
115
116 /* These variables live defined in frsh_error.c */
117 /************************************************/
118 extern fosa_abs_time_t frsh_trace_init_timespec;
119 extern long frsh_trace_init_timemsec;
120
121 extern int global_error_condition;  /* Used to propagate error
122                                      * conditions in debugging */
123
124 static inline long int FRSH_GET_TIMESTAMP_MSECS()
125 {
126     int terror = -1;
127     fosa_abs_time_t current_time;
128     long int current_time_msec = -1;
129     long int result = -1;
130
131     PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
132     current_time_msec = fosa_abs_time_to_msec(current_time);
133
134     result = current_time_msec - frsh_trace_init_timemsec;
135
136     return result;
137 }
138
139 static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
140 {
141     long int time_msecs = -1;
142
143     time_msecs = fosa_abs_time_to_msec(*timestamp);
144
145     return time_msecs - frsh_trace_init_timemsec;
146 }
147
148 /**
149  * FRSH_TRACE()
150  *
151  * If the boolean value is true, print the format line optionally
152  * preceded by a timestamp in ms relative to the start of the
153  * program.
154  *
155  * Due to the "..." argument passing, this function cannot be
156  * inlined.
157  **/
158 void FRSH_TRACE(bool is_active, const char *format, ...);
159
160 FRSH_CPP_END_DECLS
161
162 #endif