memspy/Engine/Source/ClientServer/MemSpyEngineServer.cpp
changeset 0 a03f92240627
child 20 a71a3e32a2ae
child 43 ca8a1b6995f6
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     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 
       
    23 // User includes
       
    24 #include <memspy/engine/memspyengine.h>
       
    25 #include <memspy/engine/memspyenginelogger.h>
       
    26 #include <memspyengineclientinterface.h>
       
    27 #include <memspy/engine/memspyengineobjectthread.h>
       
    28 #include <memspy/engine/memspyengineobjectprocess.h>
       
    29 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    30 #include <memspy/engine/memspyenginehelperchunk.h>
       
    31 #include <memspy/engine/memspyenginehelpercodesegment.h>
       
    32 #include <memspy/engine/memspyenginehelperheap.h>
       
    33 #include <memspy/engine/memspyenginehelperstack.h>
       
    34 #include <memspy/engine/memspyenginehelperthread.h>
       
    35 #include <memspy/engine/memspyenginehelperprocess.h>
       
    36 #include <memspy/engine/memspyenginehelperfilesystem.h>
       
    37 #include <memspy/engine/memspyenginehelperram.h>
       
    38 #include <memspy/engine/memspyenginehelpersysmemtracker.h>
       
    39 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
       
    40 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    41 
       
    42 
       
    43 CMemSpyEngineServer::CMemSpyEngineServer( CMemSpyEngine& aEngine )
       
    44 :   CServer2( EPriorityNormal ), iEngine( aEngine )
       
    45     {
       
    46     }
       
    47 
       
    48 
       
    49 CMemSpyEngineServer::~CMemSpyEngineServer()
       
    50     {
       
    51     }
       
    52 
       
    53 
       
    54 void CMemSpyEngineServer::ConstructL()
       
    55     {
       
    56     StartL( KMemSpyServerName );
       
    57     }
       
    58 
       
    59 
       
    60 CMemSpyEngineServer* CMemSpyEngineServer::NewL( CMemSpyEngine& aEngine )
       
    61     {
       
    62     CMemSpyEngineServer* self = new(ELeave) CMemSpyEngineServer( aEngine );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66     return self;
       
    67     }
       
    68 
       
    69 
       
    70 CSession2* CMemSpyEngineServer::NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const
       
    71     {
       
    72     if  ( aVersion.iMajor != KMemSpyClientServerVersion )
       
    73         {
       
    74         RDebug::Printf( "[MemSpy] CMemSpyEngineSession::NewSessionL() - BAD VERSION" );
       
    75         User::Leave( KErrNotSupported );
       
    76         }
       
    77     //
       
    78     CMemSpyEngineSession* session = CMemSpyEngineSession::NewL( iEngine, aMessage );
       
    79 	return session;
       
    80     }
       
    81 
       
    82 
       
    83 
       
    84 
       
    85 
       
    86 
       
    87 
       
    88 
       
    89 
       
    90 
       
    91 
       
    92 
       
    93 
       
    94 
       
    95 
       
    96 
       
    97 
       
    98 
       
    99 
       
   100 
       
   101 
       
   102 
       
   103 
       
   104 CMemSpyEngineSession::CMemSpyEngineSession( CMemSpyEngine& aEngine )
       
   105 :   iEngine( aEngine )
       
   106     {
       
   107     }
       
   108 
       
   109 
       
   110 CMemSpyEngineSession::~CMemSpyEngineSession()
       
   111     {
       
   112 #ifdef _DEBUG
       
   113     TPtrC pThreadName( KNullDesC );
       
   114     if  ( iClientThreadName )
       
   115         {
       
   116         pThreadName.Set( *iClientThreadName );
       
   117         }
       
   118 
       
   119     RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::~CMemSpyEngineSession() - DEAD SESSION - this: 0x%08x, id: %4d, name: %S"), this, iClientThreadId, iClientThreadName );
       
   120 #endif
       
   121 
       
   122     delete iClientThreadName;
       
   123     }
       
   124 
       
   125 
       
   126 void CMemSpyEngineSession::ConstructL( const RMessage2& aMessage )
       
   127     {
       
   128 	RThread thread;
       
   129     const TInt error = aMessage.Client( thread );
       
   130     CleanupClosePushL( thread );
       
   131 
       
   132     TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::ConstructL() - this: 0x%08x - opening client thread - err: %d", this, error ) );
       
   133 
       
   134     User::LeaveIfError( error );
       
   135 
       
   136     const TFullName threadName( thread.FullName() );
       
   137     iClientThreadName = threadName.AllocL();
       
   138     iClientThreadId = thread.Id();
       
   139 
       
   140     CleanupStack::PopAndDestroy( &thread );
       
   141 
       
   142     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ConstructL() - NEW SESSION - this: 0x%08x, id: %4d, client: %S"), this, iClientThreadId, iClientThreadName ) );
       
   143     }
       
   144 
       
   145 
       
   146 CMemSpyEngineSession* CMemSpyEngineSession::NewL( CMemSpyEngine& aEngine, const RMessage2& aMessage )
       
   147     {
       
   148     CMemSpyEngineSession* self = new(ELeave) CMemSpyEngineSession( aEngine );
       
   149     CleanupStack::PushL( self );
       
   150     self->ConstructL( aMessage );
       
   151     CleanupStack::Pop( self );
       
   152     return self;
       
   153     }
       
   154 
       
   155 
       
   156 void CMemSpyEngineSession::ServiceL( const RMessage2& aMessage )
       
   157     {
       
   158     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - START - this: 0x%08x, fn: 0x%08x, id: %4d, client: %S"), this, aMessage.Function(), iClientThreadId, iClientThreadName ) );
       
   159 
       
   160     TRAPD( error, DoServiceL( aMessage ) );
       
   161     if  ( error != KErrNone )
       
   162         {
       
   163         RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - SERVICE ERROR - this: 0x%08x, fn: %d, err: %d, client: %S"), this, aMessage.Function(), error, iClientThreadName );
       
   164         }
       
   165     aMessage.Complete( error );
       
   166 
       
   167     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - END - this: 0x%08x, fn: 0x%08x, id: %4d, client: %S"), this, aMessage.Function(), iClientThreadId, iClientThreadName ) );
       
   168 	}
       
   169 
       
   170 
       
   171 void CMemSpyEngineSession::DoServiceL( const RMessage2& aMessage )
       
   172     {
       
   173     TInt error = KErrNone;
       
   174 
       
   175     // Check function attributes
       
   176     const TInt function = aMessage.Function() & KMemSpyOpFlagsTypeMask;
       
   177     const TInt argSpec = aMessage.Function() & KMemSpyOpFlagsInclusionMask;
       
   178     const TBool byThreadId = ( argSpec == KMemSpyOpFlagsIncludesThreadId );
       
   179     const TBool byThreadName = ( argSpec == KMemSpyOpFlagsIncludesThreadName );
       
   180 
       
   181     TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - START - unmodified function: 0x%08x, opCode: %d [TID: %d, TN: %d]", aMessage.Function(), function, byThreadId, byThreadName ) );
       
   182 
       
   183     // Check function is supported and argument combination is valid
       
   184     error = ValidateFunction( function, byThreadId, byThreadName );
       
   185     TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - validation result: %d", error ) );
       
   186     
       
   187     // Process function request
       
   188     if  ( error == KErrNone )
       
   189         {
       
   190         if  ( byThreadId )
       
   191             {
       
   192             TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - [TID] thread-specific..." ) );
       
   193             
       
   194             const TThreadId threadId( aMessage.Int0() );
       
   195             HandleThreadSpecificOpL( function, threadId );
       
   196             }
       
   197         else if ( byThreadName )
       
   198             {
       
   199             TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - [TN] thread-specific..." ) );
       
   200 
       
   201             error = aMessage.GetDesLength( 0 /*slot 0*/ );
       
   202         
       
   203             if  ( error > 0 && error <= KMaxFullName )
       
   204                 {
       
   205                 TFullName* threadName = new(ELeave) TFullName();
       
   206                 CleanupStack::PushL( threadName );
       
   207                 aMessage.ReadL( 0, *threadName );
       
   208                 HandleThreadSpecificOpL( function, *threadName );
       
   209                 CleanupStack::PopAndDestroy( threadName );
       
   210                 }
       
   211             else
       
   212                 {
       
   213                 error = KErrArgument;
       
   214                 }
       
   215             }
       
   216         else
       
   217             {
       
   218             TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - thread-agnostic..." ) );
       
   219 
       
   220             HandleThreadAgnosticOpL( function, aMessage );
       
   221             }
       
   222         }
       
   223 
       
   224     User::LeaveIfError( error );
       
   225 
       
   226     TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::DoServiceL() - END" ) );
       
   227     }
       
   228 
       
   229 
       
   230 
       
   231 TInt CMemSpyEngineSession::ValidateFunction( TInt aFunction, TBool aIncludesThreadId, TBool aIncludesThreadName )
       
   232     {
       
   233     TInt err = KErrNotSupported;
       
   234     
       
   235     // Check the operation is within op-code range
       
   236     if  ( aFunction >= EMemSpyClientServerOpMarkerFirst && aFunction < EMemSpyClientServerOpMarkerLast )
       
   237         {
       
   238         // Check the operation doesn't include unnecessary or not supported information
       
   239         const TBool includesThreadIdentifier = ( aIncludesThreadId || aIncludesThreadName );
       
   240         if  ( includesThreadIdentifier && aFunction >= EMemSpyClientServerOpMarkerThreadAgnosticFirst )
       
   241             {
       
   242             // Passing a thread identifier to a thread agnostic operation
       
   243             err = KErrArgument;
       
   244             }
       
   245         else
       
   246             {
       
   247             err = KErrNone;
       
   248             }
       
   249         }
       
   250     //
       
   251     if  ( err != KErrNone )
       
   252         {
       
   253         RDebug::Printf( "[MemSpy] CMemSpyEngineSession::ValidateFunction() - function request did not validate - [withId: %d, withName: %d]", aIncludesThreadId, aIncludesThreadName );
       
   254         }
       
   255     //
       
   256     return err;
       
   257     }
       
   258 
       
   259 
       
   260 void CMemSpyEngineSession::HandleThreadSpecificOpL( TInt aFunction, const TThreadId& aThreadId )
       
   261     {
       
   262     TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - START - aFunction: %d, aThreadId: %d", aFunction, (TUint) aThreadId ) );
       
   263 
       
   264     ASSERT( (TUint) aThreadId != 0 );
       
   265     TInt error = KErrNone;
       
   266 
       
   267     // Check if its a kernel thread identifier
       
   268     const TBool isKernel = ( static_cast<TUint32>( aThreadId ) == KMemSpyClientServerThreadIdKernel );
       
   269 
       
   270     // Treat as thread specific operation
       
   271     CMemSpyProcess* process = NULL;
       
   272     CMemSpyThread* thread = NULL;
       
   273     if  ( !isKernel )
       
   274         {
       
   275         error = iEngine.Container().ProcessAndThreadByThreadId( aThreadId, process, thread );
       
   276         TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - search result: %d, proc: 0x%08x, thread: 0x%08x", error, process, thread ) );
       
   277         }
       
   278     else
       
   279         {
       
   280         // Kernel is only supported for a couple of operations
       
   281         if  ( aFunction == EMemSpyClientServerOpHeapInfo || aFunction == EMemSpyClientServerOpHeapData )
       
   282             {
       
   283             }
       
   284         else
       
   285             {
       
   286             TRACE( RDebug::Printf( "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - trying to call unsupported function for kernel thread!" ) );
       
   287             error = KErrArgument;
       
   288             }
       
   289         }
       
   290 
       
   291     // Must be no error so far and we must have a valid thread & process when performing a non-kernel op
       
   292     // or then if we are performing a kernel op, we don't need the thread or process.
       
   293     if  ( error == KErrNone && ( ( thread && process && !isKernel ) || ( isKernel ) ) )
       
   294         {
       
   295 #ifdef _DEBUG
       
   296         if  ( thread )
       
   297             {
       
   298             HBufC* threadName = thread->FullName().AllocLC();
       
   299             _LIT( KTrace2, "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - thread: %S" );
       
   300             RDebug::Print( KTrace2, threadName );
       
   301             CleanupStack::PopAndDestroy( threadName );
       
   302             }
       
   303         else if ( isKernel )
       
   304             {
       
   305             _LIT( KTrace2, "[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - thread: Kernel" );
       
   306             RDebug::Print( KTrace2 );
       
   307             }
       
   308 #endif
       
   309 
       
   310         // Got a valid thread object - now work out which operation to perform...
       
   311         switch( aFunction )
       
   312             {
       
   313         case EMemSpyClientServerOpSummaryInfo:
       
   314             iEngine.HelperProcess().OutputProcessInfoL( *process );
       
   315             break;
       
   316         case EMemSpyClientServerOpSummaryInfoDetailed:
       
   317             iEngine.HelperProcess().OutputProcessInfoDetailedL( *process );
       
   318             break;
       
   319         case EMemSpyClientServerOpHeapInfo:
       
   320             if  ( isKernel )
       
   321                 {
       
   322                 iEngine.HelperHeap().OutputHeapInfoKernelL();
       
   323                 }
       
   324             else
       
   325                 {
       
   326                 iEngine.HelperHeap().OutputHeapInfoUserL( *thread );
       
   327                 }
       
   328             break;
       
   329         case EMemSpyClientServerOpHeapCellListing:
       
   330             iEngine.HelperHeap().OutputCellListingUserL( *thread );
       
   331             break;
       
   332         case EMemSpyClientServerOpHeapData:
       
   333             if  ( isKernel )
       
   334                 {
       
   335                 iEngine.HelperHeap().OutputHeapDataKernelL();
       
   336                 }
       
   337             else
       
   338                 {
       
   339                 iEngine.HelperHeap().OutputHeapDataUserL( *thread );
       
   340                 }
       
   341             break;
       
   342         case EMemSpyClientServerOpStackInfo:
       
   343             iEngine.HelperStack().OutputStackInfoL( *thread );
       
   344             break;
       
   345         case EMemSpyClientServerOpStackDataUser:
       
   346             iEngine.HelperStack().OutputStackDataL( *thread, EMemSpyDriverDomainUser, EFalse );
       
   347             break;
       
   348         case EMemSpyClientServerOpStackDataKernel:
       
   349             iEngine.HelperStack().OutputStackDataL( *thread, EMemSpyDriverDomainKernel, EFalse );
       
   350             break;
       
   351         case EMemSpyClientServerOpOpenFiles:
       
   352             iEngine.HelperFileSystem().ListOpenFilesL( aThreadId );
       
   353             break;
       
   354 
       
   355         default:
       
   356             error = KErrNotSupported;
       
   357             break;
       
   358             }
       
   359         }
       
   360 
       
   361     TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - END - aFunction: %d, aThreadId: %d, error: %d", aFunction, (TUint) aThreadId, error ) );
       
   362     User::LeaveIfError( error );
       
   363     }
       
   364 
       
   365 
       
   366 void CMemSpyEngineSession::HandleThreadSpecificOpL( TInt aFunction, const TDesC& aThreadName )
       
   367     {
       
   368     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - START - aFunction: %d, aThreadName: %S"), aFunction, &aThreadName ) );
       
   369     //
       
   370     CMemSpyProcess* process = NULL;
       
   371     CMemSpyThread* thread = NULL;
       
   372     TInt error = iEngine.Container().ProcessAndThreadByPartialName( aThreadName, process, thread );
       
   373     User::LeaveIfError( error );
       
   374     //
       
   375     const TThreadId threadId( thread->Id() );
       
   376     HandleThreadSpecificOpL( aFunction, threadId );
       
   377     //
       
   378     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::HandleThreadSpecificOpL() - END - aFunction: %d, aThreadName: %S"), aFunction, &aThreadName ) );
       
   379     }
       
   380 
       
   381 
       
   382 void CMemSpyEngineSession::HandleThreadAgnosticOpL( TInt aFunction, const RMessage2& aMessage )
       
   383     {
       
   384     TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - START" ) );
       
   385     //
       
   386     if  ( aFunction ==  EMemSpyClientServerOpHeapInfoCompact )
       
   387         {
       
   388         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapInfoCompact") );
       
   389         iEngine.HelperHeap().OutputHeapInfoForDeviceL();
       
   390         }
       
   391     else if ( aFunction ==  EMemSpyClientServerOpStackInfoCompact )
       
   392         {
       
   393         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackInfoCompact") );
       
   394         iEngine.HelperStack().OutputStackInfoForDeviceL();
       
   395         }
       
   396     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart )
       
   397         {
       
   398         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart") );
       
   399         iEngine.HelperSysMemTracker().StartL();
       
   400         }
       
   401     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop )
       
   402         {
       
   403         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop") );
       
   404         iEngine.HelperSysMemTracker().StopL();
       
   405         }
       
   406     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingReset )
       
   407         {
       
   408         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingReset") );
       
   409         iEngine.HelperSysMemTracker().Reset();
       
   410         }
       
   411     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate )
       
   412         {
       
   413         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate") );
       
   414         iEngine.HelperSysMemTracker().CheckForChangesNowL();
       
   415         }
       
   416     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet )
       
   417         {
       
   418         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet") );
       
   419         
       
   420         // Get current config
       
   421         TMemSpyEngineHelperSysMemTrackerConfig config;
       
   422         iEngine.HelperSysMemTracker().GetConfig( config );
       
   423 
       
   424         // Set new timer value
       
   425         config.iTimerPeriod = aMessage.Int0();
       
   426 
       
   427         // And update config... which will leave if the config is invalid
       
   428         iEngine.HelperSysMemTracker().SetConfigL( config );
       
   429         }
       
   430     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet )
       
   431         {
       
   432         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet") );
       
   433         // Get current config
       
   434         TMemSpyEngineHelperSysMemTrackerConfig config;
       
   435         iEngine.HelperSysMemTracker().GetConfig( config );
       
   436 
       
   437         // Set new categories
       
   438         config.iEnabledCategories = aMessage.Int0();
       
   439 
       
   440         // And update config... which will leave if the config is invalid
       
   441         iEngine.HelperSysMemTracker().SetConfigL( config );
       
   442         }
       
   443     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet )
       
   444         {
       
   445         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet") );
       
   446         // Get current config
       
   447         TMemSpyEngineHelperSysMemTrackerConfig config;
       
   448         iEngine.HelperSysMemTracker().GetConfig( config );
       
   449 
       
   450         // Set new filter
       
   451         RBuf buf;
       
   452         buf.CleanupClosePushL();
       
   453         TInt len = aMessage.GetDesLength( 0 );
       
   454         if ( len > 0 )
       
   455             {
       
   456             buf.CreateL( len );
       
   457             aMessage.ReadL( 0, buf, 0 );
       
   458             config.iThreadNameFilter.Copy( buf );            
       
   459             }
       
   460         else
       
   461             {
       
   462             config.iThreadNameFilter.Zero();
       
   463             }
       
   464         CleanupStack::PopAndDestroy( &buf );
       
   465 
       
   466         // And update config... which will leave if the config is invalid
       
   467         iEngine.HelperSysMemTracker().SetConfigL( config );
       
   468         }
       
   469     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet )
       
   470         {
       
   471         // Get current config
       
   472         TMemSpyEngineHelperSysMemTrackerConfig config;
       
   473         iEngine.HelperSysMemTracker().GetConfig( config );
       
   474         
       
   475         // Set new Heap Dump value
       
   476         config.iDumpData = aMessage.Int0();
       
   477         
       
   478         // And update config... which will leave if the config is invalid
       
   479         iEngine.HelperSysMemTracker().SetConfigL( config );
       
   480         }
       
   481     else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkTrace )
       
   482         {
       
   483         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkTrace") );
       
   484         iEngine.InstallSinkL( ESinkTypeDebug );
       
   485         }
       
   486     else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkFile )
       
   487         {
       
   488         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkFile") );
       
   489         iEngine.InstallSinkL( ESinkTypeFile );
       
   490         }
       
   491     else if ( aFunction == EMemSpyClientServerOpEnumerateKernelContainer )
       
   492         {
       
   493         const TMemSpyDriverContainerType type = CMemSpyEngineHelperKernelContainers::MapToType( static_cast< TObjectType >( aMessage.Int0() ) );
       
   494 
       
   495         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpEnumerateKernelContainer - type: %d", type ) );
       
   496 
       
   497         CMemSpyEngineGenericKernelObjectList* model = iEngine.HelperKernelContainers().ObjectsForSpecificContainerL( type );
       
   498         CleanupStack::PushL( model );
       
   499         model->OutputL( iEngine.Sink() );
       
   500         CleanupStack::PopAndDestroy( model );
       
   501         }
       
   502     else if ( aFunction == EMemSpyClientServerOpEnumerateKernelContainerAll )
       
   503         {
       
   504         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpEnumerateKernelContainerAll") );
       
   505         CMemSpyEngineGenericKernelObjectContainer* model = iEngine.HelperKernelContainers().ObjectsAllL();
       
   506         CleanupStack::PushL( model );
       
   507         model->OutputL( iEngine.Sink() );
       
   508         CleanupStack::PopAndDestroy( model );
       
   509         }
       
   510     else if ( aFunction == EMemSpyClientServerOpOpenFiles )
       
   511         {
       
   512         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpOpenFiles") );
       
   513         iEngine.ListOpenFilesL();
       
   514         }
       
   515     else if ( aFunction == EMemSpyClientServerOpDisableAknIconCache )
       
   516         {
       
   517         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpDisableAknIconCache") );
       
   518         iEngine.HelperRAM().SetAknIconCacheStatusL( EFalse );
       
   519         }
       
   520     else
       
   521         {
       
   522         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - [device-wide operation] => invoking UI") );
       
   523         iEngine.NotifyClientServerOperationRequestL( aFunction );
       
   524         }
       
   525     //
       
   526     TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - END" ) );
       
   527     }
       
   528 
       
   529 
       
   530 
       
   531 
       
   532