20
|
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
|
62
|
33 |
DMemoryEventHandler(DProfilerSampleBuffer* aSampleBuffer, TProfilerGppSamplerData* aGppSamplerDataIn);
|
20
|
34 |
TInt Create();
|
|
35 |
~DMemoryEventHandler();
|
|
36 |
TInt Start();
|
|
37 |
TInt Stop();
|
|
38 |
TBool Tracking() {return iTracking;}
|
|
39 |
|
|
40 |
TBool SampleNeeded();
|
62
|
41 |
void SampleHandled();
|
20
|
42 |
|
|
43 |
private:
|
|
44 |
static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis);
|
|
45 |
TUint HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2);
|
|
46 |
// handle chunk activity
|
|
47 |
TBool HandleAddChunk(DChunk* aChunk);
|
|
48 |
TBool HandleUpdateChunk(DChunk* aChunk);
|
|
49 |
TBool HandleDeleteChunk(DChunk* aChunk);
|
|
50 |
// handle chunk activity
|
|
51 |
TBool HandleAddThread(DThread* aThread);
|
|
52 |
TBool HandleUpdateThread(DThread* aThread);
|
|
53 |
TBool HandleDeleteThread(DThread* aThread);
|
|
54 |
// handle chunk activity
|
|
55 |
TBool HandleAddProcess(DProcess* aProcess);
|
|
56 |
TBool HandleUpdateProcess(DProcess* aProcess);
|
|
57 |
TBool HandleDeleteProcess(DProcess* aProcess);
|
|
58 |
// handle library activity
|
|
59 |
TBool HandleAddLibrary(DLibrary* aLibrary, DThread* aThread);
|
|
60 |
TBool HandleDeleteLibrary(DLibrary* aLibrary);
|
|
61 |
|
|
62 |
// data handling
|
|
63 |
TInt AddHeader();
|
|
64 |
TInt AddFooter();
|
|
65 |
TInt EncodeTotalMemory();
|
|
66 |
TInt EncodeNameCode();
|
|
67 |
TInt EncodeNewCode();
|
|
68 |
TInt EncodeUpdateCode();
|
|
69 |
TInt EncodeRemoveCode();
|
|
70 |
TInt EncodeChunkName(DThread& t);
|
|
71 |
TInt EncodeChunkName(DChunk& c);
|
|
72 |
TInt EncodeChunkName(DLibrary& l);
|
|
73 |
TInt EncodeChunkData(DThread& t);
|
|
74 |
TInt EncodeChunkData(DChunk& c);
|
|
75 |
TInt EncodeChunkData(DLibrary& l, DThread& t);
|
|
76 |
private:
|
|
77 |
/** Lock serialising calls to event handler */
|
|
78 |
DMutex* iLock;
|
|
79 |
TBool iTracking;
|
|
80 |
|
|
81 |
DProfilerSampleBuffer* iSampleBuffer;
|
|
82 |
TInt iCounters[EEventLimit];
|
|
83 |
|
62
|
84 |
//TUint32 iCount;
|
20
|
85 |
|
|
86 |
TUint8 iSample[KEventBufferSize];
|
|
87 |
TPtr8 iSampleDescriptor;
|
|
88 |
|
|
89 |
TUint32 iPreviousCount;
|
62
|
90 |
TBool iSampleAvailable;
|
|
91 |
TProfilerGppSamplerData* gppSamplerData;
|
20
|
92 |
};
|
|
93 |
|
|
94 |
#endif
|