os/kernelhwsrv/kernel/eka/include/opensystemtrace.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Trace API
sl@0
    15
//
sl@0
    16
sl@0
    17
#ifndef OPENSYSTEMTRACEV2_H
sl@0
    18
#define OPENSYSTEMTRACEV2_H
sl@0
    19
sl@0
    20
#include <opensystemtrace_types.h>
sl@0
    21
sl@0
    22
sl@0
    23
/**
sl@0
    24
Methods for tracing from user side.
sl@0
    25
sl@0
    26
These methods are used to output trace packets.
sl@0
    27
Each trace packet consists of attributes and the user defined payload.
sl@0
    28
sl@0
    29
In order to output trace packets, tracing needs to be
sl@0
    30
included and enabled at compile time in the executable,
sl@0
    31
as well as be filtered at run-time.
sl@0
    32
sl@0
    33
Note:
sl@0
    34
OSTv2 does not enforce any security. It is the developer's responsibility
sl@0
    35
to ensure that trace packets do not contain any sensitive information that
sl@0
    36
may undermine platform security.
sl@0
    37
sl@0
    38
@file
sl@0
    39
@publishedPartner
sl@0
    40
@prototype
sl@0
    41
*/
sl@0
    42
sl@0
    43
/**
sl@0
    44
Class used to encapsulate the context of a trace point.
sl@0
    45
For more information about the attributes please @see opensystemtrace_types.h.
sl@0
    46
sl@0
    47
The attributes in @see TTraceContext are used to identify and filter the trace packet.
sl@0
    48
@see opensystemtrace.mmh
sl@0
    49
@see RUlogger for information on how to filter at run-time
sl@0
    50
sl@0
    51
@deprecated
sl@0
    52
*/
sl@0
    53
NONSHARABLE_CLASS(TTraceContext)
sl@0
    54
    {
sl@0
    55
public:
sl@0
    56
    inline TTraceContext(const TGroupId aGroupId);
sl@0
    57
    inline TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
sl@0
    58
sl@0
    59
    inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId);
sl@0
    60
    inline TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
sl@0
    61
sl@0
    62
    IMPORT_C TComponentId               ComponentId() const;
sl@0
    63
    IMPORT_C TClassification            Classification() const;
sl@0
    64
    IMPORT_C TGroupId                   GroupId() const;
sl@0
    65
    IMPORT_C THasThreadIdentification   HasThreadIdentification() const;
sl@0
    66
    IMPORT_C THasProgramCounter         HasProgramCounter() const;
sl@0
    67
    IMPORT_C static TComponentId        DefaultComponentId();
sl@0
    68
private:
sl@0
    69
    inline TTraceContext(){};
sl@0
    70
private:
sl@0
    71
    TComponentId                iComponentId;               ///<@see TComponentId
sl@0
    72
    TGroupId                    iGroupId;                   ///<@see TGroupId
sl@0
    73
    THasThreadIdentification    iHasThreadIdentification;   ///<@see THasThreadIdentification
sl@0
    74
    THasProgramCounter          iHasProgramCounter;         ///<@see THasProgramCounter
sl@0
    75
    TUint32                     iReserved1;                 //Reserved for future use
sl@0
    76
    TUint32                     iReserved2;                 //Reserved for future use
sl@0
    77
    };
sl@0
    78
sl@0
    79
	IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC8& aDes);
sl@0
    80
    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, const char* aFmt, ...);
sl@0
    81
    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC8> aFmt,...);
sl@0
    82
    #ifndef  __KERNEL_MODE__
sl@0
    83
    IMPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes);
sl@0
    84
    IMPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC16> aFmt,...);
sl@0
    85
    #endif //__KERNEL_MODE__
sl@0
    86
sl@0
    87
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId);
sl@0
    88
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint8 aData);
sl@0
    89
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint16 aData);
sl@0
    90
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData);
sl@0
    91
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint32 aData1, const TUint32 aData2);
sl@0
    92
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC8& aData);
sl@0
    93
    #ifndef __KERNEL_MODE__
sl@0
    94
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC16& aData);
sl@0
    95
    #endif
sl@0
    96
    template<typename T>
sl@0
    97
    static inline TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const T& aData);
sl@0
    98
    IMPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TAny* aData, const TInt aDataSize);
sl@0
    99
sl@0
   100
    IMPORT_C TBool IsTraceActive(const TTraceContext& aContext);
sl@0
   101
sl@0
   102
sl@0
   103
/**
sl@0
   104
The following trace APIs require a TraceCompiler to be present in the build system. 
sl@0
   105
This TraceCompiler is used to generate additional information for each trace point 
sl@0
   106
in order for traces to be generated at runtime.
sl@0
   107
*/
sl@0
   108
sl@0
   109
#include <opensystemtrace.inl>
sl@0
   110
sl@0
   111
// Macros
sl@0
   112
sl@0
   113
/**
sl@0
   114
Preprocessor category for all traces off.
sl@0
   115
This should not be used from traces
sl@0
   116
*/
sl@0
   117
#define OST_TRACE_CATEGORY_NONE 0x00000000
sl@0
   118
sl@0
   119
/**
sl@0
   120
Preprocessor category for production traces
sl@0
   121
*/
sl@0
   122
#define OST_TRACE_CATEGORY_PRODUCTION 0x00000001
sl@0
   123
sl@0
   124
/**
sl@0
   125
Preprocessor category for RnD traces
sl@0
   126
*/
sl@0
   127
#define OST_TRACE_CATEGORY_RND 0x00000002
sl@0
   128
sl@0
   129
/**
sl@0
   130
Preprocessor category for performance measurement traces
sl@0
   131
*/
sl@0
   132
#define OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT 0x00000004
sl@0
   133
sl@0
   134
/**
sl@0
   135
Preprocessor level for all traces on.
sl@0
   136
This should not be used from traces
sl@0
   137
*/
sl@0
   138
#define OST_TRACE_CATEGORY_ALL 0xFFFFFFFF
sl@0
   139
sl@0
   140
sl@0
   141
/**
sl@0
   142
A flag, which specifies if the compiler has been run for the component
sl@0
   143
*/
sl@0
   144
#if defined( OST_TRACE_COMPILER_IN_USE )
sl@0
   145
sl@0
   146
sl@0
   147
/**
sl@0
   148
The default preprocessor category is RND
sl@0
   149
Component may override this by defining
sl@0
   150
OST_TRACE_CATEGORY before including this file
sl@0
   151
*/
sl@0
   152
#if !defined( OST_TRACE_CATEGORY )
sl@0
   153
#define OST_TRACE_CATEGORY OST_TRACE_CATEGORY_RND
sl@0
   154
#endif
sl@0
   155
sl@0
   156
/**
sl@0
   157
Trace with no parameters
sl@0
   158
sl@0
   159
@param aCategory Preprocessor category for the trace
sl@0
   160
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   161
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   162
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   163
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   164
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   165
                  The text itself is not sent in the trace packet
sl@0
   166
*/
sl@0
   167
#define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText ) \
sl@0
   168
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   169
    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   170
                        EOstTrace, \
sl@0
   171
                        KOstTraceComponentID, \
sl@0
   172
                        aTraceName );} while (0)
sl@0
   173
sl@0
   174
sl@0
   175
/**
sl@0
   176
Trace with one 32-bit parameter
sl@0
   177
sl@0
   178
@param aCategory Preprocessor category for the trace
sl@0
   179
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   180
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   181
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   182
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   183
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   184
                  The text itself is not sent in the trace packet
sl@0
   185
@param aParam The 32-bit value to be traced
sl@0
   186
*/
sl@0
   187
#define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
sl@0
   188
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   189
    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   190
                         EOstTrace, \
sl@0
   191
                         KOstTraceComponentID, \
sl@0
   192
                         aTraceName, \
sl@0
   193
                         aParam );} while (0)
sl@0
   194
sl@0
   195
sl@0
   196
/**
sl@0
   197
Trace with more than 32 bits of data
sl@0
   198
sl@0
   199
@param aCategory Preprocessor category for the trace
sl@0
   200
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   201
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   202
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   203
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   204
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   205
                  The text itself is not sent in the trace packet
sl@0
   206
@param aPtr Pointer to the data to be traced
sl@0
   207
@param aLength Length of the data to be traced
sl@0
   208
*/
sl@0
   209
#define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
sl@0
   210
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   211
        OstSendNBytes( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   212
                       EOstTrace, \
sl@0
   213
                       KOstTraceComponentID, \
sl@0
   214
                       aTraceName, \
sl@0
   215
                       aPtr, \
sl@0
   216
                       aLength );} while (0)
sl@0
   217
sl@0
   218
sl@0
   219
/**
sl@0
   220
Trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
sl@0
   221
which is generated by the trace compiler. The generated function will pack the
sl@0
   222
parameter into a stack-allocated buffer and call OstTraceData with the buffer.
sl@0
   223
sl@0
   224
@param aCategory Preprocessor category for the trace
sl@0
   225
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   226
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   227
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   228
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   229
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   230
                  The text itself is not sent in the trace packet
sl@0
   231
@param aParam The parameter to be traced
sl@0
   232
*/
sl@0
   233
#define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam ) \
sl@0
   234
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   235
        OstTraceGen1( aTraceName, aParam );} while (0)
sl@0
   236
sl@0
   237
sl@0
   238
/**
sl@0
   239
Trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
sl@0
   240
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   241
call OstTraceData with the buffer.
sl@0
   242
sl@0
   243
@param aCategory Preprocessor category for the trace
sl@0
   244
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   245
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   246
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   247
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   248
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   249
                  The text itself is not sent in the trace packet
sl@0
   250
@param aParam1 The first parameter to be traced
sl@0
   251
@param aParam2 The second parameter to be traced
sl@0
   252
*/
sl@0
   253
#define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
sl@0
   254
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   255
        OstTraceGen2( aTraceName, aParam1, aParam2 );} while (0)
sl@0
   256
sl@0
   257
sl@0
   258
/**
sl@0
   259
Trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
sl@0
   260
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   261
call OstTraceData with the buffer.
sl@0
   262
sl@0
   263
@param aCategory Preprocessor category for the trace
sl@0
   264
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   265
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   266
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   267
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   268
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   269
                  The text itself is not sent in the trace packet
sl@0
   270
@param aParam1 The first parameter to be traced
sl@0
   271
@param aParam2 The second parameter to be traced
sl@0
   272
@param aParam3 The third parameter to be traced
sl@0
   273
*/
sl@0
   274
#define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
sl@0
   275
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   276
        OstTraceGen3( aTraceName, aParam1, aParam2, aParam3 );} while (0)
sl@0
   277
sl@0
   278
sl@0
   279
/**
sl@0
   280
Trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
sl@0
   281
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   282
call OstTraceData with the buffer.
sl@0
   283
sl@0
   284
@param aCategory Preprocessor category for the trace
sl@0
   285
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   286
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   287
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   288
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   289
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   290
                  The text itself is not sent in the trace packet
sl@0
   291
@param aParam1 The first parameter to be traced
sl@0
   292
@param aParam2 The second parameter to be traced
sl@0
   293
@param aParam3 The third parameter to be traced
sl@0
   294
@param aParam4 The fourth parameter to be traced
sl@0
   295
*/
sl@0
   296
#define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
sl@0
   297
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   298
        OstTraceGen4( aTraceName, aParam1, aParam2, aParam3, aParam4 );} while (0)
sl@0
   299
sl@0
   300
sl@0
   301
/**
sl@0
   302
Trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
sl@0
   303
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   304
call OstTraceData with the buffer.
sl@0
   305
sl@0
   306
@param aCategory Preprocessor category for the trace
sl@0
   307
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   308
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   309
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   310
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   311
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   312
                  The text itself is not sent in the trace packet
sl@0
   313
@param aParam1 The first parameter to be traced
sl@0
   314
@param aParam2 The second parameter to be traced
sl@0
   315
@param aParam3 The third parameter to be traced
sl@0
   316
@param aParam4 The fourth parameter to be traced
sl@0
   317
@param aParam5 The fifth parameter to be traced
sl@0
   318
*/
sl@0
   319
#define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
sl@0
   320
    do {if ( aCategory & OST_TRACE_CATEGORY ) \
sl@0
   321
        OstTraceGen5( aTraceName, aParam1, aParam2, aParam3, aParam4, aParam5 );} while (0)
sl@0
   322
sl@0
   323
sl@0
   324
/**
sl@0
   325
*************** Trace macros which use RnD as default preprocessor category ***************
sl@0
   326
*/
sl@0
   327
sl@0
   328
/**
sl@0
   329
RnD trace with no parameters
sl@0
   330
sl@0
   331
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   332
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   333
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   334
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   335
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   336
                  The text itself is not sent in the trace packet
sl@0
   337
*/
sl@0
   338
#define OstTrace0( aGroupName, aTraceName, aTraceText ) \
sl@0
   339
    OstTraceDef0( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText )
sl@0
   340
sl@0
   341
sl@0
   342
/**
sl@0
   343
RnD trace with one 32-bit parameter
sl@0
   344
sl@0
   345
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   346
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   347
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   348
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   349
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   350
                  The text itself is not sent in the trace packet
sl@0
   351
@param aParam The 32-bit value to be traced
sl@0
   352
*/
sl@0
   353
#define OstTrace1( aGroupName, aTraceName, aTraceText, aParam ) \
sl@0
   354
    OstTraceDef1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
sl@0
   355
sl@0
   356
sl@0
   357
/**
sl@0
   358
RnD trace with more than 32 bits of data
sl@0
   359
sl@0
   360
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   361
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   362
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   363
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   364
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   365
                  The text itself is not sent in the trace packet
sl@0
   366
@param aPtr Pointer to the data to be traced
sl@0
   367
@param aLength Length of the data to be traced
sl@0
   368
*/
sl@0
   369
#define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength ) \
sl@0
   370
    OstTraceDefData( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aPtr, aLength )
sl@0
   371
sl@0
   372
sl@0
   373
/**
sl@0
   374
RnD trace with one parameter that is not 32-bit integer. This calls OstTraceGen1,
sl@0
   375
which is generated by the trace compiler. The generated function will pack the
sl@0
   376
parameter into a stack-allocated buffer and call OstTraceData with the buffer.
sl@0
   377
sl@0
   378
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   379
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   380
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   381
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   382
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   383
                  The text itself is not sent in the trace packet
sl@0
   384
@param aParam The parameter to be traced
sl@0
   385
*/
sl@0
   386
#define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam ) \
sl@0
   387
    OstTraceDefExt1( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam )
sl@0
   388
sl@0
   389
sl@0
   390
/**
sl@0
   391
RnD trace with two parameters. This calls OstTraceGen2, which is generated by trace compiler.
sl@0
   392
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   393
call OstTraceData with the buffer.
sl@0
   394
sl@0
   395
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   396
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   397
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   398
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   399
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   400
                  The text itself is not sent in the trace packet
sl@0
   401
@param aParam1 The first parameter to be traced
sl@0
   402
@param aParam2 The second parameter to be traced
sl@0
   403
*/
sl@0
   404
#define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 ) \
sl@0
   405
    OstTraceDefExt2( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
sl@0
   406
sl@0
   407
sl@0
   408
/**
sl@0
   409
RnD trace with three parameters. This calls OstTraceGen3, which is generated by trace compiler.
sl@0
   410
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   411
call OstTraceData with the buffer.
sl@0
   412
sl@0
   413
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   414
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   415
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   416
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   417
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   418
                  The text itself is not sent in the trace packet
sl@0
   419
@param aParam1 The first parameter to be traced
sl@0
   420
@param aParam2 The second parameter to be traced
sl@0
   421
@param aParam3 The third parameter to be traced
sl@0
   422
*/
sl@0
   423
#define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 ) \
sl@0
   424
    OstTraceDefExt3( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
sl@0
   425
sl@0
   426
sl@0
   427
/**
sl@0
   428
RnD trace with four parameters. This calls OstTraceGen4, which is generated by trace compiler.
sl@0
   429
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   430
call OstTraceData with the buffer.
sl@0
   431
sl@0
   432
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   433
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   434
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   435
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   436
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   437
                  The text itself is not sent in the trace packet
sl@0
   438
@param aParam1 The first parameter to be traced
sl@0
   439
@param aParam2 The second parameter to be traced
sl@0
   440
@param aParam3 The third parameter to be traced
sl@0
   441
@param aParam4 The fourth parameter to be traced
sl@0
   442
*/
sl@0
   443
#define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 ) \
sl@0
   444
    OstTraceDefExt4( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
sl@0
   445
sl@0
   446
sl@0
   447
/**
sl@0
   448
RnD trace with five parameters. This calls OstTraceGen5, which is generated by trace compiler.
sl@0
   449
The generated function will pack the parameters into a stack-allocated buffer and
sl@0
   450
call OstTraceData with the buffer.
sl@0
   451
sl@0
   452
@param aGroupName Name of the trace group. Trace Compiler associates the group name with a 16-bit integer.
sl@0
   453
                  Then, it combines the group name with a unique trace id (16-bit integer) to produce the trace name
sl@0
   454
                  (aTraceName 32-bit integer). Only the trace name is sent in the trace packet.
sl@0
   455
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   456
@param aTraceText The trace text, which is parsed by the trace compiler.
sl@0
   457
                  The text itself is not sent in the trace packet
sl@0
   458
@param aParam1 The first parameter to be traced
sl@0
   459
@param aParam2 The second parameter to be traced
sl@0
   460
@param aParam3 The third parameter to be traced
sl@0
   461
@param aParam4 The fourth parameter to be traced
sl@0
   462
@param aParam5 The fifth parameter to be traced
sl@0
   463
*/
sl@0
   464
#define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 ) \
sl@0
   465
    OstTraceDefExt5( OST_TRACE_CATEGORY_RND, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
sl@0
   466
sl@0
   467
sl@0
   468
/**
sl@0
   469
Function entry trace without extra parameters.
sl@0
   470
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   471
sl@0
   472
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   473
*/
sl@0
   474
#define OstTraceFunctionEntry0( aTraceName ) \
sl@0
   475
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   476
    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   477
                        EOstTrace, \
sl@0
   478
                        KOstTraceComponentID, \
sl@0
   479
                        aTraceName );} while (0)
sl@0
   480
sl@0
   481
sl@0
   482
/**
sl@0
   483
Function entry trace with a parameter representing the instance identifier.
sl@0
   484
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   485
sl@0
   486
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   487
@param aInstance The instance identifier, for example "this" pointer
sl@0
   488
*/
sl@0
   489
#define OstTraceFunctionEntry1( aTraceName, aInstance ) \
sl@0
   490
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   491
    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   492
                         EOstTrace, \
sl@0
   493
                         KOstTraceComponentID, \
sl@0
   494
                         aTraceName, \
sl@0
   495
                         (TUint32) aInstance );} while (0)
sl@0
   496
sl@0
   497
sl@0
   498
/**
sl@0
   499
Function entry trace, which traces function parameters.
sl@0
   500
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   501
sl@0
   502
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   503
@param aInstance Name of the instance identifier
sl@0
   504
*/
sl@0
   505
#define OstTraceFunctionEntryExt( aTraceName, aInstance ) \
sl@0
   506
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   507
        OstTraceGenExt( aTraceName, ( TUint )aInstance );} while (0)
sl@0
   508
sl@0
   509
sl@0
   510
/**
sl@0
   511
Function exit trace without extra parameters.
sl@0
   512
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   513
sl@0
   514
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   515
*/
sl@0
   516
#define OstTraceFunctionExit0( aTraceName ) \
sl@0
   517
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   518
    BTraceFilteredContext8( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   519
                        EOstTrace, \
sl@0
   520
                        KOstTraceComponentID, \
sl@0
   521
                        aTraceName );} while (0)
sl@0
   522
sl@0
   523
sl@0
   524
/**
sl@0
   525
Function exit trace with a parameter representing the instance identifier.
sl@0
   526
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   527
sl@0
   528
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   529
@param aInstance The instance identifier, for example "this" pointer
sl@0
   530
*/
sl@0
   531
#define OstTraceFunctionExit1( aTraceName, aInstance ) \
sl@0
   532
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   533
    BTraceFilteredContext12( EXTRACT_GROUP_ID(aTraceName), \
sl@0
   534
                         EOstTrace, \
sl@0
   535
                         KOstTraceComponentID, \
sl@0
   536
                         aTraceName, \
sl@0
   537
                         (TUint32) aInstance );} while (0)
sl@0
   538
sl@0
   539
sl@0
   540
/**
sl@0
   541
Function exit trace with a parameters representing the instance identifier and return value.
sl@0
   542
The trace is mapped to TRACE_FLOW or TRACE_API group by the trace compiler
sl@0
   543
sl@0
   544
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   545
@param aInstance The instance identifier, for example "this" pointer
sl@0
   546
@param aRetval The function return value
sl@0
   547
*/
sl@0
   548
#define OstTraceFunctionExitExt( aTraceName, aInstance, aRetval ) \
sl@0
   549
    do {if ( OST_TRACE_CATEGORY_RND & OST_TRACE_CATEGORY ) \
sl@0
   550
        OstTraceGen2( aTraceName, ( TUint )aInstance, aRetval );} while (0)
sl@0
   551
sl@0
   552
sl@0
   553
/**
sl@0
   554
Performance measurement event start trace without extra parameters.
sl@0
   555
The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
sl@0
   556
sl@0
   557
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   558
@param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
sl@0
   559
*/
sl@0
   560
#define OstTraceEventStart0( aTraceName, aEventName ) \
sl@0
   561
        OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)1 )
sl@0
   562
sl@0
   563
sl@0
   564
/**
sl@0
   565
Performance measurement event start trace with single 32-bit parameter.
sl@0
   566
The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
sl@0
   567
sl@0
   568
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   569
@param aEventName The name of the event. A corresponding OstTraceEventStop call must be made later in code
sl@0
   570
@param aParam The parameter to be associated to the event
sl@0
   571
*/
sl@0
   572
#define OstTraceEventStart1( aTraceName, aEventName, aParam ) \
sl@0
   573
        OstTraceDef1( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, aParam )
sl@0
   574
sl@0
   575
sl@0
   576
/**
sl@0
   577
Performance measurement event end trace.
sl@0
   578
The trace is mapped to TRACE_PERFORMANCE group by the trace compiler
sl@0
   579
sl@0
   580
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   581
@param aEventName The name of the event. Must match a name passed to OstTraceEventStart
sl@0
   582
@param aStartTraceName Event start trace name. Must match a Trace Name of OstTraceEventStart trace
sl@0
   583
*/
sl@0
   584
#define OstTraceEventStop( aTraceName, aEventName, aStartTraceName ) \
sl@0
   585
        OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_PERFORMANCE", aTraceName, null, (TInt32)0, (TUint32)(aStartTraceName & 0xFFFF) ) 
sl@0
   586
sl@0
   587
sl@0
   588
/**
sl@0
   589
State transition event.
sl@0
   590
The trace is mapped to TRACE_STATE group by the trace compiler
sl@0
   591
sl@0
   592
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   593
@param aStateName The name of the state, literal string (for example "name")
sl@0
   594
@param aNewState The new value for the state, literal string (for example "value")
sl@0
   595
*/
sl@0
   596
#define OstTraceState0( aTraceName, aStateName, aNewState ) \
sl@0
   597
        OstTraceDefExt2( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState) ) 
sl@0
   598
sl@0
   599
sl@0
   600
/**
sl@0
   601
State transition event with instance identifier.
sl@0
   602
The trace is mapped to TRACE_STATE group by the trace compiler
sl@0
   603
sl@0
   604
@param aTraceName Name of the trace. The name is mapped to a 32-bit identifier and thus must be unique
sl@0
   605
@param aStateName The name of the state, literal string (for example "name")
sl@0
   606
@param aNewState The new value for the state, literal string (for example "value")
sl@0
   607
@param aInstance The instance identifier, for example "this" pointer
sl@0
   608
*/
sl@0
   609
#define OstTraceState1( aTraceName, aStateName, aNewState, aInstance ) \
sl@0
   610
        OstTraceDefExt3( OST_TRACE_CATEGORY_RND, "TRACE_STATE", aTraceName, null, _L8(aStateName), _L8(aNewState), (TUint32) aInstance ) 
sl@0
   611
       
sl@0
   612
#else // OST_TRACE_COMPILER_IN_USE
sl@0
   613
sl@0
   614
/**
sl@0
   615
API is defined empty if the trace compiler has not been run
sl@0
   616
*/
sl@0
   617
sl@0
   618
#define OstTraceDef0( aCategory, aGroupName, aTraceName, aTraceText )
sl@0
   619
#define OstTraceDef1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
sl@0
   620
#define OstTraceDefData( aCategory, aGroupName, aTraceName, aTraceText, aPtr, aLength )
sl@0
   621
#define OstTraceDefExt1( aCategory, aGroupName, aTraceName, aTraceText, aParam )
sl@0
   622
#define OstTraceDefExt2( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
sl@0
   623
#define OstTraceDefExt3( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
sl@0
   624
#define OstTraceDefExt4( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
sl@0
   625
#define OstTraceDefExt5( aCategory, aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
sl@0
   626
sl@0
   627
#define OstTrace0( aGroupName, aTraceName, aTraceText )
sl@0
   628
#define OstTrace1( aGroupName, aTraceName, aTraceText, aParam )
sl@0
   629
#define OstTraceData( aGroupName, aTraceName, aTraceText, aPtr, aLength )
sl@0
   630
#define OstTraceExt1( aGroupName, aTraceName, aTraceText, aParam )
sl@0
   631
#define OstTraceExt2( aGroupName, aTraceName, aTraceText, aParam1, aParam2 )
sl@0
   632
#define OstTraceExt3( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3 )
sl@0
   633
#define OstTraceExt4( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4 )
sl@0
   634
#define OstTraceExt5( aGroupName, aTraceName, aTraceText, aParam1, aParam2, aParam3, aParam4, aParam5 )
sl@0
   635
sl@0
   636
#define OstTraceFunctionEntry0( aTraceName )
sl@0
   637
#define OstTraceFunctionEntry1( aTraceName, aInstance )
sl@0
   638
#define OstTraceFunctionEntryExt(aTraceName, aInstance)
sl@0
   639
#define OstTraceFunctionExit0( aTraceName )
sl@0
   640
#define OstTraceFunctionExit1( aTraceName, aInstance )
sl@0
   641
#define OstTraceEventStart0( aTraceName, aEventName )
sl@0
   642
#define OstTraceEventStart1( aTraceName, aEventName, aParam )
sl@0
   643
#define OstTraceFunctionExitExt(aTraceName, aInstance, aRetval)
sl@0
   644
#define OstTraceEventStop( aTraceName, aEventName, aStartTraceName )
sl@0
   645
#define OstTraceState0( aTraceName, aStateName, aNewState )
sl@0
   646
#define OstTraceState1( aTraceName, aStateName, aNewState, aInstance )
sl@0
   647
sl@0
   648
#endif // OST_TRACE_COMPILER_IN_USE
sl@0
   649
sl@0
   650
sl@0
   651
// Data types
sl@0
   652
sl@0
   653
/**
sl@0
   654
BTrace sub-category IDs for OpenSystemTrace category
sl@0
   655
*/
sl@0
   656
enum TSubcategoryOpenSystemTrace
sl@0
   657
    {
sl@0
   658
    /**
sl@0
   659
     * Normal trace
sl@0
   660
     */
sl@0
   661
    EOstTrace                   = 0,
sl@0
   662
sl@0
   663
    /**
sl@0
   664
     * Queries if trace is active without sending it
sl@0
   665
     */
sl@0
   666
    EOstTraceActivationQuery    = 1
sl@0
   667
    };
sl@0
   668
sl@0
   669
// Forward declarations
sl@0
   670
sl@0
   671
/**
sl@0
   672
Template class for array parameter types
sl@0
   673
For example, to wrap an integer array to a trace:
sl@0
   674
TInt arr[5];
sl@0
   675
OstTraceExt( GRP, TRC, "Array: %{int32[]}", TOstArray< TInt >( arr, 5 ) );
sl@0
   676
*/
sl@0
   677
template< class T >
sl@0
   678
class TOstArray
sl@0
   679
    {
sl@0
   680
public:
sl@0
   681
    /**
sl@0
   682
     * Constructor
sl@0
   683
     *
sl@0
   684
     * @param aArray the array data
sl@0
   685
     * @param aLength the number of elements in the array
sl@0
   686
     */
sl@0
   687
    TOstArray( const T* aArray, TInt aLength ) : iArray( aArray ), iLength( aLength ) {}
sl@0
   688
sl@0
   689
    /**
sl@0
   690
     * Gets the array data pointer.
sl@0
   691
     * Used from the functions generated by trace compiler
sl@0
   692
     * 
sl@0
   693
     * @return The array data pointer.
sl@0
   694
     */
sl@0
   695
    const T* Ptr() const { return iArray; }
sl@0
   696
sl@0
   697
    /**
sl@0
   698
     * Gets the number of elements in the array.
sl@0
   699
     * Used from the functions generated by trace compiler
sl@0
   700
     * 
sl@0
   701
     * @return The number of elements in the array.
sl@0
   702
     */
sl@0
   703
    TInt Length() const { return iLength; }
sl@0
   704
sl@0
   705
    /**
sl@0
   706
     * Gets the number of bytes occupied by the array.
sl@0
   707
     * Used from the functions generated by trace compiler
sl@0
   708
     * 
sl@0
   709
     * @return The number of bytes occupied by the array.
sl@0
   710
     */
sl@0
   711
    TInt Size() const { return sizeof( T ) * iLength; }
sl@0
   712
sl@0
   713
private:
sl@0
   714
    /**
sl@0
   715
     * Array data
sl@0
   716
     */
sl@0
   717
    const T* iArray;
sl@0
   718
sl@0
   719
    /**
sl@0
   720
     * Array length, as number of elements
sl@0
   721
     */
sl@0
   722
    TInt iLength;
sl@0
   723
    };
sl@0
   724
sl@0
   725
sl@0
   726
// Class declaration
sl@0
   727
sl@0
   728
#endif //OPENSYSTEMTRACEV2_H