|
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 #include "MemSamplerImpl.h" |
|
18 |
|
19 #ifndef __PI_MEMORY_EVENT_HANDLER__ |
|
20 #define __PI_MEMORY_EVENT_HANDLER__ |
|
21 |
|
22 #include <piprofiler/ProfilerGenericClassesKrn.h> |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KEventBufferSize = 257; |
|
26 |
|
27 class DProfilerSampleBuffer; |
|
28 |
|
29 class DMemoryEventHandler : public DKernelEventHandler |
|
30 { |
|
31 public: |
|
32 // constructor |
|
33 DMemoryEventHandler(DProfilerSampleBuffer* aSampleBuffer); |
|
34 TInt Create(); |
|
35 ~DMemoryEventHandler(); |
|
36 TInt Start(); |
|
37 TInt Stop(); |
|
38 TBool Tracking() {return iTracking;} |
|
39 |
|
40 TBool SampleNeeded(); |
|
41 |
|
42 private: |
|
43 static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis); |
|
44 TUint HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2); |
|
45 // handle chunk activity |
|
46 TBool HandleAddChunk(DChunk* aChunk); |
|
47 TBool HandleUpdateChunk(DChunk* aChunk); |
|
48 TBool HandleDeleteChunk(DChunk* aChunk); |
|
49 // handle chunk activity |
|
50 TBool HandleAddThread(DThread* aThread); |
|
51 TBool HandleUpdateThread(DThread* aThread); |
|
52 TBool HandleDeleteThread(DThread* aThread); |
|
53 // handle chunk activity |
|
54 TBool HandleAddProcess(DProcess* aProcess); |
|
55 TBool HandleUpdateProcess(DProcess* aProcess); |
|
56 TBool HandleDeleteProcess(DProcess* aProcess); |
|
57 // handle library activity |
|
58 TBool HandleAddLibrary(DLibrary* aLibrary, DThread* aThread); |
|
59 TBool HandleDeleteLibrary(DLibrary* aLibrary); |
|
60 |
|
61 // data handling |
|
62 TInt AddHeader(); |
|
63 TInt AddFooter(); |
|
64 TInt EncodeTotalMemory(); |
|
65 TInt EncodeNameCode(); |
|
66 TInt EncodeNewCode(); |
|
67 TInt EncodeUpdateCode(); |
|
68 TInt EncodeRemoveCode(); |
|
69 TInt EncodeChunkName(DThread& t); |
|
70 TInt EncodeChunkName(DChunk& c); |
|
71 TInt EncodeChunkName(DLibrary& l); |
|
72 TInt EncodeChunkData(DThread& t); |
|
73 TInt EncodeChunkData(DChunk& c); |
|
74 TInt EncodeChunkData(DLibrary& l, DThread& t); |
|
75 private: |
|
76 /** Lock serialising calls to event handler */ |
|
77 DMutex* iLock; |
|
78 TBool iTracking; |
|
79 |
|
80 DProfilerSampleBuffer* iSampleBuffer; |
|
81 TInt iCounters[EEventLimit]; |
|
82 |
|
83 TUint32 iCount; |
|
84 |
|
85 TUint8 iSample[KEventBufferSize]; |
|
86 TPtr8 iSampleDescriptor; |
|
87 |
|
88 TUint32 iPreviousCount; |
|
89 }; |
|
90 |
|
91 #endif |