0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Trace API
|
|
15 |
//
|
|
16 |
|
|
17 |
#ifndef E32UTRACE_H
|
|
18 |
#define E32UTRACE_H
|
|
19 |
|
|
20 |
#include <e32utrace_basic_types.h>
|
|
21 |
|
|
22 |
|
|
23 |
/**
|
|
24 |
Methods for tracing from user and kernel side.
|
|
25 |
|
|
26 |
These methods are used to output trace packets.
|
|
27 |
Each trace packet consist of attributes and the user defined payload.
|
|
28 |
The attributes in @see TTraceContext is used to identify and filter the trace packet.
|
|
29 |
|
|
30 |
In order to output trace packets tracing needs to be
|
|
31 |
included and enabled at compile time in the executable,
|
|
32 |
as well as be filtered at run-time.
|
|
33 |
@see e32utrace.mmh
|
|
34 |
@see RUlogger for information on how to filter at run-time
|
|
35 |
|
|
36 |
Trace example:
|
|
37 |
|
|
38 |
To include tracing you need to include the e32utrace.mmh
|
|
39 |
in your executables mmp file. You also need to enable tracing at
|
|
40 |
build time, which you do by defining the
|
|
41 |
SYMBIAN_INCLUDE_EXECUTABLE_TRACE before the mmh is included.
|
|
42 |
|
|
43 |
@code
|
|
44 |
#define SYMBIAN_INCLUDE_EXECUTABLE_TRACE
|
|
45 |
#include <e32utrace.mmh>
|
|
46 |
@endcode
|
|
47 |
|
|
48 |
Example usage of UTrace:
|
|
49 |
|
|
50 |
@code
|
|
51 |
#include <e32utf.h>
|
|
52 |
using namespace UTF;
|
|
53 |
|
|
54 |
TInt E32Main()
|
|
55 |
{
|
|
56 |
TFormatId formatId = TMyAppFormatExample::KFilePrintfStringLookupId;
|
|
57 |
TUint32 myData = SomeData();
|
|
58 |
|
|
59 |
//One line trace examples
|
|
60 |
Printf(TTraceContext(EError), "My data %d.", myData);
|
|
61 |
Printf(TTraceContext(KMyModuleUid, EError), "My data %d.", myData);
|
|
62 |
Printf(TTraceContext(EError, ENoThreadIdentification, ENoProgramCounter), "My data %d.", myData);
|
|
63 |
|
|
64 |
//In case Printf is overloaded
|
|
65 |
UTF::Printf(TTraceContext(EError), "My data %d.", myData);
|
|
66 |
|
|
67 |
//Using default ModuleUid, i.e. UID3
|
|
68 |
TTraceContext context(EError);
|
|
69 |
if(WouldBeTracedNow(context))
|
|
70 |
{
|
|
71 |
Printf(context, "My data %d.", myData);
|
|
72 |
Trace(context, formatId, myData);
|
|
73 |
}
|
|
74 |
|
|
75 |
//Setting the default ModuleUid to something other than UID3
|
|
76 |
#define EXECUTABLE_DEFAULT_MODULEUID 0x00210D3B
|
|
77 |
TTraceContext otherDefault(EError);
|
|
78 |
if(WouldBeTracedNow(otherDefault))
|
|
79 |
{
|
|
80 |
Printf(otherDefault, "My data %i.", myData);
|
|
81 |
Trace(otherDefault, formatId, myData);
|
|
82 |
}
|
|
83 |
|
|
84 |
//Setting different ModuleUid for each trace point
|
|
85 |
static const TModuleUid KTelephony = 0x00210D3B;
|
|
86 |
static const TModuleUid KConnectivity = 0x0039399A;
|
|
87 |
TTraceContext telephony(KTelephony, ECallControl);
|
|
88 |
TTraceContext connectivity(KConnectivity, EBluetooth);
|
|
89 |
if(WouldBeTracedNow(telephony))
|
|
90 |
{
|
|
91 |
Printf(telephony, "My data %i.", myData);
|
|
92 |
}
|
|
93 |
if(WouldBeTracedNow(connectivity))
|
|
94 |
{
|
|
95 |
Printf(connectivity, "My data %i.", myData);
|
|
96 |
}
|
|
97 |
|
|
98 |
//Don't add the thread identification into the trace packet
|
|
99 |
TTraceContext noThreadIdentifier(EError, ENoThreadIdentification, ENoProgramCounter);
|
|
100 |
if(WouldBeTracedNow(noThreadIdentifier))
|
|
101 |
{
|
|
102 |
Printf(noThreadIdentifier, "My data %i.", myData);
|
|
103 |
Trace(noThreadIdentifier, formatId, myData);
|
|
104 |
}
|
|
105 |
|
|
106 |
return KErrNone;
|
|
107 |
}
|
|
108 |
|
|
109 |
@endcode
|
|
110 |
|
|
111 |
|
|
112 |
Note:
|
|
113 |
UTrace does not enforce any security. It is the developer's responsibility
|
|
114 |
to ensure that trace packets do not contain any sensitive information that
|
|
115 |
may undermine platform security.
|
|
116 |
|
|
117 |
@file
|
|
118 |
@publishedPartner
|
|
119 |
@prototype
|
|
120 |
*/
|
|
121 |
namespace UTF
|
|
122 |
{
|
|
123 |
/**
|
|
124 |
Class used to encapsulate the context of a trace point.
|
|
125 |
For more information about the attributes please @see e32utrace_basic_types.h.
|
|
126 |
*/
|
|
127 |
NONSHARABLE_CLASS(TTraceContext)
|
|
128 |
{
|
|
129 |
public:
|
|
130 |
inline TTraceContext(const TClassification aClassification);
|
|
131 |
inline TTraceContext(const TClassification aClassification, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
|
|
132 |
|
|
133 |
inline TTraceContext(const TModuleUid aModuleUid, const TClassification aClassification);
|
|
134 |
inline TTraceContext(const TModuleUid aModuleUid, const TClassification aClassification, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
|
|
135 |
|
|
136 |
IMPORT_C TModuleUid ModuleUid() const;
|
|
137 |
IMPORT_C TClassification Classification() const;
|
|
138 |
IMPORT_C THasThreadIdentification HasThreadIdentification() const;
|
|
139 |
IMPORT_C THasProgramCounter HasProgramCounter() const;
|
|
140 |
IMPORT_C static TModuleUid DefaultModuleUid();
|
|
141 |
private:
|
|
142 |
inline TTraceContext(){};
|
|
143 |
private:
|
|
144 |
TModuleUid iModuleUid; //@see TModuleUid
|
|
145 |
TClassification iClassification; //@see TClassification
|
|
146 |
THasThreadIdentification iHasThreadIdentification; //@see THasThreadIdentification
|
|
147 |
THasProgramCounter iHasProgramCounter; //@see THasProgramCounter
|
|
148 |
TUint32 iReserved1; //Reserved for future use
|
|
149 |
TUint32 iReserved2; //Reserved for future use
|
|
150 |
};
|
|
151 |
|
|
152 |
IMPORT_C TBool Printf(const TTraceContext& aContext, const char* aFmt, ...);
|
|
153 |
IMPORT_C TBool Print(const TTraceContext& aContext, const TDesC8& aDes);
|
|
154 |
IMPORT_C TBool Printf(const TTraceContext& aContext, TRefByValue<const TDesC8> aFmt,...);
|
|
155 |
#ifndef __KERNEL_MODE__
|
|
156 |
IMPORT_C TBool Print(const TTraceContext& aContext, const TDesC16& aDes);
|
|
157 |
IMPORT_C TBool Printf(const TTraceContext& aContext, TRefByValue<const TDesC16> aFmt,...);
|
|
158 |
#endif //__KERNEL_MODE__
|
|
159 |
|
|
160 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId);
|
|
161 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TUint8 aData);
|
|
162 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TUint16 aData);
|
|
163 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TUint32 aData);
|
|
164 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TUint32 aData1, const TUint32 aData2);
|
|
165 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TDesC8& aData);
|
|
166 |
#ifndef __KERNEL_MODE__
|
|
167 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TDesC16& aData);
|
|
168 |
#endif
|
|
169 |
template<typename T>
|
|
170 |
static inline TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const T& aData);
|
|
171 |
IMPORT_C TBool Trace(const TTraceContext& aContext, const TFormatId aFormatId, const TAny* aData, const TInt aDataSize);
|
|
172 |
|
|
173 |
IMPORT_C TBool WouldBeTracedNow(const TTraceContext& aContext);
|
|
174 |
|
|
175 |
|
|
176 |
#include <e32utrace.inl>
|
|
177 |
}//end of UTF namespace
|
|
178 |
|
|
179 |
|
|
180 |
#endif //E32UTRACE_H
|