]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_debug_and_trace.h
Updating license header in FRSH directory
[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 //  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
59 //  Public License.
60 // -----------------------------------------------------------------------
61 //==============================================
62 //  ******** *******    ********  **      **
63 //  **///// /**////**  **//////  /**     /**
64 //  **      /**   /** /**        /**     /**
65 //  ******* /*******  /********* /**********
66 //  **////  /**///**  ////////** /**//////**
67 //  **      /**  //**        /** /**     /**
68 //  **      /**   //** ********  /**     /**
69 //  //       //     // ////////   //      //
70 //
71 // FRSH(FRescor ScHeduler), pronounced "fresh"
72 //==============================================
73 //
74 // 23-Jul-2007 SANGORRIN: create this file for debugging functions
75 // 31-Jul-2007 TELLERIA:  Change "debug" for "trace"
76 // -----------------------------------------------------------------------
77 #ifndef FRSH_DEBUG_H
78 #define FRSH_DEBUG_H
79
80 #include <stdio.h> // for vprintf
81 #include <stdbool.h> // for bool
82 #include <stdarg.h> // for va_list, va_start and va_end
83 #include "fosa.h"
84 #include "frsh_debug_and_trace_types.h"
85 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
86 #include "fosa_clocks_and_timers.h"
87
88 FRSH_CPP_BEGIN_DECLS
89
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
97
98 #define FRSH_TRACE_ADMISSION_TEST false
99 #define FRSH_TRACE_ADMISSION_RESULT false
100
101 #define FRSH_TRACE_THREAD_INDEX false
102 #define FRSH_TRACE_VRES_INDEX false
103
104 #define FRSH_TRACE_DISTRIBUTED false
105
106 /**
107  * frsh_trace_point_insert()
108  *
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.
114  */
115 int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
116
117 /** If FRSH_TRACE_TS_MSECS is defined, each trace line is prefixed
118     with a msec counter **/
119 #define FRSH_TRACE_TS_MSECS
120
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;
125
126 extern int global_error_condition;  /* Used to propagate error
127                                      * conditions in debugging */
128
129 static inline long int FRSH_GET_TIMESTAMP_MSECS()
130 {
131     int terror = -1;
132     fosa_abs_time_t current_time;
133     long int current_time_msec = -1;
134     long int result = -1;
135
136     PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
137     current_time_msec = fosa_abs_time_to_msec(current_time);
138
139     result = current_time_msec - frsh_trace_init_timemsec;
140
141     return result;
142 }
143
144 static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
145 {
146     long int time_msecs = -1;
147
148     time_msecs = fosa_abs_time_to_msec(*timestamp);
149
150     return time_msecs - frsh_trace_init_timemsec;
151 }
152
153 /**
154  * FRSH_TRACE()
155  *
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
158  * program.
159  *
160  * Due to the "..." argument passing, this function cannot be
161  * inlined.
162  **/
163 void FRSH_TRACE(bool is_active, const char *format, ...);
164
165 FRSH_CPP_END_DECLS
166
167 #endif