]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_debug_and_trace.h
Update transaction API
[frescor/frsh-include.git] / frsh_debug_and_trace.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2009 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 #define FRSH_TRACE_SYNCHRONIZE_WORKLOAD false
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 #define QUICK_AND_DIRTY_FIX_JLDEMO true
102
103
104 /**
105  * frsh_trace_point_insert()
106  *
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.
112  */
113 int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
114
115 /** If FRSH_TRACE_TS_MSECS is defined, each trace line is prefixed
116     with a msec counter **/
117 #define FRSH_TRACE_TS_MSECS
118
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;
123
124 extern int global_error_condition;  /* Used to propagate error
125                                      * conditions in debugging */
126
127 static inline long int FRSH_GET_TIMESTAMP_MSECS()
128 {
129     int terror = -1;
130     fosa_abs_time_t current_time;
131     long int current_time_msec = -1;
132     long int result = -1;
133
134     PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
135     current_time_msec = fosa_abs_time_to_msec(current_time);
136
137     result = current_time_msec - frsh_trace_init_timemsec;
138
139     return result;
140 }
141
142 static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
143 {
144     long int time_msecs = -1;
145
146     time_msecs = fosa_abs_time_to_msec(*timestamp);
147
148     return time_msecs - frsh_trace_init_timemsec;
149 }
150
151 /**
152  * FRSH_TRACE()
153  *
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
156  * program.
157  *
158  * Due to the "..." argument passing, this function cannot be
159  * inlined.
160  **/
161 void FRSH_TRACE(bool is_active, const char *format, ...);
162
163 FRSH_CPP_END_DECLS
164
165 #endif