|
1 // Copyright (c) 2007-2010 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 "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 // Trace Core |
|
15 // |
|
16 |
|
17 #ifndef __TRACECORE_H__ |
|
18 #define __TRACECORE_H__ |
|
19 |
|
20 |
|
21 // Include files |
|
22 #include <kernel/kernel.h> |
|
23 #include "TraceCoreWriter.h" |
|
24 |
|
25 |
|
26 // Forward declarations |
|
27 class DTraceCoreSendReceive; |
|
28 class DTraceCoreNotifier; |
|
29 class DTraceCoreConfiguration; |
|
30 class DTraceCoreInternalMessageHandler; |
|
31 class DTraceCoreRouter; |
|
32 class DTraceCoreHandler; |
|
33 class DTraceCoreBTraceHandler; |
|
34 class DTraceCorePrintfTraceHandler; |
|
35 class DTraceCoreSettings; |
|
36 class MTraceCoreActivation; |
|
37 |
|
38 |
|
39 /** |
|
40 * TraceCore main class |
|
41 */ |
|
42 NONSHARABLE_CLASS( DTraceCore ) : public DBase |
|
43 { |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Gets the TraceCore instance. |
|
48 * NULL is returned when no instance is created. |
|
49 */ |
|
50 IMPORT_C static DTraceCore* GetInstance(); |
|
51 |
|
52 /** |
|
53 * Returns ETrue if tracecore is loaded already EFalse otherwies |
|
54 */ |
|
55 IMPORT_C static TBool IsLoaded(); |
|
56 |
|
57 /* |
|
58 * Destroy the static instance of tracecore and sets the instance to null |
|
59 */ |
|
60 IMPORT_C static void DestroyTraceCore(); |
|
61 /** |
|
62 * Gets the BTrace handler |
|
63 */ |
|
64 static DTraceCoreBTraceHandler* GetBTraceHandler(); |
|
65 |
|
66 /** |
|
67 * Gets the router |
|
68 */ |
|
69 inline DTraceCoreRouter& GetRouter(); |
|
70 |
|
71 /** |
|
72 * Gets the send-receive interface |
|
73 */ |
|
74 inline DTraceCoreSendReceive& GetSendReceive(); |
|
75 |
|
76 /** |
|
77 * Gets the trace core notifier |
|
78 */ |
|
79 inline DTraceCoreNotifier& GetNotifier(); |
|
80 |
|
81 /** |
|
82 * Registers a handler to TraceCore. |
|
83 * |
|
84 * @param aHandler The handler to be registered |
|
85 */ |
|
86 TInt RegisterHandler( DTraceCoreHandler& aHandler ); |
|
87 |
|
88 /** |
|
89 * Unregisters a handler from TraceCore. |
|
90 * |
|
91 * @param aHandler The handler to be unregistered |
|
92 */ |
|
93 void UnregisterHandler( DTraceCoreHandler& aHandler ); |
|
94 |
|
95 /** |
|
96 * Registers a writer to TraceCore. |
|
97 * |
|
98 * @param aWriter The writer to be registered |
|
99 */ |
|
100 TInt RegisterWriter( DTraceCoreWriter& aWriter ); |
|
101 |
|
102 /** |
|
103 * Unregisters a writer from TraceCore. |
|
104 * |
|
105 * @param aWriter The writer to be unregistered |
|
106 */ |
|
107 void UnregisterWriter( DTraceCoreWriter& aWriter ); |
|
108 |
|
109 /** |
|
110 * Registers a settings saver to TraceCore. |
|
111 * |
|
112 * @param aSettings The settings (saver) to be registered |
|
113 */ |
|
114 TInt RegisterSettings( DTraceCoreSettings& aSettings ); |
|
115 |
|
116 /** |
|
117 * Unregisters a settings saver from TraceCore. |
|
118 * |
|
119 * @param aSettings The Settings to be unregistered |
|
120 */ |
|
121 void UnregisterSettings( DTraceCoreSettings& aSettings ); |
|
122 |
|
123 /** |
|
124 * Registers an activation interface |
|
125 * |
|
126 * @param aActivation The activation interface |
|
127 */ |
|
128 TInt RegisterActivation( MTraceCoreActivation& aActivation ); |
|
129 |
|
130 /** |
|
131 * Gets an activation interface for a specific component ID |
|
132 * |
|
133 * @param aComponentID The component ID |
|
134 * @return The activation interface or NULL if none exist |
|
135 */ |
|
136 MTraceCoreActivation* GetActivation( TUint32 aComponentID ); |
|
137 |
|
138 /** |
|
139 * Starts to use the specific writer |
|
140 * |
|
141 * @return KErrNone if successful, KErrNotSupported if type is not valid |
|
142 */ |
|
143 IMPORT_C TInt SwitchToWriter( TWriterType aWriterType ); |
|
144 |
|
145 /** |
|
146 * Get current writer type |
|
147 * |
|
148 * @return Current writer type |
|
149 */ |
|
150 IMPORT_C TInt GetCurrentWriterType(); |
|
151 |
|
152 |
|
153 /** |
|
154 * Returns pointer to TraceCore owned activation / deactivation TDfcQue object. |
|
155 */ |
|
156 inline TDynamicDfcQue* ActivationQ() { |
|
157 return iActivationQ; |
|
158 } |
|
159 |
|
160 /** |
|
161 * Static method that returns pointer to TraceCore activation / deactivation dfc queue. |
|
162 */ |
|
163 static TDynamicDfcQue* GetActivationQ() { |
|
164 DTraceCore* tCore = DTraceCore::GetInstance(); |
|
165 if(tCore) |
|
166 return tCore->ActivationQ(); |
|
167 else |
|
168 return NULL; |
|
169 } |
|
170 |
|
171 |
|
172 |
|
173 /** |
|
174 * @internalTechnology |
|
175 * Sets the "Trace Dropped" flag |
|
176 * @param aTraceDropped ETrue if Trace Dropped, EFalse Otherwise |
|
177 */ |
|
178 IMPORT_C void SetPreviousTraceDropped(TBool aTraceDropped); |
|
179 |
|
180 /** |
|
181 * @internalTechnology |
|
182 * returns the state of the "Trace Dropped" flag |
|
183 * @param none |
|
184 */ |
|
185 IMPORT_C TBool PreviousTraceDropped() const; |
|
186 |
|
187 /** |
|
188 * @internalTechnology |
|
189 * @return DTraceCore instance or NULL if creation failed. |
|
190 */ |
|
191 IMPORT_C static DTraceCore* CreateInstance(); |
|
192 |
|
193 /** |
|
194 * Reactivate all currently activated traces |
|
195 * @param none |
|
196 * @return KErrNone if refresh successful |
|
197 */ |
|
198 TInt RefreshActivations(); |
|
199 |
|
200 /** |
|
201 * Returns whether or not tracing is certified. |
|
202 * The certification status is checked when TraceCore is initialised and then stored for later use. |
|
203 * This stored value is used throughout the session, even if the status of the certificate changes. |
|
204 * This is done to avoid performance issues when performing the check with every trace outputted. |
|
205 * @param none |
|
206 * @return ETrue if tracing is certified, EFalse otherwise |
|
207 */ |
|
208 inline TBool IsTraceCertified() { return iTraceCertified; }; |
|
209 |
|
210 /** |
|
211 * Get the active writer |
|
212 * @param none |
|
213 * @return a pointer to the current |
|
214 */ |
|
215 IMPORT_C DTraceCoreWriter* GetActiveWriter(); |
|
216 |
|
217 private: |
|
218 |
|
219 /** |
|
220 * Constructor |
|
221 */ |
|
222 DTraceCore(); |
|
223 |
|
224 /** |
|
225 * Destructor |
|
226 */ |
|
227 ~DTraceCore(); |
|
228 |
|
229 /** |
|
230 * Initializes trace core |
|
231 */ |
|
232 TInt Init(); |
|
233 |
|
234 /** |
|
235 * Starts the BTrace handler |
|
236 */ |
|
237 TInt StartBTrace(); |
|
238 |
|
239 /** |
|
240 * Starts the Printf trace handler |
|
241 */ |
|
242 TInt StartPrintfTraceHandler(); |
|
243 |
|
244 /** |
|
245 * Starts to use the first writer from the writers list |
|
246 */ |
|
247 void SwitchToFirstWriter(); |
|
248 |
|
249 /** |
|
250 * Forwards the active writer to handlers |
|
251 */ |
|
252 void SetWriterToHandlers(); |
|
253 |
|
254 private: |
|
255 |
|
256 /** |
|
257 * TraceCore instance |
|
258 */ |
|
259 static DTraceCore* iInstance; |
|
260 |
|
261 /** |
|
262 * List of writers |
|
263 */ |
|
264 RPointerArray< DTraceCoreWriter > iWriters; |
|
265 |
|
266 /** |
|
267 * List of handlers |
|
268 */ |
|
269 RPointerArray< DTraceCoreHandler > iHandlers; |
|
270 |
|
271 /** |
|
272 * List of activation interfaces |
|
273 */ |
|
274 RPointerArray< MTraceCoreActivation > iActivations; |
|
275 |
|
276 /** |
|
277 * Message router |
|
278 */ |
|
279 DTraceCoreRouter* iRouter; |
|
280 |
|
281 /** |
|
282 * Message sender / receiver |
|
283 */ |
|
284 DTraceCoreSendReceive* iSendReceive; |
|
285 |
|
286 /** |
|
287 * Activation notifier |
|
288 */ |
|
289 DTraceCoreNotifier* iNotifier; |
|
290 |
|
291 /** |
|
292 * Configuration |
|
293 */ |
|
294 DTraceCoreConfiguration* iConfiguration; |
|
295 |
|
296 /** |
|
297 * Internal message handler |
|
298 */ |
|
299 DTraceCoreInternalMessageHandler* iInternalMessageHandler; |
|
300 |
|
301 |
|
302 /** |
|
303 * BTrace handler |
|
304 */ |
|
305 DTraceCoreBTraceHandler* iBTrace; |
|
306 |
|
307 /** |
|
308 * Printf trace handler |
|
309 */ |
|
310 DTraceCorePrintfTraceHandler* iPrintf; |
|
311 |
|
312 /** |
|
313 * TraceCore settings |
|
314 */ |
|
315 DTraceCoreSettings* iTraceCoreSettings; |
|
316 |
|
317 /** |
|
318 * Writer that is currently active |
|
319 */ |
|
320 DTraceCoreWriter* iActiveWriter; |
|
321 |
|
322 /** |
|
323 * Activation / Deactivation DFC queue. |
|
324 */ |
|
325 TDynamicDfcQue* iActivationQ; |
|
326 |
|
327 /** |
|
328 * Previous missing trace flag |
|
329 */ |
|
330 TBool iPreviousTraceDropped; |
|
331 |
|
332 /** |
|
333 * Trace certified flag. |
|
334 * The certification status is checked when TraceCore is initialised and then stored in this variable. |
|
335 * This stored value is used throughout the session, even if the status of the certificate changes. |
|
336 * This is done to avoid performance issues when performing the check with every trace outputted. |
|
337 */ |
|
338 TBool iTraceCertified; |
|
339 |
|
340 }; |
|
341 |
|
342 #endif |
|
343 |
|
344 #include "TraceCore.inl" |
|
345 |
|
346 // End of File |