First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #ifndef OPENSYSTEMTRACEV2_H
18 #define OPENSYSTEMTRACEV2_H
20 #include <opensystemtrace_types.h>
24 Methods for tracing from user side.
26 These methods are used to output trace packets.
27 Each trace packet consists of attributes and the user defined payload.
29 In order to output trace packets, tracing needs to be
30 included and enabled at compile time in the executable,
31 as well as be filtered at run-time.
34 OSTv2 does not enforce any security. It is the developer's responsibility
35 to ensure that trace packets do not contain any sensitive information that
36 may undermine platform security.
44 Class used to encapsulate the context of a trace point.
45 For more information about the attributes please @see opensystemtrace_types.h.
47 The attributes in @see TTraceContext are used to identify and filter the trace packet.
48 @see opensystemtrace.mmh
49 @see RUlogger for information on how to filter at run-time
53 NONSHARABLE_CLASS(TTraceContext)
56 inline TTraceContext(const TGroupId aGroupId);
57 inline TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
59 inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId);
60 inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
62 IMPORT_C TComponentId ComponentId() const;
63 IMPORT_C TClassification Classification() const;
64 IMPORT_C TGroupId GroupId() const;
65 IMPORT_C THasThreadIdentification HasThreadIdentification() const;
66 IMPORT_C THasProgramCounter HasProgramCounter() const;
67 IMPORT_C static TComponentId DefaultComponentId();
69 inline TTraceContext(){};
71 TComponentId iComponentId; ///<@see TComponentId
72 TGroupId iGroupId; ///<@see TGroupId
73 THasThreadIdentification iHasThreadIdentification; ///<@see THasThreadIdentification
74 THasProgramCounter iHasProgramCounter; ///<@see THasProgramCounter
75 TUint32 iReserved1; //Reserved for future use
76 TUint32 iReserved2; //Reserved for future use
79 IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC8& aDes);
80 IMPORT_C TBool OstPrintf(const TTraceContext& aContext, const char* aFmt, ...);
81 IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC8> aFmt,...);
82 #ifndef __KERNEL_MODE__
83 IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes);
84 IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC16> aFmt,...);
85 #endif //__KERNEL_MODE__
87 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId);
88 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint8 aData);
89 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint16 aData);
90 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData);
91 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData1, const TUint32 aData2);
92 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC8& aData);
93 #ifndef __KERNEL_MODE__
94 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC16& aData);
97 static inline TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const T& aData);
98 IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TAny* aData, const TInt aDataSize);
100 IMPORT_C TBool IsTraceActive(const TTraceContext& aContext);
104 The following trace APIs require a TraceCompiler to be present in the build system.
105 This TraceCompiler is used to generate additional information for each trace point
106 in order for traces to be generated at runtime.
109 #include <opensystemtrace.inl>
114 Preprocessor category for all traces off.
115 This should not be used from traces
117 #define OST_TRACE_CATEGORY_NONE 0x00000000
120 Preprocessor category for production traces
122 #define OST_TRACE_CATEGORY_PRODUCTION 0x00000001
125 Preprocessor category for RnD traces
127 #define OST_TRACE_CATEGORY_RND 0x00000002
130 Preprocessor category for performance measurement traces
132 #define OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT 0x00000004
135 Preprocessor level for all traces on.
136 This should not be used from traces
138 #define OST_TRACE_CATEGORY_ALL 0xFFFFFFFF
142 A flag, which specifies if the compiler has been run for the component
144 #if defined( OST_TRACE_COMPILER_IN_USE )
148 The default preprocessor category is RND
149 Component may override this by defining
150 OST_TRACE_CATEGORY before including this file
152 #if !defined( OST_TRACE_CATEGORY )
153 #define OST_TRACE_CATEGORY OST_TRACE_CATEGORY_RND
157 Trace with no parameters
159 @param aCategory Preprocessor category for the trace
160 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
161 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
162 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
163 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
164 @param aTraceText The trace text, which is parsed by the trace compiler.
165 The text itself is not sent in the trace packet
167 #define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText ) \
168 do {if ( aCategory & OST_TRACE_CATEGORY ) \
169 BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
171 KOstTraceComponentID, \
172 aTraceName );} while (0)
176 Trace with one 32-bit parameter
178 @param aCategory Preprocessor category for the trace
179 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
180 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
181 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
182 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
183 @param aTraceText The trace text, which is parsed by the trace compiler.
184 The text itself is not sent in the trace packet
185 @param aParam The 32-bit value to be traced
187 #define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
188 do {if ( aCategory & OST_TRACE_CATEGORY ) \
189 BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
191 KOstTraceComponentID, \
197 Trace with more than 32 bits of data
199 @param aCategory Preprocessor category for the trace
200 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
201 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
202 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
203 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
204 @param aTraceText The trace text, which is parsed by the trace compiler.
205 The text itself is not sent in the trace packet
206 @param aPtr Pointer to the data to be traced
207 @param aLength Length of the data to be traced
209 #define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
210 do {if ( aCategory & OST_TRACE_CATEGORY ) \
211 OstSendNBytes( EXTRACT_GROUP_ID(aTraceName), \
213 KOstTraceComponentID, \
216 aLength );} while (0)
220 Trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
221 which is generated by the trace compiler. The generated function will pack the
222 parameter into a stack-allocated buffer and call OstTraceData with the buffer.
224 @param aCategory Preprocessor category for the trace
225 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
226 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
227 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
228 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
229 @param aTraceText The trace text, which is parsed by the trace compiler.
230 The text itself is not sent in the trace packet
231 @param aParam The parameter to be traced
233 #define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
234 do {if ( aCategory & OST_TRACE_CATEGORY ) \
235 OstTraceGen1( aTraceName, aParam );} while (0)
239 Trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
240 The generated function will pack the parameters into a stack-allocated buffer and
241 call OstTraceData with the buffer.
243 @param aCategory Preprocessor category for the trace
244 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
245 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
246 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
247 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
248 @param aTraceText The trace text, which is parsed by the trace compiler.
249 The text itself is not sent in the trace packet
250 @param aParam1 The first parameter to be traced
251 @param aParam2 The second parameter to be traced
253 #define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
254 do {if ( aCategory & OST_TRACE_CATEGORY ) \
255 OstTraceGen2( aTraceName, aParam1, aParam2 );} while (0)
259 Trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
260 The generated function will pack the parameters into a stack-allocated buffer and
261 call OstTraceData with the buffer.
263 @param aCategory Preprocessor category for the trace
264 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
265 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
266 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
267 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
268 @param aTraceText The trace text, which is parsed by the trace compiler.
269 The text itself is not sent in the trace packet
270 @param aParam1 The first parameter to be traced
271 @param aParam2 The second parameter to be traced
272 @param aParam3 The third parameter to be traced
274 #define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
275 do {if ( aCategory & OST_TRACE_CATEGORY ) \
276 OstTraceGen3( aTraceName, aParam1, aParam2, aParam3 );} while (0)
280 Trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
281 The generated function will pack the parameters into a stack-allocated buffer and
282 call OstTraceData with the buffer.
284 @param aCategory Preprocessor category for the trace
285 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
286 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
287 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
288 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
289 @param aTraceText The trace text, which is parsed by the trace compiler.
290 The text itself is not sent in the trace packet
291 @param aParam1 The first parameter to be traced
292 @param aParam2 The second parameter to be traced
293 @param aParam3 The third parameter to be traced
294 @param aParam4 The fourth parameter to be traced
296 #define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
297 do {if ( aCategory & OST_TRACE_CATEGORY ) \
298 OstTraceGen4( aTraceName, aParam1, aParam2, aParam3, aParam4 );} while (0)
302 Trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
303 The generated function will pack the parameters into a stack-allocated buffer and
304 call OstTraceData with the buffer.
306 @param aCategory Preprocessor category for the trace
307 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
308 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
309 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
310 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
311 @param aTraceText The trace text, which is parsed by the trace compiler.
312 The text itself is not sent in the trace packet
313 @param aParam1 The first parameter to be traced
314 @param aParam2 The second parameter to be traced
315 @param aParam3 The third parameter to be traced
316 @param aParam4 The fourth parameter to be traced
317 @param aParam5 The fifth parameter to be traced
319 #define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
320 do {if ( aCategory & OST_TRACE_CATEGORY ) \
321 OstTraceGen5( aTraceName, aParam1, aParam2, aParam3, aParam4, aParam5 );} while (0)
325 *************** Trace macros which use RnD as default preprocessor category ***************
329 RnD trace with no parameters
331 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
332 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
333 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
334 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
335 @param aTraceText The trace text, which is parsed by the trace compiler.
336 The text itself is not sent in the trace packet
338 #define OstTrace0( aGroupName, aTraceName, aTraceText ) \
339 OstTraceDef0( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText )
343 RnD trace with one 32-bit parameter
345 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
346 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
347 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
348 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
349 @param aTraceText The trace text, which is parsed by the trace compiler.
350 The text itself is not sent in the trace packet
351 @param aParam The 32-bit value to be traced
353 #define OstTrace1( aGroupName, aTraceName, aTraceText, aParam ) \
354 OstTraceDef1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
358 RnD trace with more than 32 bits of data
360 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
361 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
362 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
363 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
364 @param aTraceText The trace text, which is parsed by the trace compiler.
365 The text itself is not sent in the trace packet
366 @param aPtr Pointer to the data to be traced
367 @param aLength Length of the data to be traced
369 #define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
370 OstTraceDefData( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aPtr, aLength )
374 RnD trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
375 which is generated by the trace compiler. The generated function will pack the
376 parameter into a stack-allocated buffer and call OstTraceData with the buffer.
378 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
379 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
380 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
381 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
382 @param aTraceText The trace text, which is parsed by the trace compiler.
383 The text itself is not sent in the trace packet
384 @param aParam The parameter to be traced
386 #define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam ) \
387 OstTraceDefExt1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
391 RnD trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
392 The generated function will pack the parameters into a stack-allocated buffer and
393 call OstTraceData with the buffer.
395 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
396 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
397 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
398 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
399 @param aTraceText The trace text, which is parsed by the trace compiler.
400 The text itself is not sent in the trace packet
401 @param aParam1 The first parameter to be traced
402 @param aParam2 The second parameter to be traced
404 #define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
405 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
409 RnD trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
410 The generated function will pack the parameters into a stack-allocated buffer and
411 call OstTraceData with the buffer.
413 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
414 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
415 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
416 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
417 @param aTraceText The trace text, which is parsed by the trace compiler.
418 The text itself is not sent in the trace packet
419 @param aParam1 The first parameter to be traced
420 @param aParam2 The second parameter to be traced
421 @param aParam3 The third parameter to be traced
423 #define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
424 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
428 RnD trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
429 The generated function will pack the parameters into a stack-allocated buffer and
430 call OstTraceData with the buffer.
432 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
433 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
434 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
435 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
436 @param aTraceText The trace text, which is parsed by the trace compiler.
437 The text itself is not sent in the trace packet
438 @param aParam1 The first parameter to be traced
439 @param aParam2 The second parameter to be traced
440 @param aParam3 The third parameter to be traced
441 @param aParam4 The fourth parameter to be traced
443 #define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
444 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
448 RnD trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
449 The generated function will pack the parameters into a stack-allocated buffer and
450 call OstTraceData with the buffer.
452 @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
453 Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
454 (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
455 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
456 @param aTraceText The trace text, which is parsed by the trace compiler.
457 The text itself is not sent in the trace packet
458 @param aParam1 The first parameter to be traced
459 @param aParam2 The second parameter to be traced
460 @param aParam3 The third parameter to be traced
461 @param aParam4 The fourth parameter to be traced
462 @param aParam5 The fifth parameter to be traced
464 #define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
465 OstTraceDefExt5( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
469 Function entry trace without extra parameters.
470 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
472 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
474 #define OstTraceFunctionEntry0( aTraceName ) \
475 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
476 BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
478 KOstTraceComponentID, \
479 aTraceName );} while (0)
483 Function entry trace with a parameter representing the instance identifier.
484 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
486 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
487 @param aInstance The instance identifier, for example "this" pointer
489 #define OstTraceFunctionEntry1( aTraceName, aInstance ) \
490 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
491 BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
493 KOstTraceComponentID, \
495 (TUint32) aInstance );} while (0)
499 Function entry trace, which traces function parameters.
500 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
502 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
503 @param aInstance Name of the instance identifier
505 #define OstTraceFunctionEntryExt( aTraceName, aInstance ) \
506 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
507 OstTraceGenExt( aTraceName, ( TUint )aInstance );} while (0)
511 Function exit trace without extra parameters.
512 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
514 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
516 #define OstTraceFunctionExit0( aTraceName ) \
517 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
518 BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
520 KOstTraceComponentID, \
521 aTraceName );} while (0)
525 Function exit trace with a parameter representing the instance identifier.
526 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
528 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
529 @param aInstance The instance identifier, for example "this" pointer
531 #define OstTraceFunctionExit1( aTraceName, aInstance ) \
532 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
533 BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
535 KOstTraceComponentID, \
537 (TUint32) aInstance );} while (0)
541 Function exit trace with a parameters representing the instance identifier and return value.
542 The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
544 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
545 @param aInstance The instance identifier, for example "this" pointer
546 @param aRetval The function return value
548 #define OstTraceFunctionExitExt( aTraceName, aInstance, aRetval ) \
549 do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
550 OstTraceGen2( aTraceName, ( TUint )aInstance, aRetval );} while (0)
554 Performance measurement event start trace without extra parameters.
555 The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
557 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
558 @param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
560 #define OstTraceEventStart0( aTraceName, aEventName ) \
561 OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)1 )
565 Performance measurement event start trace with single 32-bit parameter.
566 The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
568 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
569 @param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
570 @param aParam The parameter to be associated to the event
572 #define OstTraceEventStart1( aTraceName, aEventName, aParam ) \
573 OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, aParam )
577 Performance measurement event end trace.
578 The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
580 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
581 @param aEventName The name of the event. Must match a name passed to OstTraceEventStart
582 @param aStartTraceName Event start trace name. Must match a Trace Name of OstTraceEventStart trace
584 #define OstTraceEventStop( aTraceName, aEventName, aStartTraceName ) \
585 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)0, (TUint32)(aStartTraceName & 0xFFFF) )
589 State transition event.
590 The trace is mapped to TRACE_STATE group by the trace compiler
592 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
593 @param aStateName The name of the state, literal string (for example "name")
594 @param aNewState The new value for the state, literal string (for example "value")
596 #define OstTraceState0( aTraceName, aStateName, aNewState ) \
597 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState) )
601 State transition event with instance identifier.
602 The trace is mapped to TRACE_STATE group by the trace compiler
604 @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
605 @param aStateName The name of the state, literal string (for example "name")
606 @param aNewState The new value for the state, literal string (for example "value")
607 @param aInstance The instance identifier, for example "this" pointer
609 #define OstTraceState1( aTraceName, aStateName, aNewState, aInstance ) \
610 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState), (TUint32) aInstance )
612 #else // OST_TRACE_COMPILER_IN_USE
615 API is defined empty if the trace compiler has not been run
618 #define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText )
619 #define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
620 #define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength )
621 #define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
622 #define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
623 #define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
624 #define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
625 #define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
627 #define OstTrace0( aGroupName, aTraceName, aTraceText )
628 #define OstTrace1( aGroupName, aTraceName, aTraceText, aParam )
629 #define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength )
630 #define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam )
631 #define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
632 #define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
633 #define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
634 #define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
636 #define OstTraceFunctionEntry0( aTraceName )
637 #define OstTraceFunctionEntry1( aTraceName, aInstance )
638 #define OstTraceFunctionEntryExt(aTraceName, aInstance)
639 #define OstTraceFunctionExit0( aTraceName )
640 #define OstTraceFunctionExit1( aTraceName, aInstance )
641 #define OstTraceEventStart0( aTraceName, aEventName )
642 #define OstTraceEventStart1( aTraceName, aEventName, aParam )
643 #define OstTraceFunctionExitExt(aTraceName, aInstance, aRetval)
644 #define OstTraceEventStop( aTraceName, aEventName, aStartTraceName )
645 #define OstTraceState0( aTraceName, aStateName, aNewState )
646 #define OstTraceState1( aTraceName, aStateName, aNewState, aInstance )
648 #endif // OST_TRACE_COMPILER_IN_USE
654 BTrace sub-category IDs for OpenSystemTrace category
656 enum TSubcategoryOpenSystemTrace
664 * Queries if trace is active without sending it
666 EOstTraceActivationQuery = 1
669 // Forward declarations
672 Template class for array parameter types
673 For example, to wrap an integer array to a trace:
675 OstTraceExt( GRP, TRC, "Array: %{int32[]}", TOstArray< TInt >( arr, 5 ) );
684 * @param aArray the array data
685 * @param aLength the number of elements in the array
687 TOstArray( const T* aArray, TInt aLength ) : iArray( aArray ), iLength( aLength ) {}
690 * Gets the array data pointer.
691 * Used from the functions generated by trace compiler
693 * @return The array data pointer.
695 const T* Ptr() const { return iArray; }
698 * Gets the number of elements in the array.
699 * Used from the functions generated by trace compiler
701 * @return The number of elements in the array.
703 TInt Length() const { return iLength; }
706 * Gets the number of bytes occupied by the array.
707 * Used from the functions generated by trace compiler
709 * @return The number of bytes occupied by the array.
711 TInt Size() const { return sizeof( T ) * iLength; }
720 * Array length, as number of elements
728 #endif //OPENSYSTEMTRACEV2_H