OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qtrace.h
1
8#ifndef QTRACE_H
9 #define QTRACE_H
10
11 #include "qtypes.h"
12 #include "qclock.h"
13 #include "qioutils.h"
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19
20 #ifndef Q_TRACE_VARIABLES
21 #define Q_TRACE_VARIABLES ( 1 )
22 #endif
23
24 #ifndef Q_DEBUGTRACE_BUFSIZE
25 #define Q_DEBUGTRACE_BUFSIZE ( 36 )
26 #endif
27
28 #ifndef Q_DEBUGTRACE_FULL
29 #define Q_DEBUGTRACE_FULL ( 1 )
30 #endif
31
32 #if ( Q_DEBUGTRACE_BUFSIZE < 36 )
33 #error Q_DEBUGTRACE_BUFSIZE its is too small. Use a value greater o equal to 36.
34 #endif
35
36 #define _qSTRINGIFY(x) #x // skipcq: CXX-E2000
37 #define _qTOSTRING(x) _qSTRINGIFY( x ) // skipcq: CXX-E2000
38
39 #ifndef _QTRACE_FUNC
40 #if defined __cplusplus && defined __GNUC__ /* Use g++'s demangled names in C++. */
41 #if __GNUC__ >= 2
42 #define _QFCN __PRETTY_FUNCTION__
43 #else
44 #define _QFCN __func__
45 #endif
46 #elif defined( __GNUC__ ) || ( defined( __MWERKS__ ) && ( __MWERKS__ >= 0x3000 ) ) || ( defined( __ICC ) && ( __ICC >= 600 ) ) || defined( __ghs__ )
47 #define _QFCN __PRETTY_FUNCTION__ // skipcq: CXX-E2000
48 #elif defined( __DMC__ ) && ( __DMC__ >= 0x810 )
49 #define _QFCN __PRETTY_FUNCTION__
50 #elif defined( __FUNCSIG__ )
51 #define _QFCN __FUNCSIG__
52 #elif ( defined( __INTEL_COMPILER ) && ( __INTEL_COMPILER >= 600 ) ) || ( defined( __IBMCPP__ ) && ( __IBMCPP__ >= 500 ) )
53 #define _QFCN __FUNCTION__
54 #elif defined( __BORLANDC__ ) && ( __BORLANDC__ >= 0x550 )
55 #define _QFCN __FUNC__
56 #elif defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901 )
57 #define _QFCN __func__
58 #elif defined( __cplusplus ) && ( __cplusplus >= 201103 )
59 #define _QFCN __func__
60 #else /* failed to detect __func__ support. */
61 #define _QFCN ( (char *)0 )
62 #endif
63 #endif
64
65 #define _qAT() ":" _qTOSTRING(__LINE__) " " // skipcq: CXX-E2000
66
73 #ifndef Message
74 #define Message Message
75 #endif
76 #ifndef String
77 #define String String
78 #endif
79 #ifndef Bool
80 #define Bool Bool
81 #endif
82 #ifndef qBool
83 #define qBool qBool
84 #endif
85 #ifndef Float
86 #define Float Float
87 #endif
88 #ifndef Binary
89 #define Binary Binary
90 #endif
91 #ifndef Octal
92 #define Octal Octal
93 #endif
94 #ifndef Decimal
95 #define Decimal Decimal
96 #endif
97 #ifndef Hexadecimal
98 #define Hexadecimal Hexadecimal
99 #endif
100 #ifndef UnsignedBinary
101 #define UnsignedBinary UnsignedBinary
102 #endif
103 #ifndef UnsignedOctal
104 #define UnsignedOctal UnsignedOctal
105 #endif
106 #ifndef UnsignedDecimal
107 #define UnsignedDecimal UnsignedDecimal
108 #endif
109 #ifndef UnsignedHexadecimal
110 #define UnsignedHexadecimal UnsignedHexadecimal
111 #endif
115 #if ( Q_TRACE_VARIABLES == 1 )
117 #if ( Q_TRACE_KERNEL_AND_MODULES == 1 )
118 void _qTrace_krn( const char *msg,
119 const void *id,
120 const void *obj );
121 #define _qTrace_Kernel( msg, id, obj ) \
122 _qTrace_krn( (char*)(msg), (id), (obj) ); \
123
124 #else
125 #define _qTrace_Kernel( msg, id, obj ) // skipcq: CXX-E2000
126 #endif
127
128 extern char qTrace_PublicBuffer[ Q_DEBUGTRACE_BUFSIZE ]; // skipcq: CXX-W2009
129 void _qTrace_dgb( const char *loc, // skipcq: CXX-E2000
130 const char* fcn,
131 const char *vName,
132 const char* vValue,
133 void* ptr,
134 const size_t blockSize );
142 void qTrace_Set_OutputFcn( qPutChar_t fcn );
143
144 /*On-demand debug/trace macros*/
151 #define qTrace() \
152 _qTrace_dgb( _qAT(), _QFCN, "", "", NULL, 0 ) \
153
160 #define qDebug_Caller() \
161 _qTrace_dgb( "", _QFCN, "", "", NULL, 0 ) \
162
163
165 #define qDebug_Message( v ) \
166 _qTrace_dgb( "", NULL, "", (char*)(v), NULL, 0 ) \
167
168
169 #define qDebug_String( v ) \
170 _qTrace_dgb( "", NULL, #v "=" , (char*)(v), NULL, 0 ) \
171
172
173 #define qDebug_Bool( v ) \
174 qIOUtil_BtoA( (qBool_t)(v), qTrace_PublicBuffer ); \
175 _qTrace_dgb( "", NULL, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
176
177
178 #define qDebug_qBool( v ) \
179 qIOUtil_QBtoA( (qBool_t)(v), qTrace_PublicBuffer ); \
180 _qTrace_dgb( "", NULL, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
181
182 #define qDebug_Binary( v ) \
183 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 2 ); \
184 _qTrace_dgb( "", NULL, #v "=0b", qTrace_PublicBuffer, NULL, 0 ) \
185
186
187 #define qDebug_Octal( v ) \
188 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 8 ); \
189 _qTrace_dgb( "", NULL, #v "=0", qTrace_PublicBuffer, NULL, 0 ) \
190
191
192 #define qDebug_Hexadecimal( v ) \
193 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 16 ); \
194 _qTrace_dgb( "", NULL, #v "=0x", qTrace_PublicBuffer, NULL, 0 ) \
195
196
197 #define qDebug_Decimal( v ) \
198 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 10 ); \
199 _qTrace_dgb( "", NULL, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
200
201
202 #define qDebug_Float( v ) \
203 qIOUtil_FtoA( (qFloat32_t)(v), qTrace_PublicBuffer, 10 ); \
204 _qTrace_dgb( "", NULL, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
205
206
207 #define qDebug_FloatPrec( v , prec ) \
208 qIOUtil_FtoA( (qFloat32_t)(v), qTrace_PublicBuffer, (prec) ); \
209 _qTrace_dgb( "", NULL, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
210
211
212 #define qDebug_UnsignedBinary( v ) \
213 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 2 ); \
214 _qTrace_dgb( "", NULL, #v "=0b", qTrace_PublicBuffer, NULL, 0 ) \
215
216
217 #define qDebug_UnsignedOctal( v ) \
218 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 8 ); \
219 _qTrace_dgb( "", NULL, #v "=0", qTrace_PublicBuffer, NULL, 0 ) \
220
221
222 #define qDebug_UnsignedHexadecimal( v ) \
223 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 16 ); \
224 _qTrace_dgb( "", NULL, #v "=0x", qTrace_PublicBuffer, NULL, 0 ) \
225
226
227 #define qDebug_UnsignedDecimal( v ) \
228 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 10 ); \
229 _qTrace_dgb( "", NULL, #v "=", , NULL, 0 ) \
230
231
232 #define qTrace_Message( v ) \
233 _qTrace_dgb( _qAT(), _QFCN, "", (char*)(v), NULL, 0 ) \
234
235
236 #define qTrace_String( v ) \
237 _qTrace_dgb( _qAT(), _QFCN, #v "=" , (char*)(v), NULL, 0 ) \
238
239
240 #define qTrace_Bool( v ) \
241 qIOUtil_BtoA( (qBool_t)(v), qTrace_PublicBuffer ); \
242 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
243
244
245 #define qTrace_qBool( v ) \
246 qIOUtil_QBtoA( (qBool_t)(v), qTrace_PublicBuffer ); \
247 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
248
249
250 #define qTrace_Binary( v ) \
251 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 2 ); \
252 _qTrace_dgb( _qAT(), _QFCN, #v "=0b", qTrace_PublicBuffer, NULL, 0 )\
253
254
255 #define qTrace_Octal( v ) \
256 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 8 ); \
257 _qTrace_dgb( _qAT(), _QFCN, #v "=0", qTrace_PublicBuffer, NULL, 0 ) \
258
259
260 #define qTrace_Hexadecimal( v ) \
261 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 16 ); \
262 _qTrace_dgb( _qAT(), _QFCN, #v "=0x", qTrace_PublicBuffer, NULL, 0 )\
263
264
265 #define qTrace_Decimal( v ) \
266 qIOUtil_ItoA( (qINT32_t)(v), qTrace_PublicBuffer, 10 ); \
267 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
268
269
270 #define qTrace_Float( v ) \
271 qIOUtil_FtoA( (qFloat32_t)(v), qTrace_PublicBuffer, 10 ); \
272 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
273
274
275 #define qTrace_FloatPrec( v , prec ) \
276 qIOUtil_FtoA( (qFloat32_t)(v), qTrace_PublicBuffer, (prec) ); \
277 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
278
279
280 #define qTrace_UnsignedBinary( v ) \
281 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 2 ); \
282 _qTrace_dgb( _qAT(), _QFCN, #v "=0b", qTrace_PublicBuffer, NULL, 0 )\
283
284
285 #define qTrace_UnsignedOctal( v ) \
286 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 8 ); \
287 _qTrace_dgb( _qAT(), _QFCN, #v "=0", qTrace_PublicBuffer, NULL, 0 ) \
288
289
290 #define qTrace_UnsignedHexadecimal( v ) \
291 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 16 ); \
292 _qTrace_dgb( _qAT(), _QFCN, #v "=0x", qTrace_PublicBuffer, NULL, 0 )\
293
294
295 #define qTrace_UnsignedDecimal( v ) \
296 qIOUtil_UtoA( (qUINT32_t)(v), qTrace_PublicBuffer, 10 ); \
297 _qTrace_dgb( _qAT(), _QFCN, #v "=", qTrace_PublicBuffer, NULL, 0 ) \
298
299
311 #define qTrace_Mem( pMem, bSize ) qTrace_Memory( (pMem), (bSize) )
312
319 #define qTrace_Memory(pMem, bSize ) \
320 _qTrace_dgb( _qAT(), \
321 _QFCN, \
322 #pMem "=", \
323 NULL, \
324 (pMem), \
325 (bSize) ) \
326
336 #define qDebug_Mem( pMem, bSize ) qDebug_Memory( (pMem), (bSize) )
337
346 #define qDebug_Memory( pMem, bSize ) \
347 _qTrace_dgb( "", NULL, #pMem "=", NULL, (pMem), (bSize) ) \
348
372 #define qTrace_Var( v, mode ) qTrace_##mode( v )
373
382 #define qTrace_Variable( v, mode ) qTrace_##mode( v )
383
406 #define qDebug_Var( v, mode ) qDebug_##mode( v )
407
416 #define qDebug_Variable( v, mode ) qDebug_##mode( v )
417 #else
418 #define qTrace_Set_OutputFcn( fcn )
419 #define _qTrace_Kernel( msg, id, obj )
420 #define qTrace()
421 #define qTrace_Message( v )
422 #define qTrace_String( v )
423 #define qTrace_Var( v, mode )
424 #define qTrace_Variable( v, mode )
425 #define qTrace_Bool( v )
426 #define qTrace_qBool( v )
427 #define qTrace_Binary( v )
428 #define qTrace_Octal( v )
429 #define qTrace_Hexadecimal( v )
430 #define qTrace_Decimal( v )
431 #define qTrace_Float( v )
432 #define qDebug_FloatPrec( v, prec )
433 #define qTrace_UnsignedBinary( v )
434 #define qTrace_UnsignedOctal( v )
435 #define qTrace_UnsignedHexadecimal( v )
436 #define qTrace_UnsignedDecimal( v )
437 #define qTrace_UnsignedDecimal( v )
438 #define qTrace_Memory( pMem, bSize )
439 #define qTrace_Mem( pMem, bSize )
440 #define qTrace_Variable( v , mode )
441 #define qTrace_Var( v , mode )
442
443 #define qDebug_Caller()
444 #define qDebug_Message( v )
445 #define qDebug_String( v )
446 #define qDebug_Bool( v )
447 #define qDebug_qBool( v )
448 #define qDebug_Binary( v )
449 #define qDebug_Octal( v )
450 #define qDebug_Hexadecimal( v )
451 #define qDebug_Decimal( v )
452 #define qDebug_Float( v )
453 #define qDebug_FloatPrec( v , prec )
454 #define qDebug_UnsignedBinary( v )
455 #define qDebug_UnsignedOctal( v )
456 #define qDebug_UnsignedHexadecimal( v )
457 #define qDebug_UnsignedDecimal( v )
458 #define qDebug_Memory( pMem, bSize )
459 #define qDebug_Mem( pMem, bSize )
460 #define qDebug_Var( v , mode )
461 #define qDebug_Variable( v , mode )
462 #endif
463
467 #ifdef __cplusplus
468 }
469 #endif
470
471#endif
void(* qPutChar_t)(void *arg1, const char arg2)
Pointer to function that write-out a single character.
Definition qioutils.h:52