memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
--- a/memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h	Wed Sep 15 13:53:27 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h	Wed Oct 13 16:17:58 2010 +0300
@@ -29,23 +29,32 @@
 #include "MemSpyDriverHeap.h"
 #include "MemSpyDriverHeapStatistics.h"
 
-#include "heaputils.h"
-using namespace LtkUtils;
 
 // Heap walker observer interface - can be used to make a record of each cell
 class MMemSpyHeapWalkerObserver
     {
 public:
-    virtual TBool HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber) = 0;
+    virtual TBool HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber ) = 0;
     virtual void HandleHeapWalkInit() = 0;
     };
 
 
+
+// A null observer that is used to collect basic statistics
+class TMemSpyHeapWalkerNullObserver : public MMemSpyHeapWalkerObserver
+    {
+public:
+    TBool HandleHeapCell( TInt /*aCellType*/, TAny* /*aCellAddress*/, TInt /*aLength*/, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/ ) { return ETrue; }
+    void HandleHeapWalkInit() { }
+    };
+
+
 // Heap walker - allows in-place walking of any heap
 class RMemSpyDriverHeapWalker
     {
 public:
-	RMemSpyDriverHeapWalker(RMemSpyDriverRHeapBase& aHeap, MMemSpyHeapWalkerObserver* aObserver=NULL);
+    RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator );
+    RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator, MMemSpyHeapWalkerObserver& aObserver );
 		
 public: // API
     TInt Traverse();
@@ -54,9 +63,12 @@
     inline void SetPrintDebug() { iPrintDebug = ETrue; }
     inline const TMemSpyHeapWalkStatistics& Stats() const { return iStats; }
 
+public: // Utility functions
+    static TAny* KernelAddress( TAny* aUserAddress, TUint aDelta );
+    static TAny* UserAddress( TAny* aKernelAddress, TUint aDelta );
+    static RMemSpyDriverRHeapBase::SCell* CellByUserAddress( TAny* aAddress, TUint aDelta );
+
 private: // Internal methods
-	static TBool CellCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength);
-	TBool DoCellCallback(RAllocatorHelper& aHelper, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength);
     TBool NotifyCell( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel = -1, TInt aAllocNumber = -1 );
     //
     void UpdateStats( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
@@ -64,10 +76,14 @@
     void FinaliseStats();
     void PrintStats();
     //
+    TAny* KernelAddress( TAny* aUserAddress ) const;
+    TAny* UserAddress( TAny* aKernelAddress ) const;
+    //
     inline TBool PrintDebug() const { return iPrintDebug; }
 
 private:
     RMemSpyDriverRHeapBase& iHeap;
+    TBool iIsDebugAllocator;
     TBool iPrintDebug;
     MMemSpyHeapWalkerObserver* iObserver;
     TMemSpyHeapWalkStatistics iStats;