memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryManager.cpp
changeset 0 a03f92240627
child 30 86a2e675b80a
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 "MemSpyEngineHelperSysMemTrackerEntryManager.h"
       
    19 
       
    20 // System includes
       
    21 #include <e32debug.h>
       
    22 
       
    23 // Driver includes
       
    24 #include <memspy/driver/memspydriverclient.h>
       
    25 
       
    26 // User includes
       
    27 #include <memspy/engine/memspyengine.h>
       
    28 #include <memspy/engine/memspyengineutils.h>
       
    29 #include <memspy/engine/memspyenginemidwife.h>
       
    30 #include <memspy/engine/memspyengineundertaker.h>
       
    31 #include <memspy/engine/memspyengineobjectthread.h>
       
    32 #include <memspy/engine/memspyengineobjectprocess.h>
       
    33 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    34 #include <memspy/engine/memspyenginehelperheap.h>
       
    35 #include <memspy/engine/memspyenginehelperchunk.h>
       
    36 #include <memspy/engine/memspyenginehelperfbserv.h>
       
    37 #include <memspy/engine/memspyenginehelperfilesystem.h>
       
    38 #include <memspy/engine/memspyenginehelpercodesegment.h>
       
    39 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
       
    40 #include <memspy/engine/memspyenginehelperwindowserver.h>
       
    41 #include <memspy/engine/memspyenginehelpersysmemtracker.h>
       
    42 #include "MemSpyEngineHelperSysMemTrackerImp.h"
       
    43 #include "MemSpyEngineHelperSysMemTrackerLog.h"
       
    44 #include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
       
    45 #include <memspy/engine/memspyenginehelpersysmemtrackercyclechange.h>
       
    46 #include "MemSpyEngineHelperSysMemTrackerEntries.h"
       
    47 #include "MemSpyEngineHelperSysMemTrackerEntryChunk.h"
       
    48 #include "MemSpyEngineHelperSysMemTrackerEntryGlobalData.h"
       
    49 #include "MemSpyEngineHelperSysMemTrackerEntryHeap.h"
       
    50 #include "MemSpyEngineHelperSysMemTrackerEntryRamDrive.h"
       
    51 #include "MemSpyEngineHelperSysMemTrackerEntryStack.h"
       
    52 #include "MemSpyEngineHelperSysMemTrackerEntryCode.h"
       
    53 #include "MemSpyEngineHelperSysMemTrackerEntryHandleGeneric.h"
       
    54 #include "MemSpyEngineHelperSysMemTrackerEntryHandlePAndS.h"
       
    55 #include "MemSpyEngineHelperSysMemTrackerEntryOpenFile.h"
       
    56 #include "MemSpyEngineHelperSysMemTrackerEntryDiskSpace.h"
       
    57 #include "MemSpyEngineHelperSysMemTrackerEntryBitmap.h"
       
    58 #include "MemSpyEngineHelperSysMemTrackerEntryFbserv.h"
       
    59 #include "MemSpyEngineHelperSysMemTrackerEntryFileServerCache.h"
       
    60 #include "MemSpyEngineHelperSysMemTrackerEntrySystemMemory.h"
       
    61 #include "MemSpyEngineHelperSysMemTrackerEntryWindowServer.h"
       
    62 
       
    63 
       
    64 // Constants
       
    65 
       
    66 // Message printed to RDebug output for some clients that may be reading traces 
       
    67 _LIT( KMemSpyKeepaliveMessage, "<MEMSPY_PROGRESS>" );
       
    68 
       
    69 
       
    70 CMemSpyEngineHelperSysMemTrackerEntryManager::CMemSpyEngineHelperSysMemTrackerEntryManager( CMemSpyEngineHelperSysMemTrackerImp& aTracker, CMemSpyEngineHelperSysMemTrackerEntryManager* aMasterList )
       
    71 :   iTracker( aTracker ), iMasterList( aMasterList )
       
    72     {
       
    73     }
       
    74 
       
    75     
       
    76 CMemSpyEngineHelperSysMemTrackerEntryManager::~CMemSpyEngineHelperSysMemTrackerEntryManager()
       
    77     {
       
    78     iEntries.ResetAndDestroy();
       
    79     iEntries.Close();
       
    80     }
       
    81 
       
    82 
       
    83 void CMemSpyEngineHelperSysMemTrackerEntryManager::ConstructL()
       
    84     {
       
    85     CreateSeedItemsL();
       
    86     }
       
    87 
       
    88 
       
    89 CMemSpyEngineHelperSysMemTrackerEntryManager* CMemSpyEngineHelperSysMemTrackerEntryManager::NewL( CMemSpyEngineHelperSysMemTrackerImp& aTracker )
       
    90     {
       
    91     CMemSpyEngineHelperSysMemTrackerEntryManager* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerEntryManager( aTracker );
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL();
       
    94     CleanupStack::Pop( self );
       
    95     return self;
       
    96     }
       
    97 
       
    98 
       
    99 CMemSpyEngineHelperSysMemTrackerEntryManager* CMemSpyEngineHelperSysMemTrackerEntryManager::NewL( CMemSpyEngineHelperSysMemTrackerImp& aTracker, CMemSpyEngineHelperSysMemTrackerEntryManager& aMasterList )
       
   100     {
       
   101     CMemSpyEngineHelperSysMemTrackerEntryManager* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerEntryManager( aTracker, &aMasterList );
       
   102     CleanupStack::PushL( self );
       
   103     self->ConstructL();
       
   104     CleanupStack::Pop( self );
       
   105     return self;
       
   106     }
       
   107 
       
   108 
       
   109 void CMemSpyEngineHelperSysMemTrackerEntryManager::IdentifyChangesL( CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   110     {
       
   111     // Mark everything in this list (i.e. the master list) as dead.
       
   112     MarkEverythingDead();
       
   113 
       
   114     // Create a new list which will act as a secondary list. This new list will only contain
       
   115     // new entries. Any entries which it attempts to create that already exist in the master list
       
   116     // will be discared (after updating the corresponding master list entry with new values).
       
   117     CMemSpyEngineHelperSysMemTrackerEntryManager* newEM = CMemSpyEngineHelperSysMemTrackerEntryManager::NewL( iTracker, *this );
       
   118     CleanupStack::PushL( newEM );
       
   119 
       
   120     // At this point, we have performed several key operations
       
   121     // 
       
   122     // 1) We have tagged everything that is still alive as "alive".
       
   123     // 2) We have left everything that no longer exists as "dead"
       
   124     // 3) We have updated all alive entries with new values (if they have changed)
       
   125     // 4) We have identified new entries (these are currently orphaned within the secondary list right now).
       
   126     //
       
   127     // We now need to merge the two lists, i.e. take all the new entries in 'newEM' and merge them
       
   128     // into the current master list.
       
   129     MergeListIntoMeL( *newEM );
       
   130 
       
   131     // We can throw the other list away now as it will be empty.
       
   132     CleanupStack::PopAndDestroy( newEM );
       
   133 
       
   134     // At this point we have our final new list, but it still contains dead entries.
       
   135     // We must next output all the change information required for this cycle.
       
   136     ProcessChangesL( aCycle );
       
   137     }
       
   138 
       
   139 
       
   140 void CMemSpyEngineHelperSysMemTrackerEntryManager::EverythingHasChangedL( CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   141     {
       
   142     ProcessChangesL( aCycle );
       
   143     }
       
   144 
       
   145 
       
   146 
       
   147 
       
   148 
       
   149 
       
   150 
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159 
       
   160 
       
   161 
       
   162 
       
   163 
       
   164 
       
   165 
       
   166 
       
   167 void CMemSpyEngineHelperSysMemTrackerEntryManager::ProcessChangesL( CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   168     {
       
   169     const TInt count = iEntries.Count();
       
   170     for( TInt i=count-1; i>=0; i-- )
       
   171         {
       
   172         CMemSpyEngineHelperSysMemTrackerEntry* entry = iEntries[ i ];
       
   173         
       
   174         // Create any change descriptors etc
       
   175         TRAP_IGNORE( entry->HandleNewCycleL( aCycle ) );
       
   176 
       
   177         // Destroy the entry if it's no longer needed
       
   178         if  ( entry->IsDead() )
       
   179             {
       
   180             delete entry;
       
   181             iEntries.Remove( i );
       
   182             }
       
   183         else
       
   184             {
       
   185             // It's not new anymore
       
   186             entry->SetNew( EFalse );
       
   187             }
       
   188         }
       
   189     }
       
   190 
       
   191 
       
   192 void CMemSpyEngineHelperSysMemTrackerEntryManager::AddItemAndPopL( CMemSpyEngineHelperSysMemTrackerEntry* aItem )
       
   193     {
       
   194     // We sort by entry key, we do not allow duplicates
       
   195     TLinearOrder<CMemSpyEngineHelperSysMemTrackerEntry> orderer( CompareKey );
       
   196 
       
   197     // Before we save the entry we must check to see if the master list knows about it.
       
   198     const TUint64 key( aItem->Key() );
       
   199 
       
   200     // Operates in one of two ways. If we're in stand-alone mode, then it saves every specified entry.
       
   201     // If we're in secondary mode (i.e. we have an associated master list) then it only saves new entries.
       
   202     // Entries which are changed are updated (in the master list) and entries that don't exist anymore
       
   203     // are tagged as dead.
       
   204     //
       
   205     if  ( ActingAsSecondaryList() )
       
   206         {
       
   207         CMemSpyEngineHelperSysMemTrackerEntry* existingEntry = iMasterList->EntryByKey( key );
       
   208         if  ( existingEntry )
       
   209             {
       
   210             // Entry used to exist, still does. Update the master list entry with the information
       
   211             // from the transient (new) entry.
       
   212             existingEntry->UpdateFromL( *aItem );
       
   213 
       
   214             // Entry is still alive. Previously, at the start of the cycle, we'd tagged all master list
       
   215             // entries as dead, hence we must undo that if we find the entry really still exists...
       
   216             // NB: this also updates the timestamp for the entry, to show when it was last still alive.
       
   217             existingEntry->SetAlive();
       
   218 
       
   219             // But it definitely isn't new anymore as we've seen it at least once before
       
   220             existingEntry->SetNew( EFalse );
       
   221 
       
   222             // Transient entry not needed anymore, keep original
       
   223             CleanupStack::PopAndDestroy( aItem );
       
   224             }
       
   225         else
       
   226             {
       
   227             // Entry didn't exist before - it's a new one
       
   228             iEntries.InsertInOrderL( aItem, orderer );
       
   229             CleanupStack::Pop( aItem );
       
   230             }
       
   231 
       
   232         // Any entries in the master list which aren't present anymore in this list (aka, dead entries)
       
   233         // will remain tagged as dead and will be filtered out and dealt with shortly...
       
   234         }
       
   235     else
       
   236         {
       
   237         // We ARE the master list
       
   238         const TInt err = iEntries.InsertInOrder( aItem, orderer );
       
   239         if  ( err == KErrAlreadyExists )
       
   240             {
       
   241             // Don't allow duplicates
       
   242             RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::AddItemAndPopL() - ******* duplicate key ******* key: %LU, type: %d, tid: 0x%08x, pid: 0x%08x, handle: 0x%08x", key, aItem->Type(), (TUint32) aItem->ThreadId(), (TUint32) aItem->ProcessId(), aItem->Handle() );
       
   243             delete aItem;
       
   244             }
       
   245         else if ( err != KErrNone )
       
   246             {
       
   247             User::Leave( err );
       
   248             }
       
   249 
       
   250         CleanupStack::Pop( aItem );
       
   251         }
       
   252     }
       
   253 
       
   254 
       
   255 void CMemSpyEngineHelperSysMemTrackerEntryManager::MarkEverythingDead()
       
   256     {
       
   257     const TInt count = iEntries.Count();
       
   258     for( TInt i=count-1; i>=0; i-- )
       
   259         {
       
   260         CMemSpyEngineHelperSysMemTrackerEntry* entry = iEntries[ i ];
       
   261         entry->SetDead();
       
   262         }
       
   263     }
       
   264 
       
   265 
       
   266 void CMemSpyEngineHelperSysMemTrackerEntryManager::MergeListIntoMeL( CMemSpyEngineHelperSysMemTrackerEntryManager& aOtherList )
       
   267     {
       
   268     const TInt count = aOtherList.iEntries.Count();
       
   269     for( TInt i=count-1; i>=0; i-- )
       
   270         {
       
   271         CMemSpyEngineHelperSysMemTrackerEntry* entry = aOtherList.iEntries[ i ];
       
   272         CleanupStack::PushL( entry );
       
   273         aOtherList.iEntries.Remove( i );
       
   274         AddItemAndPopL( entry );
       
   275         }
       
   276     }
       
   277 
       
   278 
       
   279 TInt CMemSpyEngineHelperSysMemTrackerEntryManager::FindByHandle( TUint aHandle, TMemSpyEngineSysMemTrackerType aType ) const
       
   280     {
       
   281     TInt ret = KErrNotFound;
       
   282     //
       
   283     const TInt count = iEntries.Count();
       
   284     for( TInt i=0; i<count; i++ )
       
   285         {
       
   286         const CMemSpyEngineHelperSysMemTrackerEntry* entry = iEntries[ i ];
       
   287         if  ( entry->Handle() == aHandle && entry->Type() == aType )
       
   288             {
       
   289             ret = i;
       
   290             break;
       
   291             }
       
   292         }
       
   293     //
       
   294     return ret;
       
   295     }
       
   296 
       
   297 
       
   298 TInt CMemSpyEngineHelperSysMemTrackerEntryManager::FindByThreadId( const TThreadId& aThreadId ) const
       
   299     {
       
   300     TInt ret = KErrNotFound;
       
   301     //
       
   302     const TInt count = iEntries.Count();
       
   303     for( TInt i=0; i<count; i++ )
       
   304         {
       
   305         const CMemSpyEngineHelperSysMemTrackerEntry* entry = iEntries[ i ];
       
   306         if  ( entry->ThreadId() == aThreadId )
       
   307             {
       
   308             ret = i;
       
   309             break;
       
   310             }
       
   311         }
       
   312     //
       
   313     return ret;
       
   314     }
       
   315 
       
   316 
       
   317 CMemSpyEngineHelperSysMemTrackerEntry* CMemSpyEngineHelperSysMemTrackerEntryManager::EntryByKey( const TUint64& aKey )
       
   318     {
       
   319     TLinearOrder<CMemSpyEngineHelperSysMemTrackerEntry> orderer( CompareKey );
       
   320     //
       
   321     CMemSpyEngineHelperSysMemTrackerEntryWithSuppliedKey tempEntry( iTracker, aKey );
       
   322     const TInt pos = iEntries.FindInOrder( &tempEntry, orderer );
       
   323     //
       
   324     CMemSpyEngineHelperSysMemTrackerEntry* ret = NULL;
       
   325     if  ( pos >= 0 )
       
   326         {
       
   327         ret = iEntries[ pos ];
       
   328         }
       
   329     //
       
   330     return ret;
       
   331     }
       
   332 
       
   333 
       
   334 TInt CMemSpyEngineHelperSysMemTrackerEntryManager::CompareKey( const CMemSpyEngineHelperSysMemTrackerEntry& aLeft, const CMemSpyEngineHelperSysMemTrackerEntry& aRight )
       
   335     {
       
   336     TInt ret = -1;
       
   337     //
       
   338     const TUint64 kLeft( aLeft.Key() );
       
   339     const TUint64 kRight( aRight.Key() );
       
   340     //
       
   341     if  ( kLeft > kRight )
       
   342         {
       
   343         ret = 1;
       
   344         }
       
   345     else if ( kLeft == kRight )
       
   346         {
       
   347         ret = 0;
       
   348         }
       
   349     //
       
   350     return ret;
       
   351     }
       
   352 
       
   353 
       
   354 TInt CMemSpyEngineHelperSysMemTrackerEntryManager::CompareKeyAndTimeStamp( const CMemSpyEngineHelperSysMemTrackerEntry& aLeft, const CMemSpyEngineHelperSysMemTrackerEntry& aRight )
       
   355     {
       
   356     TInt ret = CompareKey( aLeft, aRight );
       
   357     if  ( ret == 0 )
       
   358         {
       
   359         // Keys are the same, so compare time stamps
       
   360         const TTime& tLeft = aLeft.LastUpdateTime();
       
   361         const TTime& tRight = aRight.LastUpdateTime();
       
   362         //
       
   363         ret = -1;
       
   364         if  ( tLeft > tRight )
       
   365             {
       
   366             ret = 1;
       
   367             }
       
   368         else if ( tLeft == tRight )
       
   369             {
       
   370             ret = 0;
       
   371             }
       
   372         }
       
   373     //
       
   374     return ret;
       
   375     }
       
   376 
       
   377 
       
   378 CMemSpyEngine& CMemSpyEngineHelperSysMemTrackerEntryManager::Engine()
       
   379     {
       
   380     return iTracker.Engine();
       
   381     }
       
   382 
       
   383 
       
   384 
       
   385 
       
   386 
       
   387 
       
   388 
       
   389 
       
   390 
       
   391 
       
   392 
       
   393 
       
   394 
       
   395 
       
   396 
       
   397 
       
   398 
       
   399 
       
   400 
       
   401 
       
   402 
       
   403 
       
   404 
       
   405 
       
   406 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL()
       
   407     {
       
   408     RDebug::Print( KMemSpyKeepaliveMessage );
       
   409     
       
   410     TMemSpyEngineHelperSysMemTrackerConfig config;
       
   411     Engine().HelperSysMemTracker().GetConfig( config );
       
   412     
       
   413     // Get chunk list for entire device
       
   414     CMemSpyEngineChunkList* chunks = Engine().HelperChunk().ListL( );
       
   415     CleanupStack::PushL( chunks );
       
   416 
       
   417 #ifdef SYSMEMTRACKERLOGGING
       
   418     {
       
   419     const TInt chunkCount = chunks->Count();
       
   420     for( TInt i=chunkCount-1; i>=0; i-- )
       
   421         {
       
   422         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   423         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() - MASTER - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   424         }
       
   425     }
       
   426 #endif
       
   427     
       
   428     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryFileServerCache )
       
   429         {
       
   430         RDebug::Print( KMemSpyKeepaliveMessage );
       
   431         // Extract F32 cache chunk
       
   432         CreateSeedItemsFileServerCacheL( *chunks );        
       
   433         }
       
   434 
       
   435 #ifdef SYSMEMTRACKERLOGGING
       
   436     {
       
   437     const TInt chunkCount = chunks->Count();
       
   438     for( TInt i=chunkCount-1; i>=0; i-- )
       
   439         {
       
   440         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   441         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER F32 CACHE - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   442         }
       
   443     }
       
   444 #endif
       
   445 
       
   446     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles )
       
   447         {
       
   448         RDebug::Print( KMemSpyKeepaliveMessage );
       
   449         // Bitmap
       
   450         CreateSeedItemsBitmapL( *chunks );        
       
   451         }
       
   452 
       
   453 #ifdef SYSMEMTRACKERLOGGING
       
   454     {
       
   455     const TInt chunkCount = chunks->Count();
       
   456     for( TInt i=chunkCount-1; i>=0; i-- )
       
   457         {
       
   458         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   459         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER BITMAPS - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   460         }
       
   461     }
       
   462 #endif
       
   463 
       
   464     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap )
       
   465         {
       
   466         RDebug::Print( KMemSpyKeepaliveMessage );
       
   467         // Look for user heaps
       
   468         CreateSeedItemsHeapUserL( *chunks );
       
   469         }
       
   470 
       
   471 #ifdef SYSMEMTRACKERLOGGING
       
   472     {
       
   473     const TInt chunkCount = chunks->Count();
       
   474     for( TInt i=chunkCount-1; i>=0; i-- )
       
   475         {
       
   476         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   477         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER USER HEAP - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   478         }
       
   479     }
       
   480 #endif
       
   481 
       
   482     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap )
       
   483         {
       
   484         RDebug::Print( KMemSpyKeepaliveMessage );
       
   485         // Look for kernel heaps
       
   486         CreateSeedItemsHeapKernelL( *chunks );
       
   487         }
       
   488 
       
   489 #ifdef SYSMEMTRACKERLOGGING
       
   490     {
       
   491     const TInt chunkCount = chunks->Count();
       
   492     for( TInt i=chunkCount-1; i>=0; i-- )
       
   493         {
       
   494         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   495         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER KERNEL HEAP - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   496         }
       
   497     }
       
   498 #endif
       
   499 
       
   500     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryLocalChunks )
       
   501         {
       
   502         RDebug::Print( KMemSpyKeepaliveMessage );
       
   503         // Local chunks
       
   504         CreateSeedItemsChunkLocalL( *chunks );        
       
   505         }
       
   506 
       
   507 #ifdef SYSMEMTRACKERLOGGING
       
   508     {
       
   509     const TInt chunkCount = chunks->Count();
       
   510     for( TInt i=chunkCount-1; i>=0; i-- )
       
   511         {
       
   512         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   513         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER LOCL CHUNK - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   514         }
       
   515     }
       
   516 #endif
       
   517 
       
   518     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalChunks )
       
   519         {
       
   520         RDebug::Print( KMemSpyKeepaliveMessage );
       
   521         // Global chunks
       
   522         CreateSeedItemsChunkGlobalL( *chunks );        
       
   523         }
       
   524 
       
   525 #ifdef SYSMEMTRACKERLOGGING
       
   526     {
       
   527     const TInt chunkCount = chunks->Count();
       
   528     for( TInt i=chunkCount-1; i>=0; i-- )
       
   529         {
       
   530         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   531         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER GLOB CHUNK - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   532         }
       
   533     }
       
   534 #endif
       
   535 
       
   536     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMDrive )
       
   537         {
       
   538         RDebug::Print( KMemSpyKeepaliveMessage );
       
   539         // RAM drive
       
   540         CreateSeedItemRamDriveL( *chunks );        
       
   541         }
       
   542 
       
   543 #ifdef SYSMEMTRACKERLOGGING
       
   544     {
       
   545     const TInt chunkCount = chunks->Count();
       
   546     for( TInt i=chunkCount-1; i>=0; i-- )
       
   547         {
       
   548         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   549         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER RAMD - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   550         }
       
   551     }
       
   552 #endif
       
   553 
       
   554     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks )
       
   555         {
       
   556         RDebug::Print( KMemSpyKeepaliveMessage );
       
   557         // Stacks ($DAT)
       
   558         CreateSeedItemsStacksL( *chunks );        
       
   559         }
       
   560 
       
   561 #ifdef SYSMEMTRACKERLOGGING
       
   562      {
       
   563    const TInt chunkCount = chunks->Count();
       
   564     for( TInt i=chunkCount-1; i>=0; i-- )
       
   565         {
       
   566         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   567         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER STACKS - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   568         }
       
   569     }
       
   570 #endif
       
   571 
       
   572     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData )
       
   573         {
       
   574         RDebug::Print( KMemSpyKeepaliveMessage );
       
   575         // Global data (DLL$DATA)
       
   576         CreateSeedItemsGlobalDataL( *chunks );        
       
   577         }
       
   578 
       
   579  #ifdef SYSMEMTRACKERLOGGING
       
   580     {
       
   581     const TInt chunkCount = chunks->Count();
       
   582     for( TInt i=chunkCount-1; i>=0; i-- )
       
   583         {
       
   584         const TMemSpyDriverChunkInfo& info = chunks->At( i ).Info();
       
   585         RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsL() -  AFTER GLOBAL DATA - info[%03d]: type: %d, size: %d, name: %S"), i, info.iType, info.iSize, &info.iName );
       
   586         }
       
   587     }
       
   588 #endif
       
   589 
       
   590     // Don't need the chunks anymore
       
   591     CleanupStack::PopAndDestroy( chunks );
       
   592 
       
   593     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMLoadedCode )
       
   594         {
       
   595         RDebug::Print( KMemSpyKeepaliveMessage );
       
   596         // Code
       
   597         CreateSeedItemsCodeL();        
       
   598         }
       
   599 
       
   600     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHandles )
       
   601         {
       
   602         // Handles
       
   603         RDebug::Print( KMemSpyKeepaliveMessage);
       
   604         CreateSeedItemsHandlesL();        
       
   605         }
       
   606 
       
   607     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryOpenFiles )
       
   608         {
       
   609         RDebug::Print( KMemSpyKeepaliveMessage );
       
   610         // Open files
       
   611         CreateSeedItemsOpenFilesL();        
       
   612         }
       
   613 
       
   614     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryDiskusage )
       
   615         {
       
   616         RDebug::Print( KMemSpyKeepaliveMessage );
       
   617         // Disk space
       
   618         CreateSeedItemsDiskSpaceL();        
       
   619         }
       
   620 
       
   621     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory )
       
   622         {
       
   623         RDebug::Print( KMemSpyKeepaliveMessage );
       
   624         // System memory
       
   625         CreateSeedItemsSystemMemoryL();        
       
   626         }
       
   627 	
       
   628     if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups )
       
   629         {
       
   630         RDebug::Print( KMemSpyKeepaliveMessage );
       
   631         // Window Server
       
   632         CreateSeedItemsWindowServerL();        
       
   633         }
       
   634     }
       
   635 
       
   636 
       
   637 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL( CMemSpyEngineChunkList& aList )
       
   638     {
       
   639     CMemSpyEngine& engine = Engine();
       
   640     const TInt procCount = engine.Container().Count();
       
   641     for(TInt i=0; i<procCount; i++)
       
   642         {
       
   643         if ( !( i % 10 ) ) // Print the message on only every 10th cycle
       
   644             {
       
   645             RDebug::Print( KMemSpyKeepaliveMessage  );
       
   646             }
       
   647         CMemSpyProcess& process = engine.Container().At( i );
       
   648         TRAP_IGNORE( CreateSeedItemsHeapUserL( process, &aList ) );
       
   649         }
       
   650     }
       
   651 
       
   652 
       
   653 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL( CMemSpyProcess& aProcess, CMemSpyEngineChunkList* aList )
       
   654     {
       
   655     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL() - START - aProcess: %d", (TUint) aProcess.Id() ) );
       
   656     
       
   657     CMemSpyEngine& engine = Engine();
       
   658     engine.ProcessSuspendLC( aProcess.Id() );
       
   659 
       
   660     const TInt threadCount = aProcess.Count();
       
   661     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL() - threadCount: %d", threadCount ) );
       
   662 
       
   663     for( TInt j=0; j<threadCount; j++ )
       
   664         {
       
   665         CMemSpyThread& thread = aProcess.At( j );
       
   666         //
       
   667         if  ( !thread.IsDead() )
       
   668             {
       
   669             TRAP_IGNORE( CreateSeedItemsHeapUserL( thread, aList ) );
       
   670             }
       
   671         }
       
   672     
       
   673     CleanupStack::PopAndDestroy(); // ProcessSuspendLC
       
   674 
       
   675     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL() - END" ) );
       
   676     }
       
   677 
       
   678 
       
   679 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL( CMemSpyThread& aThread, CMemSpyEngineChunkList* aList )
       
   680     {
       
   681     TBool exists = FindByThreadId( aThread.Id() ) != KErrNotFound;
       
   682     //
       
   683     if  ( !exists )
       
   684         {
       
   685         CMemSpyEngineHelperSysMemTrackerEntryHeap* entry = CMemSpyEngineHelperSysMemTrackerEntryHeap::NewUserLC( iTracker, aThread );
       
   686 
       
   687         // Check if chunk already logged
       
   688         TInt entryIndex = FindByHandle( entry->Handle(), EMemSpyEngineSysMemTrackerTypeHeapUser ); 
       
   689         exists =  entryIndex != KErrNotFound;
       
   690         SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapUserL() - heapChunkHandle: 0x%08x, already exists: %d", entry->Handle(), exists ) );
       
   691         if ( exists )
       
   692             {
       
   693             CMemSpyEngineHelperSysMemTrackerEntryHeap& sharedheapEntry = static_cast< CMemSpyEngineHelperSysMemTrackerEntryHeap& >( *iEntries[ entryIndex ] );
       
   694             sharedheapEntry.SetAsShared( ETrue );
       
   695             }
       
   696 
       
   697         // Remove utilised entries
       
   698         if  ( aList )
       
   699             {
       
   700             aList->RemoveByHandle( (TAny*) entry->Handle() );
       
   701             }
       
   702 
       
   703         // Save
       
   704         if  ( !exists )
       
   705             {
       
   706             AddItemAndPopL( entry );
       
   707             }
       
   708         else
       
   709             {
       
   710             CleanupStack::PopAndDestroy( entry );
       
   711             }
       
   712         }
       
   713     }
       
   714 
       
   715 
       
   716 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapKernelL( CMemSpyEngineChunkList& aList )
       
   717     {
       
   718     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapKernelL() - START" ) );
       
   719 
       
   720     CMemSpyEngine& engine = Engine();
       
   721     CMemSpyEngineHelperSysMemTrackerEntryHeap* entry = CMemSpyEngineHelperSysMemTrackerEntryHeap::NewKernelLC( iTracker );
       
   722     AddItemAndPopL( entry );
       
   723 
       
   724     // Remove utilised entries
       
   725     aList.RemoveByHandle( (TAny*) entry->Handle() );
       
   726 
       
   727     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHeapKernelL() - END" ) );
       
   728     }
       
   729 
       
   730 
       
   731 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkLocalL( CMemSpyEngineChunkList& aList )
       
   732     {
       
   733     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkL() - START" ) );
       
   734 
       
   735     const TInt chunkCount = aList.Count();
       
   736     for( TInt i=chunkCount-1; i>=0; i-- )
       
   737         {
       
   738         const TMemSpyDriverChunkInfo& info = aList.At( i ).Info();
       
   739         SYSMEMTRACKERLOG_PRINTF( RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkLocalL() - info[%03d]: type: %d, pid: 0x%04x, size: %d, name: %S"), i, info.iType, info.iOwnerId, info.iSize, &info.iName ) );
       
   740         //
       
   741         if  ( info.iType == EMemSpyDriverChunkTypeLocal )
       
   742             {
       
   743             // Try to find corresponding process
       
   744             const TInt processIndex = Engine().Container().ProcessIndexById( info.iOwnerId );
       
   745             SYSMEMTRACKERLOG_PRINTF( RDebug::Print( _L("CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkLocalL() - processIndex: %d"), processIndex ) );
       
   746             //
       
   747             if  ( processIndex >= 0 )
       
   748                 {
       
   749                 CMemSpyProcess& process = Engine().Container().At( processIndex );
       
   750                 //
       
   751                 TRAP_IGNORE(
       
   752                     CMemSpyEngineHelperSysMemTrackerEntryChunk* entry = CMemSpyEngineHelperSysMemTrackerEntryChunk::NewLC( iTracker, info, process );
       
   753                     AddItemAndPopL( entry );
       
   754                     );
       
   755                 //
       
   756                 aList.Remove( i );
       
   757                 }
       
   758             }
       
   759         }
       
   760 
       
   761     SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkL() - END" ) );
       
   762     }
       
   763 
       
   764 
       
   765 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsChunkGlobalL( CMemSpyEngineChunkList& aList )
       
   766     {
       
   767     const TInt chunkCount = aList.Count();
       
   768     for( TInt i=chunkCount-1; i>=0; i-- )
       
   769         {
       
   770         const TMemSpyDriverChunkInfo& info = aList.At( i ).Info();
       
   771         if  ( info.iType == EMemSpyDriverChunkTypeGlobal )
       
   772             {
       
   773             if  ( CMemSpyEngineHelperFbServ::IsSharedBitmapChunk( info ) || CMemSpyEngineHelperFbServ::IsLargeBitmapChunk( info ) )
       
   774                 {
       
   775                 // Don't process these two yet, they'll be handled by the bitmap code
       
   776                 }
       
   777             else
       
   778                 {
       
   779                 TRAP_IGNORE(
       
   780                     CMemSpyEngineHelperSysMemTrackerEntryChunk* entry = CMemSpyEngineHelperSysMemTrackerEntryChunk::NewLC( iTracker, info );
       
   781                     AddItemAndPopL( entry );
       
   782                     );
       
   783 
       
   784                 // Remove processed item
       
   785                 aList.Remove( i );
       
   786                 }
       
   787             }
       
   788         }
       
   789     }
       
   790 
       
   791 
       
   792 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemRamDriveL( CMemSpyEngineChunkList& aList )
       
   793     {
       
   794     const TInt chunkCount = aList.Count();
       
   795     for( TInt i=chunkCount-1; i>=0; i-- )
       
   796         {
       
   797         const TMemSpyDriverChunkInfo& info = aList.At( i ).Info();
       
   798         if  ( info.iType == EMemSpyDriverChunkTypeRamDrive )
       
   799             {
       
   800             TRAP_IGNORE(
       
   801                 CMemSpyEngineHelperSysMemTrackerEntryRamDrive* entry = CMemSpyEngineHelperSysMemTrackerEntryRamDrive::NewLC( iTracker, info );
       
   802                 AddItemAndPopL( entry );
       
   803                 );
       
   804 
       
   805             // Remove processed item
       
   806             aList.Remove( i );
       
   807             }
       
   808         }
       
   809     }
       
   810 
       
   811 
       
   812 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsStacksL( CMemSpyEngineChunkList& aList )
       
   813     {
       
   814     CMemSpyEngine& engine = Engine();
       
   815     CMemSpyEngineObjectContainer& container = engine.Container();
       
   816     //
       
   817     const TInt procCount = container.Count();
       
   818     for( TInt p=0; p<procCount; p++ )
       
   819         {
       
   820         CMemSpyProcess& process = container.At( p );
       
   821 
       
   822         // We've now sized the user-mode stacks for the process.
       
   823         // Try to locate the stack/data chunk
       
   824         const TInt index = aList.ItemIndexByProcessId( process.Id(), EMemSpyDriverChunkTypeStackAndProcessGlobalData );
       
   825         if  ( index >= 0 )
       
   826             {
       
   827             const TMemSpyDriverChunkInfo& stackChunkInfo = aList.At( index ).Info();
       
   828             //
       
   829             const TInt threadCount = process.Count();
       
   830             for( TInt t=0; t<threadCount; t++ )
       
   831                 {
       
   832                 CMemSpyThread& thread = process.At( t );
       
   833                 //
       
   834                 if  ( !thread.IsDead() )
       
   835                     {
       
   836                     TRAP_IGNORE( CreateSeedItemsStacksL( thread, stackChunkInfo ) );
       
   837                     }
       
   838                 }
       
   839             }
       
   840         }
       
   841     }
       
   842 
       
   843 
       
   844 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsStacksL( CMemSpyThread& aThread, const TMemSpyDriverChunkInfo& aStackChunkInfo )
       
   845     {
       
   846     RThread rThread;
       
   847     if  ( aThread.Open( rThread ) == KErrNone )
       
   848         {
       
   849         CleanupClosePushL( rThread );
       
   850 
       
   851         TThreadStackInfo stackInfo;
       
   852         if  ( rThread.StackInfo( stackInfo ) == KErrNone )
       
   853             {
       
   854             CMemSpyEngineHelperSysMemTrackerEntryStack* entry = CMemSpyEngineHelperSysMemTrackerEntryStack::NewLC( iTracker, aThread, aStackChunkInfo, stackInfo );
       
   855             AddItemAndPopL( entry );
       
   856             }
       
   857 
       
   858         CleanupStack::PopAndDestroy( &rThread );
       
   859         }
       
   860     }
       
   861 
       
   862 
       
   863 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsGlobalDataL( CMemSpyEngineChunkList& aList )
       
   864     {
       
   865     CMemSpyEngine& engine = Engine();
       
   866     CMemSpyEngineObjectContainer& container = engine.Container();
       
   867     //
       
   868     const TInt chunkCount = aList.Count();
       
   869     for( TInt i=chunkCount-1; i>=0; i-- )
       
   870         {
       
   871         const TMemSpyDriverChunkInfo& info = aList.At( i ).Info();
       
   872 
       
   873         if  ( info.iType == EMemSpyDriverChunkTypeGlobalData || info.iType == EMemSpyDriverChunkTypeStackAndProcessGlobalData )
       
   874             {
       
   875             // Need to get associated process
       
   876             const TInt processIndex = container.ProcessIndexById( info.iOwnerId );
       
   877             if  ( processIndex >= 0 )
       
   878                 {
       
   879                 CMemSpyProcess& process = container.At( processIndex );
       
   880                 //
       
   881                 if  ( info.iType == EMemSpyDriverChunkTypeGlobalData )
       
   882                     {
       
   883                     if ( !( i % 10 ) ) // Print the message on only every 10th cycle
       
   884                         {
       
   885                         RDebug::Print( KMemSpyKeepaliveMessage  );
       
   886                         }
       
   887                     // Pure global data, unique chunk
       
   888                     TRAP_IGNORE( 
       
   889                         CMemSpyEngineHelperSysMemTrackerGlobalData* entry = CMemSpyEngineHelperSysMemTrackerGlobalData::NewLC( iTracker, process, info );
       
   890                         AddItemAndPopL( entry );
       
   891                         );
       
   892 
       
   893                     // Remove processed item
       
   894                     aList.Remove( i );
       
   895                     }
       
   896                 else if ( info.iType == EMemSpyDriverChunkTypeStackAndProcessGlobalData )
       
   897                     {
       
   898                     if ( !( i % 10 ) ) // Print the message on only every 10th cycle
       
   899                         {
       
   900                         RDebug::Print( KMemSpyKeepaliveMessage  );
       
   901                         }
       
   902                     // We don't check uniqueness as any stack entries share a common handle with the process
       
   903                     // global data.
       
   904                     TRAP_IGNORE( 
       
   905                         CMemSpyEngineHelperSysMemTrackerGlobalData* entry = CMemSpyEngineHelperSysMemTrackerGlobalData::NewLC( iTracker, process, info );
       
   906                         AddItemAndPopL( entry );
       
   907                         );
       
   908 
       
   909                     // Remove processed item
       
   910                     aList.Remove( i );
       
   911                     }
       
   912                 }
       
   913             }
       
   914         }
       
   915     }
       
   916 
       
   917 
       
   918 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsCodeL()
       
   919     {
       
   920     CMemSpyEngineCodeSegList* code = Engine().HelperCodeSegment().CodeSegmentListRamLoadedL();
       
   921     CleanupStack::PushL( code );
       
   922     //
       
   923     const TInt count = code->Count();
       
   924     for( TInt i=0; i<count; i++ )
       
   925         {
       
   926         const CMemSpyEngineCodeSegEntry& info = code->At( i );
       
   927         //
       
   928         TRAP_IGNORE( 
       
   929             CMemSpyEngineHelperSysMemTrackerEntryCode* entry = CMemSpyEngineHelperSysMemTrackerEntryCode::NewLC( iTracker, info );
       
   930             AddItemAndPopL( entry );
       
   931             );
       
   932         }
       
   933     //
       
   934     CleanupStack::PopAndDestroy( code );
       
   935     }
       
   936 
       
   937 
       
   938 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsHandlesL()
       
   939     {
       
   940     CMemSpyEngineGenericKernelObjectContainer* allContainers = Engine().HelperKernelContainers().ObjectsAllLightweightL();
       
   941     CleanupStack::PushL( allContainers );
       
   942     //
       
   943     const TInt count = allContainers->Count();
       
   944     for( TInt i=0; i<count; i++ )
       
   945         {
       
   946         const CMemSpyEngineGenericKernelObjectList& list = allContainers->At( i );
       
   947         //
       
   948         const TInt entryCount = list.Count();
       
   949         for( TInt j=0; j<entryCount; j++ )
       
   950             {
       
   951             TAny* handle = list.HandleAt( j );
       
   952             CMemSpyEngineHelperSysMemTrackerEntry* entry = NULL;
       
   953             //
       
   954             TRAP_IGNORE( 
       
   955                 if  ( list.Type() == EMemSpyDriverContainerTypePropertyRef )
       
   956                     {
       
   957                     entry = CMemSpyEngineHelperSysMemTrackerEntryHandlePAndS::NewLC( iTracker, handle );
       
   958                     }
       
   959                 else
       
   960                     {
       
   961                     entry = CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::NewLC( iTracker, handle, list.Type() );
       
   962                     }
       
   963 
       
   964                 AddItemAndPopL( entry );
       
   965                 );
       
   966             }
       
   967         }
       
   968     //
       
   969     CleanupStack::PopAndDestroy( allContainers );
       
   970     }
       
   971 
       
   972 
       
   973 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsOpenFilesL()
       
   974     {
       
   975     CMemSpyEngineOpenFileList* list = Engine().HelperFileSystem().ListOpenFilesLC();
       
   976     //
       
   977     const TInt threadCount = list->Count();
       
   978     for( TInt t=0; t<threadCount; t++ )
       
   979         {
       
   980         const CMemSpyEngineOpenFileListForThread& thread = list->At( t );
       
   981         //
       
   982         const TInt entryCount = thread.Count();
       
   983         for( TInt e=0; e<entryCount; e++ )
       
   984             {
       
   985             const CMemSpyEngineOpenFileListEntry& fileEntry = thread.At( e );
       
   986             //
       
   987             TRAP_IGNORE( 
       
   988                 CMemSpyEngineHelperSysMemTrackerEntryOpenFile* entry = CMemSpyEngineHelperSysMemTrackerEntryOpenFile::NewLC( iTracker, thread, fileEntry );
       
   989                 AddItemAndPopL( entry );
       
   990                 );
       
   991             }
       
   992         }
       
   993     //
       
   994     CleanupStack::PopAndDestroy( list );
       
   995     }
       
   996 
       
   997 
       
   998 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsDiskSpaceL()
       
   999     {
       
  1000     TDriveList list;
       
  1001     //
       
  1002     RFs& fsSession = Engine().FsSession();
       
  1003     if  ( fsSession.DriveList( list ) == KErrNone )
       
  1004         {
       
  1005         TDriveInfo info;
       
  1006         //
       
  1007         for( TInt i=0; i<KMaxDrives; i++ )
       
  1008             {
       
  1009             if  ( list[ i ] != KDriveAbsent )
       
  1010                 {
       
  1011                 if  ( fsSession.Drive( info, i ) == KErrNone )
       
  1012                     {
       
  1013                     TRAP_IGNORE( 
       
  1014                         CMemSpyEngineHelperSysMemTrackerEntryDiskSpace* entry = CMemSpyEngineHelperSysMemTrackerEntryDiskSpace::NewLC( iTracker, static_cast<TDriveNumber>( i ) );
       
  1015                         AddItemAndPopL( entry );
       
  1016                         );
       
  1017                     }
       
  1018                 }
       
  1019             }
       
  1020         }
       
  1021     }
       
  1022 
       
  1023 
       
  1024 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsSystemMemoryL()
       
  1025     {
       
  1026     TRAP_IGNORE( 
       
  1027         CMemSpyEngineHelperSysMemTrackerEntrySystemMemory* entryT = CMemSpyEngineHelperSysMemTrackerEntrySystemMemory::NewLC( iTracker, ETypeTotal );
       
  1028         AddItemAndPopL( entryT );
       
  1029         );
       
  1030     TRAP_IGNORE( 
       
  1031         CMemSpyEngineHelperSysMemTrackerEntrySystemMemory* entryF = CMemSpyEngineHelperSysMemTrackerEntrySystemMemory::NewLC( iTracker, ETypeFree );
       
  1032         AddItemAndPopL( entryF );
       
  1033         );
       
  1034     }
       
  1035 
       
  1036 
       
  1037 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsBitmapL( CMemSpyEngineChunkList& aList )
       
  1038     {
       
  1039     TInt bitmapConCount = 0;
       
  1040     TInt fontConCount = 0;
       
  1041     //
       
  1042     RArray<TInt> handles;
       
  1043     CleanupClosePushL( handles );
       
  1044     Engine().HelperFbServ().GetArrayOfBitmapHandlesL( handles, bitmapConCount, fontConCount );
       
  1045     //
       
  1046     const TInt count = handles.Count();
       
  1047     for( TInt i=0; i<count; i++ )
       
  1048         {
       
  1049         const TInt handle = handles[ i ];
       
  1050         //
       
  1051         TRAP_IGNORE( 
       
  1052             CMemSpyEngineHelperSysMemTrackerEntryBitmap* entry = CMemSpyEngineHelperSysMemTrackerEntryBitmap::NewLC( iTracker, handle );
       
  1053             AddItemAndPopL( entry );
       
  1054             );
       
  1055         }
       
  1056     //
       
  1057     CleanupStack::PopAndDestroy( &handles );
       
  1058     
       
  1059     // Make overall fbserv info item
       
  1060     TMemSpyDriverChunkInfo infoChunkLarge;
       
  1061     TMemSpyDriverChunkInfo infoChunkShared;
       
  1062     //
       
  1063     const TInt chunkCount = aList.Count();
       
  1064     for( TInt i=chunkCount-1; i>=0; i-- )
       
  1065         {
       
  1066         const TMemSpyDriverChunkInfo& info = aList.At( i ).Info();
       
  1067         if  ( CMemSpyEngineHelperFbServ::IsSharedBitmapChunk( info ) )
       
  1068             {
       
  1069             SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsBitmapL() - found FbsSharedChunk..." ) );
       
  1070             infoChunkShared = info;
       
  1071             aList.Remove( i );
       
  1072             }
       
  1073         else if ( CMemSpyEngineHelperFbServ::IsLargeBitmapChunk( info ) )
       
  1074             {
       
  1075             SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsBitmapL() - found FbsLargeChunk..." ) );
       
  1076             infoChunkLarge = info;
       
  1077             aList.Remove( i );
       
  1078             }
       
  1079         }
       
  1080 
       
  1081     TRAP_IGNORE( 
       
  1082         CMemSpyEngineHelperSysMemTrackerEntryFbserv* entry = CMemSpyEngineHelperSysMemTrackerEntryFbserv::NewLC( iTracker, infoChunkLarge, infoChunkShared, bitmapConCount, fontConCount, count );
       
  1083         AddItemAndPopL( entry );
       
  1084         );
       
  1085     }
       
  1086 
       
  1087 
       
  1088 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsFileServerCacheL( CMemSpyEngineChunkList& aList )
       
  1089     {
       
  1090     TInt index = KErrNotFound;
       
  1091     const CMemSpyEngineChunkEntry* entry = Engine().HelperFileSystem().IdentifyCacheChunk( aList, index );
       
  1092     //
       
  1093     if  ( entry )
       
  1094         {
       
  1095         const TMemSpyDriverChunkInfo& info = entry->Info();
       
  1096         SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsFileServerCacheL() - found F32 cache chunk..." ) );
       
  1097         //
       
  1098         TRAP_IGNORE( 
       
  1099             CMemSpyEngineHelperSysMemTrackerEntryFileServerCache* entry = CMemSpyEngineHelperSysMemTrackerEntryFileServerCache::NewLC( iTracker, info );
       
  1100             AddItemAndPopL( entry );
       
  1101         );
       
  1102         //
       
  1103         aList.Remove( index );
       
  1104         }
       
  1105     }
       
  1106 
       
  1107 
       
  1108 void CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsWindowServerL()
       
  1109     {
       
  1110     if ( Engine().IsHelperWindowServerSupported() )
       
  1111         {
       
  1112         MMemSpyEngineHelperWindowServer& windowServerManager = Engine().HelperWindowServer();
       
  1113         MMemSpyEngineWindowGroupList* windowGroupList = windowServerManager.WindowGroupListL();
       
  1114         CleanupDeletePushL( windowGroupList );
       
  1115         TInt count = windowGroupList->Count();
       
  1116         TBool isFocused( EFalse );
       
  1117         for ( TInt i = 0; i < count; i++ )
       
  1118             {
       
  1119             TMemSpyEngineWindowGroupDetails windowGroupDetails;
       
  1120             windowServerManager.GetWindowGroupDetailsL( windowGroupList->At( i ).iId, windowGroupDetails );
       
  1121             windowGroupDetails.iOrdinalPosition = windowGroupList->At( i ).iOrdinalPosition;
       
  1122             if ( !isFocused && windowGroupDetails.iPriority == 0 )
       
  1123                 {
       
  1124                 windowGroupDetails.iIsFocused = ETrue;
       
  1125                 isFocused = ETrue;
       
  1126                 }
       
  1127             else
       
  1128                 {
       
  1129                 windowGroupDetails.iIsFocused = EFalse;
       
  1130                 }
       
  1131             TRAP_IGNORE( 
       
  1132                 CMemSpyEngineHelperSysMemTrackerEntryWindowServer* entry = CMemSpyEngineHelperSysMemTrackerEntryWindowServer::NewLC( iTracker, windowGroupDetails );
       
  1133                 AddItemAndPopL( entry );
       
  1134                 );
       
  1135             }
       
  1136         CleanupStack::PopAndDestroy( windowGroupList );
       
  1137         }
       
  1138     else
       
  1139         {
       
  1140         SYSMEMTRACKERLOG_PRINTF( RDebug::Printf( "CMemSpyEngineHelperSysMemTrackerEntryManager::CreateSeedItemsWindowServerL() - Not supported" ) );
       
  1141         }
       
  1142     }
       
  1143 
       
  1144 
       
  1145 
       
  1146