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 |
|
|
18 |
|
|
19 |
#ifndef PROFILER_GPP_SAMPLER_H
|
|
20 |
#define PROFILER_GPP_SAMPLER_H
|
|
21 |
|
|
22 |
#include "GeneralsConfig.h"
|
|
23 |
|
|
24 |
#include <e32cmn.h>
|
|
25 |
|
|
26 |
#include <piprofiler/ProfilerGenericClassesKrn.h>
|
|
27 |
#include <piprofiler/ProfilerTraces.h>
|
|
28 |
|
|
29 |
// for RPropertyRef
|
|
30 |
#include <sproperty.h>
|
|
31 |
#include <e32cmn.h>
|
|
32 |
|
|
33 |
/*
|
|
34 |
*
|
|
35 |
* GPP sampler definition
|
|
36 |
*
|
|
37 |
*/
|
|
38 |
class DGppSamplerImpl //: public DBase
|
|
39 |
{
|
|
40 |
public:
|
|
41 |
|
|
42 |
DGppSamplerImpl();
|
|
43 |
~DGppSamplerImpl();
|
|
44 |
|
|
45 |
TUint8* EncodeTag(TUint8* aPtr);
|
|
46 |
TUint8* EncodeInt(TUint8* aPtr,TInt aValue);
|
|
47 |
TUint8* EncodeUint(TUint8* aPtr,TUint aValue);
|
|
48 |
TUint8* EncodeText(TUint8* aPtr, const TDesC& aDes);
|
|
49 |
|
|
50 |
TUint8* EncodeName(TUint8* aPtr, DObject& aObject,TUint32 id);
|
|
51 |
TUint8* EncodeThread(TUint8* aPtr, DThread& aThread);
|
|
52 |
|
|
53 |
TBool IsaTaskKnown(TUint8 task);
|
|
54 |
TUint8* EncodeIsaTask(TUint8* aPtr, TUint task);
|
|
55 |
TUint8* EncodeIsaName(TUint8* aPtr, TUint task,TBool process);
|
|
56 |
|
|
57 |
TUint8* EncodeRepeat(TUint8* aPtr);
|
|
58 |
|
|
59 |
TInt CreateFirstSample();
|
|
60 |
TInt SampleImpl();
|
|
61 |
#ifdef __SMP__
|
|
62 |
TSpinLock* LockPtr();
|
|
63 |
#endif
|
|
64 |
TInt iGppSamplingPeriod;
|
|
65 |
TUint8 tempBuf[512];
|
|
66 |
TUint iLastPc;
|
|
67 |
|
|
68 |
TBool iIsaSample;
|
|
69 |
TInt knownIsaTasks[256];
|
|
70 |
TUint8 knownIsaTaskCount;
|
|
71 |
TInt* isaOsTaskRunningAddr;
|
|
72 |
void Reset();
|
|
73 |
TUint32 iSampleCount;
|
|
74 |
#ifdef __SMP__
|
|
75 |
TInt iCpuNumber;
|
|
76 |
TUint32 iStartTime;
|
|
77 |
#endif
|
|
78 |
PROFILER_DEFINE_ISA_TASK_NAME_ARRAY
|
|
79 |
|
|
80 |
private:
|
|
81 |
enum TState {EStop,ERunning,EStopping};
|
|
82 |
|
|
83 |
const TUint* iInterruptStack;
|
|
84 |
|
|
85 |
TUint iLastThread;
|
|
86 |
TUint iRepeat;
|
|
87 |
#ifndef __SMP__
|
|
88 |
TUint32 iStartTime;
|
|
89 |
#endif
|
|
90 |
RPropertyRef iIsaStartAddr;
|
|
91 |
RPropertyRef iIsaEndAddr;
|
|
92 |
RPropertyRef iIsaPluginStatus;
|
|
93 |
RPropertyRef iIsaOsTaskRunning;
|
|
94 |
TInt iIsaStatus;
|
|
95 |
TInt iIsaStart;
|
|
96 |
TInt iIsaEnd;
|
|
97 |
TUint32 iMask;
|
|
98 |
TUint32 iCpuSelector;
|
62
|
99 |
TInt iPrevTS; // previous sample's timestamp
|
20
|
100 |
};
|
|
101 |
|
|
102 |
struct TProfilerGppSamplerData
|
|
103 |
{
|
|
104 |
//public:
|
|
105 |
TUint32 lastPcValue;
|
|
106 |
TUint32 sampleNumber;
|
|
107 |
TInt samplingPeriod;
|
|
108 |
};
|
|
109 |
|
|
110 |
template <int BufferSize>
|
|
111 |
class DProfilerGppSampler : public DProfilerGenericSampler<BufferSize>
|
|
112 |
{
|
|
113 |
public:
|
|
114 |
#ifndef __SMP__
|
|
115 |
DProfilerGppSampler();
|
|
116 |
#else
|
|
117 |
DProfilerGppSampler(TInt aCpuNumber);
|
|
118 |
#endif
|
|
119 |
~DProfilerGppSampler();
|
|
120 |
|
|
121 |
struct TProfilerGppSamplerData* GetExportData();
|
62
|
122 |
void Sample(TAny* aPtr);
|
20
|
123 |
TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset);
|
|
124 |
TInt GetPeriod();
|
|
125 |
|
|
126 |
private:
|
62
|
127 |
DGppSamplerImpl iGppSamplerImpl;
|
|
128 |
struct TProfilerGppSamplerData iExportData;
|
20
|
129 |
#ifdef __SMP__
|
|
130 |
TInt iCpuNumber;
|
|
131 |
#endif
|
|
132 |
};
|
|
133 |
|
|
134 |
/*
|
|
135 |
*
|
|
136 |
* GPP sampler implementation
|
|
137 |
*
|
|
138 |
*/
|
|
139 |
#ifndef __SMP__
|
|
140 |
template <int BufferSize>
|
|
141 |
DProfilerGppSampler<BufferSize>::DProfilerGppSampler() :
|
|
142 |
DProfilerGenericSampler<BufferSize>(PROFILER_GPP_SAMPLER_ID)
|
|
143 |
{
|
62
|
144 |
LOGSTRING2("DProfilerGppSampler<%d>::CProfilerGppSampler",BufferSize);
|
20
|
145 |
}
|
|
146 |
#else
|
|
147 |
template <int BufferSize>
|
|
148 |
DProfilerGppSampler<BufferSize>::DProfilerGppSampler(TInt aCpuNumber) :
|
|
149 |
DProfilerGenericSampler<BufferSize>(PROFILER_GPP_SAMPLER_ID+(aCpuNumber*20)), iCpuNumber(aCpuNumber)
|
|
150 |
{
|
62
|
151 |
LOGSTRING3("DProfilerGppSampler<%d>::DProfilerGppSampler, cpu %d",BufferSize, iCpuNumber);
|
20
|
152 |
}
|
|
153 |
#endif
|
|
154 |
|
|
155 |
template <int BufferSize>
|
|
156 |
DProfilerGppSampler<BufferSize>::~DProfilerGppSampler()
|
|
157 |
{
|
62
|
158 |
LOGSTRING2("DProfilerGppSampler<%d>::~CProfilerGppSampler",BufferSize);
|
20
|
159 |
}
|
|
160 |
|
|
161 |
template <int BufferSize>
|
|
162 |
TInt DProfilerGppSampler<BufferSize>::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset)
|
|
163 |
{
|
62
|
164 |
LOGSTRING2("DProfilerGppSampler<%d>::Reset - calling superclass reset",BufferSize);
|
20
|
165 |
DProfilerGenericSampler<BufferSize>::Reset(aStream, 0);
|
62
|
166 |
LOGSTRING2("DProfilerGppSampler<%d>::Reset - called superclass reset",BufferSize);
|
20
|
167 |
|
62
|
168 |
iGppSamplerImpl.Reset();
|
20
|
169 |
|
|
170 |
#ifdef __SMP__
|
62
|
171 |
iGppSamplerImpl.iCpuNumber = iCpuNumber;
|
20
|
172 |
|
|
173 |
// set common start time for all CPU samplers
|
62
|
174 |
iGppSamplerImpl.iStartTime = aSyncOffset;
|
20
|
175 |
#endif
|
62
|
176 |
iGppSamplerImpl.iGppSamplingPeriod = DProfilerGenericSampler<BufferSize>::iSamplingPeriod;
|
|
177 |
iGppSamplerImpl.iSampleCount = 0;
|
|
178 |
iExportData.sampleNumber = 0;
|
|
179 |
iExportData.lastPcValue = 0;
|
|
180 |
iExportData.samplingPeriod = iGppSamplerImpl.iGppSamplingPeriod;
|
20
|
181 |
|
62
|
182 |
TInt length = iGppSamplerImpl.CreateFirstSample();
|
|
183 |
|
|
184 |
LOGSTRING3("DProfilerGPPSampler<%d>::Reset - got first sample, size %d",BufferSize,length);
|
20
|
185 |
|
62
|
186 |
//DProfilerGenericSampler<BufferSize>::iSampleBuffer->AddSample(iGppSamplerImpl.tempBuf,length);
|
|
187 |
this->iSampleBuffer->AddSample(iGppSamplerImpl.tempBuf,length);
|
20
|
188 |
|
|
189 |
// check if sampling period > 1 ms
|
|
190 |
// NOTE: feature supported in Performance Investigator 2.01 and above
|
62
|
191 |
if(iGppSamplerImpl.iGppSamplingPeriod > 1)
|
20
|
192 |
{
|
|
193 |
// For Address/Thread (GPP) version 2.01 or above, the first word is the sampling period in milliseconds
|
62
|
194 |
TUint8* w(iGppSamplerImpl.tempBuf);
|
20
|
195 |
|
62
|
196 |
(*w++) = (iGppSamplerImpl.iGppSamplingPeriod >> 24) & 0xFF;
|
|
197 |
(*w++) = (iGppSamplerImpl.iGppSamplingPeriod >> 16) & 0xFF;
|
|
198 |
(*w++) = (iGppSamplerImpl.iGppSamplingPeriod >> 8) & 0xFF;
|
|
199 |
(*w++) = (iGppSamplerImpl.iGppSamplingPeriod) & 0xFF;
|
20
|
200 |
|
62
|
201 |
//DProfilerGenericSampler<BufferSize>::iSampleBuffer->AddSample(iGppSamplerImpl.tempBuf,4);
|
|
202 |
this->iSampleBuffer->AddSample(iGppSamplerImpl.tempBuf,4);
|
20
|
203 |
}
|
|
204 |
|
62
|
205 |
LOGSTRING2("DProfilerGPPSampler<%d>::Reset finished",BufferSize);
|
20
|
206 |
return KErrNone;
|
|
207 |
}
|
|
208 |
|
|
209 |
template <int BufferSize>
|
62
|
210 |
void DProfilerGppSampler<BufferSize>::Sample(TAny* aPtr)
|
20
|
211 |
{
|
62
|
212 |
LOGSTRING2("DProfilerGppSampler<%d>::Sample",BufferSize);
|
|
213 |
|
|
214 |
TInt length(iGppSamplerImpl.SampleImpl());
|
20
|
215 |
|
62
|
216 |
iGppSamplerImpl.iSampleCount++;
|
|
217 |
iExportData.sampleNumber += iGppSamplerImpl.iGppSamplingPeriod;
|
|
218 |
iExportData.lastPcValue = iGppSamplerImpl.iLastPc;
|
20
|
219 |
|
|
220 |
if(length > 0)
|
|
221 |
{
|
62
|
222 |
TInt ret(this->iSampleBuffer->AddSample(iGppSamplerImpl.tempBuf,length));
|
|
223 |
if (ret != 0)
|
|
224 |
{
|
|
225 |
Kern::Printf(("DProfilerGppSampler<%d>::Sample() - add to sample buffer failed, loosing data, error = %d"),BufferSize,ret);
|
|
226 |
}
|
20
|
227 |
}
|
62
|
228 |
LOGSTRING3("DProfilerGppSampler<%d>::Sample - length %d",BufferSize,length);
|
20
|
229 |
return;
|
|
230 |
}
|
|
231 |
|
|
232 |
|
|
233 |
template <int BufferSize>
|
|
234 |
struct TProfilerGppSamplerData* DProfilerGppSampler<BufferSize>::GetExportData()
|
|
235 |
{
|
62
|
236 |
LOGSTRING2("DProfilerGppSampler<%d>::GetExportData",BufferSize);
|
|
237 |
return &(iExportData);
|
20
|
238 |
}
|
|
239 |
|
|
240 |
template <int BufferSize>
|
|
241 |
TInt DProfilerGppSampler<BufferSize>::GetPeriod()
|
|
242 |
{
|
62
|
243 |
return iGppSamplerImpl.iGppSamplingPeriod;
|
20
|
244 |
}
|
|
245 |
|
|
246 |
#endif
|