memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp	Wed Sep 15 13:53:27 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp	Wed Oct 13 16:17:58 2010 +0300
@@ -300,11 +300,12 @@
     // Get the heap info - we need this for verification purposes
     TMemSpyHeapInfo info;
     TInt err = iEngine.Driver().GetHeapInfoUser( info, aFbServThread.Id() );
-    if ( err == KErrNone && info.Type() == TMemSpyHeapInfo::ETypeUnknown )
+    if ( err == KErrNone && info.Type() != TMemSpyHeapInfo::ETypeRHeap )
         {
         err = KErrNotSupported;
         }
     User::LeaveIfError( err );
+    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - allocated cell header length is: %d", info.AsRHeap().MetaData().HeaderSizeAllocated() ));
 
     // Now walk the heap!
     err = iEngine.Driver().WalkHeapInit( aFbServThread.Id() );
@@ -323,12 +324,13 @@
             err = iEngine.Driver().WalkHeapNextCell( aFbServThread.Id(), cellType, cellAddress, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
             TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - cellIndex[%d] err: %d, cellLength: %d, cellAllocationNumber: %d, cellType: %d", cellIndex, err, cellLength, cellAllocationNumber, cellType));
 
-            if  ( err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
+            if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
                 {
                 // We know we are looking for a relatively large *allocated* cell.
-                if  ( cellLength >= KFbServExpectedMinimumCellSize && cellLength <= KFbServExpectedMaximumCellSize )
+                if  ( cellLength >= KFbServExpectedMinimumCellSize && cellLength <= KFbServExpectedMaximumCellSize && cellType == EMemSpyDriverGoodAllocatedCell )
                     {
-                    const TInt payloadLength = cellLength;
+                    const TInt payloadLength = cellLength - info.AsRHeap().MetaData().HeaderSizeAllocated();
+                    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - cell was long enough. Full cell len: %d, header: %d, therefore dataLen: %d", cellLength, info.AsRHeap().MetaData().HeaderSizeAllocated(), payloadLength));
 
                     // This is *probably* the right cell. Let's get the data and check.
                     HBufC8* data = HBufC8::NewLC( payloadLength );
@@ -343,9 +345,9 @@
                         //iEngine.Sink().OutputBinaryDataL( KHeapDumpDataFormat, pData.Ptr(), (const TUint8*) cellAddress, pData.Length() );
                     
                         // Check the data
-                        const TUint heapMaxSize = info.AsRHeap().MetaData().iMaxHeapSize;
-                        const TUint heapBaseAddress = (TUint) info.AsRHeap().MetaData().ChunkBaseAddress();
-                        const TBool correctHeapCellLocated = VerifyCorrectHeapCellL( *data, cellAddress, cellPayloadAddress, heapBaseAddress, heapMaxSize );
+                        const TUint heapSize = info.AsRHeap().ObjectData().Size();
+                        const TUint heapBaseAddress = (TUint) info.AsRHeap().ObjectData().Base();
+                        const TBool correctHeapCellLocated = VerifyCorrectHeapCellL( *data, cellAddress, cellPayloadAddress, heapBaseAddress, heapSize );
                         TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - verified: %d", correctHeapCellLocated));
 
                         if  ( correctHeapCellLocated )
@@ -402,7 +404,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::ReadCObjectConInfoL() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aCellAddress, cellLength, cellAllocationNumber, cellType));
 
-	if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
+    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
         {
         // Check that the cell size meets our expectations - it should be a CObjectCon cell.
         const TInt expectedCellSize = sizeof(CObjectCon*) + cellHeaderSize;
@@ -518,7 +520,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aArrayCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aArrayCellAddress, cellLength, cellAllocationNumber, cellType));
 
-    if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
+    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
         {
         // Check that the cell size meets our expectations. 
         // The cell should be a very specific length
@@ -575,13 +577,13 @@
     }
 
 
-TBool CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapMaxSize )
+TBool CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapSize )
     {
     (void) aPayloadAddress;
     (void) aCellAddress;
-    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL() - START - aDataLen: %d, aCellAddress: 0x%08x, aPayloadAddress: 0x%08x, aHeapStartingAddress: 0x%08x, aHeapSize: %d", aData.Length(), aCellAddress, aPayloadAddress, aHeapStartingAddress, aHeapMaxSize ));
+    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL() - START - aDataLen: %d, aCellAddress: 0x%08x, aPayloadAddress: 0x%08x, aHeapStartingAddress: 0x%08x, aHeapSize: %d", aData.Length(), aCellAddress, aPayloadAddress, aHeapStartingAddress, aHeapSize ));
 
-    const TUint KFbServHeapCeilingAddress = aHeapStartingAddress + aHeapMaxSize;
+    const TUint KFbServHeapCeilingAddress = aHeapStartingAddress + aHeapSize;
 
     // Whether we can use this cell's data...
     TBool correctCell = EFalse;
@@ -744,7 +746,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::GetBitmapObjectLC() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aCellAddress, cellLength, cellAllocationNumber, cellType));
 
-    if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
+    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
         {
         // Check that the cell size meets our expectations - it should be a CBitmapObject, but without the additional "this" pointer
         // which we have tacked onto the object.