0
|
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 "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 |
// Implemetation of class CExecutableInfo
|
|
15 |
//
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@see CExecutableInfo
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <e32debug.h>
|
|
25 |
|
|
26 |
#include <debuglogging.h>
|
|
27 |
#include <executabledata.h>
|
|
28 |
|
|
29 |
|
|
30 |
/**
|
|
31 |
Allocates and constructs a CExecutableInfo object.
|
|
32 |
@param aName Name of target executable.
|
|
33 |
@param aActivelyDebugged True if executable if being actively debugged by Debug Security Server.
|
|
34 |
@param aPassivelyDebugged True if executable if being passively debugged by Debug Security Server.
|
|
35 |
|
|
36 |
@see CExecutableInfo::CExecutableInfo
|
|
37 |
*/
|
|
38 |
EXPORT_C CExecutableInfo* CExecutableInfo::NewL( const TDesC & aName,
|
|
39 |
const TBool aActivelyDebugged,
|
|
40 |
const TBool aPassivelyDebugged )
|
|
41 |
{
|
|
42 |
|
|
43 |
|
|
44 |
const TUint size =
|
|
45 |
+ sizeof( TUint32 ) // When externalized, we send the name length, so must include this
|
|
46 |
+ 2 // When externalized, the << operator writes 2 bytes for the descriptor size
|
|
47 |
+ aName.Size() // iName Size, in bytes.
|
|
48 |
+ sizeof( TUint32 ) // aActivelyDebugged
|
|
49 |
+ sizeof( TUint32 ) // aPassivelyDebugged
|
|
50 |
+ sizeof( TUint32 ) // Observed
|
|
51 |
+ sizeof( TUint32 ); // iSize itself
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
if( size >= MaxSize() )
|
|
56 |
{
|
|
57 |
LOG_MSG3( "CExecutableInfo::NewL() : Descriptorized object = 0x%X bytes would exceed the maximum of 0x%X\n",
|
|
58 |
size, MaxSize() );
|
|
59 |
|
|
60 |
User::Leave( KErrTooBig );
|
|
61 |
}
|
|
62 |
|
|
63 |
CExecutableInfo * data = new (ELeave) CExecutableInfo( aActivelyDebugged, aPassivelyDebugged );
|
|
64 |
|
|
65 |
CleanupStack::PushL( data );
|
|
66 |
|
|
67 |
data->ConstructL( aName );
|
|
68 |
|
|
69 |
CleanupStack::Pop(data);
|
|
70 |
|
|
71 |
return (data);
|
|
72 |
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
/**
|
|
77 |
Allocates and constructs a CExecutableInfo object from a descriptor.
|
|
78 |
The descriptor contains an externalised version of a CExecutableInfo object.
|
|
79 |
This method is typically used to obtain a CExecutableInfo object from a
|
|
80 |
descriptor returned by the core dump server.
|
|
81 |
|
|
82 |
@param aStreamData Descriptor with externalised/streamed object to initialize from.
|
|
83 |
@see InternalizeL
|
|
84 |
@see ExternalizeL
|
|
85 |
*/
|
|
86 |
EXPORT_C CExecutableInfo* CExecutableInfo::NewL( const TDesC8 & aStreamData )
|
|
87 |
{
|
|
88 |
|
|
89 |
CExecutableInfo* self = new (ELeave) CExecutableInfo();
|
|
90 |
|
|
91 |
CleanupStack::PushL( self );
|
|
92 |
|
|
93 |
// Open a read stream for the descriptor
|
|
94 |
RDesReadStream stream( aStreamData );
|
|
95 |
|
|
96 |
CleanupClosePushL( stream );
|
|
97 |
|
|
98 |
self->InternalizeL( stream );
|
|
99 |
|
|
100 |
CleanupStack::PopAndDestroy( &stream ); // finished with the stream
|
|
101 |
|
|
102 |
CleanupStack::Pop( self );
|
|
103 |
|
|
104 |
return ( self );
|
|
105 |
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
/**
|
|
110 |
Destructor. Deletes name if allocated.
|
|
111 |
*/
|
|
112 |
EXPORT_C CExecutableInfo::~CExecutableInfo()
|
|
113 |
{
|
|
114 |
|
|
115 |
if( NULL != iName )
|
|
116 |
{
|
|
117 |
delete iName;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
/**
|
|
122 |
First phase contructor. Sets the size to 0, name to NULL.
|
|
123 |
|
|
124 |
@param aActivelyDebugged Whether this executable is being actively
|
|
125 |
debugged according to the Debug Security Server.
|
|
126 |
@param aPassivelyDebugged Whether this executable is being passively
|
|
127 |
debugged according to the Debug Security Server.
|
|
128 |
|
|
129 |
@see CExecutableInfo::NewL().
|
|
130 |
*/
|
|
131 |
CExecutableInfo::CExecutableInfo( const TBool aActivelyDebugged,
|
|
132 |
const TBool aPassivelyDebugged ) :
|
|
133 |
iActivelyDebugged ( aActivelyDebugged ),
|
|
134 |
iPassivelyDebugged ( aPassivelyDebugged ),
|
|
135 |
iObserved ( EFalse ),
|
|
136 |
iSize ( 0 )
|
|
137 |
{
|
|
138 |
iName = NULL;
|
|
139 |
}
|
|
140 |
|
|
141 |
|
|
142 |
/**
|
|
143 |
Second phase constructor initialises the name of the executable.
|
|
144 |
@param aName Executable name
|
|
145 |
@see NameL()
|
|
146 |
*/
|
|
147 |
void CExecutableInfo::ConstructL( const TDesC & aName )
|
|
148 |
{
|
|
149 |
NameL( aName );
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
/**
|
|
154 |
Initialise this object with the contents of RReadStream aStream.
|
|
155 |
The descriptor contains an externalised version of an object.
|
|
156 |
This method is typically used to obtain a CExecutableInfo object from
|
|
157 |
the core dump server.
|
|
158 |
Any modifications to this method should be synchronised with ExternalizeL().
|
|
159 |
Also note that the methods used from RReadStream (>> or ReadUint32L)
|
|
160 |
can behave differently, especially for descriptors.
|
|
161 |
@param aStream Stream with streamed object
|
|
162 |
@see ExternalizeL
|
|
163 |
@see RReadStream
|
|
164 |
@pre Call Externalise to obtain the stream containing an externalised
|
|
165 |
version of this object.
|
|
166 |
*/
|
|
167 |
EXPORT_C void CExecutableInfo::InternalizeL( RReadStream & aStream )
|
|
168 |
{
|
|
169 |
|
|
170 |
|
|
171 |
// Read the number of character elements in the name.
|
|
172 |
TUint32 nameLength = aStream.ReadUint32L();
|
|
173 |
|
|
174 |
if( NULL != iName )
|
|
175 |
{
|
|
176 |
delete iName;
|
|
177 |
iName = NULL;
|
|
178 |
}
|
|
179 |
|
|
180 |
if ( nameLength > 0 )
|
|
181 |
{
|
|
182 |
iName = HBufC::NewL( aStream, nameLength );
|
|
183 |
}
|
|
184 |
else
|
|
185 |
{
|
|
186 |
iName = NULL;
|
|
187 |
}
|
|
188 |
|
|
189 |
iActivelyDebugged = static_cast<TBool>(aStream.ReadUint32L());
|
|
190 |
iPassivelyDebugged = static_cast<TBool>(aStream.ReadUint32L());
|
|
191 |
|
|
192 |
iObserved = static_cast<TBool>(aStream.ReadUint32L());
|
|
193 |
|
|
194 |
iSize = aStream.ReadUint32L() ;
|
|
195 |
}
|
|
196 |
|
|
197 |
|
|
198 |
/**
|
|
199 |
Make a streamed representation of this object to a RWriteStream.
|
|
200 |
|
|
201 |
This method is typically by the core dump server when contructing a list of
|
|
202 |
CExecutableInfo for a client.
|
|
203 |
Any modifications to this method should be synchronised with InternalizeL().
|
|
204 |
Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
|
|
205 |
especially for descriptors.
|
|
206 |
@param aStream Stream to stream object onto
|
|
207 |
@param buf Buffer onto the same stream, used to obtain the correct size of the externalised object
|
|
208 |
@see InternalizeL
|
|
209 |
@see RReadStream
|
|
210 |
@see RWriteStream
|
|
211 |
@post The stream contains an externalised version of this object.
|
|
212 |
*/
|
|
213 |
EXPORT_C void CExecutableInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
|
|
214 |
{
|
|
215 |
|
|
216 |
// Take the size of the buffer before we add anything to it.
|
|
217 |
TUint startBufSize = buf->Size();
|
|
218 |
|
|
219 |
TUint nameLength = 0;
|
|
220 |
|
|
221 |
if ( ( NULL != iName ) && ( iName->Des().Length() > 0 ) )
|
|
222 |
{
|
|
223 |
|
|
224 |
nameLength = iName->Des().Length();
|
|
225 |
|
|
226 |
if( nameLength > 0 )
|
|
227 |
{
|
|
228 |
// Write the number of character elements in the name.
|
|
229 |
aStream.WriteUint32L( nameLength );
|
|
230 |
aStream << iName->Des();
|
|
231 |
}
|
|
232 |
}
|
|
233 |
|
|
234 |
if( nameLength == 0 )
|
|
235 |
{
|
|
236 |
aStream.WriteUint32L( 0 );
|
|
237 |
}
|
|
238 |
|
|
239 |
aStream.WriteUint32L( static_cast<TUint32>(iActivelyDebugged) );
|
|
240 |
aStream.WriteUint32L( static_cast<TUint32>(iPassivelyDebugged) );
|
|
241 |
|
|
242 |
aStream.WriteUint32L( static_cast<TUint32>(iObserved) );
|
|
243 |
|
|
244 |
iSize = buf->Size() - startBufSize + 4;
|
|
245 |
|
|
246 |
aStream.WriteUint32L( iSize );
|
|
247 |
|
|
248 |
}
|
|
249 |
|
|
250 |
/**
|
|
251 |
Return ETrue if the executable if being actively debugged by a client of the Debug Security Server.
|
|
252 |
*/
|
|
253 |
EXPORT_C TBool CExecutableInfo::ActivelyDebugged() const
|
|
254 |
{
|
|
255 |
return ( iActivelyDebugged );
|
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
/**
|
|
260 |
Return ETrue if the executable if being passively debugged by a client of the Debug Security Server.
|
|
261 |
*/
|
|
262 |
EXPORT_C TBool CExecutableInfo::PassivelyDebugged() const
|
|
263 |
{
|
|
264 |
return ( iPassivelyDebugged );
|
|
265 |
}
|
|
266 |
|
|
267 |
|
|
268 |
/**
|
|
269 |
Set whether the executable is being actively debugged by a client of the Debug Security Server.
|
|
270 |
*/
|
|
271 |
EXPORT_C void CExecutableInfo::ActivelyDebugged( TBool aActivelyDebugged )
|
|
272 |
{
|
|
273 |
iActivelyDebugged = aActivelyDebugged;
|
|
274 |
}
|
|
275 |
|
|
276 |
|
|
277 |
/**
|
|
278 |
Set whether the executable is being passively debugged by a client of the Debug Security Server.
|
|
279 |
*/
|
|
280 |
EXPORT_C void CExecutableInfo::PassivelyDebugged( TBool aPassivelyDebugged )
|
|
281 |
{
|
|
282 |
iPassivelyDebugged = aPassivelyDebugged;
|
|
283 |
}
|
|
284 |
|
|
285 |
|
|
286 |
/**
|
|
287 |
Returns ETrue if the the Core Dump Server is observing this executable.
|
|
288 |
*/
|
|
289 |
EXPORT_C TBool CExecutableInfo::Observed() const
|
|
290 |
{
|
|
291 |
return ( iObserved );
|
|
292 |
}
|
|
293 |
|
|
294 |
|
|
295 |
/**
|
|
296 |
Set whether the the Core Dump Server is observing this executable.
|
|
297 |
*/
|
|
298 |
EXPORT_C void CExecutableInfo::Observed( TBool aFlag )
|
|
299 |
{
|
|
300 |
iObserved = aFlag;
|
|
301 |
}
|
|
302 |
|
|
303 |
|
|
304 |
/**
|
|
305 |
Set the name of the executable by deleting, allocating and then copying the parameter.
|
|
306 |
@param aName Name of the executable to set to
|
|
307 |
@see ConstructL()
|
|
308 |
*/
|
|
309 |
EXPORT_C void CExecutableInfo::NameL( const TDesC & aName )
|
|
310 |
{
|
|
311 |
|
|
312 |
if( aName.Length() > 0 )
|
|
313 |
{
|
|
314 |
TUint toCopy = aName.Length();
|
|
315 |
iName = HBufC::NewL( toCopy );
|
|
316 |
TPtr nameDes = iName->Des();
|
|
317 |
|
|
318 |
nameDes.Copy( aName.Ptr(), toCopy );
|
|
319 |
nameDes.SetLength( toCopy );
|
|
320 |
}
|
|
321 |
else
|
|
322 |
{
|
|
323 |
iName = NULL;
|
|
324 |
}
|
|
325 |
}
|
|
326 |
|
|
327 |
|
|
328 |
/**
|
|
329 |
Obtain the kernel executable name.
|
|
330 |
*/
|
|
331 |
EXPORT_C const TDesC & CExecutableInfo::Name() const
|
|
332 |
{
|
|
333 |
return ( *iName );
|
|
334 |
}
|
|
335 |
|
|
336 |
|
|
337 |
CExecutableInfo::CExecutableInfo()
|
|
338 |
{
|
|
339 |
}
|
|
340 |
|
|
341 |
|
|
342 |
/**
|
|
343 |
Get the maximum size allowed for this object. This is needed as the object is passed
|
|
344 |
across the Client Server interface.
|
|
345 |
*/
|
|
346 |
EXPORT_C TInt CExecutableInfo::MaxSize()
|
|
347 |
{
|
|
348 |
|
|
349 |
const TInt maxSize = 256;
|
|
350 |
return maxSize;
|
|
351 |
}
|
|
352 |
|
|
353 |
|
|
354 |
/**
|
|
355 |
Gets the size of the object when externalized. The sizeofs used to calculate this
|
|
356 |
must match the operators used in ExternalizeL and InternalizeL.
|
|
357 |
Special attention must be paid to the name. If the object has not been
|
|
358 |
externalized yet then this method returns the maximum that it could take.
|
|
359 |
The name descriptor is compressed when externalized, so it is not its Size().
|
|
360 |
Furthermore the << operator adds two bytes to the stream when externalizing
|
|
361 |
a descriptor.
|
|
362 |
*/
|
|
363 |
EXPORT_C TInt CExecutableInfo::Size() const
|
|
364 |
{
|
|
365 |
|
|
366 |
if( iSize != 0 )
|
|
367 |
{
|
|
368 |
return iSize;
|
|
369 |
}
|
|
370 |
|
|
371 |
TUint extNameSize = 0;
|
|
372 |
if( iName )
|
|
373 |
{
|
|
374 |
extNameSize = 2 // When externalized, the << operator writes 2 bytes for the descriptor size
|
|
375 |
+ iName->Size(); // iName itself, in bytes.
|
|
376 |
}
|
|
377 |
|
|
378 |
const TUint size =
|
|
379 |
+ sizeof( TUint32 ) // When externalized, we send the name length, so must include this
|
|
380 |
+ extNameSize
|
|
381 |
+ sizeof( TUint32 ) // iActivelyDebugged
|
|
382 |
+ sizeof( TUint32 ) // iPassivelyDebugged
|
|
383 |
+ sizeof( TUint32 ) // iObserved
|
|
384 |
+ sizeof( TUint32 ); // iSize When externalized, we send the real externalized size of the buffer
|
|
385 |
|
|
386 |
return size;
|
|
387 |
}
|
|
388 |
|
|
389 |
|