|
1 // Copyright (c) 1994-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 // e32\debug\crashMonitor\src\scmconfigitem.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 #include <e32def.h> |
|
23 #include <e32def_private.h> |
|
24 |
|
25 #include <scmconfigitem.h> |
|
26 #include <scmdatatypes.h> |
|
27 #include <scmtrace.h> |
|
28 |
|
29 namespace Debug |
|
30 { |
|
31 |
|
32 /** |
|
33 * TConfigItem constructor |
|
34 */ |
|
35 TConfigItem::TConfigItem() |
|
36 : iDataType(ELast) |
|
37 , iSizeToDump(0) |
|
38 , iSpaceRequiredToDump(0) |
|
39 , iPriority(0) |
|
40 , iNext(NULL) |
|
41 { |
|
42 } |
|
43 |
|
44 /** |
|
45 * TConfigItem constructor |
|
46 * @param aDataType - data type id |
|
47 * @param aSizeToDump - size of the config data |
|
48 * @param aPriority - priority of this data type (if 0 then not used) |
|
49 */ |
|
50 TConfigItem::TConfigItem(TSCMDataType aDataType, TUint8 aPriority, TInt32 aSizeToDump) |
|
51 : iDataType(aDataType) |
|
52 , iSizeToDump(aSizeToDump) |
|
53 , iPriority(aPriority) |
|
54 , iNext(NULL) |
|
55 { |
|
56 } |
|
57 |
|
58 /** |
|
59 * Serialize - writes this object to the supplied byte stream |
|
60 * @param aItem - aWriter - the TByteStreamWriter that will be written to |
|
61 * @return one of the OS wide codes |
|
62 */ |
|
63 TInt TConfigItem::Serialize(TByteStreamWriter& aWriter) |
|
64 { |
|
65 TInt startPos = aWriter.CurrentPosition(); |
|
66 |
|
67 aWriter.WriteByte((TUint8)iDataType); |
|
68 aWriter.WriteInt(iSizeToDump); |
|
69 aWriter.WriteByte(iPriority); |
|
70 |
|
71 TInt sizeWritten = aWriter.CurrentPosition() - startPos; |
|
72 if(sizeWritten != GetSize()) |
|
73 { |
|
74 // error between actual size & real size in data |
|
75 CLTRACE2("TConfigItem serialization size error sizeWritten %d GetSize() %d", sizeWritten, GetSize()); |
|
76 return KErrCorrupt; |
|
77 } |
|
78 |
|
79 return KErrNone; |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 * Deserialize - read this objects state from the supplied byte stream |
|
85 * @param aItem - aReader - the TByteStreamReader that will be read from |
|
86 * @return One of the OS wide codes |
|
87 */ |
|
88 TInt TConfigItem::Deserialize(TByteStreamReader& aReader) |
|
89 { |
|
90 TInt startPos = aReader.CurrentPosition(); |
|
91 |
|
92 iDataType = (TSCMDataType) aReader.ReadByte(); |
|
93 iSizeToDump = aReader.ReadInt(); |
|
94 iPriority = aReader.ReadByte(); |
|
95 |
|
96 TInt sizeRead = aReader.CurrentPosition() - startPos; |
|
97 if(sizeRead != GetSize()) |
|
98 { |
|
99 // error between actual size & real size in data |
|
100 CLTRACE("(TConfigItem::Deserialize) ERROR size error"); |
|
101 return KErrCorrupt; |
|
102 } |
|
103 |
|
104 return KErrNone; |
|
105 } |
|
106 |
|
107 |
|
108 /** |
|
109 * GetDataType |
|
110 * @return data type of this config item |
|
111 */ |
|
112 TConfigItem::TSCMDataType TConfigItem::GetDataType() const |
|
113 { |
|
114 return iDataType; |
|
115 } |
|
116 |
|
117 /** |
|
118 * GetPriority |
|
119 * @return priority of this config item (0-255) |
|
120 */ |
|
121 TInt TConfigItem::GetPriority() const |
|
122 { |
|
123 return iPriority; |
|
124 } |
|
125 |
|
126 /** |
|
127 * GetSize |
|
128 * @return size to dump in bytes |
|
129 */ |
|
130 TInt TConfigItem::GetSizeToDump() const |
|
131 { |
|
132 return iSizeToDump; |
|
133 } |
|
134 |
|
135 /** |
|
136 * GetSize |
|
137 * @return size of this object when streamed in bytes |
|
138 */ |
|
139 TInt TConfigItem::GetSize() const |
|
140 { |
|
141 return 6; |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 /** |
|
147 * Returns next item |
|
148 * @return Next item |
|
149 */ |
|
150 TConfigItem* TConfigItem::Next() const |
|
151 { |
|
152 return iNext; |
|
153 } |
|
154 |
|
155 /** |
|
156 * Print - displays info about this TConfigItem |
|
157 * @return void |
|
158 */ |
|
159 void TConfigItem::Print() const |
|
160 { |
|
161 CLTRACE3( "(TConfigItem::Print) iDataType = %d iPriority = %d iSizeToDump = %d" |
|
162 , iDataType, iPriority, iSizeToDump); |
|
163 } |
|
164 |
|
165 TBool TConfigItem::operator == (const TConfigItem& aOther) const |
|
166 { |
|
167 return (iDataType == aOther.iDataType && iSizeToDump == aOther.iSizeToDump && iPriority == aOther.iPriority); |
|
168 } |
|
169 |
|
170 /** |
|
171 * Sets the space required parameter for this config item |
|
172 * @param aSpaceReq Space required |
|
173 */ |
|
174 void TConfigItem::SetSpaceRequired(TUint aSpaceReq) |
|
175 { |
|
176 iSpaceRequiredToDump = aSpaceReq; |
|
177 } |
|
178 |
|
179 /** |
|
180 * Gets the space required to store this config item |
|
181 * @return |
|
182 */ |
|
183 TUint TConfigItem::GetSpaceRequired() |
|
184 { |
|
185 return iSpaceRequiredToDump; |
|
186 } |
|
187 |
|
188 #ifndef __KERNEL_MODE__ |
|
189 |
|
190 // human readable strings for TSCMDataType |
|
191 _LIT(KExceptionStacks, "Exception Stacks"); |
|
192 _LIT(KTraceData, "Trace data"); |
|
193 _LIT(KProcessCodeSegs, "ProcessCodeSegs"); |
|
194 _LIT(KThreadsUsrStack, "Threads UserStack"); |
|
195 _LIT(KThreadsSvrStack, "Threads Supervisor Stack"); |
|
196 _LIT(KKernelHeap, "Kernel Heap"); |
|
197 _LIT(KThreadsUsrRegisters, "Threads User Registers"); |
|
198 _LIT(KThreadsSvrRegisters, "Threads Supervisor Registers"); |
|
199 _LIT(KProcessMetaData, "Process Meta Data"); |
|
200 _LIT(KThreadsMetaData, "Threads Meta Data"); |
|
201 _LIT(KCrashedProcessCodeSegs, "Crashed Process Code Segs"); |
|
202 _LIT(KCrashedProcessUsrStacks, "Crashed Process' User Stack's"); |
|
203 _LIT(KCrashedProcessSvrStacks, "Crashed Process' Supervisor Stack's"); |
|
204 _LIT(KCrashedProcessMetaData, "Crashed Process Meta Data"); |
|
205 _LIT(KCrashedThreadMetaData, "Crashed Thread Meta Data"); |
|
206 _LIT(KLocks, "SCM Locks"); |
|
207 _LIT(KVariantSpecific, "Variant Specific Data"); |
|
208 _LIT(KRomInfo, "ROM Info"); |
|
209 _LIT(KUnknown, "Unknown"); |
|
210 |
|
211 /** |
|
212 * helper function for converting TSCMDataType enul to human readable form |
|
213 */ |
|
214 const TDesC& TConfigItem::GetSCMConfigOptionText(TConfigItem::TSCMDataType aType) |
|
215 { |
|
216 switch (aType) |
|
217 { |
|
218 case TConfigItem::EExceptionStacks: |
|
219 return KExceptionStacks; |
|
220 case TConfigItem::ETraceData: |
|
221 return KTraceData; |
|
222 case TConfigItem::EProcessCodeSegs: |
|
223 return KProcessCodeSegs(); |
|
224 case TConfigItem::EThreadsUsrStack: |
|
225 return KThreadsUsrStack(); |
|
226 case TConfigItem::EThreadsSvrStack: |
|
227 return KThreadsSvrStack; |
|
228 case TConfigItem::EThreadsUsrRegisters: |
|
229 return KThreadsUsrRegisters(); |
|
230 case TConfigItem::EThreadsSvrRegisters: |
|
231 return KThreadsSvrRegisters(); |
|
232 case TConfigItem::EProcessMetaData: |
|
233 return KProcessMetaData(); |
|
234 case TConfigItem::EThreadsMetaData: |
|
235 return KThreadsMetaData(); |
|
236 case TConfigItem::ECrashedProcessCodeSegs: |
|
237 return KCrashedProcessCodeSegs(); |
|
238 case TConfigItem::ECrashedProcessUsrStacks: |
|
239 return KCrashedProcessUsrStacks(); |
|
240 case TConfigItem::ECrashedProcessSvrStacks: |
|
241 return KCrashedProcessSvrStacks(); |
|
242 case TConfigItem::ECrashedProcessMetaData: |
|
243 return KCrashedProcessMetaData(); |
|
244 case TConfigItem::ECrashedThreadMetaData: |
|
245 return KCrashedThreadMetaData(); |
|
246 case TConfigItem::ELocks: |
|
247 return KLocks(); |
|
248 case TConfigItem::EKernelHeap: |
|
249 return KKernelHeap(); |
|
250 case TConfigItem::EVariantSpecificData: |
|
251 return KVariantSpecific(); |
|
252 case TConfigItem::ERomInfo: |
|
253 return KRomInfo(); |
|
254 case TConfigItem::ELast: |
|
255 default: |
|
256 return KUnknown(); |
|
257 } |
|
258 } |
|
259 #endif // ! __KERNEL_MODE__ |
|
260 } |
|
261 |
|
262 //eof |
|
263 |
|
264 |