perfsrv/memspy/Driver/Kernel/Include/MemSpyDriverHeap.h
changeset 48 516af714ebb4
child 52 c2f44e33b468
equal deleted inserted replaced
45:185201be11b0 48:516af714ebb4
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MEMSPYDRIVERHEAP_H
       
    19 #define MEMSPYDRIVERHEAP_H
       
    20 
       
    21 // System includes
       
    22 #include <e32cmn.h>
       
    23 #include <kern_priv.h>
       
    24 #include <memspy/driver/memspydriverobjectsshared.h>
       
    25 #include <memspy/driver/memspydriverenumerationsshared.h>
       
    26 
       
    27 // User includes
       
    28 #include "MemSpyDriverObjectsInternal.h"
       
    29 
       
    30 // Constants
       
    31 // We shouldn't be using any of these any more! -Tomsci
       
    32 const TUint KRHeapObjectSize = 0x74;
       
    33 const TUint KRAllocatorAndRHeapMemberDataOffset = 4; // 4 bytes past start of allocator address, i.e. skipping the vtable
       
    34 const TUint KRHeapMemberDataSize = KRHeapObjectSize - KRAllocatorAndRHeapMemberDataOffset;
       
    35 
       
    36 // Classes referenced
       
    37 class DMemSpyDriverOSAdaption;
       
    38 namespace LtkUtils
       
    39 	{
       
    40 	class RAllocatorHelper;
       
    41 	}
       
    42 
       
    43 /**
       
    44  * Essentially a mirror of RAllocator and RHeap's layout.
       
    45  */
       
    46 class RMemSpyDriverRHeapBase
       
    47 	{
       
    48 protected:
       
    49     RMemSpyDriverRHeapBase();
       
    50 
       
    51 public: // API
       
    52     void PrintInfo();
       
    53 	LtkUtils::RAllocatorHelper* Helper();
       
    54 	TMemSpyHeapInfo::THeapImplementationType GetTypeFromHelper() const;
       
    55 
       
    56 public: // Virtual API
       
    57     virtual void Reset();
       
    58 	virtual void Close();
       
    59     virtual DChunk& Chunk() = 0;
       
    60     virtual const DChunk& Chunk() const = 0;
       
    61 
       
    62 protected:
       
    63 	LtkUtils::RAllocatorHelper* iHelper;
       
    64     };
       
    65 
       
    66 
       
    67 
       
    68 
       
    69 class RMemSpyDriverRHeapReadFromCopy : public RMemSpyDriverRHeapBase
       
    70 	{
       
    71 protected:
       
    72     RMemSpyDriverRHeapReadFromCopy( DMemSpyDriverOSAdaption& aOSAdaption );
       
    73 
       
    74 public: // New API
       
    75     void AssociateWithKernelChunk( DChunk* aChunk, TLinAddr aAddress, TUint32 aMappingAttributes );
       
    76 
       
    77 public: // From RMemSpyDriverRHeapBase
       
    78     void Reset();
       
    79     DChunk& Chunk();
       
    80     const DChunk& Chunk() const;
       
    81 
       
    82 protected:
       
    83     inline DMemSpyDriverOSAdaption& OSAdaption() { return iOSAdaption; }
       
    84 
       
    85 private:
       
    86     DMemSpyDriverOSAdaption& iOSAdaption;
       
    87 
       
    88     // Copy of the client's heap data
       
    89     DChunk* iChunk;
       
    90     TLinAddr iChunkAddress;
       
    91     TUint32 iChunkMappingAttributes;
       
    92 
       
    93     // Calculated delta between client's address space values and actual kernel
       
    94     // address of the heap chunk.
       
    95     //TUint iClientToKernelDelta;
       
    96     };
       
    97 
       
    98 
       
    99 
       
   100 
       
   101 
       
   102 
       
   103 
       
   104 class RMemSpyDriverRHeapUser : public RMemSpyDriverRHeapBase
       
   105 	{
       
   106 public:
       
   107     RMemSpyDriverRHeapUser( DMemSpyDriverOSAdaption& aOSAdaption );
       
   108 	TInt OpenUserHeap(DThread& aThread, TBool aEuserUdeb);
       
   109 
       
   110 	DChunk& Chunk() { return *iChunk; }
       
   111 	const DChunk& Chunk() const { return *iChunk; }
       
   112 
       
   113 private:
       
   114     inline DMemSpyDriverOSAdaption& OSAdaption() { return iOSAdaption; }
       
   115 
       
   116 private:
       
   117     DMemSpyDriverOSAdaption& iOSAdaption;
       
   118 	DChunk* iChunk;
       
   119     };
       
   120 
       
   121 
       
   122 
       
   123 class RMemSpyDriverRHeapKernelFromCopy : public RMemSpyDriverRHeapReadFromCopy
       
   124     {
       
   125 public:
       
   126     RMemSpyDriverRHeapKernelFromCopy( DMemSpyDriverOSAdaption& aOSAdaption );
       
   127     
       
   128 public: // API
       
   129     void SetKernelHeap( RHeapK& aKernelHeap );
       
   130 
       
   131 public: // From RMemSpyDriverRHeapBase
       
   132     //void DisassociateWithKernelChunk();
       
   133 	void Close();
       
   134 
       
   135 private:
       
   136     RHeapK* iKernelHeap;
       
   137     };
       
   138 
       
   139 
       
   140 
       
   141 class RMemSpyDriverRHeapKernelInPlace : public RMemSpyDriverRHeapBase
       
   142     {
       
   143 public:
       
   144     RMemSpyDriverRHeapKernelInPlace();
       
   145 	TInt OpenKernelHeap();
       
   146     
       
   147 
       
   148 public: // From RMemSpyDriverRHeapBase
       
   149     void Close();
       
   150 
       
   151     DChunk& Chunk();
       
   152     const DChunk& Chunk() const;
       
   153 
       
   154 	// Only important member data is the base class's RAllocatorHelper
       
   155 	// We do cache the chunk though
       
   156 private:
       
   157 	DChunk* iChunk;
       
   158     };
       
   159 
       
   160 	
       
   161 #endif