os/kernelhwsrv/kernel/eka/include/opensystemtrace.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/opensystemtrace.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,728 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Trace API
    1.18 +//
    1.19 +
    1.20 +#ifndef OPENSYSTEMTRACEV2_H
    1.21 +#define OPENSYSTEMTRACEV2_H
    1.22 +
    1.23 +#include <opensystemtrace_types.h>
    1.24 +
    1.25 +
    1.26 +/**
    1.27 +Methods for tracing from user side.
    1.28 +
    1.29 +These methods are used to output trace packets.
    1.30 +Each trace packet consists of attributes and the user defined payload.
    1.31 +
    1.32 +In order to output trace packets, tracing needs to be
    1.33 +included and enabled at compile time in the executable,
    1.34 +as well as be filtered at run-time.
    1.35 +
    1.36 +Note:
    1.37 +OSTv2 does not enforce any security. It is the developer's responsibility
    1.38 +to ensure that trace packets do not contain any sensitive information that
    1.39 +may undermine platform security.
    1.40 +
    1.41 +@file
    1.42 +@publishedPartner
    1.43 +@prototype
    1.44 +*/
    1.45 +
    1.46 +/**
    1.47 +Class used to encapsulate the context of a trace point.
    1.48 +For more information about the attributes please @see opensystemtrace_types.h.
    1.49 +
    1.50 +The attributes in @see TTraceContext are used to identify and filter the trace packet.
    1.51 +@see opensystemtrace.mmh
    1.52 +@see RUlogger for information on how to filter at run-time
    1.53 +
    1.54 +@deprecated
    1.55 +*/
    1.56 +NONSHARABLE_CLASS(TTraceContext)
    1.57 +    {
    1.58 +public:
    1.59 +    inline TTraceContext(const TGroupId aGroupId);
    1.60 +    inline TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
    1.61 +
    1.62 +    inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId);
    1.63 +    inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
    1.64 +
    1.65 +    IMPORT_C TComponentId               ComponentId() const;
    1.66 +    IMPORT_C TClassification            Classification() const;
    1.67 +    IMPORT_C TGroupId                   GroupId() const;
    1.68 +    IMPORT_C THasThreadIdentification   HasThreadIdentification() const;
    1.69 +    IMPORT_C THasProgramCounter         HasProgramCounter() const;
    1.70 +    IMPORT_C static TComponentId        DefaultComponentId();
    1.71 +private:
    1.72 +    inline TTraceContext(){};
    1.73 +private:
    1.74 +    TComponentId                iComponentId;               ///<@see TComponentId
    1.75 +    TGroupId                    iGroupId;                   ///<@see TGroupId
    1.76 +    THasThreadIdentification    iHasThreadIdentification;   ///<@see THasThreadIdentification
    1.77 +    THasProgramCounter          iHasProgramCounter;         ///<@see THasProgramCounter
    1.78 +    TUint32                     iReserved1;                 //Reserved for future use
    1.79 +    TUint32                     iReserved2;                 //Reserved for future use
    1.80 +    };
    1.81 +
    1.82 +	IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC8& aDes);
    1.83 +    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, const char* aFmt, ...);
    1.84 +    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC8> aFmt,...);
    1.85 +    #ifndef  __KERNEL_MODE__
    1.86 +    IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes);
    1.87 +    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC16> aFmt,...);
    1.88 +    #endif //__KERNEL_MODE__
    1.89 +
    1.90 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId);
    1.91 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint8 aData);
    1.92 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint16 aData);
    1.93 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData);
    1.94 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData1, const TUint32 aData2);
    1.95 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC8& aData);
    1.96 +    #ifndef __KERNEL_MODE__
    1.97 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC16& aData);
    1.98 +    #endif
    1.99 +    template<typename T>
   1.100 +    static inline TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const T& aData);
   1.101 +    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TAny* aData, const TInt aDataSize);
   1.102 +
   1.103 +    IMPORT_C TBool IsTraceActive(const TTraceContext& aContext);
   1.104 +
   1.105 +
   1.106 +/**
   1.107 +The following trace APIs require a TraceCompiler to be present in the build system. 
   1.108 +This TraceCompiler is used to generate additional information for each trace point 
   1.109 +in order for traces to be generated at runtime.
   1.110 +*/
   1.111 +
   1.112 +#include <opensystemtrace.inl>
   1.113 +
   1.114 +// Macros
   1.115 +
   1.116 +/**
   1.117 +Preprocessor category for all traces off.
   1.118 +This should not be used from traces
   1.119 +*/
   1.120 +#define OST_TRACE_CATEGORY_NONE 0x00000000
   1.121 +
   1.122 +/**
   1.123 +Preprocessor category for production traces
   1.124 +*/
   1.125 +#define OST_TRACE_CATEGORY_PRODUCTION 0x00000001
   1.126 +
   1.127 +/**
   1.128 +Preprocessor category for RnD traces
   1.129 +*/
   1.130 +#define OST_TRACE_CATEGORY_RND 0x00000002
   1.131 +
   1.132 +/**
   1.133 +Preprocessor category for performance measurement traces
   1.134 +*/
   1.135 +#define OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT 0x00000004
   1.136 +
   1.137 +/**
   1.138 +Preprocessor level for all traces on.
   1.139 +This should not be used from traces
   1.140 +*/
   1.141 +#define OST_TRACE_CATEGORY_ALL 0xFFFFFFFF
   1.142 +
   1.143 +
   1.144 +/**
   1.145 +A flag, which specifies if the compiler has been run for the component
   1.146 +*/
   1.147 +#if defined( OST_TRACE_COMPILER_IN_USE )
   1.148 +
   1.149 +
   1.150 +/**
   1.151 +The default preprocessor category is RND
   1.152 +Component may override this by defining
   1.153 +OST_TRACE_CATEGORY before including this file
   1.154 +*/
   1.155 +#if !defined( OST_TRACE_CATEGORY )
   1.156 +#define OST_TRACE_CATEGORY OST_TRACE_CATEGORY_RND
   1.157 +#endif
   1.158 +
   1.159 +/**
   1.160 +Trace with no parameters
   1.161 +
   1.162 +@param aCategory Preprocessor category for the trace
   1.163 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.164 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.165 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.166 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.167 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.168 +                  The text itself is not sent in the trace packet
   1.169 +*/
   1.170 +#define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText ) \
   1.171 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.172 +    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
   1.173 +                        EOstTrace, \
   1.174 +                        KOstTraceComponentID, \
   1.175 +                        aTraceName );} while (0)
   1.176 +
   1.177 +
   1.178 +/**
   1.179 +Trace with one 32-bit parameter
   1.180 +
   1.181 +@param aCategory Preprocessor category for the trace
   1.182 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.183 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.184 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.185 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.186 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.187 +                  The text itself is not sent in the trace packet
   1.188 +@param aParam The 32-bit value to be traced
   1.189 +*/
   1.190 +#define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
   1.191 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.192 +    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
   1.193 +                         EOstTrace, \
   1.194 +                         KOstTraceComponentID, \
   1.195 +                         aTraceName, \
   1.196 +                         aParam );} while (0)
   1.197 +
   1.198 +
   1.199 +/**
   1.200 +Trace with more than 32 bits of data
   1.201 +
   1.202 +@param aCategory Preprocessor category for the trace
   1.203 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.204 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.205 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.206 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.207 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.208 +                  The text itself is not sent in the trace packet
   1.209 +@param aPtr Pointer to the data to be traced
   1.210 +@param aLength Length of the data to be traced
   1.211 +*/
   1.212 +#define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
   1.213 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.214 +        OstSendNBytes( EXTRACT_GROUP_ID(aTraceName), \
   1.215 +                       EOstTrace, \
   1.216 +                       KOstTraceComponentID, \
   1.217 +                       aTraceName, \
   1.218 +                       aPtr, \
   1.219 +                       aLength );} while (0)
   1.220 +
   1.221 +
   1.222 +/**
   1.223 +Trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
   1.224 +which is generated by the trace compiler. The generated function will pack the
   1.225 +parameter into a stack-allocated buffer and call OstTraceData with the buffer.
   1.226 +
   1.227 +@param aCategory Preprocessor category for the trace
   1.228 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.229 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.230 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.231 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.232 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.233 +                  The text itself is not sent in the trace packet
   1.234 +@param aParam The parameter to be traced
   1.235 +*/
   1.236 +#define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
   1.237 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.238 +        OstTraceGen1( aTraceName, aParam );} while (0)
   1.239 +
   1.240 +
   1.241 +/**
   1.242 +Trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
   1.243 +The generated function will pack the parameters into a stack-allocated buffer and
   1.244 +call OstTraceData with the buffer.
   1.245 +
   1.246 +@param aCategory Preprocessor category for the trace
   1.247 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.248 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.249 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.250 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.251 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.252 +                  The text itself is not sent in the trace packet
   1.253 +@param aParam1 The first parameter to be traced
   1.254 +@param aParam2 The second parameter to be traced
   1.255 +*/
   1.256 +#define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
   1.257 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.258 +        OstTraceGen2( aTraceName, aParam1, aParam2 );} while (0)
   1.259 +
   1.260 +
   1.261 +/**
   1.262 +Trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
   1.263 +The generated function will pack the parameters into a stack-allocated buffer and
   1.264 +call OstTraceData with the buffer.
   1.265 +
   1.266 +@param aCategory Preprocessor category for the trace
   1.267 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.268 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.269 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.270 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.271 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.272 +                  The text itself is not sent in the trace packet
   1.273 +@param aParam1 The first parameter to be traced
   1.274 +@param aParam2 The second parameter to be traced
   1.275 +@param aParam3 The third parameter to be traced
   1.276 +*/
   1.277 +#define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
   1.278 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.279 +        OstTraceGen3( aTraceName, aParam1, aParam2, aParam3 );} while (0)
   1.280 +
   1.281 +
   1.282 +/**
   1.283 +Trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
   1.284 +The generated function will pack the parameters into a stack-allocated buffer and
   1.285 +call OstTraceData with the buffer.
   1.286 +
   1.287 +@param aCategory Preprocessor category for the trace
   1.288 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.289 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.290 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.291 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.292 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.293 +                  The text itself is not sent in the trace packet
   1.294 +@param aParam1 The first parameter to be traced
   1.295 +@param aParam2 The second parameter to be traced
   1.296 +@param aParam3 The third parameter to be traced
   1.297 +@param aParam4 The fourth parameter to be traced
   1.298 +*/
   1.299 +#define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
   1.300 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.301 +        OstTraceGen4( aTraceName, aParam1, aParam2, aParam3, aParam4 );} while (0)
   1.302 +
   1.303 +
   1.304 +/**
   1.305 +Trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
   1.306 +The generated function will pack the parameters into a stack-allocated buffer and
   1.307 +call OstTraceData with the buffer.
   1.308 +
   1.309 +@param aCategory Preprocessor category for the trace
   1.310 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.311 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.312 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.313 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.314 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.315 +                  The text itself is not sent in the trace packet
   1.316 +@param aParam1 The first parameter to be traced
   1.317 +@param aParam2 The second parameter to be traced
   1.318 +@param aParam3 The third parameter to be traced
   1.319 +@param aParam4 The fourth parameter to be traced
   1.320 +@param aParam5 The fifth parameter to be traced
   1.321 +*/
   1.322 +#define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
   1.323 +    do {if ( aCategory & OST_TRACE_CATEGORY ) \
   1.324 +        OstTraceGen5( aTraceName, aParam1, aParam2, aParam3, aParam4, aParam5 );} while (0)
   1.325 +
   1.326 +
   1.327 +/**
   1.328 +*************** Trace macros which use RnD as default preprocessor category ***************
   1.329 +*/
   1.330 +
   1.331 +/**
   1.332 +RnD trace with no parameters
   1.333 +
   1.334 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.335 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.336 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.337 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.338 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.339 +                  The text itself is not sent in the trace packet
   1.340 +*/
   1.341 +#define OstTrace0( aGroupName, aTraceName, aTraceText ) \
   1.342 +    OstTraceDef0( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText )
   1.343 +
   1.344 +
   1.345 +/**
   1.346 +RnD trace with one 32-bit parameter
   1.347 +
   1.348 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.349 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.350 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.351 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.352 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.353 +                  The text itself is not sent in the trace packet
   1.354 +@param aParam The 32-bit value to be traced
   1.355 +*/
   1.356 +#define OstTrace1( aGroupName, aTraceName, aTraceText, aParam ) \
   1.357 +    OstTraceDef1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
   1.358 +
   1.359 +
   1.360 +/**
   1.361 +RnD trace with more than 32 bits of data
   1.362 +
   1.363 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.364 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.365 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.366 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.367 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.368 +                  The text itself is not sent in the trace packet
   1.369 +@param aPtr Pointer to the data to be traced
   1.370 +@param aLength Length of the data to be traced
   1.371 +*/
   1.372 +#define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
   1.373 +    OstTraceDefData( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aPtr, aLength )
   1.374 +
   1.375 +
   1.376 +/**
   1.377 +RnD trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
   1.378 +which is generated by the trace compiler. The generated function will pack the
   1.379 +parameter into a stack-allocated buffer and call OstTraceData with the buffer.
   1.380 +
   1.381 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.382 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.383 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.384 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.385 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.386 +                  The text itself is not sent in the trace packet
   1.387 +@param aParam The parameter to be traced
   1.388 +*/
   1.389 +#define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam ) \
   1.390 +    OstTraceDefExt1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
   1.391 +
   1.392 +
   1.393 +/**
   1.394 +RnD trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
   1.395 +The generated function will pack the parameters into a stack-allocated buffer and
   1.396 +call OstTraceData with the buffer.
   1.397 +
   1.398 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.399 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.400 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.401 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.402 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.403 +                  The text itself is not sent in the trace packet
   1.404 +@param aParam1 The first parameter to be traced
   1.405 +@param aParam2 The second parameter to be traced
   1.406 +*/
   1.407 +#define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
   1.408 +    OstTraceDefExt2( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
   1.409 +
   1.410 +
   1.411 +/**
   1.412 +RnD trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
   1.413 +The generated function will pack the parameters into a stack-allocated buffer and
   1.414 +call OstTraceData with the buffer.
   1.415 +
   1.416 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.417 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.418 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.419 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.420 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.421 +                  The text itself is not sent in the trace packet
   1.422 +@param aParam1 The first parameter to be traced
   1.423 +@param aParam2 The second parameter to be traced
   1.424 +@param aParam3 The third parameter to be traced
   1.425 +*/
   1.426 +#define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
   1.427 +    OstTraceDefExt3( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
   1.428 +
   1.429 +
   1.430 +/**
   1.431 +RnD trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
   1.432 +The generated function will pack the parameters into a stack-allocated buffer and
   1.433 +call OstTraceData with the buffer.
   1.434 +
   1.435 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.436 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.437 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.438 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.439 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.440 +                  The text itself is not sent in the trace packet
   1.441 +@param aParam1 The first parameter to be traced
   1.442 +@param aParam2 The second parameter to be traced
   1.443 +@param aParam3 The third parameter to be traced
   1.444 +@param aParam4 The fourth parameter to be traced
   1.445 +*/
   1.446 +#define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
   1.447 +    OstTraceDefExt4( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
   1.448 +
   1.449 +
   1.450 +/**
   1.451 +RnD trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
   1.452 +The generated function will pack the parameters into a stack-allocated buffer and
   1.453 +call OstTraceData with the buffer.
   1.454 +
   1.455 +@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
   1.456 +                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
   1.457 +                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
   1.458 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.459 +@param aTraceText The trace text, which is parsed by the trace compiler.
   1.460 +                  The text itself is not sent in the trace packet
   1.461 +@param aParam1 The first parameter to be traced
   1.462 +@param aParam2 The second parameter to be traced
   1.463 +@param aParam3 The third parameter to be traced
   1.464 +@param aParam4 The fourth parameter to be traced
   1.465 +@param aParam5 The fifth parameter to be traced
   1.466 +*/
   1.467 +#define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
   1.468 +    OstTraceDefExt5( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
   1.469 +
   1.470 +
   1.471 +/**
   1.472 +Function entry trace without extra parameters.
   1.473 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.474 +
   1.475 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.476 +*/
   1.477 +#define OstTraceFunctionEntry0( aTraceName ) \
   1.478 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.479 +    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
   1.480 +                        EOstTrace, \
   1.481 +                        KOstTraceComponentID, \
   1.482 +                        aTraceName );} while (0)
   1.483 +
   1.484 +
   1.485 +/**
   1.486 +Function entry trace with a parameter representing the instance identifier.
   1.487 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.488 +
   1.489 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.490 +@param aInstance The instance identifier, for example "this" pointer
   1.491 +*/
   1.492 +#define OstTraceFunctionEntry1( aTraceName, aInstance ) \
   1.493 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.494 +    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
   1.495 +                         EOstTrace, \
   1.496 +                         KOstTraceComponentID, \
   1.497 +                         aTraceName, \
   1.498 +                         (TUint32) aInstance );} while (0)
   1.499 +
   1.500 +
   1.501 +/**
   1.502 +Function entry trace, which traces function parameters.
   1.503 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.504 +
   1.505 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.506 +@param aInstance Name of the instance identifier
   1.507 +*/
   1.508 +#define OstTraceFunctionEntryExt( aTraceName, aInstance ) \
   1.509 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.510 +        OstTraceGenExt( aTraceName, ( TUint )aInstance );} while (0)
   1.511 +
   1.512 +
   1.513 +/**
   1.514 +Function exit trace without extra parameters.
   1.515 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.516 +
   1.517 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.518 +*/
   1.519 +#define OstTraceFunctionExit0( aTraceName ) \
   1.520 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.521 +    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
   1.522 +                        EOstTrace, \
   1.523 +                        KOstTraceComponentID, \
   1.524 +                        aTraceName );} while (0)
   1.525 +
   1.526 +
   1.527 +/**
   1.528 +Function exit trace with a parameter representing the instance identifier.
   1.529 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.530 +
   1.531 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.532 +@param aInstance The instance identifier, for example "this" pointer
   1.533 +*/
   1.534 +#define OstTraceFunctionExit1( aTraceName, aInstance ) \
   1.535 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.536 +    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
   1.537 +                         EOstTrace, \
   1.538 +                         KOstTraceComponentID, \
   1.539 +                         aTraceName, \
   1.540 +                         (TUint32) aInstance );} while (0)
   1.541 +
   1.542 +
   1.543 +/**
   1.544 +Function exit trace with a parameters representing the instance identifier and return value.
   1.545 +The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
   1.546 +
   1.547 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.548 +@param aInstance The instance identifier, for example "this" pointer
   1.549 +@param aRetval The function return value
   1.550 +*/
   1.551 +#define OstTraceFunctionExitExt( aTraceName, aInstance, aRetval ) \
   1.552 +    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
   1.553 +        OstTraceGen2( aTraceName, ( TUint )aInstance, aRetval );} while (0)
   1.554 +
   1.555 +
   1.556 +/**
   1.557 +Performance measurement event start trace without extra parameters.
   1.558 +The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
   1.559 +
   1.560 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.561 +@param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
   1.562 +*/
   1.563 +#define OstTraceEventStart0( aTraceName, aEventName ) \
   1.564 +        OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)1 )
   1.565 +
   1.566 +
   1.567 +/**
   1.568 +Performance measurement event start trace with single 32-bit parameter.
   1.569 +The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
   1.570 +
   1.571 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.572 +@param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
   1.573 +@param aParam The parameter to be associated to the event
   1.574 +*/
   1.575 +#define OstTraceEventStart1( aTraceName, aEventName, aParam ) \
   1.576 +        OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, aParam )
   1.577 +
   1.578 +
   1.579 +/**
   1.580 +Performance measurement event end trace.
   1.581 +The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
   1.582 +
   1.583 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.584 +@param aEventName The name of the event. Must match a name passed to OstTraceEventStart
   1.585 +@param aStartTraceName Event start trace name. Must match a Trace Name of OstTraceEventStart trace
   1.586 +*/
   1.587 +#define OstTraceEventStop( aTraceName, aEventName, aStartTraceName ) \
   1.588 +        OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)0, (TUint32)(aStartTraceName & 0xFFFF) ) 
   1.589 +
   1.590 +
   1.591 +/**
   1.592 +State transition event.
   1.593 +The trace is mapped to TRACE_STATE group by the trace compiler
   1.594 +
   1.595 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.596 +@param aStateName The name of the state, literal string (for example "name")
   1.597 +@param aNewState The new value for the state, literal string (for example "value")
   1.598 +*/
   1.599 +#define OstTraceState0( aTraceName, aStateName, aNewState ) \
   1.600 +        OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState) ) 
   1.601 +
   1.602 +
   1.603 +/**
   1.604 +State transition event with instance identifier.
   1.605 +The trace is mapped to TRACE_STATE group by the trace compiler
   1.606 +
   1.607 +@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
   1.608 +@param aStateName The name of the state, literal string (for example "name")
   1.609 +@param aNewState The new value for the state, literal string (for example "value")
   1.610 +@param aInstance The instance identifier, for example "this" pointer
   1.611 +*/
   1.612 +#define OstTraceState1( aTraceName, aStateName, aNewState, aInstance ) \
   1.613 +        OstTraceDefExt3( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState), (TUint32) aInstance ) 
   1.614 +       
   1.615 +#else // OST_TRACE_COMPILER_IN_USE
   1.616 +
   1.617 +/**
   1.618 +API is defined empty if the trace compiler has not been run
   1.619 +*/
   1.620 +
   1.621 +#define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText )
   1.622 +#define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
   1.623 +#define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength )
   1.624 +#define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
   1.625 +#define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
   1.626 +#define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
   1.627 +#define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
   1.628 +#define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
   1.629 +
   1.630 +#define OstTrace0( aGroupName, aTraceName, aTraceText )
   1.631 +#define OstTrace1( aGroupName, aTraceName, aTraceText, aParam )
   1.632 +#define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength )
   1.633 +#define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam )
   1.634 +#define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
   1.635 +#define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
   1.636 +#define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
   1.637 +#define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
   1.638 +
   1.639 +#define OstTraceFunctionEntry0( aTraceName )
   1.640 +#define OstTraceFunctionEntry1( aTraceName, aInstance )
   1.641 +#define OstTraceFunctionEntryExt(aTraceName, aInstance)
   1.642 +#define OstTraceFunctionExit0( aTraceName )
   1.643 +#define OstTraceFunctionExit1( aTraceName, aInstance )
   1.644 +#define OstTraceEventStart0( aTraceName, aEventName )
   1.645 +#define OstTraceEventStart1( aTraceName, aEventName, aParam )
   1.646 +#define OstTraceFunctionExitExt(aTraceName, aInstance, aRetval)
   1.647 +#define OstTraceEventStop( aTraceName, aEventName, aStartTraceName )
   1.648 +#define OstTraceState0( aTraceName, aStateName, aNewState )
   1.649 +#define OstTraceState1( aTraceName, aStateName, aNewState, aInstance )
   1.650 +
   1.651 +#endif // OST_TRACE_COMPILER_IN_USE
   1.652 +
   1.653 +
   1.654 +// Data types
   1.655 +
   1.656 +/**
   1.657 +BTrace sub-category IDs for OpenSystemTrace category
   1.658 +*/
   1.659 +enum TSubcategoryOpenSystemTrace
   1.660 +    {
   1.661 +    /**
   1.662 +     * Normal trace
   1.663 +     */
   1.664 +    EOstTrace                   = 0,
   1.665 +
   1.666 +    /**
   1.667 +     * Queries if trace is active without sending it
   1.668 +     */
   1.669 +    EOstTraceActivationQuery    = 1
   1.670 +    };
   1.671 +
   1.672 +// Forward declarations
   1.673 +
   1.674 +/**
   1.675 +Template class for array parameter types
   1.676 +For example, to wrap an integer array to a trace:
   1.677 +TInt arr[5];
   1.678 +OstTraceExt( GRP, TRC, "Array: %{int32[]}", TOstArray< TInt >( arr, 5 ) );
   1.679 +*/
   1.680 +template< class T >
   1.681 +class TOstArray
   1.682 +    {
   1.683 +public:
   1.684 +    /**
   1.685 +     * Constructor
   1.686 +     *
   1.687 +     * @param aArray the array data
   1.688 +     * @param aLength the number of elements in the array
   1.689 +     */
   1.690 +    TOstArray( const T* aArray, TInt aLength ) : iArray( aArray ), iLength( aLength ) {}
   1.691 +
   1.692 +    /**
   1.693 +     * Gets the array data pointer.
   1.694 +     * Used from the functions generated by trace compiler
   1.695 +     * 
   1.696 +     * @return The array data pointer.
   1.697 +     */
   1.698 +    const T* Ptr() const { return iArray; }
   1.699 +
   1.700 +    /**
   1.701 +     * Gets the number of elements in the array.
   1.702 +     * Used from the functions generated by trace compiler
   1.703 +     * 
   1.704 +     * @return The number of elements in the array.
   1.705 +     */
   1.706 +    TInt Length() const { return iLength; }
   1.707 +
   1.708 +    /**
   1.709 +     * Gets the number of bytes occupied by the array.
   1.710 +     * Used from the functions generated by trace compiler
   1.711 +     * 
   1.712 +     * @return The number of bytes occupied by the array.
   1.713 +     */
   1.714 +    TInt Size() const { return sizeof( T ) * iLength; }
   1.715 +
   1.716 +private:
   1.717 +    /**
   1.718 +     * Array data
   1.719 +     */
   1.720 +    const T* iArray;
   1.721 +
   1.722 +    /**
   1.723 +     * Array length, as number of elements
   1.724 +     */
   1.725 +    TInt iLength;
   1.726 +    };
   1.727 +
   1.728 +
   1.729 +// Class declaration
   1.730 +
   1.731 +#endif //OPENSYSTEMTRACEV2_H