sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\debug\crashMonitor\src\scmprocessdata.cpp
|
sl@0
|
15 |
// Core dump server - Process Data for System Crash
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalTechnology
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <scmdatatypes.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
namespace Debug
|
sl@0
|
27 |
{
|
sl@0
|
28 |
/**
|
sl@0
|
29 |
* TProcessData implementation
|
sl@0
|
30 |
* @internal technology
|
sl@0
|
31 |
*/
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
* TProcessData constructor
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
TProcessData::TProcessData()
|
sl@0
|
37 |
:iId(ESCMProcessData)
|
sl@0
|
38 |
,iVersion(EProcData1)
|
sl@0
|
39 |
,iPid(0)
|
sl@0
|
40 |
,iNamesize(0)
|
sl@0
|
41 |
,iPriority(0)
|
sl@0
|
42 |
,iSpare1(0)
|
sl@0
|
43 |
,iSpare2(0)
|
sl@0
|
44 |
,iSpare3(0)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
* Writes this classes data to the specified byte stream
|
sl@0
|
50 |
* @param aWriter byte stream to use
|
sl@0
|
51 |
* @return One of the OS wide codes
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
TInt TProcessData::Serialize(TByteStreamWriter& aWriter)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
TInt startPos = aWriter.CurrentPosition();
|
sl@0
|
56 |
|
sl@0
|
57 |
// ID saved first
|
sl@0
|
58 |
aWriter.WriteInt(iId); // 4
|
sl@0
|
59 |
|
sl@0
|
60 |
if(iId != ESCMProcessData)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
CLTRACE("TProcessData::Serialize Corrupt ID");
|
sl@0
|
63 |
return KErrCorrupt;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
aWriter.WriteShort((TUint16) iVersion); // 2
|
sl@0
|
67 |
|
sl@0
|
68 |
if(iVersion == EProcData1)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
// write data v1 format
|
sl@0
|
71 |
aWriter.WriteInt(iPriority); // 4
|
sl@0
|
72 |
aWriter.WriteInt64(iPid); // 8
|
sl@0
|
73 |
if(iName.Ptr())
|
sl@0
|
74 |
{
|
sl@0
|
75 |
aWriter.WriteInt(iName.Length()); // 4
|
sl@0
|
76 |
for(TInt cnt = 0; cnt < iName.Length(); cnt++)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
aWriter.WriteByte(iName[cnt]);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
}
|
sl@0
|
81 |
else
|
sl@0
|
82 |
{
|
sl@0
|
83 |
aWriter.WriteInt(0);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
|
sl@0
|
87 |
}
|
sl@0
|
88 |
else
|
sl@0
|
89 |
{
|
sl@0
|
90 |
CLTRACE("TProcessData::Serialize Unsupported version");
|
sl@0
|
91 |
return KErrCorrupt;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
TInt endPos = aWriter.CurrentPosition();
|
sl@0
|
95 |
if( endPos - startPos != GetSize())
|
sl@0
|
96 |
{
|
sl@0
|
97 |
// error between actual size & real size in data
|
sl@0
|
98 |
CLTRACE2("TProcessData::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
|
sl@0
|
99 |
return KErrCorrupt;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
return KErrNone;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
/**
|
sl@0
|
105 |
* Reads the classes data from the specified byte stream
|
sl@0
|
106 |
* @param aReader Byte stream to use
|
sl@0
|
107 |
* @return One of the OS wide codes
|
sl@0
|
108 |
*/
|
sl@0
|
109 |
TInt TProcessData::Deserialize(TByteStreamReader& aReader)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TInt startPos = aReader.CurrentPosition();
|
sl@0
|
112 |
|
sl@0
|
113 |
iId = (SCMStructId)aReader.ReadInt(); // 4
|
sl@0
|
114 |
if(iId != ESCMProcessData)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
CLTRACE("TProcessData::Deserialize failed - Read corrupt ID");
|
sl@0
|
117 |
return KErrCorrupt;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
iVersion = (TProcessDataVersion)aReader.ReadShort(); // 2
|
sl@0
|
121 |
|
sl@0
|
122 |
if(iVersion == EProcData1)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
// read data v1 format
|
sl@0
|
125 |
iPriority = aReader.ReadInt(); // 4
|
sl@0
|
126 |
iPid = aReader.ReadInt64(); // 8
|
sl@0
|
127 |
|
sl@0
|
128 |
iNamesize = aReader.ReadInt(); // 4
|
sl@0
|
129 |
|
sl@0
|
130 |
if(iName.Ptr() && iName.MaxLength() >= (TInt)iNamesize)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
iName.SetLength(0);
|
sl@0
|
133 |
|
sl@0
|
134 |
for(TUint cnt = 0; cnt < iNamesize; cnt++)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
iName.Append(aReader.ReadByte()); //iCategorySize bytes
|
sl@0
|
137 |
}
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
}
|
sl@0
|
142 |
else
|
sl@0
|
143 |
{
|
sl@0
|
144 |
iId = ESCMLast; //unrecognised header
|
sl@0
|
145 |
CLTRACE("TProcessData::Deserialize Unsupported version");
|
sl@0
|
146 |
return KErrCorrupt;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
TInt endPos = aReader.CurrentPosition();
|
sl@0
|
150 |
if( endPos - startPos != GetSize())
|
sl@0
|
151 |
{
|
sl@0
|
152 |
iId = ESCMLast; //unrecognised header
|
sl@0
|
153 |
|
sl@0
|
154 |
// error between actual size & real size in data
|
sl@0
|
155 |
CLTRACE("TProcessData::Deserialize serialization size error");
|
sl@0
|
156 |
return KErrCorrupt;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
return KErrNone;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
/**
|
sl@0
|
162 |
* Returns the externalised size of this class
|
sl@0
|
163 |
* @return TInt size
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
TInt TProcessData::GetSize() const
|
sl@0
|
166 |
{
|
sl@0
|
167 |
if(iVersion == EProcData1)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
return 22 + iName.Length();
|
sl@0
|
170 |
}
|
sl@0
|
171 |
else
|
sl@0
|
172 |
{
|
sl@0
|
173 |
CLTRACE("TProcessData::GetSize Unsupported version");
|
sl@0
|
174 |
return KErrNotSupported;
|
sl@0
|
175 |
}
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
}
|