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 MEMSPYDRIVERHEAPWALKER_H |
|
19 #define MEMSPYDRIVERHEAPWALKER_H |
|
20 |
|
21 // System includes |
|
22 #include <e32cmn.h> |
|
23 #include <kern_priv.h> |
|
24 |
|
25 // Shared includes |
|
26 #include <memspy/driver/memspydriverenumerationsshared.h> |
|
27 |
|
28 // User includes |
|
29 #include "MemSpyDriverHeap.h" |
|
30 #include "MemSpyDriverHeapStatistics.h" |
|
31 |
|
32 #include "heaputils.h" |
|
33 using namespace LtkUtils; |
|
34 |
|
35 // Heap walker observer interface - can be used to make a record of each cell |
|
36 class MMemSpyHeapWalkerObserver |
|
37 { |
|
38 public: |
|
39 virtual TBool HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber) = 0; |
|
40 virtual void HandleHeapWalkInit() = 0; |
|
41 }; |
|
42 |
|
43 |
|
44 // Heap walker - allows in-place walking of any heap |
|
45 class RMemSpyDriverHeapWalker |
|
46 { |
|
47 public: |
|
48 RMemSpyDriverHeapWalker(RMemSpyDriverRHeapBase& aHeap, MMemSpyHeapWalkerObserver* aObserver=NULL); |
|
49 |
|
50 public: // API |
|
51 TInt Traverse(); |
|
52 void CopyStatsTo( TMemSpyHeapStatisticsRHeap& aStats ); |
|
53 void SetObserver( MMemSpyHeapWalkerObserver* aObserver ); |
|
54 inline void SetPrintDebug() { iPrintDebug = ETrue; } |
|
55 inline const TMemSpyHeapWalkStatistics& Stats() const { return iStats; } |
|
56 |
|
57 private: // Internal methods |
|
58 static TBool CellCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength); |
|
59 TBool DoCellCallback(RAllocatorHelper& aHelper, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength); |
|
60 TBool NotifyCell( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel = -1, TInt aAllocNumber = -1 ); |
|
61 // |
|
62 void UpdateStats( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber ); |
|
63 void InitialiseStats(); |
|
64 void FinaliseStats(); |
|
65 void PrintStats(); |
|
66 // |
|
67 inline TBool PrintDebug() const { return iPrintDebug; } |
|
68 |
|
69 private: |
|
70 RMemSpyDriverRHeapBase& iHeap; |
|
71 TBool iPrintDebug; |
|
72 MMemSpyHeapWalkerObserver* iObserver; |
|
73 TMemSpyHeapWalkStatistics iStats; |
|
74 }; |
|
75 |
|
76 |
|
77 |
|
78 #endif |
|