0
|
1 |
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32utils\profiler\sampler.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#ifndef __SAMPLER_H__
|
|
19 |
#define __SAMPLER_H__
|
|
20 |
|
|
21 |
#include <e32cmn.h>
|
|
22 |
#ifndef __KERNEL_MODE__
|
|
23 |
#include <e32std.h>
|
|
24 |
#endif
|
|
25 |
|
|
26 |
//Uncomment this line to generate debug logging of the profiler and sampler.
|
|
27 |
//#define DEBUG_PROFILER(f) f
|
|
28 |
#define DEBUG_PROFILER(f)
|
|
29 |
|
|
30 |
/**
|
|
31 |
* The user device driver class for controlling the sampler.
|
|
32 |
*/
|
|
33 |
class RSampler : public RBusLogicalChannel
|
|
34 |
{
|
|
35 |
friend class DProfile;
|
|
36 |
private:
|
|
37 |
enum TControl
|
|
38 |
{
|
|
39 |
EControlGetSegments,
|
|
40 |
EControlStartProfile,
|
|
41 |
EControlStopProfile,
|
|
42 |
EControlResetProfile,
|
|
43 |
EControlResetSegments,
|
|
44 |
EControlDrain,
|
|
45 |
EControlGetErrors
|
|
46 |
};
|
|
47 |
enum TRequest
|
|
48 |
{
|
|
49 |
ERequestRead
|
|
50 |
};
|
|
51 |
static inline TInt CancelRequest(TRequest aRequest);
|
|
52 |
public:
|
|
53 |
#ifndef __KERNEL_MODE__
|
|
54 |
/** Open a channel to the sampling device */
|
|
55 |
inline TInt Open();
|
|
56 |
/** Get the current non-XIP Code Segments*/
|
|
57 |
inline void GetSegments(TDes8& aData);
|
|
58 |
/** Start sampling */
|
|
59 |
inline void Start(TInt aRate);
|
|
60 |
/** Stop sampling */
|
|
61 |
inline void Stop();
|
|
62 |
/** Extract the sample data */
|
|
63 |
inline void Read(TDes8& aData,TRequestStatus& aStatus);
|
|
64 |
/** Cancel a read request */
|
|
65 |
inline void ReadCancel();
|
|
66 |
/** Extract any remaining sample data */
|
|
67 |
inline void Drain(TDes8& aData);
|
|
68 |
/** Get error report */
|
|
69 |
inline void GetErrors(TDes8& aData);
|
|
70 |
/** Reset the sampler for a new run */
|
|
71 |
inline void Reset(TBool aXIPOnly);
|
|
72 |
/** Initialise non-XIP segments for a new run */
|
|
73 |
inline void ResetSegments();
|
|
74 |
#endif
|
|
75 |
};
|
|
76 |
|
|
77 |
_LIT(KSamplerName,"Sampler");
|
|
78 |
|
|
79 |
#ifndef __KERNEL_MODE__
|
|
80 |
inline TInt RSampler::CancelRequest(TRequest aRequest)
|
|
81 |
{return 1<<aRequest;}
|
|
82 |
|
|
83 |
inline TInt RSampler::Open()
|
|
84 |
{return DoCreate(KSamplerName,TVersion(1,0,0),KNullUnit,NULL,NULL);}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Get the existing non-XIP Code Segments.
|
|
88 |
*
|
|
89 |
* @param aData A descriptor to receive data. Returns as zero-length if all data
|
|
90 |
* records are already transfered.
|
|
91 |
*/
|
|
92 |
inline void RSampler::GetSegments(TDes8& aData)
|
|
93 |
{DoControl(EControlGetSegments, &aData);}
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Start sampling at the requested rate. If currently sampling, this will just
|
|
97 |
* change the sample rate.
|
|
98 |
*
|
|
99 |
* @param aRate The sample rate in samples/second
|
|
100 |
*/
|
|
101 |
inline void RSampler::Start(TInt aRate)
|
|
102 |
{DoControl(EControlStartProfile, reinterpret_cast<TAny*>(aRate));}
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Stop sampling. If currently sampling, any outstanding read request will be completed
|
|
106 |
* with data remaining in the buffer.
|
|
107 |
*/
|
|
108 |
inline void RSampler::Stop()
|
|
109 |
{DoControl(EControlStopProfile);}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Reset the sampler. All sample data is discarded and history is removed, preparing the
|
|
113 |
* sampler for a new run. The sampler must be stopped before it can be reset.
|
|
114 |
*
|
|
115 |
* @param aXIPOnly True if the profiler runs in XIPOnly mode.
|
|
116 |
*/
|
|
117 |
inline void RSampler::Reset(TBool aXIPOnly)
|
|
118 |
{DoControl(EControlResetProfile,(TAny*)aXIPOnly);}
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Reset non-XIP code segments, preparing the sampler for a new run
|
|
122 |
*/
|
|
123 |
inline void RSampler::ResetSegments()
|
|
124 |
{DoControl(EControlResetSegments);}
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Extract the sample data from the device. This will complete when the device's buffer is
|
|
128 |
* full, when the provided descriptor is full, or when the sampler is stopped.
|
|
129 |
*
|
|
130 |
* @param aData A descriptor to receive the sample data
|
|
131 |
* @param aStatus A request status used to signal when this request is completed
|
|
132 |
*/
|
|
133 |
inline void RSampler::Read(TDes8& aData,TRequestStatus& aStatus)
|
|
134 |
{DoRequest(ERequestRead,aStatus,&aData);}
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Cancel the outstanding read request
|
|
138 |
*/
|
|
139 |
inline void RSampler::ReadCancel()
|
|
140 |
{DoCancel(CancelRequest(ERequestRead));}
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Extract any remaining sample data from the device buffer. When the buffer is
|
|
144 |
* empty, the descriptor will be empty on return.
|
|
145 |
*
|
|
146 |
* @param aData A descriptor to receive the sample data
|
|
147 |
*/
|
|
148 |
inline void RSampler::Drain(TDes8& aData)
|
|
149 |
{DoControl(EControlDrain,&aData);}
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Get error report from the sampler.
|
|
153 |
*
|
|
154 |
* @param aData A descriptor to receive error report
|
|
155 |
*/
|
|
156 |
inline void RSampler::GetErrors(TDes8& aData)
|
|
157 |
{DoControl(EControlGetErrors,&aData);}
|
|
158 |
|
|
159 |
#endif
|
|
160 |
|
|
161 |
#endif
|