Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32utils\profiler\sampler.h
22 #ifndef __KERNEL_MODE__
26 //Uncomment this line to generate debug logging of the profiler and sampler.
27 //#define DEBUG_PROFILER(f) f
28 #define DEBUG_PROFILER(f)
31 * The user device driver class for controlling the sampler.
33 class RSampler : public RBusLogicalChannel
35 friend class DProfile;
43 EControlResetSegments,
51 static inline TInt CancelRequest(TRequest aRequest);
53 #ifndef __KERNEL_MODE__
54 /** Open a channel to the sampling device */
56 /** Get the current non-XIP Code Segments*/
57 inline void GetSegments(TDes8& aData);
59 inline void Start(TInt aRate);
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();
77 _LIT(KSamplerName,"Sampler");
79 #ifndef __KERNEL_MODE__
80 inline TInt RSampler::CancelRequest(TRequest aRequest)
83 inline TInt RSampler::Open()
84 {return DoCreate(KSamplerName,TVersion(1,0,0),KNullUnit,NULL,NULL);}
87 * Get the existing non-XIP Code Segments.
89 * @param aData A descriptor to receive data. Returns as zero-length if all data
90 * records are already transfered.
92 inline void RSampler::GetSegments(TDes8& aData)
93 {DoControl(EControlGetSegments, &aData);}
96 * Start sampling at the requested rate. If currently sampling, this will just
97 * change the sample rate.
99 * @param aRate The sample rate in samples/second
101 inline void RSampler::Start(TInt aRate)
102 {DoControl(EControlStartProfile, reinterpret_cast<TAny*>(aRate));}
105 * Stop sampling. If currently sampling, any outstanding read request will be completed
106 * with data remaining in the buffer.
108 inline void RSampler::Stop()
109 {DoControl(EControlStopProfile);}
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.
115 * @param aXIPOnly True if the profiler runs in XIPOnly mode.
117 inline void RSampler::Reset(TBool aXIPOnly)
118 {DoControl(EControlResetProfile,(TAny*)aXIPOnly);}
121 * Reset non-XIP code segments, preparing the sampler for a new run
123 inline void RSampler::ResetSegments()
124 {DoControl(EControlResetSegments);}
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.
130 * @param aData A descriptor to receive the sample data
131 * @param aStatus A request status used to signal when this request is completed
133 inline void RSampler::Read(TDes8& aData,TRequestStatus& aStatus)
134 {DoRequest(ERequestRead,aStatus,&aData);}
137 * Cancel the outstanding read request
139 inline void RSampler::ReadCancel()
140 {DoCancel(CancelRequest(ERequestRead));}
143 * Extract any remaining sample data from the device buffer. When the buffer is
144 * empty, the descriptor will be empty on return.
146 * @param aData A descriptor to receive the sample data
148 inline void RSampler::Drain(TDes8& aData)
149 {DoControl(EControlDrain,&aData);}
152 * Get error report from the sampler.
154 * @param aData A descriptor to receive error report
156 inline void RSampler::GetErrors(TDes8& aData)
157 {DoControl(EControlGetErrors,&aData);}