memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsSharedRHeap.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
    33 // Classes referenced
    33 // Classes referenced
    34 class CActiveScheduler;
    34 class CActiveScheduler;
    35 class CTrapCleanup;
    35 class CTrapCleanup;
    36 
    36 
    37 
    37 
       
    38 
       
    39 class TMemSpyHeapObjectDataRHeap
       
    40     {
       
    41 public:
       
    42     inline TMemSpyHeapObjectDataRHeap()
       
    43         : iAccessCount( 0 ),
       
    44           iHandleCount( 0 ),
       
    45           iHandles( NULL ),
       
    46           iFlags( 0 ),
       
    47           iCellCount( 0 ),
       
    48           iTotalAllocSize ( 0 ),
       
    49           //
       
    50           iMinLength( 0 ),
       
    51           iMaxLength( 0 ),
       
    52           iOffset ( 0 ),
       
    53           iGrowBy( 0 ),
       
    54           iChunkHandle ( 0 ),
       
    55           iBase( NULL ),
       
    56           iTop( NULL ),
       
    57           iAlign( 0 ),
       
    58           iMinCell( 0 ),
       
    59           iPageSize( 0 ),
       
    60           iNestingLevel( 0 ),
       
    61           iAllocCount( 0 ),
       
    62           iFailRate( 0 ),
       
    63           iFailed( EFalse ),
       
    64           iFailAllocCount( 0 ),
       
    65           iRand( 0 ),
       
    66           iTestData( NULL )
       
    67         {
       
    68         }
       
    69 
       
    70 public: // API
       
    71     inline TUint8* Base() const { return iBase; }
       
    72     inline TUint Size() const { return iTop - iBase; }
       
    73 
       
    74 public: // From RAllocator
       
    75 	TInt iAccessCount;
       
    76 	TInt iHandleCount;
       
    77 	TInt* iHandles;
       
    78 	TUint32 iFlags;
       
    79 	TInt iCellCount;
       
    80 	TInt iTotalAllocSize;
       
    81 
       
    82 public: // From RHeap
       
    83 	TInt iMinLength;
       
    84 	TInt iMaxLength;
       
    85 	TInt iOffset;
       
    86 	TInt iGrowBy;
       
    87 	TInt iChunkHandle;
       
    88     RFastLock iLock;
       
    89 	TUint8* iBase;
       
    90 	TUint8* iTop;
       
    91 	TInt iAlign;
       
    92 	TInt iMinCell;
       
    93 	TInt iPageSize;
       
    94 #ifdef __SYMBIAN_KERNEL_HYBRID_HEAP__
       
    95 	struct SCell { TInt len; SCell* next };
       
    96     SCell iFree;
       
    97 #else
       
    98     RHeap::SCell iFree;
       
    99 #endif
       
   100 	TInt iNestingLevel;
       
   101 	TInt iAllocCount;
       
   102     RAllocator::TAllocFail iFailType;
       
   103 	TInt iFailRate;
       
   104 	TBool iFailed;
       
   105 	TInt iFailAllocCount;
       
   106 	TInt iRand;
       
   107 	TAny* iTestData;
       
   108     };
       
   109 
       
   110 
       
   111 
    38 /**
   112 /**
    39  * Base class for MemSpy RHeap statistics
   113  * Base class for MemSpy RHeap statistics
    40  */
   114  */
    41 class TMemSpyHeapStatisticsRHeapBase
   115 class TMemSpyHeapStatisticsRHeapBase
    42     {
   116     {
   129     TUint iSlackSpace;
   203     TUint iSlackSpace;
   130     TAny* iSlackSpaceCellAddress;
   204     TAny* iSlackSpaceCellAddress;
   131     TUint32 iChecksum;
   205     TUint32 iChecksum;
   132     };
   206     };
   133 
   207 
       
   208 
       
   209 
       
   210 
       
   211 
       
   212 /**
       
   213  * RHeap statistics for common cell types
       
   214  */
       
   215 class TMemSpyHeapStatisticsRHeapCommon
       
   216     {
       
   217 public: // Constructors
       
   218     inline TMemSpyHeapStatisticsRHeapCommon()
       
   219         : iTotalCellCount( 0 )
       
   220         {
       
   221         }
       
   222 
       
   223 public:
       
   224     inline TUint TotalCellCount() const { return iTotalCellCount; }
       
   225     inline void SetTotalCellCount( TUint aValue ) { iTotalCellCount = aValue; }
       
   226 
       
   227 private:
       
   228     TUint iTotalCellCount;
       
   229     };
       
   230 
       
   231 
       
   232 
       
   233 
       
   234 
   134 /**
   235 /**
   135  * RHeap statistics class
   236  * RHeap statistics class
   136  */
   237  */
   137 class TMemSpyHeapStatisticsRHeap
   238 class TMemSpyHeapStatisticsRHeap
   138     {
   239     {
   139 public: // Constructors
   240 public: // Constructors
   140     inline TMemSpyHeapStatisticsRHeap()
   241     inline TMemSpyHeapStatisticsRHeap()
   141 		: iCommittedFreeSpace(0)
       
   142         {
   242         {
   143         }
   243         }
   144 
   244 
   145 public: // API
   245 public: // API
   146     inline TMemSpyHeapStatisticsRHeapFree& StatsFree() { return iStatisticsFree; }
   246     inline TMemSpyHeapStatisticsRHeapFree& StatsFree() { return iStatisticsFree; }
   147     inline const TMemSpyHeapStatisticsRHeapFree& StatsFree() const { return iStatisticsFree; }
   247     inline const TMemSpyHeapStatisticsRHeapFree& StatsFree() const { return iStatisticsFree; }
   148     //
   248     //
   149     inline TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() { return iStatisticsAllocated; }
   249     inline TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() { return iStatisticsAllocated; }
   150     inline const TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() const { return iStatisticsAllocated; }
   250     inline const TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() const { return iStatisticsAllocated; }
   151 
   251     //
       
   252     inline TMemSpyHeapStatisticsRHeapCommon& StatsCommon() { return iStatisticsCommon; }
       
   253     inline const TMemSpyHeapStatisticsRHeapCommon& StatsCommon() const { return iStatisticsCommon; }
   152 
   254 
   153 private: // Data members
   255 private: // Data members
       
   256     TMemSpyHeapStatisticsRHeapCommon iStatisticsCommon;
   154     TMemSpyHeapStatisticsRHeapFree iStatisticsFree;
   257     TMemSpyHeapStatisticsRHeapFree iStatisticsFree;
   155     TMemSpyHeapStatisticsRHeapAllocated iStatisticsAllocated;
   258     TMemSpyHeapStatisticsRHeapAllocated iStatisticsAllocated;
   156 
       
   157 public: // I am fed up of all these pointless inline accessors...
       
   158 	TInt iCommittedFreeSpace; // The amount of committed memory that isn't payload data in allocated or free cells
       
   159     };
   259     };
   160 
   260 
   161 
   261 
   162 
   262 
   163 
   263 
   173     inline TMemSpyHeapMetaDataRHeap()
   273     inline TMemSpyHeapMetaDataRHeap()
   174         : iChunkSize( 0 ),
   274         : iChunkSize( 0 ),
   175           iChunkHandle( NULL ),
   275           iChunkHandle( NULL ),
   176           iChunkBaseAddress( NULL ),
   276           iChunkBaseAddress( NULL ),
   177           iDebugAllocator( EFalse ),
   277           iDebugAllocator( EFalse ),
   178           //iHeaderSizeFree( 0 ),
   278           iHeaderSizeFree( 0 ),
   179           //iHeaderSizeAllocated( 0 ),
   279           iHeaderSizeAllocated( 0 ),
   180           iIsUserThread( ETrue ),
   280           iIsUserThread( ETrue ),
   181 		  iVTable(0),
   281           iSharedHeap( EFalse )
   182           iSharedHeap( EFalse ),
       
   183           iHeapSize(0),
       
   184           iAllocatorAddress(NULL),
       
   185 		  iMinHeapSize(0),
       
   186 		  iMaxHeapSize(0)
       
   187         {
   282         {
   188         }
   283         }
   189 
   284 
   190 public: // API
   285 public: // API
   191 #ifndef __KERNEL_MODE__
   286 #ifndef __KERNEL_MODE__
   261     inline void SetChunkHandle( TAny* aValue ) { iChunkHandle = aValue; }
   356     inline void SetChunkHandle( TAny* aValue ) { iChunkHandle = aValue; }
   262     //
   357     //
   263     inline TAny* ChunkBaseAddress() const { return iChunkBaseAddress; }
   358     inline TAny* ChunkBaseAddress() const { return iChunkBaseAddress; }
   264     inline void SetChunkBaseAddress( TAny* aValue ) { iChunkBaseAddress = aValue; }
   359     inline void SetChunkBaseAddress( TAny* aValue ) { iChunkBaseAddress = aValue; }
   265     //
   360     //
       
   361     inline TUint HeaderSizeFree() const { return iHeaderSizeFree; }
       
   362     inline void SetHeaderSizeFree( TUint aValue ) { iHeaderSizeFree = aValue; }
       
   363     //
       
   364     inline TUint HeaderSizeAllocated() const { return iHeaderSizeAllocated; }
       
   365     inline void SetHeaderSizeAllocated( TUint aValue ) { iHeaderSizeAllocated = aValue; }
       
   366     //
   266     inline TBool IsDebugAllocator() const { return iDebugAllocator; }
   367     inline TBool IsDebugAllocator() const { return iDebugAllocator; }
   267     inline void SetDebugAllocator( TBool aValue ) { iDebugAllocator = aValue; }
   368     inline void SetDebugAllocator( TBool aValue ) { iDebugAllocator = aValue; }
   268     //
   369     //
   269     inline TBool IsUserThread() const { return iIsUserThread; }
   370     inline TBool IsUserThread() const { return iIsUserThread; }
   270     inline void SetUserThread( TBool aValue ) { iIsUserThread = aValue; }
   371     inline void SetUserThread( TBool aValue ) { iIsUserThread = aValue; }
   272     inline TBool IsSharedHeap() const { return iSharedHeap; }
   373     inline TBool IsSharedHeap() const { return iSharedHeap; }
   273     inline void SetSharedHeap( TBool aValue ) { iSharedHeap = aValue; }
   374     inline void SetSharedHeap( TBool aValue ) { iSharedHeap = aValue; }
   274     //
   375     //
   275     inline TUint VTable() const { return iVTable; }
   376     inline TUint VTable() const { return iVTable; }
   276     inline void SetVTable( TUint aValue ) { iVTable = aValue; }
   377     inline void SetVTable( TUint aValue ) { iVTable = aValue; }
       
   378     //
       
   379     inline TUint ClassSize() const { return iClassSize; }
       
   380     inline void SetClassSize( TUint aValue ) { iClassSize = aValue; }
   277 
   381 
   278 private: // Data members
   382 private: // Data members
   279     TBuf8< KMaxFullName * 2 > iChunkName;
   383     TBuf8< KMaxFullName * 2 > iChunkName;
   280 public:
       
   281     TUint iChunkSize;
   384     TUint iChunkSize;
   282     TAny* iChunkHandle;
   385     TAny* iChunkHandle;
   283     TAny* iChunkBaseAddress;
   386     TAny* iChunkBaseAddress;
   284     TBool iDebugAllocator;
   387     TBool iDebugAllocator;
       
   388     TUint iHeaderSizeFree;
       
   389     TUint iHeaderSizeAllocated;
   285     TBool iSharedHeap;
   390     TBool iSharedHeap;
   286     TBool iIsUserThread;
   391     TBool iIsUserThread;
   287     TUint iVTable;
   392     TUint iVTable;
   288 	TUint iHeapSize; // Committed size - generally the same as iChunkSize (except maybe for kernel heap)
   393     TUint iClassSize;
   289 	TAny* iAllocatorAddress; // replacement for things using the RHeap base address
   394     };
   290 	TUint iMinHeapSize; // Minimum committed size
   395 
   291 	TUint iMaxHeapSize; // Max committed size
   396 
   292     };
   397 
       
   398 
       
   399 
   293 
   400 
   294 
   401 
   295 /**
   402 /**
   296  *
   403  *
   297  */
   404  */
   304 
   411 
   305 public: // API
   412 public: // API
   306     inline TMemSpyHeapMetaDataRHeap& MetaData() { return iMetaData; }
   413     inline TMemSpyHeapMetaDataRHeap& MetaData() { return iMetaData; }
   307     inline const TMemSpyHeapMetaDataRHeap& MetaData() const { return iMetaData; }
   414     inline const TMemSpyHeapMetaDataRHeap& MetaData() const { return iMetaData; }
   308     //
   415     //
   309     //inline TMemSpyHeapObjectDataRHeap& ObjectData() { return iObjectData; }
   416     inline TMemSpyHeapObjectDataRHeap& ObjectData() { return iObjectData; }
   310     //inline const TMemSpyHeapObjectDataRHeap& ObjectData() const { return iObjectData; }
   417     inline const TMemSpyHeapObjectDataRHeap& ObjectData() const { return iObjectData; }
   311     //
   418     //
   312     inline TMemSpyHeapStatisticsRHeap& Statistics() { return iStatistics; }
   419     inline TMemSpyHeapStatisticsRHeap& Statistics() { return iStatistics; }
   313     inline const TMemSpyHeapStatisticsRHeap& Statistics() const { return iStatistics; }
   420     inline const TMemSpyHeapStatisticsRHeap& Statistics() const { return iStatistics; }
   314 
   421 
   315 	inline TInt Overhead() const { return iMetaData.iHeapSize - iStatistics.StatsAllocated().TypeSize() - iStatistics.iCommittedFreeSpace; }
       
   316 
       
   317 private: // Data members
   422 private: // Data members
   318     TMemSpyHeapMetaDataRHeap iMetaData;
   423     TMemSpyHeapMetaDataRHeap iMetaData;
   319     //TMemSpyHeapObjectDataRHeap iObjectData;
   424     TMemSpyHeapObjectDataRHeap iObjectData;
   320     TMemSpyHeapStatisticsRHeap iStatistics;
   425     TMemSpyHeapStatisticsRHeap iStatistics;
   321     };
   426     };
   322 
   427 
   323 
   428 
   324 
   429