0
|
1 |
/**
|
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Trace API
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
@publishedPartner
|
|
23 |
@prototype
|
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef OPENSYSTEMTRACE_INL
|
|
27 |
#define OPENSYSTEMTRACE_INL
|
|
28 |
|
|
29 |
/**
|
|
30 |
OST maximum data length
|
|
31 |
The length of Component, Group and Trace IDs are subtracted from it
|
|
32 |
*/
|
|
33 |
const TUint KOstMaxDataLength = 512;
|
|
34 |
|
|
35 |
/**
|
|
36 |
BTrace maximum data length is defined in e32btrace.h
|
|
37 |
The length of Component, Group and Trace IDs are subtracted from it
|
|
38 |
*/
|
|
39 |
const TUint KBTraceMaxDataLength = KMaxBTraceDataArray - 2 * sizeof(TUint32);
|
|
40 |
|
|
41 |
/**
|
|
42 |
* The TraceName is an amalgamation of two separate identifiers:
|
|
43 |
* Group ID and Trace ID.
|
|
44 |
*
|
|
45 |
* These defines help get back the relevant bits from the
|
|
46 |
* TraceName.
|
|
47 |
*
|
|
48 |
* Note that whilst the Group ID is defined as 16 bits we are
|
|
49 |
* only taking the first 8 bits here.
|
|
50 |
*/
|
|
51 |
#define GROUPIDMASK 0x00ff0000
|
|
52 |
#define GROUPIDSHIFT 16
|
|
53 |
#define TRACEIDMASK 0x0000ffff
|
|
54 |
#define TRACEIDSHIFT 0
|
|
55 |
#define EXTRACT_GROUP_ID(aTraceName) static_cast<TGroupId>((aTraceName & GROUPIDMASK) >> GROUPIDSHIFT)
|
|
56 |
|
|
57 |
/**
|
|
58 |
---------------TTraceContext-----------------------
|
|
59 |
Define the context of a trace packet by setting its attributes.
|
|
60 |
|
|
61 |
The Component ID is defaulted according to the FW_DEFAULT_COMPONENTID definition.
|
|
62 |
The HasThreadIdentification is defaulted to the FW_DEFAULT_HAS_THREAD_IDENTIFICATION definition.
|
|
63 |
The HasProgramCounter is defaulted to the FW_DEFAULT_HAS_PC definition.
|
|
64 |
|
|
65 |
@deprecated
|
|
66 |
|
|
67 |
@param aGroupId @see TGroupId
|
|
68 |
|
|
69 |
*/
|
|
70 |
TTraceContext::TTraceContext(const TGroupId aGroupId)
|
|
71 |
:iComponentId(FW_DEFAULT_COMPONENTID), iGroupId(aGroupId), iHasThreadIdentification(FW_DEFAULT_HAS_THREAD_IDENTIFICATION), iHasProgramCounter(FW_DEFAULT_HAS_PC), iReserved1(0), iReserved2(0)
|
|
72 |
{
|
|
73 |
}
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Define the context of a trace packet by setting its attributes.
|
|
77 |
*
|
|
78 |
* The HasThreadIdentification is defaulted to the FW_DEFAULT_HAS_THREAD_IDENTIFICATION definition.
|
|
79 |
* The HasProgramCounter is defaulted to the FW_DEFAULT_HAS_PC definition.
|
|
80 |
*
|
|
81 |
*
|
|
82 |
* @deprecated
|
|
83 |
*
|
|
84 |
* @param aComponentId @see TComponentId
|
|
85 |
* @param aGroupId @see TGroupId
|
|
86 |
*/
|
|
87 |
TTraceContext::TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId)
|
|
88 |
:iComponentId(aComponentId), iGroupId(aGroupId), iHasThreadIdentification(FW_DEFAULT_HAS_THREAD_IDENTIFICATION), iHasProgramCounter(FW_DEFAULT_HAS_PC), iReserved1(0), iReserved2(0)
|
|
89 |
{
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Define the context of a trace packet by setting its attributes.
|
|
94 |
*
|
|
95 |
* The Component ID is defaulted according to the FW_DEFAULT_COMPONENTID definition.
|
|
96 |
*
|
|
97 |
* @deprecated
|
|
98 |
*
|
|
99 |
* @param aGroupId @see TGroupId
|
|
100 |
* @param aHasThreadIdentification Set whether to add thread identification automatically in the trace packet.
|
|
101 |
* @param aHasProgramCounter Set whether to add PC (program counter) automatically in the trace packet.
|
|
102 |
*/
|
|
103 |
TTraceContext::TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter)
|
|
104 |
:iComponentId(FW_DEFAULT_COMPONENTID), iGroupId(aGroupId), iHasThreadIdentification(aHasThreadIdentification), iHasProgramCounter(aHasProgramCounter), iReserved1(0), iReserved2(0)
|
|
105 |
{
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Define the context of a trace packet by setting its attributes.
|
|
111 |
*
|
|
112 |
* @deprecated
|
|
113 |
*
|
|
114 |
* @param aComponentId @see TComponentId
|
|
115 |
* @param aGroupId @see TGroupId
|
|
116 |
* @param aHasThreadIdentification Set whether to add thread identification automatically in the trace packet.
|
|
117 |
* @param aHasProgramCounter Set whether to add PC (program counter) automatically in the trace packet.
|
|
118 |
*/
|
|
119 |
TTraceContext::TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter)
|
|
120 |
:iComponentId(aComponentId), iGroupId(aGroupId), iHasThreadIdentification(aHasThreadIdentification), iHasProgramCounter(aHasProgramCounter), iReserved1(0), iReserved2(0)
|
|
121 |
{
|
|
122 |
}
|
|
123 |
|
|
124 |
//------------------ Trace -----------------------
|
|
125 |
/**
|
|
126 |
Outputs a trace packet containing variable length data.
|
|
127 |
|
|
128 |
If the specified data is too big to fit into a single
|
|
129 |
trace record a multipart trace is generated.
|
|
130 |
|
|
131 |
@deprecated
|
|
132 |
|
|
133 |
@param aContext Attributes of the trace point.
|
|
134 |
@param aTraceId A format identifier as specified by @see TTraceId
|
|
135 |
@param aData Additional data to add to trace packet.
|
|
136 |
Must be word aligned, i.e. a multiple of 4.
|
|
137 |
|
|
138 |
@return The trace packet was/was not logged.
|
|
139 |
|
|
140 |
@See BTrace::TMultipart
|
|
141 |
*/
|
|
142 |
template<typename T>
|
|
143 |
TBool OstTrace(const TTraceContext& aContext, TTraceId aTraceId, const T& aData)
|
|
144 |
{
|
|
145 |
return OstTrace(aContext, aTraceId, &aData, sizeof(aData));
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
/**
|
|
150 |
Send N bytes of data
|
|
151 |
|
|
152 |
@param aGroupId The Group ID of the trace packet. @see TGroupId
|
|
153 |
@param aEOstTrace BTrace sub-category. Value between 0 and 255. The meaning of this is dependent on the Category
|
|
154 |
@param aKOstTraceComponentID The Component ID of the trace
|
|
155 |
@param aTraceName The Trace ID of the trace
|
|
156 |
@param aPtr Address of addition data to add to trace.
|
|
157 |
@param aLength Number of bytes of additional data.
|
|
158 |
@return The trace packet was/was not logged.
|
|
159 |
*/
|
|
160 |
inline TBool OstSendNBytes( TUint8 aGroupId, TUint8 aEOstTrace, TUint32 aKOstTraceComponentID, TUint32 aTraceName, const TAny* aPtr, TInt aLength )
|
|
161 |
{
|
|
162 |
TBool retval;
|
|
163 |
|
|
164 |
if (aLength <= (TInt)KBTraceMaxDataLength)
|
|
165 |
{
|
|
166 |
// Data length is less than BTrace max. data length, so we can directly call BTraceFilteredContextN macro.
|
|
167 |
retval = BTraceFilteredContextN( aGroupId, aEOstTrace, aKOstTraceComponentID, aTraceName, aPtr, aLength );
|
|
168 |
}
|
|
169 |
else
|
|
170 |
{
|
|
171 |
// Data length is greater than BTrace max. data length, so we need to call BTraceContextBig macro
|
|
172 |
TUint32 data[ KOstMaxDataLength / sizeof(TUint32)+ 1 ];
|
|
173 |
|
|
174 |
TUint8* ptr = (TUint8*)((TUint32*)data+1); // First word holds Trace ID
|
|
175 |
|
|
176 |
// Write Trace ID to data part because BTraceFilteredContextBig macro takes one parameter less than BTraceFilteredContextN macro
|
|
177 |
data[0] = aTraceName;
|
|
178 |
|
|
179 |
// If there is more data than we can show
|
|
180 |
if (aLength > (TInt)KOstMaxDataLength)
|
|
181 |
{
|
|
182 |
aLength = KOstMaxDataLength;
|
|
183 |
}
|
|
184 |
|
|
185 |
// Copy the data to the buffer
|
|
186 |
memcpy( ptr, aPtr, aLength );
|
|
187 |
ptr += aLength;
|
|
188 |
|
|
189 |
// Fillers are written to get 32-bit alignment
|
|
190 |
TInt lengthAligned = ( aLength + (sizeof(TUint32)-1) ) & ~(sizeof(TUint32)-1);
|
|
191 |
while ( aLength++ < lengthAligned )
|
|
192 |
{
|
|
193 |
*ptr++ = 0;
|
|
194 |
}
|
|
195 |
|
|
196 |
retval = BTraceFilteredContextBig( aGroupId, aEOstTrace, aKOstTraceComponentID, data, lengthAligned + sizeof(TUint32));
|
|
197 |
}
|
|
198 |
|
|
199 |
return retval;
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
#endif //OPENSYSTEMTRACE_INL
|