--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp Wed Jun 23 19:59:05 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp Tue Jul 06 16:05:13 2010 +0300
@@ -47,11 +47,6 @@
DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase()
{
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - START - this: 0x%08x", this ));
-
- ReleaseFreeCells();
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - END - this: 0x%08x", this ));
}
@@ -173,207 +168,15 @@
-TInt DMemSpyDriverLogChanHeapBase::OpenUserHeap( DThread& aClientThread, TUint aExpectedHeapVTable, RMemSpyDriverRHeapUser& aHeap, DChunk*& aUserHeapChunk, TDes8* aClientHeapChunkName )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap() - START - aHeap.ChunkIsInitialised: %d, aExpectedHeapVTable: 0x%08x, aClientThread: %O", aHeap.ChunkIsInitialised(), aExpectedHeapVTable, &aClientThread ));
- __ASSERT_ALWAYS( aHeap.ChunkIsInitialised() == EFalse, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapChunkAlreadyCloned ) );
-
- TInt r = KErrNotFound;
- aUserHeapChunk = NULL;
-
- NKern::ThreadEnterCS();
-
- const TBool allocatorIsReallyRHeap = GetUserHeapHandle( aClientThread, aHeap, aExpectedHeapVTable );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - allocatorIsReallyRHeap: %d", allocatorIsReallyRHeap));
-
- if ( allocatorIsReallyRHeap )
- {
- RAllocator* allocator = OSAdaption().DThread().GetAllocator( aClientThread );
-
- // Open client's heap chunk in order to read it's dimensions
- const TInt clientsHeapChunkHandle = aHeap.iChunkHandle;
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunkHandle: 0x%08x, allocatorAddress: 0x%08x", clientsHeapChunkHandle, allocator));
-
- NKern::LockSystem();
- DChunk* clientsHeapChunk = (DChunk*) Kern::ObjectFromHandle( &aClientThread, clientsHeapChunkHandle, EChunk );
- NKern::UnlockSystem();
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunk: 0x%08x", clientsHeapChunk ));
-
- if ( clientsHeapChunk != NULL )
- {
- // Get the chunk name (if the caller asked for it)
- if ( aClientHeapChunkName )
- {
- clientsHeapChunk->FullName( *aClientHeapChunkName );
- }
-
- // Update the heap chunk pointer. We do this now because this
- // should point to the _real_ user-side heap chunk, rather than
- // the copy of the chunk that we are about to make.
- aUserHeapChunk = clientsHeapChunk;
-
- // Set up ourselves to duplicate their heap chunk
- const TInt clientsHeapChunkSize = OSAdaption().DChunk().GetSize( *clientsHeapChunk );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - chunkBase: 0x%08x, size: %8d, maxLen: %8d, chunk: %O", clientsHeapChunk->iBase, clientsHeapChunkSize, clientsHeapChunk->iMaxSize, clientsHeapChunk ));
-
- // Make a new chunk that is the same size, owned by this thread.
- TChunkCreateInfo info;
- info.iType = TChunkCreateInfo::ESharedKernelSingle;
- info.iMaxSize = clientsHeapChunkSize;
- info.iOwnsMemory = ETrue; // Use memory from system's free pool
- info.iDestroyedDfc = NULL;
- #ifdef __EPOC32__
- info.iMapAttr = (TInt)EMapAttrFullyBlocking; // Full caching
- #endif
-
- // Holds a copy of the client's heap chunk
- DChunk* heapCopyChunk;
- TLinAddr heapCopyChunkAddress;
- TUint32 heapCopyChunkMappingAttributes;
- r = Kern::ChunkCreate( info, heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - creating chunk returned: %d", r));
- //
- if ( r == KErrNone )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - copy chunk base: 0x%08x, heapCopyChunkAddress: 0x%08x", heapCopyChunk->iBase, heapCopyChunkAddress));
-
- // Commit memory for entire buffer
- TUint32 physicalAddress = 0;
- r = Kern::ChunkCommitContiguous( heapCopyChunk, 0, clientsHeapChunkSize, physicalAddress );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - commiting chunk returned: %d", r));
-
- if ( r != KErrNone)
- {
- // On error, thow away the chunk we have created
- Kern::ChunkClose( heapCopyChunk );
- heapCopyChunk = NULL;
- }
- else
- {
- 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));
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - trying to copy %d bytes from clients allocator address of 0x%08x", clientsHeapChunkSize, allocator ));
- r = Kern::ThreadRawRead( &aClientThread, allocator, (TAny*) heapCopyChunkAddress, clientsHeapChunkSize );
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - read result of clients heap data is: %d", r));
- if ( r == KErrNone )
- {
- // Transfer ownership of the copy heap chunk to the heap object. This also calculates the delta
- // beween the heap addresses in the client's address space and the kernel address space.
- aHeap.AssociateWithKernelChunk( heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
- }
- }
- }
- }
- else
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - could not open clients heap chunk by its handle" ) );
- r = KErrNotFound;
- }
- }
- else
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clients heap is not an RHeap (allocated vTable mismatch)" ) );
- r = KErrNotSupported;
- }
-
- NKern::ThreadLeaveCS();
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - r: %d", r ));
- return r;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-TBool DMemSpyDriverLogChanHeapBase::GetUserHeapHandle( DThread& aThread, RMemSpyDriverRHeapUser& aHeap, TUint aExpectedVTable )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle() - START - aExpectedVTable: 0x%08x", aExpectedVTable) );
-
- RAllocator* allocator = OSAdaption().DThread().GetAllocator( aThread );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - allocator addr: 0x%08x", allocator) );
- TUint* pAllocator = (TUint*) allocator;
- //
- TBool vTableOkay = EFalse;
- TUint vtable = 0;
-
- // Read a bit more data than is available for debugging purposes
- TBuf8<32> vtableBuf;
- TInt r = Kern::ThreadRawRead( &aThread, pAllocator, (TUint8*) vtableBuf.Ptr(), vtableBuf.MaxLength() );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - read result of vtable data from requested thread is: %d", r));
- if ( r == KErrNone )
- {
- TRACE( MemSpyDriverUtils::DataDump("allocator vtable data - %lS", vtableBuf.Ptr(), vtableBuf.MaxLength(), vtableBuf.MaxLength() ) );
- vtableBuf.SetLength( vtableBuf.MaxLength() );
-
- vtable = vtableBuf[0] +
- (vtableBuf[1] << 8) +
- (vtableBuf[2] << 16) +
- (vtableBuf[3] << 24);
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - client VTable is: 0x%08x", vtable) );
-
- // Check the v-table to work out if it really is an RHeap
- vTableOkay = ( vtable == aExpectedVTable );
- if ( vTableOkay )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - vtables okay") );
- r = aHeap.ReadFromUserAllocator( aThread );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - after userget, error: %d", r));
-
- }
- else
- {
- 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 ) );
- }
- }
- else
- {
- TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - error during client vTable reading: %d, aThread: %O", r, &aThread ) );
- }
- //
- return (vTableOkay && (r == KErrNone));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
void DMemSpyDriverLogChanHeapBase::PrintHeapInfo( const TMemSpyHeapInfo& aInfo )
{
const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
- const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
+ //const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
+ /*
+ TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator -" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iAccessCount: %d", rHeapObjectData.iAccessCount ) );
@@ -408,7 +211,7 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iRand: %d", rHeapObjectData.iRand ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iTestData: 0x%08x", rHeapObjectData.iTestData ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
-
+ */
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Free) -" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
@@ -431,12 +234,6 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Common) -" ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - total cell count: %d", rHeapStats.StatsCommon().TotalCellCount() ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Misc. Info -" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk size: %d", rHeapMetaData.ChunkSize() ) );
@@ -445,73 +242,15 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - debug allocator: %d", rHeapMetaData.IsDebugAllocator() ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - shared heap: %d", rHeapMetaData.IsSharedHeap() ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - user thread: %d", rHeapMetaData.IsUserThread() ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free): %d", rHeapMetaData.HeaderSizeFree() ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc): %d", rHeapMetaData.HeaderSizeAllocated() ) );
+ //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free): %d", rHeapMetaData.HeaderSizeFree() ) );
+ //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc): %d", rHeapMetaData.HeaderSizeAllocated() ) );
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap vTable: 0x%08x", rHeapMetaData.VTable() ) );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size: %d", rHeapMetaData.ClassSize() ) );
+ //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size: %d", rHeapMetaData.ClassSize() ) );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap size: %d", rHeapMetaData.iHeapSize ) );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - allocator address: 0x%08x", rHeapMetaData.iAllocatorAddress ) );
}
-
-
-
-
-
-
-
-
-
-TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel()
- {
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
-
- TInt r = KErrNone;
- TBool debugKernel = EFalse;
-
- NKern::ThreadEnterCS();
- RMemSpyDriverRHeapKernelInPlace rHeap;
- r = OpenKernelHeap( rHeap );
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - open kernel heap returned: %d", r) );
-
- if ( r == KErrNone )
- {
- debugKernel = IsDebugKernel( rHeap );
-
- // Tidy up
- rHeap.DisassociateWithKernelChunk();
- }
-
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - debugKernel: %d", debugKernel) );
- NKern::ThreadLeaveCS();
-
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - ret: %d", r) );
- return debugKernel;
- }
-
-
-TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel( RMemSpyDriverRHeapKernelInPlace& aHeap )
- {
- TBool debugKernel = EFalse;
- //
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
- NKern::ThreadEnterCS();
-
- // Request that the kernel fail the next heap allocation
- aHeap.FailNext();
-
- // Allocate a new cell, and in debug builds of the kernel, this should be NULL
- TInt* cell = new TInt();
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - cell: 0x%08x", cell) );
- debugKernel = ( cell == NULL );
- delete cell;
-
- NKern::ThreadLeaveCS();
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - debugKernel: %d", debugKernel) );
- //
- return debugKernel;
- }
-
-
-TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel( RMemSpyDriverRHeapBase& aHeap, TBool aIsDebugAllocator, const TDesC8& aChunkName, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
+TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel(RMemSpyDriverRHeapBase& aHeap, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
{
TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel() - START - aTransferBuffer: 0x%08x", aTransferBuffer ) );
@@ -520,16 +259,13 @@
// This object holds all of the info we will accumulate for the client.
TMemSpyHeapInfo masterHeapInfo;
- masterHeapInfo.SetType( TMemSpyHeapInfo::ETypeRHeap );
+ masterHeapInfo.SetType(aHeap.GetTypeFromHelper());
masterHeapInfo.SetTid( 2 );
masterHeapInfo.SetPid( 1 );
// This is the RHeap-specific object that contains all RHeap info
TMemSpyHeapInfoRHeap& rHeapInfo = masterHeapInfo.AsRHeap();
- // This is the object data for the RHeap instance
- TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
- aHeap.CopyObjectDataTo( rHeapObjectData );
// When walking the kernel heap we must keep track of the free cells
// without allocating any more memory (on the kernel heap...)
@@ -544,7 +280,7 @@
// We must walk the client's heap in order to build statistics
TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - calling heap walker constructor..."));
- RMemSpyDriverHeapWalker heapWalker( aHeap, aIsDebugAllocator );
+ RMemSpyDriverHeapWalker heapWalker(aHeap);
if ( aTransferBuffer )
{
// This will allow us to identify that we're writing directly to the stream
@@ -596,18 +332,19 @@
// Get remaining meta data that isn't stored elsewhere
TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
- rHeapMetaData.SetChunkName( aChunkName );
+ TFullName chunkName;
+ aHeap.Chunk().FullName(chunkName);
+ rHeapMetaData.SetChunkName(chunkName);
rHeapMetaData.SetChunkSize( (TUint) aHeap.Chunk().Size() );
rHeapMetaData.SetChunkHandle( &aHeap.Chunk() );
- rHeapMetaData.SetChunkBaseAddress( aHeap.Chunk().Base() );
- rHeapMetaData.SetDebugAllocator( aIsDebugAllocator );
- rHeapMetaData.SetHeaderSizeFree( RMemSpyDriverRHeapBase::FreeCellHeaderSize() );
- rHeapMetaData.SetHeaderSizeAllocated( RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( aIsDebugAllocator ) );
+ rHeapMetaData.SetChunkBaseAddress( OSAdaption().DChunk().GetBase(aHeap.Chunk()) );
+ rHeapMetaData.SetDebugAllocator(aHeap.Helper()->AllocatorIsUdeb());
rHeapMetaData.SetUserThread( EFalse );
rHeapMetaData.SetSharedHeap( ETrue );
-
- // Get any heap-specific info
- aHeap.GetHeapSpecificInfo( masterHeapInfo );
+ rHeapMetaData.iHeapSize = aHeap.Helper()->CommittedSize();
+ rHeapMetaData.iAllocatorAddress = (TAny*)aHeap.Helper()->AllocatorAddress();
+ rHeapMetaData.iMinHeapSize = aHeap.Helper()->MinCommittedSize();
+ rHeapMetaData.iMaxHeapSize = aHeap.Helper()->MaxCommittedSize();
PrintHeapInfo( masterHeapInfo );
@@ -641,17 +378,12 @@
-TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/ )
+TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/)
{
TInt error = KErrNone;
//
- if ( aCellType == EMemSpyDriverGoodFreeCell || aCellType == EMemSpyDriverBadFreeCellAddress || aCellType == EMemSpyDriverBadFreeCellSize )
+ if (aCellType & EMemSpyDriverFreeCellMask)
{
- TMemSpyDriverFreeCell cell;
- cell.iType = aCellType;
- cell.iAddress = aCellAddress;
- cell.iLength = aLength;
- //
if ( iStackStream )
{
if ( !iStackStream->IsFull() )
@@ -669,163 +401,16 @@
error = KErrAbort;
}
}
- else
- {
- NKern::ThreadEnterCS();
- error = iFreeCells.Append( cell );
- NKern::ThreadLeaveCS();
- //
- if ( error == KErrNone )
- {
- ++iFreeCellCount;
- }
- }
- }
+ }
//
return ( error == KErrNone );
}
void DMemSpyDriverLogChanHeapBase::HandleHeapWalkInit()
- {
- // Can't delete the free cell list here as we might be walking the kernel heap
- iFreeCellCount = 0;
- }
-
-
-
-
-
-
-TInt DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer()
- {
- // Transfer free cells immediately from xfer stream
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - START - iHeapStream: 0x%08x", iHeapStream ));
- __ASSERT_ALWAYS( !iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotClosed ) );
- //
- TInt r = KErrNoMemory;
- //
- NKern::ThreadEnterCS();
- //
- iHeapStream = new RMemSpyMemStreamWriter();
- if ( iHeapStream )
- {
- const TInt requiredMemory = CalculateFreeCellBufferSize();
- r = OpenXferStream( *iHeapStream, requiredMemory );
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - requested %d bytes for free cell list, r: %d", requiredMemory, r ));
-
- if ( r == KErrNone )
- {
- const TInt count = iFreeCells.Count();
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - free cell count: %d", count ));
- //
- iHeapStream->WriteInt32( count );
- for( TInt i=0; i<count; i++ )
- {
- const TMemSpyDriverFreeCell& cell = iFreeCells[ i ];
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - storing entry: %d", i ));
- //
- iHeapStream->WriteInt32( cell.iType );
- iHeapStream->WriteUint32( reinterpret_cast<TUint32>( cell.iAddress ) );
- iHeapStream->WriteInt32( cell.iLength );
- }
-
- // Finished with the array now
- iFreeCells.Reset();
-
- // We return the amount of client-side memory that needs to be allocated to hold the buffer
- r = requiredMemory;
- }
- }
- //
- NKern::ThreadLeaveCS();
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - END - r: %d", r));
- return r;
- }
-
-
-TInt DMemSpyDriverLogChanHeapBase::FetchFreeCells( TDes8* aBufferSink )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - START - iHeapStream: 0x%08x", iHeapStream ));
- __ASSERT_ALWAYS( iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotOpen ) );
-
- TInt r = KErrNone;
-
- // Write buffer to client
- NKern::ThreadEnterCS();
- r = iHeapStream->WriteAndClose( aBufferSink );
-
- // Tidy up
- ReleaseFreeCells();
-
- NKern::ThreadLeaveCS();
- //
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - END - r: %d", r));
- return r;
- }
-
-
-
-TInt DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() const
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - START" ));
-
- const TInt count = iFreeCells.Count();
- const TInt entrySize = sizeof( TInt32 ) + sizeof( TInt32 ) + sizeof( TUint32 );
- const TInt r = ( count * entrySize ) + sizeof( TInt ); // Extra TInt to hold count
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - END - r: %d, count: %d, entrySize: %d", r, count, entrySize ));
- return r;
- }
-
-
-
-void DMemSpyDriverLogChanHeapBase::ReleaseFreeCells()
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - START - this: 0x%08x", this ));
-
- // Housekeeping
- NKern::ThreadEnterCS();
- iFreeCells.Reset();
- //
- iStackStream = NULL;
- //
- delete iHeapStream;
- iHeapStream = NULL;
- NKern::ThreadLeaveCS();
-
- TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - END - this: 0x%08x", this ));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {
+ iFreeCellCount = 0;
+ }
TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RHeapK*& aHeap, DChunk*& aChunk, TDes8* aClientHeapChunkName )
{
@@ -905,7 +490,7 @@
// Finalise construction of heap
if ( kernelHeap != NULL )
{
- //TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeap->Base(): 0x%08x, kernelHeapChunk->Base(): 0x%08x", kernelHeap->Base(), kernelHeapChunk->Base() ) );
+ TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeapChunk->Base(): 0x%08x", kernelHeapChunk->Base() ) );
aHeap = kernelHeap;
aChunk = kernelHeapChunk;
@@ -935,27 +520,6 @@
return r;
}
-
-TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelInPlace& aHeap, TDes8* aClientHeapChunkName )
- {
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - START") );
-
- RHeapK* heap = NULL;
- DChunk* chunk = NULL;
- TInt r = OpenKernelHeap( heap, chunk, aClientHeapChunkName );
-
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - open err: %d", r ) );
- if ( r == KErrNone )
- {
- aHeap.SetKernelHeap( *heap );
- aHeap.AssociateWithKernelChunk( chunk, TLinAddr( chunk->iBase ), 0 );
- }
-
- TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - END - ret: %d", r ) );
- return r;
- }
-
-
TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelFromCopy& aHeap, TDes8* aClientHeapChunkName )
{
TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - START") );
@@ -1017,7 +581,7 @@
NKern::LockSystem();
const TUint32 copyLength = heapSize; // TODO Min( heap->Size(), heapSize );
- //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() ));
+ 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));
memcpy( (TUint8*) heapCopyChunkAddress, heap, copyLength );
NKern::UnlockSystem();