memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp
branchRCL_3
changeset 21 52e343bb8f80
parent 20 ca8a1b6995f6
equal deleted inserted replaced
20:ca8a1b6995f6 21:52e343bb8f80
    45     }
    45     }
    46 
    46 
    47 
    47 
    48 DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase()
    48 DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase()
    49 	{
    49 	{
       
    50 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - START - this: 0x%08x", this ));
       
    51 
       
    52     ReleaseFreeCells();
       
    53 
       
    54 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - END - this: 0x%08x", this ));
    50 	}
    55 	}
    51 
    56 
    52 
    57 
    53 TInt DMemSpyDriverLogChanHeapBase::Construct()
    58 TInt DMemSpyDriverLogChanHeapBase::Construct()
    54 	{
    59 	{
   166 
   171 
   167 
   172 
   168 
   173 
   169 
   174 
   170 
   175 
       
   176 TInt DMemSpyDriverLogChanHeapBase::OpenUserHeap( DThread& aClientThread, TUint aExpectedHeapVTable, RMemSpyDriverRHeapUser& aHeap, DChunk*& aUserHeapChunk, TDes8* aClientHeapChunkName )
       
   177     {
       
   178     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap() - START - aHeap.ChunkIsInitialised: %d, aExpectedHeapVTable: 0x%08x, aClientThread: %O", aHeap.ChunkIsInitialised(), aExpectedHeapVTable, &aClientThread ));
       
   179     __ASSERT_ALWAYS( aHeap.ChunkIsInitialised() == EFalse, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapChunkAlreadyCloned ) );
       
   180 
       
   181     TInt r = KErrNotFound;
       
   182     aUserHeapChunk = NULL;
       
   183     
       
   184     NKern::ThreadEnterCS();
       
   185 
       
   186     const TBool allocatorIsReallyRHeap = GetUserHeapHandle( aClientThread, aHeap, aExpectedHeapVTable );
       
   187 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - allocatorIsReallyRHeap: %d", allocatorIsReallyRHeap));
       
   188 
       
   189     if  ( allocatorIsReallyRHeap )
       
   190         {
       
   191         RAllocator* allocator = OSAdaption().DThread().GetAllocator( aClientThread );
       
   192 
       
   193         // Open client's heap chunk in order to read it's dimensions
       
   194         const TInt clientsHeapChunkHandle = aHeap.iChunkHandle;
       
   195 	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunkHandle: 0x%08x, allocatorAddress: 0x%08x", clientsHeapChunkHandle, allocator));
       
   196 
       
   197  	    NKern::LockSystem();
       
   198         DChunk* clientsHeapChunk = (DChunk*) Kern::ObjectFromHandle( &aClientThread, clientsHeapChunkHandle, EChunk );
       
   199         NKern::UnlockSystem();
       
   200 	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunk: 0x%08x", clientsHeapChunk ));
       
   201        
       
   202         if  ( clientsHeapChunk != NULL )
       
   203             {
       
   204             // Get the chunk name (if the caller asked for it)
       
   205             if  ( aClientHeapChunkName )
       
   206                 {
       
   207                 clientsHeapChunk->FullName( *aClientHeapChunkName );
       
   208                 }
       
   209                 
       
   210             // Update the heap chunk pointer. We do this now because this
       
   211             // should point to the _real_ user-side heap chunk, rather than
       
   212             // the copy of the chunk that we are about to make.
       
   213             aUserHeapChunk = clientsHeapChunk;
       
   214 
       
   215             // Set up ourselves to duplicate their heap chunk
       
   216             const TInt clientsHeapChunkSize = OSAdaption().DChunk().GetSize( *clientsHeapChunk );
       
   217 	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - chunkBase: 0x%08x, size: %8d, maxLen: %8d, chunk: %O", clientsHeapChunk->iBase, clientsHeapChunkSize, clientsHeapChunk->iMaxSize, clientsHeapChunk ));
       
   218 
       
   219             // Make a new chunk that is the same size, owned by this thread.
       
   220             TChunkCreateInfo info;
       
   221             info.iType         = TChunkCreateInfo::ESharedKernelSingle;
       
   222             info.iMaxSize      = clientsHeapChunkSize;
       
   223             info.iOwnsMemory   = ETrue; // Use memory from system's free pool
       
   224             info.iDestroyedDfc = NULL;
       
   225         #ifdef __EPOC32__
       
   226             info.iMapAttr      = (TInt)EMapAttrFullyBlocking; // Full caching
       
   227         #endif
       
   228 
       
   229             // Holds a copy of the client's heap chunk
       
   230             DChunk* heapCopyChunk;
       
   231             TLinAddr heapCopyChunkAddress;
       
   232             TUint32 heapCopyChunkMappingAttributes;
       
   233             r = Kern::ChunkCreate( info, heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
       
   234 	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - creating chunk returned: %d", r));
       
   235             //
       
   236             if  ( r == KErrNone )
       
   237                 {
       
   238 	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - copy chunk base: 0x%08x, heapCopyChunkAddress: 0x%08x", heapCopyChunk->iBase, heapCopyChunkAddress));
       
   239                 
       
   240                 // Commit memory for entire buffer
       
   241                 TUint32 physicalAddress = 0;
       
   242                 r = Kern::ChunkCommitContiguous( heapCopyChunk, 0, clientsHeapChunkSize, physicalAddress );
       
   243 	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - commiting chunk returned: %d", r));
       
   244 
       
   245                 if  ( r != KErrNone)
       
   246                     {
       
   247                     // On error, thow away the chunk we have created
       
   248                     Kern::ChunkClose( heapCopyChunk );
       
   249                     heapCopyChunk = NULL;
       
   250                     }
       
   251                 else
       
   252                     {
       
   253     	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - heapCopyChunk->iSize: 0x%08x, heapCopyChunk->iBase: 0x%08x, heapCopyChunkAddress: 0x%08x, physicalAddress: 0x%08x", heapCopyChunk->iSize, heapCopyChunk->iBase, heapCopyChunkAddress, physicalAddress));
       
   254     
       
   255                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - trying to copy %d bytes from clients allocator address of 0x%08x", clientsHeapChunkSize, allocator ));
       
   256                     r = Kern::ThreadRawRead( &aClientThread, allocator, (TAny*) heapCopyChunkAddress, clientsHeapChunkSize );
       
   257 
       
   258                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - read result of clients heap data is: %d", r));
       
   259                     if  ( r == KErrNone )
       
   260                         {
       
   261                         // Transfer ownership of the copy heap chunk to the heap object. This also calculates the delta
       
   262                         // beween the heap addresses in the client's address space and the kernel address space.
       
   263                         aHeap.AssociateWithKernelChunk( heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
       
   264                         }
       
   265                     }
       
   266                 }
       
   267             }
       
   268         else
       
   269             {
       
   270 	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - could not open clients heap chunk by its handle" ) );
       
   271             r = KErrNotFound;
       
   272             }
       
   273         }
       
   274     else
       
   275         {
       
   276 	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clients heap is not an RHeap (allocated vTable mismatch)" ) );
       
   277         r = KErrNotSupported;
       
   278         }
       
   279 
       
   280     NKern::ThreadLeaveCS();
       
   281 
       
   282     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - r: %d", r ));
       
   283     return r;
       
   284     }
       
   285 
       
   286 
       
   287 
       
   288 
       
   289 
       
   290 
       
   291 
       
   292 
       
   293 
       
   294 
       
   295 
       
   296 
       
   297 
       
   298 
       
   299 
       
   300 
       
   301 
       
   302 
       
   303 
       
   304 
       
   305 
       
   306 
       
   307 
       
   308 TBool DMemSpyDriverLogChanHeapBase::GetUserHeapHandle( DThread& aThread, RMemSpyDriverRHeapUser& aHeap, TUint aExpectedVTable )
       
   309     {
       
   310     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle() - START - aExpectedVTable: 0x%08x", aExpectedVTable) );
       
   311 
       
   312     RAllocator* allocator = OSAdaption().DThread().GetAllocator( aThread );
       
   313 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - allocator addr: 0x%08x", allocator) );
       
   314     TUint* pAllocator = (TUint*) allocator;
       
   315     // 
       
   316     TBool vTableOkay = EFalse;
       
   317     TUint vtable = 0;
       
   318 
       
   319     // Read a bit more data than is available for debugging purposes
       
   320     TBuf8<32> vtableBuf;
       
   321     TInt r = Kern::ThreadRawRead( &aThread, pAllocator, (TUint8*) vtableBuf.Ptr(), vtableBuf.MaxLength() );
       
   322     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - read result of vtable data from requested thread is: %d", r));
       
   323     if  ( r == KErrNone )
       
   324         {
       
   325         TRACE( MemSpyDriverUtils::DataDump("allocator vtable data - %lS", vtableBuf.Ptr(), vtableBuf.MaxLength(), vtableBuf.MaxLength() ) );
       
   326         vtableBuf.SetLength( vtableBuf.MaxLength() );
       
   327         
       
   328         vtable = vtableBuf[0] +
       
   329                 (vtableBuf[1] << 8) + 
       
   330                 (vtableBuf[2] << 16) + 
       
   331                 (vtableBuf[3] << 24);
       
   332         TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - client VTable is: 0x%08x", vtable) );
       
   333 
       
   334         // Check the v-table to work out if it really is an RHeap
       
   335         vTableOkay = ( vtable == aExpectedVTable );
       
   336         if  ( vTableOkay )
       
   337             {
       
   338             TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - vtables okay") );
       
   339             r = aHeap.ReadFromUserAllocator( aThread );
       
   340             TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - after userget, error: %d", r));
       
   341         
       
   342             }
       
   343         else
       
   344             {
       
   345             TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - vtables dont match! - aExpectedVTable: 0x%08x, allocator addr: 0x%08x, client VTable is: 0x%08x, aThread: %O", aExpectedVTable, allocator, vtable, &aThread ) );
       
   346             }
       
   347         }
       
   348     else
       
   349         {
       
   350         TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - error during client vTable reading: %d, aThread: %O", r, &aThread ) );
       
   351         }
       
   352     //
       
   353     return (vTableOkay && (r == KErrNone));
       
   354     }
       
   355 
       
   356 
       
   357 
       
   358 
       
   359 
       
   360 
       
   361 
       
   362 
       
   363 
       
   364 
       
   365 
       
   366 
       
   367 
       
   368 
   171 void DMemSpyDriverLogChanHeapBase::PrintHeapInfo( const TMemSpyHeapInfo& aInfo )
   369 void DMemSpyDriverLogChanHeapBase::PrintHeapInfo( const TMemSpyHeapInfo& aInfo )
   172     {
   370     {
   173     const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
   371     const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
   174     //const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
   372     const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
   175     const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
   373     const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
   176     const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
   374     const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
   177 
   375 
   178     /*
   376     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   179 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
       
   180     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator                                      -" ) );
   377     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator                                      -" ) );
   181     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   378     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   182     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iAccessCount:       %d", rHeapObjectData.iAccessCount ) );
   379     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iAccessCount:       %d", rHeapObjectData.iAccessCount ) );
   183     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandleCount:       %d", rHeapObjectData.iHandleCount ) );
   380     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandleCount:       %d", rHeapObjectData.iHandleCount ) );
   184     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandles:           0x%08x", rHeapObjectData.iHandles ) );
   381     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandles:           0x%08x", rHeapObjectData.iHandles ) );
   209     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailed:                 %d", rHeapObjectData.iFailed ) );
   406     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailed:                 %d", rHeapObjectData.iFailed ) );
   210     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailAllocCount:         %d", rHeapObjectData.iFailAllocCount ) );
   407     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailAllocCount:         %d", rHeapObjectData.iFailAllocCount ) );
   211     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iRand:                   %d", rHeapObjectData.iRand ) );
   408     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iRand:                   %d", rHeapObjectData.iRand ) );
   212     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iTestData:               0x%08x", rHeapObjectData.iTestData ) );
   409     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iTestData:               0x%08x", rHeapObjectData.iTestData ) );
   213     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
   410     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
   214 	*/
   411 
   215     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   412     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   216     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Free)                                    -" ) );
   413     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Free)                                    -" ) );
   217     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   414     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   218     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell count:                     %d", rHeapStats.StatsFree().TypeCount() ) );
   415     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell count:                     %d", rHeapStats.StatsFree().TypeCount() ) );
   219     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell size:                      %d", rHeapStats.StatsFree().TypeSize() ) );
   416     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell size:                      %d", rHeapStats.StatsFree().TypeSize() ) );
   232     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest:                   0x%08x", rHeapStats.StatsAllocated().LargestCellAddress() ) );
   429     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest:                   0x%08x", rHeapStats.StatsAllocated().LargestCellAddress() ) );
   233     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest size:              %d", rHeapStats.StatsAllocated().LargestCellSize() ) );
   430     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest size:              %d", rHeapStats.StatsAllocated().LargestCellSize() ) );
   234     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
   431     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
   235 
   432 
   236     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   433     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
       
   434     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Common)                                  -" ) );
       
   435     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
       
   436     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - total cell count:               %d", rHeapStats.StatsCommon().TotalCellCount() ) );
       
   437     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
       
   438 
       
   439     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   237     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Misc. Info                                      -" ) );
   440     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Misc. Info                                      -" ) );
   238     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   441     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
   239     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk size:                     %d", rHeapMetaData.ChunkSize() ) );
   442     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk size:                     %d", rHeapMetaData.ChunkSize() ) );
   240     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk handle:                   0x%08x", rHeapMetaData.ChunkHandle() ) );
   443     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk handle:                   0x%08x", rHeapMetaData.ChunkHandle() ) );
   241     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk base address:             0x%08x", rHeapMetaData.ChunkBaseAddress() ) );
   444     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk base address:             0x%08x", rHeapMetaData.ChunkBaseAddress() ) );
   242     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - debug allocator:                %d", rHeapMetaData.IsDebugAllocator() ) );
   445     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - debug allocator:                %d", rHeapMetaData.IsDebugAllocator() ) );
   243     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - shared heap:                    %d", rHeapMetaData.IsSharedHeap() ) );
   446     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - shared heap:                    %d", rHeapMetaData.IsSharedHeap() ) );
   244     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - user thread:                    %d", rHeapMetaData.IsUserThread() ) );
   447     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - user thread:                    %d", rHeapMetaData.IsUserThread() ) );
   245     //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree() ) );
   448     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree() ) );
   246     //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated() ) );
   449     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated() ) );
   247     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap vTable:                    0x%08x", rHeapMetaData.VTable() ) );
   450     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap vTable:                    0x%08x", rHeapMetaData.VTable() ) );
   248     //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size:               %d", rHeapMetaData.ClassSize() ) );
   451     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size:               %d", rHeapMetaData.ClassSize() ) );
   249     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap size:                      %d", rHeapMetaData.iHeapSize ) );
   452     }
   250     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - allocator address:              0x%08x", rHeapMetaData.iAllocatorAddress ) );
   453 
   251     }
   454 
   252 
   455 
   253 TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel(RMemSpyDriverRHeapBase& aHeap, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
   456 
       
   457 
       
   458 
       
   459 
       
   460 
       
   461 
       
   462 
       
   463 TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel()
       
   464     {
       
   465     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
       
   466     
       
   467     TInt r = KErrNone;
       
   468     TBool debugKernel = EFalse;
       
   469 
       
   470     NKern::ThreadEnterCS();
       
   471     RMemSpyDriverRHeapKernelInPlace rHeap;
       
   472     r = OpenKernelHeap( rHeap );
       
   473     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - open kernel heap returned: %d", r) );
       
   474 
       
   475     if  ( r == KErrNone )
       
   476         {
       
   477         debugKernel = IsDebugKernel( rHeap );
       
   478 
       
   479         // Tidy up
       
   480         rHeap.DisassociateWithKernelChunk();
       
   481         }
       
   482 
       
   483     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - debugKernel: %d", debugKernel) );
       
   484     NKern::ThreadLeaveCS();
       
   485 
       
   486  	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - ret: %d", r) );
       
   487     return debugKernel;
       
   488     }
       
   489 
       
   490 
       
   491 TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel( RMemSpyDriverRHeapKernelInPlace& aHeap )
       
   492     {
       
   493     TBool debugKernel = EFalse;
       
   494     //
       
   495  	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
       
   496     NKern::ThreadEnterCS();
       
   497 
       
   498     // Request that the kernel fail the next heap allocation
       
   499     aHeap.FailNext();
       
   500 
       
   501     // Allocate a new cell, and in debug builds of the kernel, this should be NULL
       
   502     TInt* cell = new TInt();
       
   503     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - cell: 0x%08x", cell) );
       
   504     debugKernel = ( cell == NULL );
       
   505     delete cell;
       
   506 
       
   507     NKern::ThreadLeaveCS();
       
   508  	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - debugKernel: %d", debugKernel) );
       
   509     //
       
   510     return debugKernel;
       
   511     }
       
   512 
       
   513 
       
   514 TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel( RMemSpyDriverRHeapBase& aHeap, TBool aIsDebugAllocator, const TDesC8& aChunkName, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
   254     {
   515     {
   255     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel() - START - aTransferBuffer: 0x%08x", aTransferBuffer ) );
   516     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel() - START - aTransferBuffer: 0x%08x", aTransferBuffer ) );
   256 
   517 
   257     TInt r = KErrNone;
   518     TInt r = KErrNone;
   258     NKern::ThreadEnterCS();
   519     NKern::ThreadEnterCS();
   259 
   520 
   260     // This object holds all of the info we will accumulate for the client.
   521     // This object holds all of the info we will accumulate for the client.
   261     TMemSpyHeapInfo masterHeapInfo;
   522     TMemSpyHeapInfo masterHeapInfo;
   262     masterHeapInfo.SetType(aHeap.GetTypeFromHelper());
   523     masterHeapInfo.SetType( TMemSpyHeapInfo::ETypeRHeap );
   263     masterHeapInfo.SetTid( 2 );
   524     masterHeapInfo.SetTid( 2 );
   264     masterHeapInfo.SetPid( 1 );
   525     masterHeapInfo.SetPid( 1 );
   265 
   526 
   266     // This is the RHeap-specific object that contains all RHeap info
   527     // This is the RHeap-specific object that contains all RHeap info
   267     TMemSpyHeapInfoRHeap& rHeapInfo = masterHeapInfo.AsRHeap();
   528     TMemSpyHeapInfoRHeap& rHeapInfo = masterHeapInfo.AsRHeap();
   268 
   529 
       
   530     // This is the object data for the RHeap instance
       
   531     TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
       
   532     aHeap.CopyObjectDataTo( rHeapObjectData );
   269 
   533 
   270     // When walking the kernel heap we must keep track of the free cells
   534     // When walking the kernel heap we must keep track of the free cells
   271     // without allocating any more memory (on the kernel heap...)
   535     // without allocating any more memory (on the kernel heap...)
   272     //
   536     //
   273     // Therefore, we start a stream immediately, which is actually already
   537     // Therefore, we start a stream immediately, which is actually already
   278     RMemSpyMemStreamWriter stream;
   542     RMemSpyMemStreamWriter stream;
   279     TInt32* pCount = NULL;
   543     TInt32* pCount = NULL;
   280 
   544 
   281     // We must walk the client's heap in order to build statistics
   545     // We must walk the client's heap in order to build statistics
   282     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - calling heap walker constructor..."));
   546     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - calling heap walker constructor..."));
   283     RMemSpyDriverHeapWalker heapWalker(aHeap);
   547     RMemSpyDriverHeapWalker heapWalker( aHeap, aIsDebugAllocator );
   284     if  ( aTransferBuffer )
   548     if  ( aTransferBuffer )
   285         {
   549         {
   286         // This will allow us to identify that we're writing directly to the stream
   550         // This will allow us to identify that we're writing directly to the stream
   287         stream = OpenXferStream();
   551         stream = OpenXferStream();
   288         iStackStream = &stream;
   552         iStackStream = &stream;
   330     TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
   594     TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
   331     heapWalker.CopyStatsTo( rHeapStats );
   595     heapWalker.CopyStatsTo( rHeapStats );
   332 
   596 
   333     // Get remaining meta data that isn't stored elsewhere
   597     // Get remaining meta data that isn't stored elsewhere
   334     TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
   598     TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
   335 	TFullName chunkName;
   599     rHeapMetaData.SetChunkName( aChunkName );
   336 	aHeap.Chunk().FullName(chunkName);
       
   337     rHeapMetaData.SetChunkName(chunkName);
       
   338     rHeapMetaData.SetChunkSize( (TUint) aHeap.Chunk().Size() );
   600     rHeapMetaData.SetChunkSize( (TUint) aHeap.Chunk().Size() );
   339     rHeapMetaData.SetChunkHandle( &aHeap.Chunk() );
   601     rHeapMetaData.SetChunkHandle( &aHeap.Chunk() );
   340     rHeapMetaData.SetChunkBaseAddress( OSAdaption().DChunk().GetBase(aHeap.Chunk()) );
   602     rHeapMetaData.SetChunkBaseAddress( aHeap.Chunk().Base() );
   341     rHeapMetaData.SetDebugAllocator(aHeap.Helper()->AllocatorIsUdeb());
   603     rHeapMetaData.SetDebugAllocator( aIsDebugAllocator );
       
   604     rHeapMetaData.SetHeaderSizeFree( RMemSpyDriverRHeapBase::FreeCellHeaderSize() );
       
   605     rHeapMetaData.SetHeaderSizeAllocated( RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( aIsDebugAllocator ) );
   342     rHeapMetaData.SetUserThread( EFalse );
   606     rHeapMetaData.SetUserThread( EFalse );
   343     rHeapMetaData.SetSharedHeap( ETrue );
   607     rHeapMetaData.SetSharedHeap( ETrue );
   344 	rHeapMetaData.iHeapSize = aHeap.Helper()->CommittedSize();
   608 
   345 	rHeapMetaData.iAllocatorAddress = (TAny*)aHeap.Helper()->AllocatorAddress();
   609     // Get any heap-specific info
   346 	rHeapMetaData.iMinHeapSize = aHeap.Helper()->MinCommittedSize();
   610     aHeap.GetHeapSpecificInfo( masterHeapInfo );
   347 	rHeapMetaData.iMaxHeapSize = aHeap.Helper()->MaxCommittedSize();
       
   348 
   611 
   349     PrintHeapInfo( masterHeapInfo );
   612     PrintHeapInfo( masterHeapInfo );
   350 
   613 
   351     // Update info ready for writing back to the user-side
   614     // Update info ready for writing back to the user-side
   352     if  ( r == KErrNone )
   615     if  ( r == KErrNone )
   376 
   639 
   377 
   640 
   378 
   641 
   379 
   642 
   380 
   643 
   381 TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/)
   644 TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/ )
   382     {
   645     {
   383     TInt error = KErrNone;
   646     TInt error = KErrNone;
   384     //
   647     //
   385     if  (aCellType & EMemSpyDriverFreeCellMask)
   648     if  ( aCellType == EMemSpyDriverGoodFreeCell || aCellType == EMemSpyDriverBadFreeCellAddress || aCellType == EMemSpyDriverBadFreeCellSize )
   386         {
   649         {
       
   650         TMemSpyDriverFreeCell cell;
       
   651         cell.iType = aCellType;
       
   652         cell.iAddress = aCellAddress;
       
   653         cell.iLength = aLength;
       
   654         //
   387         if  ( iStackStream )
   655         if  ( iStackStream )
   388             {
   656             {
   389             if  ( !iStackStream->IsFull() )
   657             if  ( !iStackStream->IsFull() )
   390                 {
   658                 {
   391                 ++iFreeCellCount;
   659                 ++iFreeCellCount;
   399                 {
   667                 {
   400                 Kern::Printf( "DMemSpyDriverLogChanHeapBase::HandleHeapCell - Kernel Free Cell stack stream IS FULL!" );
   668                 Kern::Printf( "DMemSpyDriverLogChanHeapBase::HandleHeapCell - Kernel Free Cell stack stream IS FULL!" );
   401                 error = KErrAbort;
   669                 error = KErrAbort;
   402                 }
   670                 }
   403             }
   671             }
   404        }
   672         else
       
   673             {
       
   674             NKern::ThreadEnterCS();
       
   675             error = iFreeCells.Append( cell );
       
   676             NKern::ThreadLeaveCS();
       
   677             //
       
   678             if ( error == KErrNone )
       
   679                 {
       
   680                 ++iFreeCellCount;
       
   681                 }
       
   682             }
       
   683         }
   405     //
   684     //
   406     return ( error == KErrNone );
   685     return ( error == KErrNone );
   407     }
   686     }
   408 
   687 
   409 
   688 
   410 void DMemSpyDriverLogChanHeapBase::HandleHeapWalkInit()
   689 void DMemSpyDriverLogChanHeapBase::HandleHeapWalkInit()
   411 	{
   690     {
   412 	iFreeCellCount = 0;
   691     // Can't delete the free cell list here as we might be walking the kernel heap
   413 	}
   692     iFreeCellCount = 0;
       
   693     }
       
   694 
       
   695 
       
   696 
       
   697 
       
   698 
       
   699 
       
   700 TInt DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer()
       
   701     {
       
   702     // Transfer free cells immediately from xfer stream
       
   703     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - START - iHeapStream: 0x%08x", iHeapStream ));
       
   704     __ASSERT_ALWAYS( !iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotClosed ) );
       
   705     //
       
   706     TInt r = KErrNoMemory;
       
   707     //
       
   708     NKern::ThreadEnterCS();
       
   709     //
       
   710     iHeapStream = new RMemSpyMemStreamWriter();
       
   711     if  ( iHeapStream )
       
   712         {
       
   713         const TInt requiredMemory = CalculateFreeCellBufferSize();
       
   714         r = OpenXferStream( *iHeapStream, requiredMemory );
       
   715         TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - requested %d bytes for free cell list, r: %d", requiredMemory, r ));
       
   716 
       
   717         if  ( r == KErrNone )
       
   718             {
       
   719             const TInt count = iFreeCells.Count();
       
   720             TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - free cell count: %d", count ));
       
   721             //
       
   722             iHeapStream->WriteInt32( count );
       
   723             for( TInt i=0; i<count; i++ )
       
   724                 {
       
   725                 const TMemSpyDriverFreeCell& cell = iFreeCells[ i ];
       
   726                 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - storing entry: %d", i ));
       
   727                 //
       
   728                 iHeapStream->WriteInt32( cell.iType );
       
   729                 iHeapStream->WriteUint32( reinterpret_cast<TUint32>( cell.iAddress ) );
       
   730                 iHeapStream->WriteInt32( cell.iLength );
       
   731                 }
       
   732 
       
   733             // Finished with the array now
       
   734             iFreeCells.Reset();
       
   735 
       
   736             // We return the amount of client-side memory that needs to be allocated to hold the buffer
       
   737             r = requiredMemory;
       
   738             }
       
   739         }
       
   740     //
       
   741     NKern::ThreadLeaveCS();
       
   742                
       
   743     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - END - r: %d", r));
       
   744 	return r;
       
   745     }
       
   746 
       
   747 
       
   748 TInt DMemSpyDriverLogChanHeapBase::FetchFreeCells( TDes8* aBufferSink )
       
   749     {
       
   750     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - START - iHeapStream: 0x%08x", iHeapStream ));
       
   751     __ASSERT_ALWAYS( iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotOpen ) );
       
   752 
       
   753     TInt r = KErrNone;
       
   754 
       
   755     // Write buffer to client
       
   756     NKern::ThreadEnterCS();
       
   757     r = iHeapStream->WriteAndClose( aBufferSink );
       
   758 
       
   759     // Tidy up
       
   760     ReleaseFreeCells();
       
   761 
       
   762     NKern::ThreadLeaveCS();
       
   763     //
       
   764     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - END - r: %d", r));
       
   765 	return r;
       
   766     }
       
   767 
       
   768 
       
   769 
       
   770 TInt DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() const
       
   771     {
       
   772     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - START" ));
       
   773 
       
   774     const TInt count = iFreeCells.Count();
       
   775     const TInt entrySize = sizeof( TInt32 ) + sizeof( TInt32 ) + sizeof( TUint32 );
       
   776     const TInt r = ( count * entrySize ) + sizeof( TInt ); // Extra TInt to hold count
       
   777                 
       
   778     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - END - r: %d, count: %d, entrySize: %d", r, count, entrySize ));
       
   779 	return r;
       
   780     }
       
   781 
       
   782 
       
   783 
       
   784 void DMemSpyDriverLogChanHeapBase::ReleaseFreeCells()
       
   785     {
       
   786 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - START - this: 0x%08x", this ));
       
   787 
       
   788     // Housekeeping
       
   789     NKern::ThreadEnterCS();
       
   790     iFreeCells.Reset();
       
   791     //
       
   792     iStackStream = NULL;
       
   793     //
       
   794     delete iHeapStream;
       
   795     iHeapStream = NULL;
       
   796     NKern::ThreadLeaveCS();
       
   797 
       
   798     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - END - this: 0x%08x", this ));
       
   799     }
       
   800 
       
   801 
       
   802 
       
   803 
       
   804 
       
   805 
       
   806 
       
   807 
       
   808 
       
   809 
       
   810 
       
   811 
       
   812 
       
   813 
       
   814 
       
   815 
       
   816 
       
   817 
       
   818 
       
   819 
       
   820 
       
   821 
       
   822 
       
   823 
       
   824 
       
   825 
       
   826 
       
   827 
       
   828 
   414 
   829 
   415 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RHeapK*& aHeap, DChunk*& aChunk, TDes8* aClientHeapChunkName )
   830 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RHeapK*& aHeap, DChunk*& aChunk, TDes8* aClientHeapChunkName )
   416     {
   831     {
   417     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap() - START") );
   832     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap() - START") );
   418 
   833 
   488         kernelHeap = (RHeapK*) kernelHeapChunk->Base();
   903         kernelHeap = (RHeapK*) kernelHeapChunk->Base();
   489 #endif
   904 #endif
   490         // Finalise construction of heap 
   905         // Finalise construction of heap 
   491         if  ( kernelHeap != NULL )
   906         if  ( kernelHeap != NULL )
   492             {
   907             {
   493             TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeapChunk->Base(): 0x%08x", kernelHeapChunk->Base() ) );
   908             TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeap->Base(): 0x%08x, kernelHeapChunk->Base(): 0x%08x", kernelHeap->Base(), kernelHeapChunk->Base() ) );
   494             aHeap = kernelHeap;
   909             aHeap = kernelHeap;
   495             aChunk = kernelHeapChunk;
   910             aChunk = kernelHeapChunk;
   496 
   911 
   497             // Get the chunk name (if the caller asked for it)
   912             // Get the chunk name (if the caller asked for it)
   498             if  ( aClientHeapChunkName )
   913             if  ( aClientHeapChunkName )
   517  	NKern::ThreadLeaveCS();
   932  	NKern::ThreadLeaveCS();
   518 
   933 
   519 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap() - END - ret: %d", r ) );
   934 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap() - END - ret: %d", r ) );
   520     return r;
   935     return r;
   521     }
   936     }
       
   937 
       
   938 
       
   939 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelInPlace& aHeap, TDes8* aClientHeapChunkName )
       
   940     {
       
   941     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - START") );
       
   942 
       
   943     RHeapK* heap = NULL;
       
   944     DChunk* chunk = NULL;
       
   945     TInt r = OpenKernelHeap( heap, chunk, aClientHeapChunkName );
       
   946 	
       
   947     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - open err: %d", r ) );
       
   948     if  ( r == KErrNone )
       
   949         {
       
   950         aHeap.SetKernelHeap( *heap );
       
   951         aHeap.AssociateWithKernelChunk( chunk, TLinAddr( chunk->iBase ), 0 );
       
   952         }
       
   953 
       
   954 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - END - ret: %d", r ) );
       
   955     return r;
       
   956     }
       
   957 
   522 
   958 
   523 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelFromCopy& aHeap, TDes8* aClientHeapChunkName )
   959 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelFromCopy& aHeap, TDes8* aClientHeapChunkName )
   524     {
   960     {
   525     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - START") );
   961     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - START") );
   526 
   962 
   579                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - heapCopyChunk->iSize: 0x%08x, heapCopyChunk->iBase: 0x%08x, heapCopyChunkAddress: 0x%08x, physicalAddress: 0x%08x", heapCopyChunk->iSize, heapCopyChunk->iBase, heapCopyChunkAddress, physicalAddress));
  1015                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - heapCopyChunk->iSize: 0x%08x, heapCopyChunk->iBase: 0x%08x, heapCopyChunkAddress: 0x%08x, physicalAddress: 0x%08x", heapCopyChunk->iSize, heapCopyChunk->iBase, heapCopyChunkAddress, physicalAddress));
   580 
  1016 
   581                 NKern::LockSystem();
  1017                 NKern::LockSystem();
   582                 const TUint32 copyLength = heapSize; // TODO Min( heap->Size(), heapSize );
  1018                 const TUint32 copyLength = heapSize; // TODO Min( heap->Size(), heapSize );
   583 
  1019 
   584                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - trying to copy %d (vs orig estimate of %d) bytes from kernel allocator address: 0x%08x", copyLength, heapSize, heap));
  1020                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - trying to copy %d (vs orig estimate of %d) bytes from kernel allocator address: 0x%08x", copyLength, heapSize, heap->Base() ));
   585                 memcpy( (TUint8*) heapCopyChunkAddress, heap, copyLength );
  1021                 memcpy( (TUint8*) heapCopyChunkAddress, heap, copyLength );
   586 
  1022 
   587                 NKern::UnlockSystem();
  1023                 NKern::UnlockSystem();
   588 
  1024 
   589                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - copied kernel heap data" ));
  1025                 TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - copied kernel heap data" ));