Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include <e32utrace_basic_types.h>
24 Methods for tracing from user and kernel side.
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.
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.
34 @see RUlogger for information on how to filter at run-time
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.
44 #define SYMBIAN_INCLUDE_EXECUTABLE_TRACE
45 #include <e32utrace.mmh>
48 Example usage of UTrace:
56 TFormatId formatId = TMyAppFormatExample::KFilePrintfStringLookupId;
57 TUint32 myData = SomeData();
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);
64 //In case Printf is overloaded
65 UTF::Printf(TTraceContext(EError), "My data %d.", myData);
67 //Using default ModuleUid, i.e. UID3
68 TTraceContext context(EError);
69 if(WouldBeTracedNow(context))
71 Printf(context, "My data %d.", myData);
72 Trace(context, formatId, myData);
75 //Setting the default ModuleUid to something other than UID3
76 #define EXECUTABLE_DEFAULT_MODULEUID 0x00210D3B
77 TTraceContext otherDefault(EError);
78 if(WouldBeTracedNow(otherDefault))
80 Printf(otherDefault, "My data %i.", myData);
81 Trace(otherDefault, formatId, myData);
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))
91 Printf(telephony, "My data %i.", myData);
93 if(WouldBeTracedNow(connectivity))
95 Printf(connectivity, "My data %i.", myData);
98 //Don't add the thread identification into the trace packet
99 TTraceContext noThreadIdentifier(EError, ENoThreadIdentification, ENoProgramCounter);
100 if(WouldBeTracedNow(noThreadIdentifier))
102 Printf(noThreadIdentifier, "My data %i.", myData);
103 Trace(noThreadIdentifier, formatId, myData);
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.
124 Class used to encapsulate the context of a trace point.
125 For more information about the attributes please @see e32utrace_basic_types.h.
127 NONSHARABLE_CLASS(TTraceContext)
130 inline TTraceContext(const TClassification aClassification);
131 inline TTraceContext(const TClassification aClassification, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
133 inline TTraceContext(const TModuleUid aModuleUid, const TClassification aClassification);
134 inline TTraceContext(const TModuleUid aModuleUid, const TClassification aClassification, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter);
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();
142 inline TTraceContext(){};
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
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__
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);
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);
173 IMPORT_C TBool WouldBeTracedNow(const TTraceContext& aContext);
176 #include <e32utrace.inl>
177 }//end of UTF namespace