Update contrib.
1 // Copyright (c) 2008-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.
14 // e32\debug\crashMonitor\src\scmthreaddata.cpp
15 // Core dump server - Thread Data for System Crash
24 #include <scmdatatypes.h>
29 * TThreadData implementation
30 * @internal technology
34 * TThreadData constructor
36 TThreadData::TThreadData()
38 ,iVersion(EThreadData1)
56 * Writes this classes data to the specified byte stream
57 * @param aWriter byte stream to use
60 TInt TThreadData::Serialize(TByteStreamWriter& aWriter)
62 TInt startPos = aWriter.CurrentPosition();
64 if(iId != ESCMThreadData)
66 CLTRACE("TThreadData::Serialize Corrupt ID");
71 aWriter.WriteInt(iId); // 4
73 aWriter.WriteShort((TUint16) iVersion); // 2
75 if(iVersion == EThreadData1)
77 // write data v1 format
78 aWriter.WriteInt(iPriority); // 4
79 aWriter.WriteInt64(iTid); // 8
80 aWriter.WriteInt64(iOwnerId); // 8
81 aWriter.WriteInt(iSvcSP); // 4
82 aWriter.WriteInt(iSvcStack); // 4
83 aWriter.WriteInt(iSvcStacksize); // 4
84 aWriter.WriteInt(iUsrSP); // 4
85 aWriter.WriteInt(iUsrStack); // 4
86 aWriter.WriteInt(iUsrStacksize); // 4
87 aWriter.WriteInt(iLastCpu); // 4
88 aWriter.WriteInt(iSvcHeap); // 4
89 aWriter.WriteInt(iSvcHeapSize); // 4
92 aWriter.WriteInt(iName.Length()); // 4
93 for(TInt cnt = 0; cnt < iName.Length(); cnt++)
95 aWriter.WriteByte(iName[cnt]);
105 CLTRACE("TThreadData::Serialize Unsupported version");
109 TInt endPos = aWriter.CurrentPosition();
110 if( endPos - startPos != GetSize())
112 // error between actual size & real size in data
113 CLTRACE("TThreadData::Serialize serialization size error");
121 * Reads the classes data from the specified byte stream
122 * @param aReader Byte stream to use
125 TInt TThreadData::Deserialize(TByteStreamReader& aReader)
127 TInt startPos = aReader.CurrentPosition();
129 iId = (SCMStructId)aReader.ReadInt(); // 4
130 if(iId != ESCMThreadData)
132 CLTRACE("TThreadData::Deserialize Corrupt ID read");
136 iVersion = (TThreadDataVersion)aReader.ReadShort(); // 2
138 if(iVersion == EThreadData1)
140 // read data v1 format
141 iPriority = aReader.ReadInt(); // 4
142 iTid = aReader.ReadInt64(); // 8
143 iOwnerId = aReader.ReadInt64(); // 8
144 iSvcSP = aReader.ReadInt(); // 4
145 iSvcStack = aReader.ReadInt(); // 4
146 iSvcStacksize = aReader.ReadInt(); // 4
147 iUsrSP = aReader.ReadInt(); // 4
148 iUsrStack = aReader.ReadInt(); // 4
149 iUsrStacksize = aReader.ReadInt(); // 4
150 iLastCpu = aReader.ReadInt(); // 4
151 iSvcHeap = aReader.ReadInt(); // 4
152 iSvcHeapSize = aReader.ReadInt(); // 4
154 iNamesize = aReader.ReadInt(); // 4
156 if(iName.Ptr() && iName.MaxLength() >= (TInt)iNamesize)
160 for(TUint cnt = 0; cnt < iNamesize; cnt++)
162 iName.Append(aReader.ReadByte()); //iNamesize bytes
168 iId = ESCMLast; //unrecognised header
169 CLTRACE("TThreadData::Deserialize Unsupported version");
173 TInt endPos = aReader.CurrentPosition();
174 if( endPos - startPos != GetSize())
176 iId = ESCMLast; //unrecognised header
178 // error between actual size & real size in data
179 CLTRACE("TThreadData::Deserialize serialization size error");
186 * Returns the externalised size of this class
189 TInt TThreadData::GetSize() const
191 if(iVersion == EThreadData1)
193 return 66 + iName.Length();
197 CLTRACE("TThreadData::GetSize Unsupported version");
198 return KErrNotSupported;