51
|
1 |
/*
|
|
2 |
* Copyright (c) 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 "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 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "MemSpyEngineServer.h"
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <w32std.h>
|
52
|
23 |
//#include <coedef.h>
|
51
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include <memspy/engine/memspyengine.h>
|
|
27 |
#include <memspy/engine/memspyenginelogger.h>
|
|
28 |
#include <memspyengineclientinterface.h>
|
|
29 |
#include <memspy/engine/memspyengineobjectthread.h>
|
|
30 |
#include <memspy/engine/memspyengineobjectprocess.h>
|
|
31 |
#include <memspy/engine/memspyengineobjectcontainer.h>
|
|
32 |
#include <memspy/engine/memspyenginehelperchunk.h>
|
|
33 |
#include <memspy/engine/memspyenginehelpercodesegment.h>
|
|
34 |
#include <memspy/engine/memspyenginehelperheap.h>
|
|
35 |
#include <memspy/engine/memspyenginehelperstack.h>
|
|
36 |
#include <memspy/engine/memspyenginehelperthread.h>
|
|
37 |
#include <memspy/engine/memspyenginehelperprocess.h>
|
|
38 |
#include <memspy/engine/memspyenginehelperfilesystem.h>
|
|
39 |
#include <memspy/engine/memspyenginehelperram.h>
|
|
40 |
#include <memspy/engine/memspyenginehelpersysmemtracker.h>
|
|
41 |
#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
|
|
42 |
#include <memspy/engine/memspyenginehelperkernelcontainers.h>
|
|
43 |
#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
|
|
44 |
#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
|
|
45 |
#include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
|
|
46 |
#include <memspy/engine/memspyenginehelperserver.h>
|
|
47 |
#include <memspy/engine/memspyenginehelperecom.h>
|
|
48 |
|
|
49 |
#include <memspy/engine/memspyprocessdata.h>
|
|
50 |
#include <memspy/engine/memspythreaddata.h>
|
|
51 |
#include <memspy/engine/memspykernelobjectdata.h>
|
|
52 |
#include <memspy/engine/memspythreadinfoitemdata.h>
|
|
53 |
#include <memspy/engine/memspymemorytrackingcycledata.h>
|
|
54 |
#include <memspy/engine/memspyengineoutputsink.h>
|
|
55 |
#include <memspy/engine/memspyenginehelperactiveobject.h>
|
|
56 |
#include <memspy/engine/memspyserverdata.h>
|
|
57 |
#include <memspysession.h>
|
|
58 |
#include <memspy/engine/memspyecomdata.h>
|
62
|
59 |
#include <memspy/engine/memspychunkdata.h>
|
|
60 |
#include <memspy/engine/memspycodesegmentdata.h>
|
51
|
61 |
|
|
62 |
inline CShutdown::CShutdown() :CTimer(-1)
|
|
63 |
{
|
|
64 |
CActiveScheduler::Add(this);
|
|
65 |
}
|
|
66 |
|
|
67 |
inline void CShutdown::ConstructL()
|
|
68 |
{
|
|
69 |
CTimer::ConstructL();
|
|
70 |
}
|
|
71 |
|
|
72 |
inline void CShutdown::Start()
|
|
73 |
{
|
|
74 |
After(KMyShutdownDelay);
|
|
75 |
}
|
|
76 |
|
|
77 |
void CShutdown::RunL()
|
|
78 |
//
|
|
79 |
// Initiate server exit when the timer expires
|
|
80 |
//
|
|
81 |
{
|
|
82 |
CActiveScheduler::Stop();
|
|
83 |
}
|
|
84 |
|
|
85 |
CMemSpyEngineServer::CMemSpyEngineServer( CMemSpyEngine& aEngine )
|
|
86 |
: CServer2( EPriorityNormal ), iEngine( aEngine )
|
|
87 |
{
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
CMemSpyEngineServer::~CMemSpyEngineServer()
|
|
92 |
{
|
62
|
93 |
if (iNotificationTracker)
|
|
94 |
{
|
|
95 |
delete iNotificationTracker;
|
|
96 |
}
|
51
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
void CMemSpyEngineServer::ConstructL()
|
|
101 |
{
|
|
102 |
StartL( KMemSpyServerName );
|
62
|
103 |
|
|
104 |
// create and setup notification tracker
|
|
105 |
iNotificationTracker = CMemSpyNotificationTracker::NewL();
|
|
106 |
iEngine.SetObserver( iNotificationTracker );
|
51
|
107 |
|
|
108 |
iShutdown.ConstructL();
|
|
109 |
// ensure that the server still exits even if the 1st client fails to connect
|
|
110 |
iShutdown.Start();
|
|
111 |
}
|
|
112 |
|
|
113 |
|
|
114 |
CMemSpyEngineServer* CMemSpyEngineServer::NewL( CMemSpyEngine& aEngine )
|
|
115 |
{
|
|
116 |
CMemSpyEngineServer* self = new(ELeave) CMemSpyEngineServer( aEngine );
|
|
117 |
CleanupStack::PushL( self );
|
|
118 |
self->ConstructL();
|
|
119 |
CleanupStack::Pop( self );
|
|
120 |
return self;
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
CSession2* CMemSpyEngineServer::NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const
|
|
125 |
{
|
|
126 |
if ( aVersion.iMajor != KMemSpyClientServerVersion )
|
|
127 |
{
|
|
128 |
RDebug::Printf( "[MemSpy] CMemSpyEngineSession::NewSessionL() - BAD VERSION" );
|
|
129 |
User::Leave( KErrNotSupported );
|
|
130 |
}
|
|
131 |
//
|
|
132 |
CMemSpyEngineSession* session = CMemSpyEngineSession::NewL( iEngine, aMessage );
|
|
133 |
return session;
|
|
134 |
}
|
|
135 |
|
|
136 |
void CMemSpyEngineServer::AddSession(TBool aCliRequest)
|
|
137 |
{
|
|
138 |
if (aCliRequest)
|
|
139 |
{
|
|
140 |
iCliConnected = ETrue;
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
++iSessionCount;
|
|
145 |
}
|
|
146 |
iShutdown.Cancel();
|
|
147 |
}
|
|
148 |
|
|
149 |
void CMemSpyEngineServer::DropSession(TBool aCliRequest)
|
|
150 |
{
|
|
151 |
if (!aCliRequest)
|
|
152 |
{
|
|
153 |
--iSessionCount;
|
|
154 |
}
|
|
155 |
|
|
156 |
if (iSessionCount == 0 && !iCliConnected)
|
|
157 |
{
|
|
158 |
iShutdown.Start();
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
CMemSpyEngineSession::CMemSpyEngineSession( CMemSpyEngine& aEngine )
|
|
186 |
: iEngine( aEngine )
|
|
187 |
{
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
CMemSpyEngineSession::~CMemSpyEngineSession()
|
|
192 |
{
|
|
193 |
#ifdef _DEBUG
|
|
194 |
TPtrC pThreadName( KNullDesC );
|
|
195 |
if ( iClientThreadName )
|
|
196 |
{
|
|
197 |
pThreadName.Set( *iClientThreadName );
|
|
198 |
}
|
|
199 |
|
|
200 |
RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::~CMemSpyEngineSession() - DEAD SESSION - this: 0x%08x, id: %4d, name: %S"), this, iClientThreadId, iClientThreadName );
|
|
201 |
#endif
|
|
202 |
|
|
203 |
delete iClientThreadName;
|
|
204 |
|
|
205 |
Server().DropSession(iIsCliRequest);
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
void CMemSpyEngineSession::ConstructL( const RMessage2& aMessage )
|
|
210 |
{
|
|
211 |
RThread thread;
|
|
212 |
const TInt error = aMessage.Client( thread );
|
|
213 |
CleanupClosePushL( thread );
|
|
214 |
|
|
215 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::ConstructL() - this: 0x%08x - opening client thread - err: %d", this, error ) );
|
|
216 |
|
|
217 |
User::LeaveIfError( error );
|
|
218 |
|
|
219 |
const TFullName threadName( thread.FullName() );
|
|
220 |
iClientThreadName = threadName.AllocL();
|
|
221 |
iClientThreadId = thread.Id();
|
|
222 |
|
|
223 |
CleanupStack::PopAndDestroy( &thread );
|
|
224 |
|
|
225 |
const TUid KCliUid3 = { 0x2002129D };
|
|
226 |
iIsCliRequest = aMessage.SecureId() == TSecureId(KCliUid3);
|
|
227 |
|
|
228 |
TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ConstructL() - NEW SESSION - this: 0x%08x, id: %4d, client: %S"), this, iClientThreadId, iClientThreadName ) );
|
|
229 |
}
|
|
230 |
|
|
231 |
void CMemSpyEngineSession::CreateL()
|
|
232 |
{
|
|
233 |
Server().AddSession(iIsCliRequest);
|
|
234 |
}
|
|
235 |
|
|
236 |
CMemSpyEngineSession* CMemSpyEngineSession::NewL( CMemSpyEngine& aEngine, const RMessage2& aMessage )
|
|
237 |
{
|
|
238 |
CMemSpyEngineSession* self = new(ELeave) CMemSpyEngineSession( aEngine );
|
|
239 |
CleanupStack::PushL( self );
|
|
240 |
self->ConstructL( aMessage );
|
|
241 |
CleanupStack::Pop( self );
|
|
242 |
return self;
|
|
243 |
}
|
|
244 |
|
|
245 |
|
|
246 |
void CMemSpyEngineSession::ServiceL( const RMessage2& aMessage )
|
|
247 |
{
|
|
248 |
TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - START - this: 0x%08x, fn: 0x%08x, id: %4d, client: %S"), this, aMessage.Function(), iClientThreadId, iClientThreadName ) );
|
|
249 |
|
|
250 |
TRAPD( error, DoServiceL( aMessage ) );
|
|
251 |
if ( error != KErrNone )
|
|
252 |
{
|
|
253 |
RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - SERVICE ERROR - this: 0x%08x, fn: %d, err: %d, client: %S"), this, aMessage.Function(), error, iClientThreadName );
|
|
254 |
}
|
|
255 |
|
|
256 |
if ((aMessage.Function() & KMemSpyOpFlagsAsyncOperation) == 0 || error != KErrNone)
|
|
257 |
{
|
|
258 |
aMessage.Complete( error );
|
|
259 |
}
|
|
260 |
|
|
261 |
TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - END - this: 0x%08x, fn: 0x%08x, id: %4d, client: %S"), this, aMessage.Function(), iClientThreadId, iClientThreadName ) );
|
|
262 |
}
|
|
263 |
|
|
264 |
// ---------------------------------------------------------
|
|
265 |
// DoServiceL( const RMessage2& aMessage )
|
|
266 |
// ---------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CMemSpyEngineSession::DoServiceL( const RMessage2& aMessage )
|
|
269 |
{
|
|
270 |
TInt function = aMessage.Function() & KMemSpyOpFlagsTypeMask;
|
|
271 |
if (function >= EMemSpyClientServerOpMarkerUiFirst &&
|
|
272 |
function < EMemSpyClientServerOpMarkerUiLast)
|
|
273 |
|
|
274 |
DoUiServiceL(aMessage);
|
|
275 |
else
|
|
276 |
DoCmdServiceL(aMessage);
|
|
277 |
}
|
|
278 |
// ---------------------------------------------------------
|
|
279 |
// DoUiServiceL( const RMessage2& aMessage )
|
|
280 |
// ---------------------------------------------------------
|
|
281 |
//
|
|
282 |
void CMemSpyEngineSession::DoUiServiceL( const RMessage2& aMessage )
|
|
283 |
{
|
|
284 |
switch (aMessage.Function() & KMemSpyOpFlagsTypeMask)
|
|
285 |
{
|
|
286 |
case EMemSpyClientServerOpGetOutputSink:
|
|
287 |
{
|
|
288 |
TMemSpySinkType sink = iEngine.SinkType();
|
|
289 |
TPckgBuf<TMemSpySinkType> type( sink );
|
|
290 |
|
|
291 |
aMessage.WriteL( 0, type );
|
|
292 |
break;
|
|
293 |
}
|
|
294 |
case EMemSpyClientServerOpGetProcessCount:
|
|
295 |
{
|
|
296 |
aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.Container().Count()));
|
|
297 |
break;
|
|
298 |
}
|
|
299 |
case EMemSpyClientServerOpGetProcesses:
|
|
300 |
{
|
|
301 |
CMemSpyEngineObjectContainer& list = iEngine.Container();
|
|
302 |
|
|
303 |
TPckgBuf<TInt> a0;
|
|
304 |
aMessage.ReadL(0, a0);
|
|
305 |
TInt realCount = Min(a0(), list.Count());
|
|
306 |
|
|
307 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyProcessData))
|
|
308 |
{
|
|
309 |
CMemSpyProcess& process = iEngine.Container().At(i);
|
|
310 |
TMemSpyProcessData data;
|
|
311 |
data.iIsDead = process.IsDead();
|
|
312 |
data.iId = process.Id();
|
|
313 |
data.iName.Copy(process.Name().Left(KMaxFullName));
|
|
314 |
data.iThreadCount = process.Count();
|
|
315 |
data.iPriority = process.Priority();
|
|
316 |
data.iExitType = process.ExitType();
|
|
317 |
data.iExitReason = process.ExitReason();
|
|
318 |
data.iExitCategory = process.ExitCategory();
|
|
319 |
data.iSID = process.SID();
|
|
320 |
|
|
321 |
TPckgBuf<TMemSpyProcessData> buffer(data);
|
|
322 |
aMessage.WriteL(1, buffer, offset);
|
|
323 |
}
|
|
324 |
|
|
325 |
a0 = list.Count();
|
|
326 |
aMessage.WriteL(0, a0);
|
|
327 |
|
|
328 |
break;
|
|
329 |
}
|
|
330 |
case EMemSpyClienServerOpGetProcessIdByName:
|
|
331 |
{
|
|
332 |
TFullName processName;
|
|
333 |
aMessage.ReadL(0, processName);
|
|
334 |
|
|
335 |
TBool found(EFalse);
|
|
336 |
|
|
337 |
for (TInt i=0; i<iEngine.Container().Count(); i++)
|
|
338 |
{
|
|
339 |
CMemSpyProcess& process = iEngine.Container().At(i);
|
|
340 |
if (process.Name().FindF(processName) >= 0)
|
|
341 |
{
|
|
342 |
found = ETrue;
|
|
343 |
TPckgBuf<TProcessId> procId(process.Id());
|
|
344 |
aMessage.WriteL(1, procId);
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
if (!found)
|
|
349 |
{
|
|
350 |
User::Leave(KErrNotFound);
|
|
351 |
}
|
|
352 |
|
|
353 |
break;
|
|
354 |
}
|
|
355 |
case EMemSpyClientServerOpProcessSystemPermanentOrCritical:
|
|
356 |
{
|
|
357 |
TBool ret = EFalse;
|
|
358 |
TPckgBuf<TProcessId> id;
|
|
359 |
aMessage.ReadL( 0, id );
|
|
360 |
|
|
361 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
362 |
CMemSpyProcess& process = container.ProcessByIdL( id() );
|
|
363 |
|
|
364 |
if ( process.IsSystemPermanent() || process.IsSystemCritical() )
|
|
365 |
{
|
|
366 |
ret = ETrue;
|
|
367 |
}
|
|
368 |
TPckgBuf<TBool> retBuf( ret );
|
|
369 |
aMessage.WriteL( 1, retBuf );
|
|
370 |
|
|
371 |
break;
|
|
372 |
}
|
|
373 |
case EMemSpyClientServerOpEndProcess:
|
|
374 |
{
|
|
375 |
TPckgBuf<TProcessId> id;
|
|
376 |
aMessage.ReadL( 0, id );
|
|
377 |
TPckgBuf<TMemSpyEndType> type;
|
|
378 |
aMessage.ReadL( 1, type );
|
|
379 |
|
|
380 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
381 |
CMemSpyProcess& process = container.ProcessByIdL( id() );
|
|
382 |
|
|
383 |
switch ( type() )
|
|
384 |
{
|
|
385 |
case ETerminate:
|
|
386 |
{
|
|
387 |
process.TerminateL();
|
|
388 |
break;
|
|
389 |
}
|
|
390 |
case EPanic:
|
|
391 |
{
|
|
392 |
process.PanicL();
|
|
393 |
break;
|
|
394 |
}
|
|
395 |
case EKill:
|
|
396 |
{
|
|
397 |
process.KillL();
|
|
398 |
break;
|
|
399 |
}
|
62
|
400 |
case EExit:
|
|
401 |
{
|
|
402 |
if (!iEngine.IsHelperWindowServerSupported())
|
|
403 |
{
|
|
404 |
User::Leave(KErrNotSupported);
|
|
405 |
}
|
|
406 |
|
|
407 |
MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
|
|
408 |
windowServerManager.EndTaskL( process.Name() );
|
|
409 |
|
|
410 |
break;
|
|
411 |
}
|
51
|
412 |
}
|
|
413 |
break;
|
|
414 |
}
|
|
415 |
case EMemSpyClientServerOpSwitchToProcess:
|
|
416 |
{/*
|
|
417 |
TInt wgCount;
|
|
418 |
RWsSession wsSession;
|
|
419 |
User::LeaveIfError( wsSession.Connect() );
|
|
420 |
CleanupClosePushL( wsSession );
|
|
421 |
User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
|
|
422 |
RArray<RWsSession::TWindowGroupChainInfo> wgArray;
|
|
423 |
CleanupClosePushL( wgArray );
|
|
424 |
User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
|
|
425 |
TApaTask task( wsSession );
|
|
426 |
TBool brought( EFalse );
|
|
427 |
TInt wgId( KErrNotFound );
|
|
428 |
TThreadId threadId;
|
|
429 |
|
|
430 |
TPckgBuf<TProcessId> id;
|
|
431 |
aMessage.ReadL( 0, id );
|
|
432 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
433 |
CMemSpyProcess& process = container.ProcessByIdL( id() );
|
|
434 |
|
|
435 |
// loop trough threads in a process
|
|
436 |
for ( TInt i = 0; i < process.MdcaCount(); i++ )
|
|
437 |
{
|
|
438 |
TInt wgCountLocal = wgCount;
|
|
439 |
|
|
440 |
// loop trough all window groups and see if a thread id matches
|
|
441 |
while( !brought && wgCountLocal-- )
|
|
442 |
{
|
|
443 |
wgId = wgArray[wgCountLocal].iId;
|
|
444 |
User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
|
|
445 |
if ( threadId == process.At( i ).Id() )
|
|
446 |
{
|
|
447 |
CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
|
|
448 |
task.SetWgId( wgId );
|
|
449 |
if ( !wgName->Hidden() && task.Exists() )
|
|
450 |
{
|
|
451 |
task.BringToForeground();
|
|
452 |
brought = ETrue;
|
|
453 |
}
|
|
454 |
CleanupStack::PopAndDestroy( wgName );
|
|
455 |
}
|
|
456 |
}
|
|
457 |
}
|
|
458 |
|
|
459 |
TPckgBuf<TBool> ret( brought );
|
|
460 |
aMessage.WriteL( 1, ret );
|
|
461 |
|
|
462 |
break;*/
|
|
463 |
}
|
|
464 |
case EMemSpyClientServerOpGetThreadCount:
|
|
465 |
{
|
|
466 |
TPckgBuf<TProcessId> pid;
|
|
467 |
aMessage.ReadL(1, pid);
|
|
468 |
CMemSpyProcess& process = iEngine.Container().ProcessByIdL(pid());
|
|
469 |
aMessage.WriteL(0, TPckgBuf<TInt>(process.Count()));
|
|
470 |
break;
|
|
471 |
}
|
|
472 |
case EMemSpyClientServerOpGetThreads:
|
|
473 |
{
|
|
474 |
TPckgBuf<TProcessId> pid;
|
|
475 |
aMessage.ReadL(2, pid);
|
|
476 |
|
|
477 |
CMemSpyProcess& list = iEngine.Container().ProcessByIdL(pid());
|
|
478 |
|
|
479 |
TPckgBuf<TInt> a0;
|
|
480 |
aMessage.ReadL(0, a0);
|
|
481 |
TInt realCount = Min(a0(), list.Count());
|
|
482 |
|
|
483 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyThreadData))
|
|
484 |
{
|
|
485 |
CMemSpyThread& thread = list.At(i);
|
|
486 |
|
|
487 |
TMemSpyThreadData data;
|
|
488 |
data.iId = thread.Id();
|
|
489 |
data.iName.Copy(thread.Name().Left(KMaxFullName));
|
|
490 |
data.iThreadPriority = thread.Priority();
|
|
491 |
|
|
492 |
TPckgBuf<TMemSpyThreadData> buffer(data);
|
|
493 |
aMessage.WriteL(1, buffer, offset);
|
|
494 |
}
|
|
495 |
|
|
496 |
a0 = list.Count();
|
|
497 |
aMessage.WriteL(0, a0);
|
|
498 |
|
|
499 |
break;
|
|
500 |
}
|
|
501 |
case EMemSpyClientServerOpSetThreadPriority:
|
|
502 |
{
|
|
503 |
TPckgBuf<TThreadId> tid;
|
|
504 |
TPckgBuf<TInt> priority;
|
|
505 |
aMessage.ReadL(0, tid);
|
|
506 |
aMessage.ReadL(1, priority);
|
|
507 |
|
|
508 |
CMemSpyProcess* process = NULL;
|
|
509 |
CMemSpyThread* thread = NULL;
|
|
510 |
User::LeaveIfError(iEngine.Container().ProcessAndThreadByThreadId(tid(), process, thread));
|
|
511 |
|
|
512 |
if (thread)
|
|
513 |
{
|
|
514 |
thread->SetPriorityL(static_cast<TThreadPriority>(priority()));
|
|
515 |
}
|
|
516 |
break;
|
|
517 |
}
|
|
518 |
case EMemSpyClientServerOpThreadSystemPermanentOrCritical:
|
|
519 |
{
|
|
520 |
TPckgBuf<TThreadId> id;
|
|
521 |
aMessage.ReadL( 0, id );
|
|
522 |
|
|
523 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
524 |
CMemSpyProcess* process = NULL;
|
|
525 |
CMemSpyThread* thread = NULL;
|
|
526 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
|
|
527 |
|
|
528 |
TBool ret = thread && ( thread->IsSystemPermanent() || thread->IsSystemCritical() );
|
|
529 |
|
|
530 |
TPckgBuf<TBool> retBuf( ret );
|
|
531 |
aMessage.WriteL( 1, retBuf );
|
|
532 |
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
case EMemSpyClientServerOpEndThread:
|
|
536 |
{
|
|
537 |
TPckgBuf<TThreadId> id;
|
|
538 |
aMessage.ReadL( 0, id );
|
|
539 |
TPckgBuf<TMemSpyEndType> type;
|
|
540 |
aMessage.ReadL( 1, type );
|
|
541 |
|
|
542 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
543 |
CMemSpyProcess* process = NULL;
|
|
544 |
CMemSpyThread* thread = NULL;
|
|
545 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
|
|
546 |
|
|
547 |
if( thread )
|
|
548 |
{
|
|
549 |
switch ( type() )
|
|
550 |
{
|
|
551 |
case ETerminate:
|
|
552 |
{
|
|
553 |
thread->TerminateL();
|
|
554 |
break;
|
|
555 |
}
|
|
556 |
case EPanic:
|
|
557 |
{
|
|
558 |
thread->PanicL();
|
|
559 |
break;
|
|
560 |
}
|
|
561 |
case EKill:
|
|
562 |
{
|
|
563 |
thread->KillL();
|
|
564 |
break;
|
|
565 |
}
|
|
566 |
}
|
|
567 |
}
|
|
568 |
break;
|
|
569 |
}
|
|
570 |
case EMemSpyClientServerOpSwitchToThread:
|
|
571 |
{
|
|
572 |
TInt wgCount;
|
|
573 |
RWsSession wsSession;
|
|
574 |
User::LeaveIfError( wsSession.Connect() );
|
|
575 |
CleanupClosePushL( wsSession );
|
|
576 |
User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
|
|
577 |
RArray<RWsSession::TWindowGroupChainInfo> wgArray;
|
|
578 |
CleanupClosePushL( wgArray );
|
|
579 |
User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
|
52
|
580 |
|
|
581 |
//TApaTask task( wsSession );
|
|
582 |
TBool brought = EFalse;
|
51
|
583 |
TInt wgId( KErrNotFound );
|
|
584 |
TThreadId threadId;
|
|
585 |
|
|
586 |
TPckgBuf<TThreadId> id;
|
|
587 |
aMessage.ReadL( 0, id );
|
|
588 |
|
|
589 |
// loop trough all window groups and see if a thread id matches
|
|
590 |
while( !brought && wgCount-- )
|
|
591 |
{
|
|
592 |
wgId = wgArray[wgCount].iId;
|
|
593 |
User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
|
|
594 |
if ( threadId == id() )
|
|
595 |
{
|
52
|
596 |
TInt handle = wsSession.GetWindowGroupHandle( wgId );
|
|
597 |
if( handle == KErrNone )
|
51
|
598 |
{
|
52
|
599 |
RWindowGroup* group = new (ELeave) RWindowGroup();
|
|
600 |
group->Construct( handle );
|
|
601 |
group->SetOrdinalPosition( 0 ); //foreground
|
|
602 |
|
|
603 |
brought = ETrue;
|
|
604 |
|
|
605 |
group->Close();
|
|
606 |
delete group;
|
51
|
607 |
}
|
52
|
608 |
}
|
|
609 |
//task.SetWgId( wgId );
|
|
610 |
//if ( !wgName->Hidden() && task.Exists() )
|
|
611 |
// {
|
|
612 |
// task.BringToForeground();
|
|
613 |
// brought = ETrue;
|
|
614 |
// }
|
51
|
615 |
}
|
52
|
616 |
|
51
|
617 |
TPckgBuf<TBool> ret( brought );
|
|
618 |
aMessage.WriteL( 1, ret );
|
|
619 |
|
|
620 |
break;
|
|
621 |
}
|
|
622 |
case EMemSpyClientServerOpGetInfoItemType:
|
|
623 |
{
|
|
624 |
|
|
625 |
TPckgBuf<TInt> index;
|
|
626 |
aMessage.ReadL( 0, index );
|
|
627 |
TPckgBuf<TThreadId> id;
|
|
628 |
aMessage.ReadL( 1, id);
|
|
629 |
|
|
630 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
631 |
CMemSpyProcess* process = NULL; //not needed
|
|
632 |
CMemSpyThread* thread = NULL;
|
|
633 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
|
|
634 |
|
|
635 |
CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
|
|
636 |
TMemSpyThreadInfoItemType retType = threadInfoContainer.Item( index() ).Type();
|
|
637 |
|
|
638 |
TPckgBuf<TMemSpyThreadInfoItemType> ret( retType );
|
|
639 |
aMessage.WriteL( 2, ret );
|
|
640 |
|
|
641 |
break;
|
|
642 |
}
|
|
643 |
case EMemSpyClientServerOpGetThreadInfoItemsCount:
|
|
644 |
{
|
|
645 |
TPckgBuf<TThreadId> id;
|
|
646 |
aMessage.ReadL( 0, id );
|
|
647 |
TPckgBuf<TMemSpyThreadInfoItemType> type;
|
|
648 |
aMessage.ReadL( 1, type );
|
|
649 |
|
|
650 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
651 |
CMemSpyProcess* process = NULL;
|
|
652 |
CMemSpyThread* thread = NULL;
|
|
653 |
|
|
654 |
container.ProcessAndThreadByThreadId( id(), process, thread );
|
|
655 |
|
|
656 |
CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
|
|
657 |
|
|
658 |
CMemSpyThreadInfoItemBase& threadInfoItemBase = threadInfoContainer.Item( type() );
|
|
659 |
|
|
660 |
TInt count = threadInfoItemBase.MdcaCount();
|
|
661 |
TPckgBuf<TInt> tempret( count );
|
|
662 |
aMessage.WriteL( 2, tempret );
|
|
663 |
|
|
664 |
break;
|
|
665 |
}
|
|
666 |
case EMemSpyClientServerOpGetThreadInfoItems:
|
|
667 |
{
|
|
668 |
TPckgBuf<TInt> count;
|
|
669 |
aMessage.ReadL( 0, count );
|
|
670 |
TPckgBuf<TThreadId> id;
|
|
671 |
aMessage.ReadL( 1, id );
|
|
672 |
TPckgBuf<TMemSpyThreadInfoItemType> type;
|
|
673 |
aMessage.ReadL( 2, type );
|
|
674 |
|
|
675 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
676 |
CMemSpyProcess* process = NULL;
|
|
677 |
CMemSpyThread* thread = NULL;
|
|
678 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
|
|
679 |
|
|
680 |
CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
|
|
681 |
|
|
682 |
CMemSpyThreadInfoItemBase& threadInfoItemBase = threadInfoContainer.Item( type() ); //get ThreadInfoItemBaseByType
|
|
683 |
|
|
684 |
TInt itemCount = Min(count(), threadInfoItemBase.MdcaCount());
|
|
685 |
|
|
686 |
for( TInt i=0, offset = 0; i<itemCount; i++, offset += sizeof( TMemSpyThreadInfoItemData ) )
|
|
687 |
{
|
|
688 |
TMemSpyThreadInfoItemData data;
|
|
689 |
|
|
690 |
TPtrC caption(threadInfoItemBase.MdcaPoint(i).Mid(1));
|
|
691 |
TInt tabPos = caption.Locate('\t');
|
|
692 |
if (tabPos != KErrNotFound)
|
|
693 |
caption.Set(caption.Left(tabPos));
|
|
694 |
|
|
695 |
TPtrC value(threadInfoItemBase.MdcaPoint(i));
|
|
696 |
tabPos = value.LocateReverse('\t');
|
|
697 |
if (tabPos != KErrNotFound)
|
|
698 |
value.Set(value.Mid(tabPos + 1));
|
|
699 |
|
|
700 |
data.iCaption.Copy( caption.Left(64) );
|
|
701 |
data.iValue.Copy( value.Left(32) );
|
|
702 |
|
|
703 |
TPckgBuf<TMemSpyThreadInfoItemData> buffer(data);
|
|
704 |
aMessage.WriteL(3, buffer, offset);
|
|
705 |
}
|
|
706 |
aMessage.WriteL(0, count);
|
|
707 |
|
|
708 |
break;
|
|
709 |
}
|
|
710 |
|
|
711 |
case EMemSpyClientServerOpGetProcessIdByThreadId:
|
|
712 |
{
|
|
713 |
TPckgBuf<TThreadId> tid;
|
|
714 |
aMessage.ReadL( 1, tid );
|
|
715 |
|
|
716 |
CMemSpyProcess* process = NULL;
|
|
717 |
CMemSpyThread* thread = NULL;
|
|
718 |
//
|
|
719 |
const TInt error = iEngine.Container().ProcessAndThreadByThreadId( tid(), process, thread );
|
|
720 |
|
|
721 |
TProcessId pid = process->Id();
|
|
722 |
|
|
723 |
TPckgBuf<TProcessId> ret(pid);
|
|
724 |
aMessage.WriteL( 0, ret );
|
|
725 |
|
|
726 |
break;
|
|
727 |
}
|
|
728 |
|
|
729 |
// --- KernelObjects related functions ---
|
|
730 |
case EMemSpyClientServerOpGetKernelObjectCount:
|
|
731 |
{
|
|
732 |
TInt iCount = EMemSpyDriverContainerTypeLast - EMemSpyDriverContainerTypeFirst + 1;
|
|
733 |
TPckgBuf<TInt> ret( iCount );
|
|
734 |
aMessage.WriteL(0, ret);
|
|
735 |
break;
|
|
736 |
}
|
|
737 |
case EMemSpyClientServerOpGetKernelObjects:
|
|
738 |
{
|
|
739 |
TPckgBuf<TInt> count;
|
|
740 |
aMessage.ReadL(0, count);
|
|
741 |
|
|
742 |
CMemSpyEngineGenericKernelObjectContainer* model = iEngine.HelperKernelContainers().ObjectsAllL(); //contains all the objects
|
|
743 |
CleanupStack::PushL( model );
|
|
744 |
|
|
745 |
for( TInt i=0, offset = 0; i<count(); i++, offset += sizeof( TMemSpyKernelObjectData ) )
|
|
746 |
{
|
|
747 |
TMemSpyKernelObjectData data;
|
|
748 |
|
|
749 |
TPtrC name(model->At(i).Name().Mid(1));
|
|
750 |
TInt tabPos = name.Locate('\t');
|
|
751 |
if (tabPos != KErrNotFound)
|
|
752 |
name.Set(name.Left(tabPos));
|
|
753 |
|
|
754 |
data.iName.Copy(name);
|
|
755 |
data.iType = model->At(i).Type();
|
|
756 |
data.iCount = model->At(i).Count();
|
|
757 |
data.iSize = model->At(i).Count() * model->At(i).Count();
|
|
758 |
|
|
759 |
TPckgBuf<TMemSpyKernelObjectData> buffer(data);
|
|
760 |
aMessage.WriteL(1, buffer, offset);
|
|
761 |
}
|
|
762 |
aMessage.WriteL(0, count);
|
|
763 |
CleanupStack::PopAndDestroy( model );
|
|
764 |
break;
|
|
765 |
}
|
|
766 |
case EMemSpyClientServerOpGetKernelObjectItemCount:
|
|
767 |
{
|
|
768 |
TPckgBuf<TMemSpyDriverContainerType> tempType;
|
|
769 |
aMessage.ReadL(1, tempType); //get type of kernel object
|
|
770 |
TMemSpyDriverContainerType type = tempType();
|
|
771 |
|
|
772 |
CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
|
|
773 |
CMemSpyEngineGenericKernelObjectList* iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( type );
|
|
774 |
|
|
775 |
TInt count = iObjectList->Count();
|
|
776 |
TPckgBuf<TInt> ret( count );
|
|
777 |
aMessage.WriteL( 0, ret );
|
|
778 |
|
|
779 |
break;
|
|
780 |
}
|
|
781 |
case EMemSpyClientServerOpGetKernelObjectItems:
|
|
782 |
{
|
|
783 |
TPckgBuf<TInt> count;
|
|
784 |
TPckgBuf<TMemSpyDriverContainerType> tempType;
|
|
785 |
aMessage.ReadL( 0, count ); //get count of items
|
|
786 |
aMessage.ReadL(1, tempType); //get type of kernel object
|
|
787 |
TInt c = count();
|
|
788 |
|
|
789 |
CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
|
|
790 |
CMemSpyEngineGenericKernelObjectList* iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( tempType() );
|
|
791 |
|
|
792 |
for( TInt i=0, offset = 0; i<c; i++, offset += sizeof( TMemSpyDriverHandleInfoGeneric ) )
|
|
793 |
{
|
|
794 |
TMemSpyDriverHandleInfoGeneric data;
|
|
795 |
|
|
796 |
data = iObjectList->At( i );
|
|
797 |
|
|
798 |
TPckgBuf<TMemSpyDriverHandleInfoGeneric> buffer(data);
|
|
799 |
aMessage.WriteL(2, buffer, offset);
|
|
800 |
}
|
|
801 |
|
|
802 |
break;
|
|
803 |
}
|
|
804 |
|
|
805 |
case EMemSpyClientServerOpOutputAllContainerContents:
|
|
806 |
{
|
|
807 |
CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
|
|
808 |
CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
|
|
809 |
|
|
810 |
model->OutputL( iEngine.Sink() );
|
|
811 |
|
|
812 |
break;
|
|
813 |
}
|
|
814 |
|
|
815 |
case EMemSpyClientServerOpDumpKernelHeap:
|
|
816 |
{
|
|
817 |
iEngine.HelperHeap().OutputHeapDataKernelL();
|
|
818 |
|
|
819 |
break;
|
|
820 |
}
|
|
821 |
|
|
822 |
case EMemSpyClientServerOpOutputInfoHandles:
|
|
823 |
{
|
|
824 |
TPckgBuf<TThreadId> id;
|
|
825 |
aMessage.ReadL(0, id);
|
|
826 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
827 |
CMemSpyProcess* process = NULL;
|
|
828 |
CMemSpyThread* thread = NULL;
|
|
829 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
|
|
830 |
|
|
831 |
CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
|
|
832 |
|
|
833 |
threadInfoContainer.PrintL();
|
|
834 |
|
|
835 |
break;
|
|
836 |
}
|
|
837 |
|
|
838 |
case EMemSpyClientServerOpOutputAOList:
|
|
839 |
{
|
|
840 |
TPckgBuf<TThreadId> id;
|
|
841 |
TPckgBuf<TMemSpyThreadInfoItemType> type;
|
|
842 |
aMessage.ReadL(0, id);
|
|
843 |
aMessage.ReadL(1, type);
|
|
844 |
|
|
845 |
CMemSpyEngineObjectContainer& container = iEngine.Container();
|
|
846 |
CMemSpyProcess* process = NULL;
|
|
847 |
CMemSpyThread* thread = NULL;
|
|
848 |
User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
|
|
849 |
|
|
850 |
CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
|
|
851 |
|
|
852 |
CMemSpyThreadInfoItemBase* threadInfoItem = &threadInfoContainer.Item( type() );
|
|
853 |
|
|
854 |
CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( threadInfoItem );
|
|
855 |
|
|
856 |
// Begin a new data stream
|
|
857 |
_LIT( KMemSpyContext, "Active Object List - " );
|
|
858 |
_LIT( KMemSpyFolder, "Active Objects" );
|
|
859 |
iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
|
|
860 |
|
|
861 |
// Set prefix for overall listing
|
|
862 |
iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
|
|
863 |
|
|
864 |
// Create header
|
|
865 |
CMemSpyEngineActiveObjectArray::OutputDataColumnsL( iEngine );
|
|
866 |
|
|
867 |
// List items
|
|
868 |
const TInt count = activeObjectArray->Array().Count();
|
|
869 |
for(TInt i=0; i<count; i++)
|
|
870 |
{
|
|
871 |
const CMemSpyEngineActiveObject& object = activeObjectArray->Array().At( i );
|
|
872 |
//
|
|
873 |
object.OutputDataL( iEngine );
|
|
874 |
}
|
|
875 |
|
|
876 |
// Tidy up
|
|
877 |
CleanupStack::PopAndDestroy(); // prefix
|
|
878 |
|
|
879 |
// End data stream
|
|
880 |
iEngine.Sink().DataStreamEndL();
|
|
881 |
|
|
882 |
break;
|
|
883 |
}
|
|
884 |
|
|
885 |
// --- Kernel Heap related functions ---
|
|
886 |
case EMemSpyClientServerOpGetHeap:
|
|
887 |
{
|
|
888 |
TMemSpyHeapInfo heapInfo;
|
|
889 |
iEngine.HelperHeap().GetHeapInfoKernelL( heapInfo );
|
|
890 |
TMemSpyHeapData data = iEngine.HelperHeap().NewHeapRawInfo( heapInfo );
|
|
891 |
|
|
892 |
TPckgBuf<TMemSpyHeapData> buffer(data);
|
|
893 |
aMessage.WriteL(0, buffer);
|
|
894 |
|
|
895 |
break;
|
|
896 |
}
|
|
897 |
|
|
898 |
case EMemSpyClientServerOpGetServerCount:
|
|
899 |
{
|
|
900 |
CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
|
|
901 |
CleanupStack::PushL(list);
|
|
902 |
// TODO: cache it between calls
|
|
903 |
aMessage.WriteL(0, TPckgBuf<TInt>(list->MdcaCount()));
|
|
904 |
|
|
905 |
CleanupStack::PopAndDestroy(list);
|
|
906 |
break;
|
|
907 |
}
|
|
908 |
// --- Servers related functions
|
|
909 |
case EMemSpyClientServerOpGetServers:
|
|
910 |
{
|
|
911 |
CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
|
|
912 |
CleanupStack::PushL(list);
|
|
913 |
|
|
914 |
TPckgBuf<TInt> a0;
|
|
915 |
aMessage.ReadL(0, a0);
|
|
916 |
TInt realCount = Min(a0(), list->MdcaCount());
|
|
917 |
|
|
918 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyServerData))
|
|
919 |
{
|
|
920 |
const CMemSpyEngineServerEntry& server = list->At(i);
|
|
921 |
TMemSpyServerData data;
|
|
922 |
|
|
923 |
CMemSpyProcess* process = NULL;
|
|
924 |
CMemSpyThread* thread = NULL;
|
|
925 |
TInt error = iEngine.Container().ProcessAndThreadByThreadId( server.Id(), process, thread );
|
|
926 |
if (error == KErrNone && thread)
|
|
927 |
{
|
52
|
928 |
data.iProcessId = thread->Process().Id();
|
|
929 |
data.iThreadId = thread->Id();
|
51
|
930 |
}
|
|
931 |
data.iName.Copy(server.Name().Left(KMaxFullName));
|
|
932 |
data.iSessionCount = server.SessionCount();
|
|
933 |
|
|
934 |
TPckgBuf<TMemSpyServerData> buffer(data);
|
|
935 |
aMessage.WriteL(1, buffer, offset);
|
|
936 |
}
|
|
937 |
|
|
938 |
a0 = list->Count();
|
|
939 |
aMessage.WriteL(0, a0);
|
|
940 |
|
|
941 |
CleanupStack::PopAndDestroy(list);
|
|
942 |
|
|
943 |
break;
|
|
944 |
}
|
|
945 |
|
|
946 |
case EMemSpyClientServerOpGetSortedServers:
|
|
947 |
{
|
|
948 |
CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
|
|
949 |
CleanupStack::PushL(list);
|
|
950 |
|
|
951 |
TPckgBuf<TSortType> a2;
|
|
952 |
aMessage.ReadL( 2, a2 );
|
|
953 |
|
|
954 |
//sort the list of the servers
|
|
955 |
if( a2() == ESortServByName )
|
|
956 |
list->SortByNameL();
|
|
957 |
else
|
|
958 |
list->SortBySessionCountL();
|
|
959 |
|
|
960 |
TPckgBuf<TInt> a0;
|
|
961 |
aMessage.ReadL(0, a0);
|
|
962 |
|
|
963 |
TInt realCount = Min(a0(), list->MdcaCount());
|
|
964 |
|
|
965 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyServerData))
|
|
966 |
{
|
|
967 |
const CMemSpyEngineServerEntry& server = list->At(i);
|
|
968 |
TMemSpyServerData data;
|
|
969 |
|
52
|
970 |
CMemSpyProcess* process = NULL;
|
|
971 |
CMemSpyThread* thread = NULL;
|
|
972 |
TInt error = iEngine.Container().ProcessAndThreadByThreadId( server.Id(), process, thread );
|
|
973 |
if (error == KErrNone && thread)
|
|
974 |
{
|
|
975 |
data.iProcessId = thread->Process().Id();
|
|
976 |
data.iThreadId = thread->Id();
|
|
977 |
}
|
51
|
978 |
data.iName.Copy(server.Name().Left(KMaxFullName));
|
|
979 |
data.iSessionCount = server.SessionCount();
|
|
980 |
|
|
981 |
TPckgBuf<TMemSpyServerData> buffer(data);
|
|
982 |
aMessage.WriteL(1, buffer, offset);
|
|
983 |
}
|
|
984 |
a0 = list->Count();
|
|
985 |
aMessage.WriteL(0, a0);
|
|
986 |
|
|
987 |
CleanupStack::PopAndDestroy(list);
|
|
988 |
break;
|
|
989 |
}
|
|
990 |
case EMemSpyClientServerOpServerListOutputGeneric:
|
|
991 |
{
|
|
992 |
TPckgBuf<TBool> a0;
|
|
993 |
aMessage.ReadL(0, a0);
|
|
994 |
|
|
995 |
CMemSpyEngineServerList* list;
|
|
996 |
list = iEngine.HelperServer().ServerListL();
|
|
997 |
CleanupStack::PushL(list);
|
|
998 |
|
|
999 |
_LIT( KMemSpyContext, "Server List - " );
|
|
1000 |
_LIT( KMemSpyFolder, "Servers" );
|
|
1001 |
iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
|
|
1002 |
|
|
1003 |
// Set prefix for overall listing
|
|
1004 |
iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
|
|
1005 |
|
|
1006 |
// Create header
|
|
1007 |
CMemSpyEngineServerList::OutputDataColumnsL( iEngine, a0() );
|
|
1008 |
|
|
1009 |
// List items
|
|
1010 |
const TInt count = list->Count();
|
|
1011 |
for(TInt i=0; i<count; i++)
|
|
1012 |
{
|
|
1013 |
const CMemSpyEngineServerEntry& server = list->At( i );
|
|
1014 |
//
|
|
1015 |
server.OutputDataL( iEngine.HelperServer(), a0() );
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
// Tidy up
|
|
1019 |
CleanupStack::PopAndDestroy(); // prefix
|
|
1020 |
|
|
1021 |
// End data stream
|
|
1022 |
iEngine.Sink().DataStreamEndL();
|
|
1023 |
|
|
1024 |
CleanupStack::PopAndDestroy(list);
|
|
1025 |
break;
|
|
1026 |
}
|
62
|
1027 |
case EMemSpyClientServerOpGetChunksCount:
|
|
1028 |
{
|
|
1029 |
CMemSpyEngineChunkList* list = iEngine.HelperChunk().ListL();
|
|
1030 |
CleanupStack::PushL( list );
|
|
1031 |
aMessage.WriteL(0, TPckgBuf<TInt>(list->MdcaCount()));
|
|
1032 |
CleanupStack::PopAndDestroy( list );
|
|
1033 |
|
|
1034 |
break;
|
|
1035 |
}
|
|
1036 |
case EMemSpyClientServerOpGetSortedChunks:
|
|
1037 |
{
|
|
1038 |
CMemSpyEngineChunkList* list = iEngine.HelperChunk().ListL();
|
|
1039 |
CleanupStack::PushL( list );
|
|
1040 |
|
|
1041 |
TPckgBuf<TSortType> a2;
|
|
1042 |
aMessage.ReadL( 2, a2 );
|
|
1043 |
|
|
1044 |
//sort the list of chunks
|
|
1045 |
if( a2() == ESortChunkByName )
|
|
1046 |
list->SortByNameL();
|
|
1047 |
else
|
|
1048 |
list->SortBySizeL();
|
|
1049 |
|
|
1050 |
TPckgBuf<TInt> a0;
|
|
1051 |
aMessage.ReadL(0, a0);
|
|
1052 |
|
|
1053 |
TInt realCount = Min(a0(), list->MdcaCount());
|
|
1054 |
|
|
1055 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyChunkData))
|
|
1056 |
{
|
|
1057 |
const CMemSpyEngineChunkEntry& chunk = list->At(i);
|
|
1058 |
TMemSpyChunkData data;
|
|
1059 |
|
|
1060 |
data.iName.Copy( chunk.Name() );
|
|
1061 |
data.iHandle = (TUint8*)chunk.Handle();
|
|
1062 |
data.iSize = chunk.Size();
|
|
1063 |
data.iMaxSize = chunk.MaxSize();
|
|
1064 |
data.iBaseAddress = (TUint8*)chunk.BaseAddress();
|
|
1065 |
data.iOwnerId = chunk.OwnerId();
|
|
1066 |
TFullName ownerName;
|
|
1067 |
chunk.OwnerName( ownerName );
|
|
1068 |
data.iOwnerName = ownerName;
|
|
1069 |
data.iType = chunk.Type();
|
|
1070 |
data.iAttributes = chunk.Attributes();
|
|
1071 |
|
|
1072 |
TPckgBuf<TMemSpyChunkData> buffer(data);
|
|
1073 |
aMessage.WriteL(1, buffer, offset);
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
CleanupStack::PopAndDestroy( list );
|
|
1077 |
|
|
1078 |
break;
|
|
1079 |
}
|
|
1080 |
case EMemSpyClientServerOpChunkListOutput:
|
|
1081 |
{
|
|
1082 |
//Get Chunk list
|
|
1083 |
CMemSpyEngineChunkList* list = iEngine.HelperChunk().ListL();
|
|
1084 |
CleanupStack::PushL( list );
|
51
|
1085 |
|
62
|
1086 |
// Begin a new data stream
|
|
1087 |
_LIT( KMemSpyContext, "Chunk List" );
|
|
1088 |
_LIT( KMemSpyFolder, "Chunks" );
|
|
1089 |
iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
|
|
1090 |
|
|
1091 |
// Set prefix for overall listing
|
|
1092 |
_LIT( KOverallPrefix, "Chunk List - " );
|
|
1093 |
iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
|
|
1094 |
|
|
1095 |
// Create header
|
|
1096 |
CMemSpyEngineChunkList::OutputDataColumnsL( iEngine );
|
|
1097 |
|
|
1098 |
// List items
|
|
1099 |
const TInt count = list->Count();
|
|
1100 |
for(TInt i=0; i<count; i++)
|
|
1101 |
{
|
|
1102 |
const CMemSpyEngineChunkEntry& entry = list->At( i );
|
|
1103 |
//
|
|
1104 |
entry.OutputDataL( iEngine.HelperChunk() );
|
|
1105 |
}
|
|
1106 |
|
|
1107 |
// Tidy up
|
|
1108 |
CleanupStack::PopAndDestroy(); // prefix
|
|
1109 |
|
|
1110 |
// End data stream
|
|
1111 |
iEngine.Sink().DataStreamEndL();
|
|
1112 |
CleanupStack::PopAndDestroy( list );
|
|
1113 |
|
|
1114 |
break;
|
|
1115 |
}
|
51
|
1116 |
case EMemSpyClientServerOpGetMemoryTrackingCycleCount:
|
|
1117 |
{
|
|
1118 |
TInt count = iEngine.HelperSysMemTracker().CompletedCycles().Count();
|
|
1119 |
TPckgBuf<TInt> ret( count );
|
|
1120 |
aMessage.WriteL( 0, ret );
|
|
1121 |
break;
|
|
1122 |
}
|
|
1123 |
|
|
1124 |
case EMemSpyClientServerOpGetMemoryTrackingCycles:
|
|
1125 |
{
|
|
1126 |
const RPointerArray<CMemSpyEngineHelperSysMemTrackerCycle>& list = iEngine.HelperSysMemTracker().CompletedCycles();
|
|
1127 |
|
|
1128 |
TPckgBuf<TInt> a0;
|
|
1129 |
aMessage.ReadL(0, a0);
|
|
1130 |
TInt realCount = Min(a0(), list.Count());
|
|
1131 |
|
|
1132 |
for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyMemoryTrackingCycleData))
|
|
1133 |
{
|
|
1134 |
CMemSpyProcess& process = iEngine.Container().At(i);
|
|
1135 |
TMemSpyMemoryTrackingCycleData data;
|
|
1136 |
data.iCycleNumber = list[i]->CycleNumber();
|
|
1137 |
data.iCaption.Copy(list[i]->Caption().Left(KMaxFullName));
|
|
1138 |
data.iTime = list[i]->Time();
|
|
1139 |
data.iFreeMemory = list[i]->MemoryFree();
|
|
1140 |
data.iMemoryDelta = list[i]->MemoryDelta();
|
|
1141 |
data.iPreviousCycleDiff = list[i]->MemoryFreePreviousCycle();
|
|
1142 |
data.iChangeCount = list[i]->ChangeCount();
|
|
1143 |
|
|
1144 |
TPckgBuf<TMemSpyMemoryTrackingCycleData> buffer(data);
|
|
1145 |
aMessage.WriteL(1, buffer, offset);
|
|
1146 |
}
|
|
1147 |
|
|
1148 |
a0 = list.Count();
|
|
1149 |
aMessage.WriteL(0, a0);
|
|
1150 |
|
|
1151 |
break;
|
|
1152 |
}
|
|
1153 |
|
|
1154 |
case EMemSpyClientServerOpIsSwmtRunning:
|
|
1155 |
{
|
|
1156 |
TPckgBuf<TBool> running(iEngine.HelperSysMemTracker().IsActive());
|
|
1157 |
aMessage.WriteL(0, running);
|
|
1158 |
break;
|
|
1159 |
}
|
|
1160 |
|
|
1161 |
case EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodGet:
|
|
1162 |
{
|
|
1163 |
// Get current config
|
|
1164 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1165 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1166 |
TInt time = config.iTimerPeriod.Int();
|
|
1167 |
TPckgBuf<TInt> tim(time);
|
|
1168 |
aMessage.WriteL( 0, tim );
|
|
1169 |
break;
|
|
1170 |
}
|
|
1171 |
|
|
1172 |
case EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesGet:
|
|
1173 |
{
|
|
1174 |
// Get current config
|
|
1175 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1176 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1177 |
TInt categories = config.iEnabledCategories;
|
|
1178 |
TPckgBuf<TInt> ret( categories );
|
|
1179 |
aMessage.WriteL( 0, ret );
|
|
1180 |
break;
|
|
1181 |
}
|
|
1182 |
|
|
1183 |
case EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterGet:
|
|
1184 |
{
|
|
1185 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1186 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1187 |
TName threadNameFilter = config.iThreadNameFilter;
|
|
1188 |
TPckgBuf<TName> name(threadNameFilter);
|
|
1189 |
aMessage.WriteL( 0, name );
|
|
1190 |
|
|
1191 |
break;
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
case EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpGet:
|
|
1195 |
{
|
|
1196 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1197 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1198 |
TBool heapDump = config.iDumpData;
|
|
1199 |
TPckgBuf<TBool> heap(heapDump);
|
|
1200 |
aMessage.WriteL( 0, heap );
|
|
1201 |
break;
|
|
1202 |
}
|
|
1203 |
|
|
1204 |
case EMemSpyClientServerOpSystemWideMemoryTrackingModeGet:
|
|
1205 |
{
|
|
1206 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1207 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1208 |
TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mod(config.iMode);
|
|
1209 |
aMessage.WriteL(0, mod);
|
|
1210 |
break;
|
|
1211 |
}
|
|
1212 |
|
|
1213 |
case EMemSpyClientServerOpNotifyDeviceWideOperationProgress:
|
|
1214 |
{
|
|
1215 |
if (!Server().CurrentOperationTracker())
|
|
1216 |
{
|
|
1217 |
User::Leave(KErrNotReady);
|
|
1218 |
}
|
|
1219 |
|
|
1220 |
Server().CurrentOperationTracker()->AddNotificationL(aMessage);
|
|
1221 |
break;
|
|
1222 |
}
|
|
1223 |
|
|
1224 |
case EMemSpyClientServerOpCancelDeviceWideOperation:
|
|
1225 |
if (!Server().CurrentOperationTracker())
|
|
1226 |
{
|
|
1227 |
User::Leave(KErrNotReady);
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
Server().CurrentOperationTracker()->Cancel();
|
|
1231 |
break;
|
|
1232 |
|
|
1233 |
|
|
1234 |
case EMemSpyClientServerOpGetEComCategoryCount:
|
|
1235 |
aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.HelperECom().MdcaCount()));
|
|
1236 |
break;
|
|
1237 |
|
|
1238 |
|
|
1239 |
case EMemSpyClientServerOpGetEComCategories:
|
|
1240 |
{
|
|
1241 |
TPckgBuf<TInt> a0;
|
|
1242 |
aMessage.ReadL(0, a0);
|
|
1243 |
TInt realCount = Min(a0(), iEngine.HelperECom().MdcaCount());
|
|
1244 |
|
|
1245 |
for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComCategoryData))
|
|
1246 |
{
|
|
1247 |
TMemSpyEComCategoryData data;
|
|
1248 |
data.iId.iUid = i;
|
|
1249 |
data.iName.Copy(iEngine.HelperECom().At(i).Name());
|
|
1250 |
data.iInterfaceCount = iEngine.HelperECom().At(i).MdcaCount();
|
|
1251 |
|
|
1252 |
TPckgBuf<TMemSpyEComCategoryData> buffer(data);
|
|
1253 |
aMessage.WriteL(1, buffer, offset);
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
a0 = iEngine.HelperECom().MdcaCount();
|
|
1257 |
aMessage.WriteL(0, a0);
|
|
1258 |
break;
|
|
1259 |
}
|
|
1260 |
|
|
1261 |
case EMemSpyClientServerOpGetEComInterfaceCount:
|
|
1262 |
{
|
|
1263 |
TPckgBuf<TUid> a1;
|
|
1264 |
aMessage.ReadL(1, a1);
|
|
1265 |
TInt index = a1().iUid;
|
|
1266 |
|
|
1267 |
if (index < 0 || index >= iEngine.HelperECom().MdcaCount())
|
|
1268 |
{
|
|
1269 |
User::Leave(KErrArgument);
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.HelperECom().At(index).MdcaCount()));
|
|
1273 |
break;
|
|
1274 |
}
|
|
1275 |
|
|
1276 |
case EMemSpyClientServerOpGetEComInterfaces:
|
|
1277 |
{
|
|
1278 |
TPckgBuf<TInt> a0;
|
|
1279 |
aMessage.ReadL(0, a0);
|
|
1280 |
TInt realCount = Min(a0(), iEngine.HelperECom().MdcaCount());
|
|
1281 |
|
|
1282 |
TPckgBuf<TUid> a1;
|
|
1283 |
aMessage.ReadL(1, a1);
|
|
1284 |
TInt categoryIndex = a1().iUid;
|
|
1285 |
|
|
1286 |
if (categoryIndex < 0 || categoryIndex >= iEngine.HelperECom().MdcaCount())
|
|
1287 |
{
|
|
1288 |
User::Leave(KErrArgument);
|
|
1289 |
}
|
|
1290 |
|
|
1291 |
CMemSpyEngineEComCategory &category = iEngine.HelperECom().At(categoryIndex);
|
|
1292 |
|
|
1293 |
for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComInterfaceData))
|
|
1294 |
{
|
|
1295 |
TMemSpyEComInterfaceData data;
|
|
1296 |
data.iId.iUid = (TInt32) &category.At(i);
|
|
1297 |
data.iCategoryId.iUid = categoryIndex;
|
|
1298 |
data.iName.Copy(category.At(i).Name());
|
|
1299 |
data.iImplementationCount = category.At(i).MdcaCount();
|
|
1300 |
|
|
1301 |
TPckgBuf<TMemSpyEComInterfaceData> buffer(data);
|
|
1302 |
aMessage.WriteL(2, buffer, offset);
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
a0 = realCount;
|
|
1306 |
aMessage.WriteL(0, a0);
|
|
1307 |
|
|
1308 |
break;
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
case EMemSpyClientServerOpGetEComImplementationCount:
|
|
1312 |
{
|
|
1313 |
TPckgBuf<TUid> a1;
|
|
1314 |
aMessage.ReadL(1, a1);
|
|
1315 |
CMemSpyEngineEComInterface* interface = reinterpret_cast<CMemSpyEngineEComInterface*>(a1().iUid);
|
|
1316 |
|
|
1317 |
// TODO: check if it really is valid interface
|
|
1318 |
|
|
1319 |
aMessage.WriteL(0, TPckgBuf<TInt>(interface->MdcaCount()));
|
|
1320 |
break;
|
|
1321 |
}
|
|
1322 |
|
|
1323 |
case EMemSpyClientServerOpGetEComImplementations:
|
|
1324 |
{
|
|
1325 |
TPckgBuf<TUid> a1;
|
|
1326 |
aMessage.ReadL(1, a1);
|
|
1327 |
CMemSpyEngineEComInterface* interface = reinterpret_cast<CMemSpyEngineEComInterface*>(a1().iUid);
|
|
1328 |
|
|
1329 |
TPckgBuf<TInt> a0;
|
|
1330 |
aMessage.ReadL(0, a0);
|
|
1331 |
TInt realCount = Min(a0(), interface->MdcaCount());
|
|
1332 |
|
|
1333 |
|
|
1334 |
for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComImplementationData))
|
|
1335 |
{
|
|
1336 |
TMemSpyEComImplementationData data;
|
|
1337 |
data.iName.Copy(interface->At(i).Info().DisplayName());
|
|
1338 |
data.iImplementationUid = interface->At(i).Info().ImplementationUid();
|
|
1339 |
data.iVersion = interface->At(i).Info().Version();
|
|
1340 |
data.iDataType.Copy(interface->At(i).Info().DataType());
|
|
1341 |
data.iOpaqueData.Copy(interface->At(i).Info().OpaqueData());
|
|
1342 |
data.iDrive = interface->At(i).Info().Drive();
|
|
1343 |
data.iRomOnly = interface->At(i).Info().RomOnly();
|
|
1344 |
data.iRomBased = interface->At(i).Info().RomBased();
|
|
1345 |
data.iVendorId = interface->At(i).Info().VendorId();
|
|
1346 |
data.iDisabled = interface->At(i).Info().Disabled();
|
|
1347 |
|
|
1348 |
TPckgBuf<TMemSpyEComImplementationData> buffer(data);
|
|
1349 |
aMessage.WriteL(2, buffer, offset);
|
|
1350 |
}
|
|
1351 |
|
|
1352 |
a0 = realCount;
|
|
1353 |
aMessage.WriteL(0, a0);
|
|
1354 |
|
|
1355 |
break;
|
|
1356 |
}
|
|
1357 |
|
52
|
1358 |
case EMemSpyClientServerOpGetWindowGroupCount:
|
|
1359 |
{
|
|
1360 |
if (!iEngine.IsHelperWindowServerSupported())
|
|
1361 |
{
|
|
1362 |
User::Leave(KErrNotSupported);
|
|
1363 |
}
|
|
1364 |
|
|
1365 |
RWsSession windowSession;
|
|
1366 |
windowSession.Connect();
|
|
1367 |
TInt result = windowSession.NumWindowGroups();
|
|
1368 |
windowSession.Close();
|
|
1369 |
User::LeaveIfError(result);
|
|
1370 |
|
|
1371 |
aMessage.WriteL(0, TPckgBuf<TInt>(result));
|
|
1372 |
break;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
case EMemSpyClientServerOpGetWindowGroups:
|
|
1376 |
{
|
|
1377 |
if (!iEngine.IsHelperWindowServerSupported())
|
|
1378 |
{
|
|
1379 |
User::Leave(KErrNotSupported);
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
RArray<TMemSpyEngineWindowGroupBasicInfo> groups;
|
|
1383 |
CleanupClosePushL( groups );
|
|
1384 |
|
|
1385 |
iEngine.HelperWindowServer().GetWindowGroupListL( groups );
|
|
1386 |
|
|
1387 |
TPckgBuf<TInt> a0;
|
|
1388 |
aMessage.ReadL(0, a0);
|
|
1389 |
TInt realCount = Min(a0(), groups.Count());
|
|
1390 |
|
|
1391 |
for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEngineWindowGroupDetails))
|
|
1392 |
{
|
|
1393 |
TMemSpyEngineWindowGroupDetails data;
|
|
1394 |
|
|
1395 |
|
|
1396 |
iEngine.HelperWindowServer().GetWindowGroupDetailsL(groups[i].iId, data);
|
|
1397 |
|
|
1398 |
TPckgBuf<TMemSpyEngineWindowGroupDetails> buffer(data);
|
|
1399 |
aMessage.WriteL(1, buffer, offset);
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
a0 = realCount;
|
|
1403 |
aMessage.WriteL(0, a0);
|
|
1404 |
|
|
1405 |
CleanupStack::PopAndDestroy( &groups );
|
|
1406 |
|
|
1407 |
break;
|
|
1408 |
}
|
62
|
1409 |
case EMemSpyClientServerOpSwitchToWindowGroup:
|
|
1410 |
{
|
|
1411 |
TPckgBuf<TInt> id;
|
|
1412 |
aMessage.ReadL(0, id);
|
|
1413 |
|
|
1414 |
MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
|
|
1415 |
windowServerManager.SwitchToL( id() );
|
|
1416 |
|
|
1417 |
break;
|
|
1418 |
}
|
|
1419 |
case EMemSpyClientServerOpIsAknIconCacheConfigurable:
|
|
1420 |
{
|
|
1421 |
TBool ret = iEngine.HelperRAM().IsAknIconCacheConfigurable();
|
|
1422 |
|
|
1423 |
TPckgBuf<TBool> retBuf( ret );
|
|
1424 |
aMessage.WriteL( 0, retBuf );
|
|
1425 |
break;
|
|
1426 |
}
|
|
1427 |
case EMemSpyClientServerOpSetAknIconCacheStatus:
|
|
1428 |
{
|
|
1429 |
TPckgBuf<TBool> enabled;
|
|
1430 |
aMessage.ReadL(0, enabled);
|
|
1431 |
|
|
1432 |
TInt64 savedAmount = iEngine.HelperRAM().SetAknIconCacheStatusL( enabled() );
|
|
1433 |
|
|
1434 |
TPckgBuf<TInt64> ret(savedAmount);
|
|
1435 |
aMessage.WriteL(1, ret);
|
|
1436 |
break;
|
|
1437 |
}
|
|
1438 |
|
|
1439 |
// Code Segments
|
|
1440 |
case EMemSpyClientServerOpGetCodeSegmentsCount:
|
|
1441 |
{
|
|
1442 |
TInt result = 0;
|
|
1443 |
|
|
1444 |
CMemSpyEngineCodeSegList* list = iEngine.HelperCodeSegment().CodeSegmentListL();
|
|
1445 |
CleanupStack::PushL( list );
|
|
1446 |
result = list->MdcaCount();
|
|
1447 |
aMessage.WriteL(0, TPckgBuf<TInt>(result));
|
|
1448 |
CleanupStack::Pop( list );
|
|
1449 |
break;
|
|
1450 |
}
|
|
1451 |
case EMemSpyClientServerOpGetSortedCodeSegments:
|
|
1452 |
{
|
|
1453 |
CMemSpyEngineCodeSegList* list = iEngine.HelperCodeSegment().CodeSegmentListL();
|
|
1454 |
CleanupStack::PushL( list );
|
|
1455 |
|
|
1456 |
TPckgBuf<TSortType> a2;
|
|
1457 |
aMessage.ReadL( 2, a2 );
|
|
1458 |
|
|
1459 |
//sort the list of Code Segments
|
|
1460 |
if( a2() == ESortCodeSegByName )
|
|
1461 |
list->SortByFileNameL();
|
|
1462 |
else if ( a2() == ESortCodeSegBySize )
|
|
1463 |
list->SortByCodeSizeL();
|
|
1464 |
else if ( a2() == ESortCodeSegByTotalDataSize )
|
|
1465 |
list->SortByDataSizeL();
|
|
1466 |
else
|
|
1467 |
list->SortByUidsL();
|
|
1468 |
|
|
1469 |
TPckgBuf<TInt> a0;
|
|
1470 |
aMessage.ReadL(0, a0);
|
|
1471 |
|
|
1472 |
TInt realCount = Min(a0(), list->MdcaCount());
|
|
1473 |
|
|
1474 |
for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyCodeSegmentData))
|
|
1475 |
{
|
|
1476 |
const CMemSpyEngineCodeSegEntry& codeSegment = list->At(i);
|
|
1477 |
TMemSpyCodeSegmentData data;
|
|
1478 |
TCodeSegCreateInfo createInfo = codeSegment.CreateInfo();
|
|
1479 |
|
|
1480 |
data.iName.Copy( codeSegment.FileName() );
|
|
1481 |
data.iCodeSize = createInfo.iCodeSize;
|
|
1482 |
data.iTotalDataSize = createInfo.iTotalDataSize;
|
|
1483 |
data.iTextSize = createInfo.iTextSize;
|
|
1484 |
data.iDataSize = createInfo.iDataSize;
|
|
1485 |
data.iBssSize = createInfo.iBssSize;
|
|
1486 |
data.iUids = createInfo.iUids;
|
|
1487 |
data.iModuleVersion = createInfo.iModuleVersion;
|
|
1488 |
data.iSecureId = createInfo.iS.iSecureId;
|
|
1489 |
data.iVendorId = createInfo.iS.iVendorId;
|
|
1490 |
data.iEntryPtVeneer = createInfo.iEntryPtVeneer;
|
|
1491 |
data.iFileEntryPoint = createInfo.iFileEntryPoint;
|
|
1492 |
data.iDepCount = createInfo.iDepCount;
|
|
1493 |
data.iCodeLoadAddress = createInfo.iCodeLoadAddress;
|
|
1494 |
data.iDataLoadAddress = createInfo.iDataLoadAddress;
|
|
1495 |
data.iCapabilities1 = static_cast<TUint32>(createInfo.iS.iCaps[0]);
|
|
1496 |
data.iCapabilities2 = static_cast<TUint32>(createInfo.iS.iCaps[1]);
|
|
1497 |
|
|
1498 |
TPckgBuf<TMemSpyCodeSegmentData> buffer(data);
|
|
1499 |
aMessage.WriteL(1, buffer, offset);
|
|
1500 |
}
|
|
1501 |
CleanupStack::PopAndDestroy( list );
|
|
1502 |
|
|
1503 |
break;
|
|
1504 |
}
|
|
1505 |
case EMemSpyClientServerOpCodeSegmentsOutput:
|
|
1506 |
{
|
|
1507 |
CMemSpyEngineCodeSegList* list = iEngine.HelperCodeSegment().CodeSegmentListL();
|
|
1508 |
CleanupStack::PushL( list );
|
|
1509 |
// Begin a new data stream
|
|
1510 |
_LIT( KMemSpyContext, "CodeSeg List - " );
|
|
1511 |
_LIT( KMemSpyFolder, "CodeSegs" );
|
|
1512 |
iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
|
|
1513 |
|
|
1514 |
// Set prefix for overall listing
|
|
1515 |
_LIT(KOverallPrefix, "CodeSeg List - ");
|
|
1516 |
iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
|
|
1517 |
|
|
1518 |
// Create header
|
|
1519 |
CMemSpyEngineCodeSegList::OutputDataColumnsL( iEngine );
|
|
1520 |
|
|
1521 |
// List items
|
|
1522 |
const TInt count = list->Count();
|
|
1523 |
for(TInt i=0; i<count; i++)
|
|
1524 |
{
|
|
1525 |
const CMemSpyEngineCodeSegEntry& entry = list->At( i );
|
|
1526 |
//
|
|
1527 |
entry.OutputDataL( iEngine.HelperCodeSegment() );
|
|
1528 |
}
|
|
1529 |
|
|
1530 |
// Tidy up
|
|
1531 |
CleanupStack::PopAndDestroy(); // prefix
|
|
1532 |
|
|
1533 |
// End data stream
|
|
1534 |
iEngine.Sink().DataStreamEndL();
|
|
1535 |
|
|
1536 |
// Tidy up Code segment list
|
|
1537 |
CleanupStack::PopAndDestroy( list );
|
|
1538 |
|
|
1539 |
break;
|
|
1540 |
}
|
|
1541 |
|
|
1542 |
case EMemSpyClientServerOpNotifyEvent:
|
|
1543 |
Server().NotificationTracker()->AddNotificationL( aMessage );
|
|
1544 |
break;
|
|
1545 |
|
|
1546 |
case EMemSpyClientServerOpCancelEventNotification:
|
|
1547 |
Server().NotificationTracker()->CancelNotification( aMessage );
|
|
1548 |
break;
|
52
|
1549 |
|
|
1550 |
|
51
|
1551 |
}
|
|
1552 |
}
|
|
1553 |
|
|
1554 |
// ---------------------------------------------------------
|
|
1555 |
// DoCmdServiceL( const RMessage2& aMessage )
|
|
1556 |
// ---------------------------------------------------------
|
|
1557 |
//
|
|
1558 |
void CMemSpyEngineSession::DoCmdServiceL( const RMessage2& aMessage )
|
|
1559 |
{
|
|
1560 |
TInt error = KErrNone;
|
|
1561 |
|
|
1562 |
// Check function attributes
|
|
1563 |
const TInt function = aMessage.Function() & KMemSpyOpFlagsTypeMask;
|
|
1564 |
const TInt argSpec = aMessage.Function() & KMemSpyOpFlagsInclusionMask;
|
|
1565 |
const TBool byThreadId = ( argSpec == KMemSpyOpFlagsIncludesThreadId );
|
|
1566 |
const TBool byThreadName = ( argSpec == KMemSpyOpFlagsIncludesThreadName );
|
|
1567 |
|
|
1568 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - START - unmodified function: 0x%08x, opCode: %d [TID: %d, TN: %d]", aMessage.Function(), function, byThreadId, byThreadName ) );
|
|
1569 |
|
|
1570 |
// Check function is supported and argument combination is valid
|
|
1571 |
error = ValidateFunction( function, byThreadId, byThreadName );
|
|
1572 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - validation result: %d", error ) );
|
|
1573 |
|
|
1574 |
// Process function request
|
|
1575 |
if ( error == KErrNone )
|
|
1576 |
{
|
|
1577 |
if ( byThreadId )
|
|
1578 |
{
|
|
1579 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - [TID] thread-specific..." ) );
|
|
1580 |
|
|
1581 |
const TThreadId threadId( aMessage.Int0() );
|
|
1582 |
HandleThreadSpecificOpL( function, threadId );
|
|
1583 |
}
|
|
1584 |
else if ( byThreadName )
|
|
1585 |
{
|
|
1586 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - [TN] thread-specific..." ) );
|
|
1587 |
|
|
1588 |
error = aMessage.GetDesLength( 0 /*slot 0*/ );
|
|
1589 |
|
|
1590 |
if ( error > 0 && error <= KMaxFullName )
|
|
1591 |
{
|
|
1592 |
TFullName* threadName = new(ELeave) TFullName();
|
|
1593 |
CleanupStack::PushL( threadName );
|
|
1594 |
aMessage.ReadL( 0, *threadName );
|
|
1595 |
HandleThreadSpecificOpL( function, *threadName );
|
|
1596 |
CleanupStack::PopAndDestroy( threadName );
|
|
1597 |
}
|
|
1598 |
else
|
|
1599 |
{
|
|
1600 |
error = KErrArgument;
|
|
1601 |
}
|
|
1602 |
}
|
|
1603 |
else
|
|
1604 |
{
|
|
1605 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - thread-agnostic..." ) );
|
|
1606 |
|
|
1607 |
HandleThreadAgnosticOpL( function, aMessage );
|
|
1608 |
}
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
User::LeaveIfError( error );
|
|
1612 |
|
|
1613 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - END" ) );
|
|
1614 |
}
|
|
1615 |
|
|
1616 |
|
|
1617 |
|
|
1618 |
TInt CMemSpyEngineSession::ValidateFunction( TInt aFunction, TBool aIncludesThreadId, TBool aIncludesThreadName )
|
|
1619 |
{
|
|
1620 |
TInt err = KErrNotSupported;
|
|
1621 |
|
|
1622 |
// Check the operation is within op-code range
|
|
1623 |
if ( aFunction >= EMemSpyClientServerOpMarkerFirst && aFunction < EMemSpyClientServerOpMarkerLast )
|
|
1624 |
{
|
|
1625 |
// Check the operation doesn't include unnecessary or not supported information
|
|
1626 |
const TBool includesThreadIdentifier = ( aIncludesThreadId || aIncludesThreadName );
|
|
1627 |
if ( includesThreadIdentifier && aFunction >= EMemSpyClientServerOpMarkerThreadAgnosticFirst )
|
|
1628 |
{
|
|
1629 |
// Passing a thread identifier to a thread agnostic operation
|
|
1630 |
err = KErrArgument;
|
|
1631 |
}
|
|
1632 |
else
|
|
1633 |
{
|
|
1634 |
err = KErrNone;
|
|
1635 |
}
|
|
1636 |
}
|
|
1637 |
//
|
|
1638 |
if ( err != KErrNone )
|
|
1639 |
{
|
|
1640 |
RDebug::Printf( "[MemSpy] CMemSpyEngineSession::ValidateFunction() - function request did not validate - [withId: %d, withName: %d]", aIncludesThreadId, aIncludesThreadName );
|
|
1641 |
}
|
|
1642 |
//
|
|
1643 |
return err;
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
|
|
1647 |
void CMemSpyEngineSession::HandleThreadSpecificOpL( TInt aFunction, const TThreadId& aThreadId )
|
|
1648 |
{
|
|
1649 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - START - aFunction: %d, aThreadId: %d", aFunction, (TUint) aThreadId ) );
|
|
1650 |
|
|
1651 |
ASSERT( (TUint) aThreadId != 0 );
|
|
1652 |
TInt error = KErrNone;
|
|
1653 |
|
|
1654 |
// Check if its a kernel thread identifier
|
|
1655 |
const TBool isKernel = ( static_cast<TUint32>( aThreadId ) == KMemSpyClientServerThreadIdKernel );
|
|
1656 |
|
|
1657 |
// Treat as thread specific operation
|
|
1658 |
CMemSpyProcess* process = NULL;
|
|
1659 |
CMemSpyThread* thread = NULL;
|
|
1660 |
if ( !isKernel )
|
|
1661 |
{
|
|
1662 |
error = iEngine.Container().ProcessAndThreadByThreadId( aThreadId, process, thread );
|
|
1663 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - search result: %d, proc: 0x%08x, thread: 0x%08x", error, process, thread ) );
|
|
1664 |
}
|
|
1665 |
else
|
|
1666 |
{
|
|
1667 |
// Kernel is only supported for a couple of operations
|
|
1668 |
if ( aFunction == EMemSpyClientServerOpHeapInfo || aFunction == EMemSpyClientServerOpHeapData )
|
|
1669 |
{
|
|
1670 |
}
|
|
1671 |
else
|
|
1672 |
{
|
|
1673 |
TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - trying to call unsupported function for kernel thread!" ) );
|
|
1674 |
error = KErrArgument;
|
|
1675 |
}
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
// Must be no error so far and we must have a valid thread & process when performing a non-kernel op
|
|
1679 |
// or then if we are performing a kernel op, we don't need the thread or process.
|
|
1680 |
if ( error == KErrNone && ( ( thread && process && !isKernel ) || ( isKernel ) ) )
|
|
1681 |
{
|
|
1682 |
#ifdef _DEBUG
|
|
1683 |
if ( thread )
|
|
1684 |
{
|
|
1685 |
HBufC* threadName = thread->FullName().AllocLC();
|
|
1686 |
_LIT( KTrace2, "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - thread: %S" );
|
|
1687 |
RDebug::Print( KTrace2, threadName );
|
|
1688 |
CleanupStack::PopAndDestroy( threadName );
|
|
1689 |
}
|
|
1690 |
else if ( isKernel )
|
|
1691 |
{
|
|
1692 |
_LIT( KTrace2, "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - thread: Kernel" );
|
|
1693 |
RDebug::Print( KTrace2 );
|
|
1694 |
}
|
|
1695 |
#endif
|
|
1696 |
|
|
1697 |
// Got a valid thread object - now work out which operation to perform...
|
|
1698 |
switch( aFunction )
|
|
1699 |
{
|
|
1700 |
case EMemSpyClientServerOpSummaryInfo:
|
|
1701 |
iEngine.HelperProcess().OutputProcessInfoL( *process );
|
|
1702 |
break;
|
|
1703 |
case EMemSpyClientServerOpSummaryInfoDetailed:
|
|
1704 |
iEngine.HelperProcess().OutputProcessInfoDetailedL( *process );
|
|
1705 |
break;
|
|
1706 |
case EMemSpyClientServerOpHeapInfo:
|
|
1707 |
if ( isKernel )
|
|
1708 |
{
|
|
1709 |
iEngine.HelperHeap().OutputHeapInfoKernelL();
|
|
1710 |
}
|
|
1711 |
else
|
|
1712 |
{
|
|
1713 |
iEngine.HelperHeap().OutputHeapInfoUserL( *thread );
|
|
1714 |
}
|
|
1715 |
break;
|
|
1716 |
case EMemSpyClientServerOpHeapCellListing:
|
|
1717 |
iEngine.HelperHeap().OutputCellListingUserL( *thread );
|
|
1718 |
break;
|
|
1719 |
case EMemSpyClientServerOpHeapData:
|
|
1720 |
if ( isKernel )
|
|
1721 |
{
|
|
1722 |
iEngine.HelperHeap().OutputHeapDataKernelL();
|
|
1723 |
}
|
|
1724 |
else
|
|
1725 |
{
|
|
1726 |
iEngine.HelperHeap().OutputHeapDataUserL( *thread );
|
|
1727 |
}
|
|
1728 |
break;
|
|
1729 |
case EMemSpyClientServerOpStackInfo:
|
|
1730 |
iEngine.HelperStack().OutputStackInfoL( *thread );
|
|
1731 |
break;
|
|
1732 |
case EMemSpyClientServerOpStackDataUser:
|
|
1733 |
iEngine.HelperStack().OutputStackDataL( *thread, EMemSpyDriverDomainUser, EFalse );
|
|
1734 |
break;
|
|
1735 |
case EMemSpyClientServerOpStackDataKernel:
|
|
1736 |
iEngine.HelperStack().OutputStackDataL( *thread, EMemSpyDriverDomainKernel, EFalse );
|
|
1737 |
break;
|
|
1738 |
case EMemSpyClientServerOpOpenFiles:
|
|
1739 |
iEngine.HelperFileSystem().ListOpenFilesL( aThreadId );
|
|
1740 |
break;
|
|
1741 |
|
|
1742 |
default:
|
|
1743 |
error = KErrNotSupported;
|
|
1744 |
break;
|
|
1745 |
}
|
|
1746 |
}
|
|
1747 |
|
|
1748 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - END - aFunction: %d, aThreadId: %d, error: %d", aFunction, (TUint) aThreadId, error ) );
|
|
1749 |
User::LeaveIfError( error );
|
|
1750 |
}
|
|
1751 |
|
|
1752 |
|
|
1753 |
void CMemSpyEngineSession::HandleThreadSpecificOpL( TInt aFunction, const TDesC& aThreadName )
|
|
1754 |
{
|
|
1755 |
TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - START - aFunction: %d, aThreadName: %S"), aFunction, &aThreadName ) );
|
|
1756 |
//
|
|
1757 |
CMemSpyProcess* process = NULL;
|
|
1758 |
CMemSpyThread* thread = NULL;
|
|
1759 |
TInt error = iEngine.Container().ProcessAndThreadByPartialName( aThreadName, process, thread );
|
|
1760 |
User::LeaveIfError( error );
|
|
1761 |
//
|
|
1762 |
const TThreadId threadId( thread->Id() );
|
|
1763 |
HandleThreadSpecificOpL( aFunction, threadId );
|
|
1764 |
//
|
|
1765 |
TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - END - aFunction: %d, aThreadName: %S"), aFunction, &aThreadName ) );
|
|
1766 |
}
|
|
1767 |
|
|
1768 |
|
|
1769 |
void CMemSpyEngineSession::HandleThreadAgnosticOpL( TInt aFunction, const RMessage2& aMessage )
|
|
1770 |
{
|
|
1771 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - START" ) );
|
|
1772 |
|
|
1773 |
//
|
|
1774 |
if ( aFunction == EMemSpyClientServerOpHeapInfoCompact )
|
|
1775 |
{
|
|
1776 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapInfoCompact") );
|
|
1777 |
if (aMessage.Function() & KMemSpyOpFlagsAsyncOperation)
|
|
1778 |
{
|
|
1779 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact, aMessage);
|
|
1780 |
}
|
|
1781 |
else
|
|
1782 |
{
|
|
1783 |
iEngine.HelperHeap().OutputHeapInfoForDeviceL();
|
|
1784 |
}
|
|
1785 |
}
|
|
1786 |
else if ( aFunction == EMemSpyClientServerOpStackInfoCompact )
|
|
1787 |
{
|
|
1788 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackInfoCompact") );
|
|
1789 |
if (aMessage.Function() & KMemSpyOpFlagsAsyncOperation)
|
|
1790 |
{
|
|
1791 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact, aMessage);
|
|
1792 |
}
|
|
1793 |
else
|
|
1794 |
{
|
|
1795 |
iEngine.HelperStack().OutputStackInfoForDeviceL();
|
|
1796 |
}
|
|
1797 |
}
|
|
1798 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart )
|
|
1799 |
{
|
|
1800 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart") );
|
|
1801 |
iEngine.HelperSysMemTracker().StartL();
|
|
1802 |
}
|
|
1803 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop )
|
|
1804 |
{
|
|
1805 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop") );
|
|
1806 |
iEngine.HelperSysMemTracker().StopL();
|
|
1807 |
}
|
|
1808 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingReset )
|
|
1809 |
{
|
|
1810 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingReset") );
|
|
1811 |
iEngine.HelperSysMemTracker().Reset();
|
|
1812 |
}
|
|
1813 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate )
|
|
1814 |
{
|
|
1815 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate") );
|
|
1816 |
iEngine.HelperSysMemTracker().CheckForChangesNowL();
|
|
1817 |
}
|
|
1818 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet )
|
|
1819 |
{
|
|
1820 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet") );
|
|
1821 |
|
|
1822 |
// Get current config
|
|
1823 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1824 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1825 |
|
|
1826 |
// Set new timer value
|
|
1827 |
config.iTimerPeriod = aMessage.Int0();
|
|
1828 |
|
|
1829 |
// And update config... which will leave if the config is invalid
|
|
1830 |
iEngine.HelperSysMemTracker().SetConfigL( config );
|
|
1831 |
}
|
|
1832 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet )
|
|
1833 |
{
|
|
1834 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet") );
|
|
1835 |
// Get current config
|
|
1836 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1837 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1838 |
|
|
1839 |
// Set new categories
|
|
1840 |
config.iEnabledCategories = aMessage.Int0();
|
|
1841 |
|
|
1842 |
// And update config... which will leave if the config is invalid
|
|
1843 |
iEngine.HelperSysMemTracker().SetConfigL( config );
|
|
1844 |
}
|
|
1845 |
|
|
1846 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet )
|
|
1847 |
{
|
|
1848 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet") );
|
|
1849 |
// Get current config
|
|
1850 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1851 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1852 |
|
|
1853 |
// Set new filter
|
|
1854 |
RBuf buf;
|
|
1855 |
buf.CleanupClosePushL();
|
|
1856 |
TInt len = aMessage.GetDesLength( 0 );
|
|
1857 |
if ( len > 0 )
|
|
1858 |
{
|
|
1859 |
buf.CreateL( len );
|
|
1860 |
aMessage.ReadL( 0, buf, 0 );
|
|
1861 |
config.iThreadNameFilter.Copy( buf );
|
|
1862 |
}
|
|
1863 |
else
|
|
1864 |
{
|
|
1865 |
config.iThreadNameFilter.Zero();
|
|
1866 |
}
|
|
1867 |
CleanupStack::PopAndDestroy( &buf );
|
|
1868 |
|
|
1869 |
// And update config... which will leave if the config is invalid
|
|
1870 |
iEngine.HelperSysMemTracker().SetConfigL( config );
|
|
1871 |
}
|
|
1872 |
else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet )
|
|
1873 |
{
|
|
1874 |
// Get current config
|
|
1875 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1876 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1877 |
|
|
1878 |
// Set new Heap Dump value
|
|
1879 |
config.iDumpData = aMessage.Int0();
|
|
1880 |
|
|
1881 |
// And update config... which will leave if the config is invalid
|
|
1882 |
iEngine.HelperSysMemTracker().SetConfigL( config );
|
|
1883 |
}
|
|
1884 |
else if( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingModeSet)
|
|
1885 |
{
|
|
1886 |
TMemSpyEngineHelperSysMemTrackerConfig config;
|
|
1887 |
iEngine.HelperSysMemTracker().GetConfig( config );
|
|
1888 |
|
|
1889 |
TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode;
|
|
1890 |
aMessage.ReadL( 0, mode );
|
|
1891 |
|
|
1892 |
config.iMode = mode();
|
|
1893 |
|
|
1894 |
// And update config... which will leave if the config is invalid
|
|
1895 |
iEngine.HelperSysMemTracker().SetConfigL( config );
|
|
1896 |
}
|
|
1897 |
|
|
1898 |
else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkTrace )
|
|
1899 |
{
|
|
1900 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkTrace") );
|
|
1901 |
iEngine.InstallDebugSinkL();
|
|
1902 |
}
|
|
1903 |
else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkFile )
|
|
1904 |
{
|
|
1905 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkFile") );
|
|
1906 |
// Read file name from message.
|
|
1907 |
TFileName fileName;
|
|
1908 |
RBuf buf;
|
|
1909 |
buf.CleanupClosePushL();
|
|
1910 |
|
|
1911 |
TInt len = aMessage.GetDesLength( 0 );
|
|
1912 |
if ( len > 0 )
|
|
1913 |
{
|
|
1914 |
buf.CreateL( len );
|
|
1915 |
aMessage.ReadL( 0, buf, 0 );
|
|
1916 |
|
|
1917 |
iEngine.InstallFileSinkL( buf );
|
|
1918 |
}
|
|
1919 |
else
|
|
1920 |
{
|
|
1921 |
iEngine.InstallFileSinkL( KNullDesC );
|
|
1922 |
}
|
|
1923 |
|
|
1924 |
CleanupStack::PopAndDestroy( &buf );
|
|
1925 |
|
|
1926 |
}
|
|
1927 |
else if ( aFunction == EMemSpyClientServerOpEnumerateKernelContainer )
|
|
1928 |
{
|
|
1929 |
const TMemSpyDriverContainerType type = CMemSpyEngineHelperKernelContainers::MapToType( static_cast< TObjectType >( aMessage.Int0() ) );
|
|
1930 |
|
|
1931 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpEnumerateKernelContainer - type: %d", type ) );
|
|
1932 |
|
|
1933 |
CMemSpyEngineGenericKernelObjectList* model = iEngine.HelperKernelContainers().ObjectsForSpecificContainerL( type );
|
|
1934 |
CleanupStack::PushL( model );
|
|
1935 |
model->OutputL( iEngine.Sink() );
|
|
1936 |
CleanupStack::PopAndDestroy( model );
|
|
1937 |
}
|
|
1938 |
else if ( aFunction == EMemSpyClientServerOpEnumerateKernelContainerAll )
|
|
1939 |
{
|
|
1940 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpEnumerateKernelContainerAll") );
|
|
1941 |
CMemSpyEngineGenericKernelObjectContainer* model = iEngine.HelperKernelContainers().ObjectsAllL();
|
|
1942 |
CleanupStack::PushL( model );
|
|
1943 |
model->OutputL( iEngine.Sink() );
|
|
1944 |
CleanupStack::PopAndDestroy( model );
|
|
1945 |
}
|
|
1946 |
else if ( aFunction == EMemSpyClientServerOpOpenFiles )
|
|
1947 |
{
|
|
1948 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpOpenFiles") );
|
|
1949 |
iEngine.ListOpenFilesL();
|
|
1950 |
}
|
|
1951 |
else if ( aFunction == EMemSpyClientServerOpDisableAknIconCache )
|
|
1952 |
{
|
|
1953 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpDisableAknIconCache") );
|
|
1954 |
iEngine.HelperRAM().SetAknIconCacheStatusL( EFalse );
|
|
1955 |
}
|
|
1956 |
else if ( aFunction == EMemSpyClientServerOpSummaryInfo )
|
|
1957 |
{
|
|
1958 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSummaryInfo") );
|
|
1959 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityGeneralSummary, aMessage);
|
|
1960 |
}
|
|
1961 |
else if ( aFunction == EMemSpyClientServerOpSummaryInfoDetailed )
|
|
1962 |
{
|
|
1963 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSummaryInfoDetailed") );
|
|
1964 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed, aMessage);
|
|
1965 |
}
|
|
1966 |
else if ( aFunction == EMemSpyClientServerOpHeapInfo )
|
|
1967 |
{
|
|
1968 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapInfo") );
|
|
1969 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapInfo, aMessage);
|
|
1970 |
}
|
|
1971 |
else if ( aFunction == EMemSpyClientServerOpHeapCellListing )
|
|
1972 |
{
|
|
1973 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapCellListing") );
|
|
1974 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapCellListing, aMessage);
|
|
1975 |
}
|
|
1976 |
else if ( aFunction == EMemSpyClientServerOpHeapData )
|
|
1977 |
{
|
|
1978 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapData") );
|
|
1979 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapData, aMessage);
|
|
1980 |
}
|
|
1981 |
else if ( aFunction == EMemSpyClientServerOpStackInfo )
|
|
1982 |
{
|
|
1983 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackInfo") );
|
|
1984 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackInfo, aMessage);
|
|
1985 |
}
|
|
1986 |
else if ( aFunction == EMemSpyClientServerOpStackDataUser )
|
|
1987 |
{
|
|
1988 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackDataUser") );
|
|
1989 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackDataUser, aMessage);
|
|
1990 |
}
|
|
1991 |
else if ( aFunction == EMemSpyClientServerOpStackDataKernel )
|
|
1992 |
{
|
|
1993 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackDataKernel") );
|
|
1994 |
StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackDataKernel, aMessage);
|
|
1995 |
}
|
|
1996 |
else
|
|
1997 |
{
|
|
1998 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - [device-wide operation] => invoking UI") );
|
|
1999 |
iEngine.NotifyClientServerOperationRequestL( aFunction );
|
|
2000 |
}
|
|
2001 |
//
|
|
2002 |
TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - END" ) );
|
|
2003 |
}
|
|
2004 |
|
|
2005 |
void CMemSpyEngineSession::StartDeviceWideOperationL(CMemSpyDeviceWideOperations::TOperation aOperation, const RMessage2& aMessage)
|
|
2006 |
{
|
|
2007 |
if (Server().CurrentOperationTracker())
|
|
2008 |
{
|
|
2009 |
User::Leave(KErrInUse);
|
|
2010 |
}
|
|
2011 |
|
|
2012 |
Server().SetCurrentOperationTracker(CMemSpyDwOperationTracker::NewL(aOperation, aMessage, Server()));
|
|
2013 |
}
|
|
2014 |
|
|
2015 |
|
|
2016 |
|
|
2017 |
|
|
2018 |
|
|
2019 |
|
|
2020 |
|
|
2021 |
|
|
2022 |
|
|
2023 |
CMemSpyDwOperationTracker* CMemSpyDwOperationTracker::NewL(CMemSpyDeviceWideOperations::TOperation aOperation,
|
|
2024 |
const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer)
|
|
2025 |
{
|
|
2026 |
CMemSpyDwOperationTracker* self = new (ELeave) CMemSpyDwOperationTracker(aOperationMessage, aServer);
|
|
2027 |
CleanupStack::PushL( self );
|
|
2028 |
self->ConstructL(aOperation);
|
|
2029 |
CleanupStack::Pop( self );
|
|
2030 |
return self;
|
|
2031 |
}
|
|
2032 |
|
|
2033 |
CMemSpyDwOperationTracker::~CMemSpyDwOperationTracker()
|
|
2034 |
{
|
|
2035 |
delete iOperation;
|
|
2036 |
delete iPendingNotifications;
|
|
2037 |
}
|
|
2038 |
|
|
2039 |
CMemSpyDwOperationTracker::CMemSpyDwOperationTracker(const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer) :
|
|
2040 |
iOperationMessage(aOperationMessage),
|
|
2041 |
iServer(aServer),
|
|
2042 |
iPendingNotifications(0),
|
|
2043 |
iOperation(0),
|
|
2044 |
iProgress(0)
|
|
2045 |
{
|
|
2046 |
}
|
|
2047 |
|
|
2048 |
|
|
2049 |
void CMemSpyDwOperationTracker::ConstructL(CMemSpyDeviceWideOperations::TOperation aOperation)
|
|
2050 |
{
|
|
2051 |
iPendingNotifications = new (ELeave) CArrayFixFlat<RMessage2>(3);
|
|
2052 |
iOperation = CMemSpyDeviceWideOperations::NewL(iServer.Engine(), *this, aOperation);
|
|
2053 |
}
|
|
2054 |
|
|
2055 |
void CMemSpyDwOperationTracker::AddNotificationL(const RMessage2& aMessage)
|
|
2056 |
{
|
|
2057 |
iPendingNotifications->AppendL(aMessage);
|
|
2058 |
}
|
|
2059 |
|
|
2060 |
void CMemSpyDwOperationTracker::Cancel()
|
|
2061 |
{
|
|
2062 |
iOperation->Cancel();
|
|
2063 |
}
|
|
2064 |
|
|
2065 |
void CMemSpyDwOperationTracker::HandleDeviceWideOperationEvent(TEvent aEvent, TInt aParam1, const TDesC& aParam2)
|
|
2066 |
{
|
|
2067 |
switch( aEvent )
|
|
2068 |
{
|
|
2069 |
case MMemSpyDeviceWideOperationsObserver::EOperationCompleted:
|
|
2070 |
case MMemSpyDeviceWideOperationsObserver::EOperationCancelled:
|
|
2071 |
iServer.SetCurrentOperationTracker(0);
|
|
2072 |
|
|
2073 |
for (TInt i=0; i<iPendingNotifications->Count(); i++)
|
|
2074 |
{
|
|
2075 |
iPendingNotifications->At(i).Complete(KErrCancel);
|
|
2076 |
}
|
|
2077 |
|
|
2078 |
if (iOperationMessage.Function() & KMemSpyOpFlagsAsyncOperation)
|
|
2079 |
{
|
|
2080 |
iOperationMessage.Complete(
|
|
2081 |
aEvent == MMemSpyDeviceWideOperationsObserver::EOperationCompleted ? KErrNone : KErrCancel);
|
|
2082 |
}
|
|
2083 |
|
|
2084 |
iPendingNotifications->Reset();
|
|
2085 |
|
|
2086 |
delete this;
|
|
2087 |
break;
|
|
2088 |
|
|
2089 |
case MMemSpyDeviceWideOperationsObserver::EOperationProgressEnd:
|
|
2090 |
{
|
|
2091 |
iProgress += aParam1;
|
|
2092 |
for (TInt i=0; i<iPendingNotifications->Count(); i++)
|
|
2093 |
{
|
|
2094 |
TInt err;
|
|
2095 |
TRAP(err, iPendingNotifications->At(i).WriteL(0, TPckgBuf<TInt>( iProgress * 100 / iOperation->TotalOperationSize() )));
|
|
2096 |
TRAP(err, iPendingNotifications->At(i).WriteL(1, aParam2));
|
|
2097 |
if (err != KErrNone)
|
|
2098 |
{
|
|
2099 |
// TODO: iPendingProgressNotifications->At(i).Panic()
|
|
2100 |
}
|
|
2101 |
iPendingNotifications->At(i).Complete(KErrNone);
|
|
2102 |
}
|
|
2103 |
iPendingNotifications->Reset();
|
|
2104 |
break;
|
|
2105 |
}
|
|
2106 |
|
|
2107 |
}
|
|
2108 |
|
|
2109 |
}
|
62
|
2110 |
|
|
2111 |
|
|
2112 |
|
|
2113 |
|
|
2114 |
|
|
2115 |
|
|
2116 |
|
|
2117 |
|
|
2118 |
|
|
2119 |
CMemSpyNotificationTracker* CMemSpyNotificationTracker::NewL()
|
|
2120 |
{
|
|
2121 |
CMemSpyNotificationTracker* self = new (ELeave) CMemSpyNotificationTracker();
|
|
2122 |
CleanupStack::PushL( self );
|
|
2123 |
self->ConstructL();
|
|
2124 |
CleanupStack::Pop( self );
|
|
2125 |
return self;
|
|
2126 |
}
|
|
2127 |
|
|
2128 |
CMemSpyNotificationTracker::~CMemSpyNotificationTracker()
|
|
2129 |
{
|
|
2130 |
delete iPendingNotifications;
|
|
2131 |
}
|
|
2132 |
|
|
2133 |
void CMemSpyNotificationTracker::ConstructL()
|
|
2134 |
{
|
|
2135 |
iPendingNotifications = new (ELeave) CArrayFixFlat<RMessage2>(3);
|
|
2136 |
}
|
|
2137 |
|
|
2138 |
void CMemSpyNotificationTracker::AddNotificationL( const RMessage2& aMessage )
|
|
2139 |
{
|
|
2140 |
iPendingNotifications->AppendL(aMessage);
|
|
2141 |
}
|
|
2142 |
|
|
2143 |
void CMemSpyNotificationTracker::CancelNotification( const RMessage2& aMessage )
|
|
2144 |
{
|
|
2145 |
for (TInt i = iPendingNotifications->Count()-1; i >= 0; --i)
|
|
2146 |
{
|
|
2147 |
if (iPendingNotifications->At( i ).Session() == aMessage.Session())
|
|
2148 |
{
|
|
2149 |
iPendingNotifications->At( i ).Complete( KErrCancel );
|
|
2150 |
iPendingNotifications->Delete( i );
|
|
2151 |
}
|
|
2152 |
}
|
|
2153 |
}
|
|
2154 |
|
|
2155 |
void CMemSpyNotificationTracker::HandleMemSpyEngineEventL( TEvent aEvent, TAny* aContext )
|
|
2156 |
{
|
|
2157 |
switch( aEvent )
|
|
2158 |
{
|
|
2159 |
|
|
2160 |
case MMemSpyEngineObserver::EHandleThreadsOrProcessesChanged:
|
|
2161 |
{
|
|
2162 |
for (TInt i=0; i<iPendingNotifications->Count(); i++)
|
|
2163 |
{
|
|
2164 |
TRAPD(err, iPendingNotifications->At(i).WriteL(0, TPckgBuf<TInt>( aEvent )));
|
|
2165 |
if (err != KErrNone)
|
|
2166 |
{
|
|
2167 |
// TODO: iPendingProgressNotifications->At(i).Panic()
|
|
2168 |
}
|
|
2169 |
iPendingNotifications->At(i).Complete( KErrNone );
|
|
2170 |
}
|
|
2171 |
iPendingNotifications->Reset();
|
|
2172 |
break;
|
|
2173 |
}
|
|
2174 |
|
|
2175 |
}
|
|
2176 |
|
|
2177 |
}
|