sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Trace API sl@0: // sl@0: sl@0: #ifndef OPENSYSTEMTRACEV2_H sl@0: #define OPENSYSTEMTRACEV2_H sl@0: sl@0: #include sl@0: sl@0: sl@0: /** sl@0: Methods for tracing from user side. sl@0: sl@0: These methods are used to output trace packets. sl@0: Each trace packet consists of attributes and the user defined payload. sl@0: sl@0: In order to output trace packets, tracing needs to be sl@0: included and enabled at compile time in the executable, sl@0: as well as be filtered at run-time. sl@0: sl@0: Note: sl@0: OSTv2 does not enforce any security. It is the developer's responsibility sl@0: to ensure that trace packets do not contain any sensitive information that sl@0: may undermine platform security. sl@0: sl@0: @file sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: sl@0: /** sl@0: Class used to encapsulate the context of a trace point. sl@0: For more information about the attributes please @see opensystemtrace_types.h. sl@0: sl@0: The attributes in @see TTraceContext are used to identify and filter the trace packet. sl@0: @see opensystemtrace.mmh sl@0: @see RUlogger for information on how to filter at run-time sl@0: sl@0: @deprecated sl@0: */ sl@0: NONSHARABLE_CLASS(TTraceContext) sl@0: { sl@0: public: sl@0: inline TTraceContext(const TGroupId aGroupId); sl@0: inline TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter); sl@0: sl@0: inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId); sl@0: inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter); sl@0: sl@0: IMPORT_C TComponentId ComponentId() const; sl@0: IMPORT_C TClassification Classification() const; sl@0: IMPORT_C TGroupId GroupId() const; sl@0: IMPORT_C THasThreadIdentification HasThreadIdentification() const; sl@0: IMPORT_C THasProgramCounter HasProgramCounter() const; sl@0: IMPORT_C static TComponentId DefaultComponentId(); sl@0: private: sl@0: inline TTraceContext(){}; sl@0: private: sl@0: TComponentId iComponentId; ///<@see TComponentId sl@0: TGroupId iGroupId; ///<@see TGroupId sl@0: THasThreadIdentification iHasThreadIdentification; ///<@see THasThreadIdentification sl@0: THasProgramCounter iHasProgramCounter; ///<@see THasProgramCounter sl@0: TUint32 iReserved1; //Reserved for future use sl@0: TUint32 iReserved2; //Reserved for future use sl@0: }; sl@0: sl@0: IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC8& aDes); sl@0: IMPORT_C TBool OstPrintf(const TTraceContext& aContext, const char* aFmt, ...); sl@0: IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue aFmt,...); sl@0: #ifndef __KERNEL_MODE__ sl@0: IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes); sl@0: IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue aFmt,...); sl@0: #endif //__KERNEL_MODE__ sl@0: sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint8 aData); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint16 aData); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData1, const TUint32 aData2); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC8& aData); sl@0: #ifndef __KERNEL_MODE__ sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC16& aData); sl@0: #endif sl@0: template sl@0: static inline TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const T& aData); sl@0: IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TAny* aData, const TInt aDataSize); sl@0: sl@0: IMPORT_C TBool IsTraceActive(const TTraceContext& aContext); sl@0: sl@0: sl@0: /** sl@0: The following trace APIs require a TraceCompiler to be present in the build system. sl@0: This TraceCompiler is used to generate additional information for each trace point sl@0: in order for traces to be generated at runtime. sl@0: */ sl@0: sl@0: #include sl@0: sl@0: // Macros sl@0: sl@0: /** sl@0: Preprocessor category for all traces off. sl@0: This should not be used from traces sl@0: */ sl@0: #define OST_TRACE_CATEGORY_NONE 0x00000000 sl@0: sl@0: /** sl@0: Preprocessor category for production traces sl@0: */ sl@0: #define OST_TRACE_CATEGORY_PRODUCTION 0x00000001 sl@0: sl@0: /** sl@0: Preprocessor category for RnD traces sl@0: */ sl@0: #define OST_TRACE_CATEGORY_RND 0x00000002 sl@0: sl@0: /** sl@0: Preprocessor category for performance measurement traces sl@0: */ sl@0: #define OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT 0x00000004 sl@0: sl@0: /** sl@0: Preprocessor level for all traces on. sl@0: This should not be used from traces sl@0: */ sl@0: #define OST_TRACE_CATEGORY_ALL 0xFFFFFFFF sl@0: sl@0: sl@0: /** sl@0: A flag, which specifies if the compiler has been run for the component sl@0: */ sl@0: #if defined( OST_TRACE_COMPILER_IN_USE ) sl@0: sl@0: sl@0: /** sl@0: The default preprocessor category is RND sl@0: Component may override this by defining sl@0: OST_TRACE_CATEGORY before including this file sl@0: */ sl@0: #if !defined( OST_TRACE_CATEGORY ) sl@0: #define OST_TRACE_CATEGORY OST_TRACE_CATEGORY_RND sl@0: #endif sl@0: sl@0: /** sl@0: Trace with no parameters sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: */ sl@0: #define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with one 32-bit parameter sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam The 32-bit value to be traced sl@0: */ sl@0: #define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName, \ sl@0: aParam );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with more than 32 bits of data sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aPtr Pointer to the data to be traced sl@0: @param aLength Length of the data to be traced sl@0: */ sl@0: #define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstSendNBytes( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName, \ sl@0: aPtr, \ sl@0: aLength );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with one parameter that is not 32-bit integer. This calls OstTraceGen1, sl@0: which is generated by the trace compiler. The generated function will pack the sl@0: parameter into a stack-allocated buffer and call OstTraceData with the buffer. sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam The parameter to be traced sl@0: */ sl@0: #define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen1( aTraceName, aParam );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: */ sl@0: #define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen2( aTraceName, aParam1, aParam2 );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: */ sl@0: #define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen3( aTraceName, aParam1, aParam2, aParam3 );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: @param aParam4 The fourth parameter to be traced sl@0: */ sl@0: #define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen4( aTraceName, aParam1, aParam2, aParam3, aParam4 );} while (0) sl@0: sl@0: sl@0: /** sl@0: Trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aCategory Preprocessor category for the trace sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: @param aParam4 The fourth parameter to be traced sl@0: @param aParam5 The fifth parameter to be traced sl@0: */ sl@0: #define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \ sl@0: do {if ( aCategory & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen5( aTraceName, aParam1, aParam2, aParam3, aParam4, aParam5 );} while (0) sl@0: sl@0: sl@0: /** sl@0: *************** Trace macros which use RnD as default preprocessor category *************** sl@0: */ sl@0: sl@0: /** sl@0: RnD trace with no parameters sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: */ sl@0: #define OstTrace0( aGroupName, aTraceName, aTraceText ) \ sl@0: OstTraceDef0( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with one 32-bit parameter sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam The 32-bit value to be traced sl@0: */ sl@0: #define OstTrace1( aGroupName, aTraceName, aTraceText, aParam ) \ sl@0: OstTraceDef1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with more than 32 bits of data sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aPtr Pointer to the data to be traced sl@0: @param aLength Length of the data to be traced sl@0: */ sl@0: #define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength ) \ sl@0: OstTraceDefData( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aPtr, aLength ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with one parameter that is not 32-bit integer. This calls OstTraceGen1, sl@0: which is generated by the trace compiler. The generated function will pack the sl@0: parameter into a stack-allocated buffer and call OstTraceData with the buffer. sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam The parameter to be traced sl@0: */ sl@0: #define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam ) \ sl@0: OstTraceDefExt1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: */ sl@0: #define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \ sl@0: OstTraceDefExt2( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: */ sl@0: #define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \ sl@0: OstTraceDefExt3( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: @param aParam4 The fourth parameter to be traced sl@0: */ sl@0: #define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \ sl@0: OstTraceDefExt4( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) sl@0: sl@0: sl@0: /** sl@0: RnD trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler. sl@0: The generated function will pack the parameters into a stack-allocated buffer and sl@0: call OstTraceData with the buffer. sl@0: sl@0: @param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer. sl@0: Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name sl@0: (aTraceName 32-bit integer). Only the trace name is sent in the trace packet. sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aTraceText The trace text, which is parsed by the trace compiler. sl@0: The text itself is not sent in the trace packet sl@0: @param aParam1 The first parameter to be traced sl@0: @param aParam2 The second parameter to be traced sl@0: @param aParam3 The third parameter to be traced sl@0: @param aParam4 The fourth parameter to be traced sl@0: @param aParam5 The fifth parameter to be traced sl@0: */ sl@0: #define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \ sl@0: OstTraceDefExt5( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) sl@0: sl@0: sl@0: /** sl@0: Function entry trace without extra parameters. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: */ sl@0: #define OstTraceFunctionEntry0( aTraceName ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName );} while (0) sl@0: sl@0: sl@0: /** sl@0: Function entry trace with a parameter representing the instance identifier. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aInstance The instance identifier, for example "this" pointer sl@0: */ sl@0: #define OstTraceFunctionEntry1( aTraceName, aInstance ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName, \ sl@0: (TUint32) aInstance );} while (0) sl@0: sl@0: sl@0: /** sl@0: Function entry trace, which traces function parameters. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aInstance Name of the instance identifier sl@0: */ sl@0: #define OstTraceFunctionEntryExt( aTraceName, aInstance ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGenExt( aTraceName, ( TUint )aInstance );} while (0) sl@0: sl@0: sl@0: /** sl@0: Function exit trace without extra parameters. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: */ sl@0: #define OstTraceFunctionExit0( aTraceName ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName );} while (0) sl@0: sl@0: sl@0: /** sl@0: Function exit trace with a parameter representing the instance identifier. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aInstance The instance identifier, for example "this" pointer sl@0: */ sl@0: #define OstTraceFunctionExit1( aTraceName, aInstance ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \ sl@0: EOstTrace, \ sl@0: KOstTraceComponentID, \ sl@0: aTraceName, \ sl@0: (TUint32) aInstance );} while (0) sl@0: sl@0: sl@0: /** sl@0: Function exit trace with a parameters representing the instance identifier and return value. sl@0: The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aInstance The instance identifier, for example "this" pointer sl@0: @param aRetval The function return value sl@0: */ sl@0: #define OstTraceFunctionExitExt( aTraceName, aInstance, aRetval ) \ sl@0: do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \ sl@0: OstTraceGen2( aTraceName, ( TUint )aInstance, aRetval );} while (0) sl@0: sl@0: sl@0: /** sl@0: Performance measurement event start trace without extra parameters. sl@0: The trace is mapped to TRACE_PERFORMANCE group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code sl@0: */ sl@0: #define OstTraceEventStart0( aTraceName, aEventName ) \ sl@0: OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)1 ) sl@0: sl@0: sl@0: /** sl@0: Performance measurement event start trace with single 32-bit parameter. sl@0: The trace is mapped to TRACE_PERFORMANCE group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code sl@0: @param aParam The parameter to be associated to the event sl@0: */ sl@0: #define OstTraceEventStart1( aTraceName, aEventName, aParam ) \ sl@0: OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, aParam ) sl@0: sl@0: sl@0: /** sl@0: Performance measurement event end trace. sl@0: The trace is mapped to TRACE_PERFORMANCE group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aEventName The name of the event. Must match a name passed to OstTraceEventStart sl@0: @param aStartTraceName Event start trace name. Must match a Trace Name of OstTraceEventStart trace sl@0: */ sl@0: #define OstTraceEventStop( aTraceName, aEventName, aStartTraceName ) \ sl@0: OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)0, (TUint32)(aStartTraceName & 0xFFFF) ) sl@0: sl@0: sl@0: /** sl@0: State transition event. sl@0: The trace is mapped to TRACE_STATE group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aStateName The name of the state, literal string (for example "name") sl@0: @param aNewState The new value for the state, literal string (for example "value") sl@0: */ sl@0: #define OstTraceState0( aTraceName, aStateName, aNewState ) \ sl@0: OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState) ) sl@0: sl@0: sl@0: /** sl@0: State transition event with instance identifier. sl@0: The trace is mapped to TRACE_STATE group by the trace compiler sl@0: sl@0: @param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique sl@0: @param aStateName The name of the state, literal string (for example "name") sl@0: @param aNewState The new value for the state, literal string (for example "value") sl@0: @param aInstance The instance identifier, for example "this" pointer sl@0: */ sl@0: #define OstTraceState1( aTraceName, aStateName, aNewState, aInstance ) \ sl@0: OstTraceDefExt3( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState), (TUint32) aInstance ) sl@0: sl@0: #else // OST_TRACE_COMPILER_IN_USE sl@0: sl@0: /** sl@0: API is defined empty if the trace compiler has not been run sl@0: */ sl@0: sl@0: #define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText ) sl@0: #define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) sl@0: #define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength ) sl@0: #define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) sl@0: #define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) sl@0: #define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) sl@0: #define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) sl@0: #define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) sl@0: sl@0: #define OstTrace0( aGroupName, aTraceName, aTraceText ) sl@0: #define OstTrace1( aGroupName, aTraceName, aTraceText, aParam ) sl@0: #define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength ) sl@0: #define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam ) sl@0: #define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) sl@0: #define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) sl@0: #define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) sl@0: #define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) sl@0: sl@0: #define OstTraceFunctionEntry0( aTraceName ) sl@0: #define OstTraceFunctionEntry1( aTraceName, aInstance ) sl@0: #define OstTraceFunctionEntryExt(aTraceName, aInstance) sl@0: #define OstTraceFunctionExit0( aTraceName ) sl@0: #define OstTraceFunctionExit1( aTraceName, aInstance ) sl@0: #define OstTraceEventStart0( aTraceName, aEventName ) sl@0: #define OstTraceEventStart1( aTraceName, aEventName, aParam ) sl@0: #define OstTraceFunctionExitExt(aTraceName, aInstance, aRetval) sl@0: #define OstTraceEventStop( aTraceName, aEventName, aStartTraceName ) sl@0: #define OstTraceState0( aTraceName, aStateName, aNewState ) sl@0: #define OstTraceState1( aTraceName, aStateName, aNewState, aInstance ) sl@0: sl@0: #endif // OST_TRACE_COMPILER_IN_USE sl@0: sl@0: sl@0: // Data types sl@0: sl@0: /** sl@0: BTrace sub-category IDs for OpenSystemTrace category sl@0: */ sl@0: enum TSubcategoryOpenSystemTrace sl@0: { sl@0: /** sl@0: * Normal trace sl@0: */ sl@0: EOstTrace = 0, sl@0: sl@0: /** sl@0: * Queries if trace is active without sending it sl@0: */ sl@0: EOstTraceActivationQuery = 1 sl@0: }; sl@0: sl@0: // Forward declarations sl@0: sl@0: /** sl@0: Template class for array parameter types sl@0: For example, to wrap an integer array to a trace: sl@0: TInt arr[5]; sl@0: OstTraceExt( GRP, TRC, "Array: %{int32[]}", TOstArray< TInt >( arr, 5 ) ); sl@0: */ sl@0: template< class T > sl@0: class TOstArray sl@0: { sl@0: public: sl@0: /** sl@0: * Constructor sl@0: * sl@0: * @param aArray the array data sl@0: * @param aLength the number of elements in the array sl@0: */ sl@0: TOstArray( const T* aArray, TInt aLength ) : iArray( aArray ), iLength( aLength ) {} sl@0: sl@0: /** sl@0: * Gets the array data pointer. sl@0: * Used from the functions generated by trace compiler sl@0: * sl@0: * @return The array data pointer. sl@0: */ sl@0: const T* Ptr() const { return iArray; } sl@0: sl@0: /** sl@0: * Gets the number of elements in the array. sl@0: * Used from the functions generated by trace compiler sl@0: * sl@0: * @return The number of elements in the array. sl@0: */ sl@0: TInt Length() const { return iLength; } sl@0: sl@0: /** sl@0: * Gets the number of bytes occupied by the array. sl@0: * Used from the functions generated by trace compiler sl@0: * sl@0: * @return The number of bytes occupied by the array. sl@0: */ sl@0: TInt Size() const { return sizeof( T ) * iLength; } sl@0: sl@0: private: sl@0: /** sl@0: * Array data sl@0: */ sl@0: const T* iArray; sl@0: sl@0: /** sl@0: * Array length, as number of elements sl@0: */ sl@0: TInt iLength; sl@0: }; sl@0: sl@0: sl@0: // Class declaration sl@0: sl@0: #endif //OPENSYSTEMTRACEV2_H