|
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: tracing functionality for video collection |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef VIDEOCOLLETIONTRACE_H |
|
19 #define VIDEOCOLLETIONTRACE_H |
|
20 |
|
21 #include "xqaiwrequeststub.h" |
|
22 #include "xqappmgrstub.h" |
|
23 #include "apaidstub.h" |
|
24 #include "apgclistub.h" |
|
25 #include "coemainstub.h" |
|
26 #include "apgtaskstub.h" |
|
27 |
|
28 /** |
|
29 * Set 1 to enable tracing in urel builds. Default is 0. |
|
30 */ |
|
31 #define UREL_TRACE 0 |
|
32 |
|
33 /** |
|
34 * Set to 1 to disable tracing. Default is 0. |
|
35 */ |
|
36 #define DISABLE_TRACE 0 |
|
37 |
|
38 /** |
|
39 * 0 = Tracing into RDebug in all builds. (Default) |
|
40 * 1 = Tracing into RDebug in winscw, file in ARM. |
|
41 * 2 = Tracing into file in all builds. |
|
42 */ |
|
43 #define TRACE_OUTPUT 0 |
|
44 |
|
45 //----------------------------------------------------------------------------- |
|
46 // Trace configuration |
|
47 //----------------------------------------------------------------------------- |
|
48 // |
|
49 #if ( (defined(_DEBUG) || UREL_TRACE == 1) && DISABLE_TRACE == 0 ) |
|
50 |
|
51 // Error trace |
|
52 #define ERROR_TRACE |
|
53 |
|
54 // Function trace |
|
55 #define FUNC_TRACE |
|
56 |
|
57 // Info trace |
|
58 #define INFO_TRACE |
|
59 |
|
60 // Timestamp trace |
|
61 #define TIMESTAMP_TRACE |
|
62 |
|
63 // Tracing current client process and thread |
|
64 #define CLIENT_TRACE |
|
65 |
|
66 // Enable tracing into file. |
|
67 #if ((TRACE_OUTPUT == 1 && !defined(__WINSCW__)) || TRACE_OUTPUT == 2) |
|
68 #define TRACE_INTO_FILE |
|
69 #endif |
|
70 |
|
71 #else // TRACING DISABLED |
|
72 |
|
73 #undef ERROR_TRACE |
|
74 #undef INFO_TRACE |
|
75 #undef TIMESTAMP_TRACE |
|
76 #undef FUNC_TRACE |
|
77 #undef CLIENT_TRACE |
|
78 #undef TRACE_INTO_FILE |
|
79 |
|
80 #endif // TRACING ENABLED |
|
81 |
|
82 //----------------------------------------------------------------------------- |
|
83 // INCLUDES |
|
84 //----------------------------------------------------------------------------- |
|
85 // |
|
86 #include <qstring.h> |
|
87 #include <e32debug.h> // RDebug |
|
88 |
|
89 #if defined TRACE_INTO_FILE |
|
90 #include <flogger.h> // RFileLogger |
|
91 #endif |
|
92 |
|
93 //----------------------------------------------------------------------------- |
|
94 // Constants |
|
95 //----------------------------------------------------------------------------- |
|
96 // |
|
97 /** |
|
98 * Trace prefixes for macros with component name. |
|
99 */ |
|
100 #define _PREFIX_TRACE( a ) TPtrC( (const TText*) L"#Fu#Co# " L##a ) |
|
101 #define _PREFIX_TRACE_2( a, b ) TPtrC( (const TText*) L"#Fu#Co# " L##a L##b ) |
|
102 #define _PREFIX_TRACE8( a ) (const char*)( "#Fu#Co# " a ) |
|
103 |
|
104 /** |
|
105 * Prefix error trace |
|
106 */ |
|
107 #define _PREFIX_ERROR( aMsg ) _PREFIX_TRACE( "[ERROR: %d]: " L##aMsg ) |
|
108 |
|
109 /** |
|
110 * Define needed if TRACE_INTO_FILE macro in use |
|
111 */ |
|
112 #ifdef TRACE_INTO_FILE |
|
113 _LIT( KTracePath, "Fusion" ); |
|
114 _LIT( KTraceFile, "videos.log" ); |
|
115 #endif |
|
116 |
|
117 //----------------------------------------------------------------------------- |
|
118 // Error trace macros |
|
119 //----------------------------------------------------------------------------- |
|
120 // |
|
121 #ifdef ERROR_TRACE |
|
122 |
|
123 /** |
|
124 * Error trace definitions. |
|
125 */ |
|
126 #ifdef TRACE_INTO_FILE |
|
127 |
|
128 #define ERROR( aErr, aMsg )\ |
|
129 {\ |
|
130 if( aErr < KErrNone )\ |
|
131 {\ |
|
132 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
133 EFileLoggingModeAppend,\ |
|
134 _PREFIX_ERROR( aMsg ), aErr );\ |
|
135 }\ |
|
136 } |
|
137 #define ERROR_1( aErr, aMsg, aP1 )\ |
|
138 {\ |
|
139 if( aErr < KErrNone )\ |
|
140 {\ |
|
141 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
142 EFileLoggingModeAppend,\ |
|
143 _PREFIX_ERROR( aMsg ), aErr, aP1 );\ |
|
144 }\ |
|
145 } |
|
146 #define ERROR_2( aErr, aMsg, aP1, aP2 )\ |
|
147 {\ |
|
148 if( aErr < KErrNone )\ |
|
149 {\ |
|
150 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
151 EFileLoggingModeAppend,\ |
|
152 _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ |
|
153 }\ |
|
154 } |
|
155 #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ |
|
156 {\ |
|
157 if( aErr < KErrNone )\ |
|
158 {\ |
|
159 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
160 EFileLoggingModeAppend,\ |
|
161 _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ |
|
162 }\ |
|
163 } |
|
164 |
|
165 #else//TRACE_INTO_FILE not defined |
|
166 |
|
167 #define ERROR( aErr, aMsg )\ |
|
168 {\ |
|
169 if( aErr < KErrNone )\ |
|
170 {\ |
|
171 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\ |
|
172 }\ |
|
173 } |
|
174 #define ERROR_1( aErr, aMsg, aP1 )\ |
|
175 {\ |
|
176 if( aErr < KErrNone )\ |
|
177 {\ |
|
178 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\ |
|
179 }\ |
|
180 } |
|
181 #define ERROR_2( aErr, aMsg, aP1, aP2 )\ |
|
182 {\ |
|
183 if( aErr < KErrNone )\ |
|
184 {\ |
|
185 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ |
|
186 }\ |
|
187 } |
|
188 #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ |
|
189 {\ |
|
190 if( aErr < KErrNone )\ |
|
191 {\ |
|
192 RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ |
|
193 }\ |
|
194 } |
|
195 |
|
196 #endif//TRACE_INTO_FILE |
|
197 |
|
198 #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg ) |
|
199 #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 ) |
|
200 #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 ) |
|
201 #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 ) |
|
202 |
|
203 #define ERROR_PARAM(_p) _p |
|
204 |
|
205 #define TRAPD_ERR( aErr, aStmt ) TRAPD( aErr, aStmt ) |
|
206 #define TRAP_ERR( aErr, aStmt ) TRAP( aErr, aStmt ) |
|
207 |
|
208 #define TRAP_AND_LEAVE(_s,_t) \ |
|
209 { TRAPD(_e,_s); ERROR(_e,_t); User::LeaveIfError(_e); } |
|
210 |
|
211 #else//ERROR_TRACE not defined |
|
212 |
|
213 #define ERROR( aErr, aMsg ) |
|
214 #define ERROR_1( aErr, aMsg, aP1 ) |
|
215 #define ERROR_2( aErr, aMsg, aP1, aP2 ) |
|
216 #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 ) |
|
217 #define ERROR_GEN( aMsg ) |
|
218 #define ERROR_GEN_1( aMsg, aP1 ) |
|
219 #define ERROR_GEN_2( aMsg, aP1, aP2 ) |
|
220 #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) |
|
221 |
|
222 #define ERROR_PARAM(_p) |
|
223 |
|
224 #define TRAPD_ERR( aErr, aStmt ) TRAP_IGNORE( aStmt ) |
|
225 #define TRAP_ERR( aErr, aStmt ) TRAP_IGNORE( aStmt ) |
|
226 |
|
227 #define TRAP_AND_LEAVE(_s,_t) { _s; } |
|
228 |
|
229 #endif//ERROR_TRACE |
|
230 |
|
231 //----------------------------------------------------------------------------- |
|
232 // Info trace macros |
|
233 //----------------------------------------------------------------------------- |
|
234 // |
|
235 #ifdef INFO_TRACE |
|
236 |
|
237 /** |
|
238 * Info log message definitions. |
|
239 */ |
|
240 #ifdef TRACE_INTO_FILE |
|
241 |
|
242 #define INFO( aMsg )\ |
|
243 {\ |
|
244 RFileLogger::Write( KTracePath, KTraceFile,\ |
|
245 EFileLoggingModeAppend,\ |
|
246 _PREFIX_TRACE( aMsg ) );\ |
|
247 } |
|
248 #define INFO_1( aMsg, aP1 )\ |
|
249 {\ |
|
250 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
251 EFileLoggingModeAppend,\ |
|
252 _PREFIX_TRACE( aMsg ), aP1 );\ |
|
253 } |
|
254 #define INFO_2( aMsg, aP1, aP2 )\ |
|
255 {\ |
|
256 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
257 EFileLoggingModeAppend,\ |
|
258 _PREFIX_TRACE( aMsg ), aP1, aP2 );\ |
|
259 } |
|
260 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
|
261 {\ |
|
262 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
263 EFileLoggingModeAppend,\ |
|
264 _PREFIX_TRACE( aMsg ), aP1, aP2, aP3 );\ |
|
265 } |
|
266 #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\ |
|
267 {\ |
|
268 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
269 EFileLoggingModeAppend,\ |
|
270 _PREFIX_TRACE( aMsg ), aP1, aP2, aP3, aP4 );\ |
|
271 } |
|
272 #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ |
|
273 {\ |
|
274 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
275 EFileLoggingModeAppend,\ |
|
276 _PREFIX_TRACE( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ |
|
277 } |
|
278 #define INFOQSTR_1( aMsg, aQStr )\ |
|
279 {\ |
|
280 TPtrC _qstringptrc(aQStr.utf16()); \ |
|
281 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
282 EFileLoggingModeAppend,\ |
|
283 _PREFIX_TRACE( aMsg ), &_qstringptrc );\ |
|
284 } |
|
285 #define INFOQSTR_2( aMsg, aQStr1, aQStr2 )\ |
|
286 {\ |
|
287 TPtrC _qstringptrc1(aQStr1.utf16()); \ |
|
288 TPtrC _qstringptrc2(aQStr2.utf16()); \ |
|
289 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
290 EFileLoggingModeAppend,\ |
|
291 _PREFIX_TRACE( aMsg ), &_qstringptrc1, &_qstringptrc2 );\ |
|
292 } |
|
293 |
|
294 #else//TRACE_INTO_FILE not defined |
|
295 |
|
296 #define INFO( aMsg )\ |
|
297 {\ |
|
298 RDebug::Print( _PREFIX_TRACE( aMsg ) );\ |
|
299 } |
|
300 #define INFO_1( aMsg, aP1 )\ |
|
301 {\ |
|
302 RDebug::Print( _PREFIX_TRACE( aMsg ), aP1 );\ |
|
303 } |
|
304 #define INFO_2( aMsg, aP1, aP2 )\ |
|
305 {\ |
|
306 RDebug::Print( _PREFIX_TRACE( aMsg ), aP1, aP2 );\ |
|
307 } |
|
308 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
|
309 {\ |
|
310 RDebug::Print( _PREFIX_TRACE( aMsg ), aP1, aP2, aP3 );\ |
|
311 } |
|
312 #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\ |
|
313 {\ |
|
314 RDebug::Print( _PREFIX_TRACE( aMsg ), aP1, aP2, aP3, aP4 );\ |
|
315 } |
|
316 #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ |
|
317 {\ |
|
318 RDebug::Print( _PREFIX_TRACE( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ |
|
319 } |
|
320 |
|
321 #define INFOQSTR_1( aMsg, aQStr )\ |
|
322 {\ |
|
323 TPtrC _qstringptrc(aQStr.utf16()); \ |
|
324 RDebug::Print( _PREFIX_TRACE( aMsg ), &_qstringptrc );\ |
|
325 } |
|
326 |
|
327 #define INFOQSTR_2( aMsg, aQStr1, aQStr2 )\ |
|
328 {\ |
|
329 TPtrC _qstringptrc1(aQStr1.utf16()); \ |
|
330 TPtrC _qstringptrc2(aQStr2.utf16()); \ |
|
331 RDebug::Print( _PREFIX_TRACE( aMsg ), &_qstringptrc1, &_qstringptrc2 );\ |
|
332 } |
|
333 |
|
334 #endif//TRACE_INTO_FILE |
|
335 |
|
336 #define INFO_PARAM( aParam ) aParam |
|
337 |
|
338 #else//INFO_TRACE not defined |
|
339 |
|
340 #define INFO( aMsg ) |
|
341 #define INFO_1( aMsg, aP1 ) |
|
342 #define INFO_2( aMsg, aP1, aP2 ) |
|
343 #define INFO_3( aMsg, aP1, aP2, aP3 ) |
|
344 #define INFO_4( aMsg, aP1, aP2, aP3, aP4 ) |
|
345 #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) |
|
346 #define INFO_PARAM( aParam ) |
|
347 #define INFOQSTR_1( aMsg, aP1 ); |
|
348 #define INFOQSTR_2( aMsg, aP1, aP2 ); |
|
349 |
|
350 #endif//INFO_TRACE |
|
351 |
|
352 //----------------------------------------------------------------------------- |
|
353 // Trace current client thread name and process id |
|
354 //----------------------------------------------------------------------------- |
|
355 // |
|
356 #ifdef CLIENT_TRACE |
|
357 |
|
358 #define _PREFIX_CLIENT( aMsg ) _PREFIX_TRACE( "[CLIENT: sid [0x%x] thread [%S]] " L##aMsg ) |
|
359 |
|
360 #ifdef TRACE_INTO_FILE |
|
361 |
|
362 #define CLIENT_TRACE_2( aMsg, aP1, aP2 )\ |
|
363 {\ |
|
364 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
365 EFileLoggingModeAppend, _PREFIX_CLIENT(aMsg), aP1, aP2 );\ |
|
366 } |
|
367 |
|
368 #else//TRACE_INTO_FILE not defined |
|
369 |
|
370 #define CLIENT_TRACE_2( aMsg, aP1, aP2 )\ |
|
371 {\ |
|
372 RDebug::Print( _PREFIX_CLIENT(aMsg), aP1, aP2 );\ |
|
373 } |
|
374 |
|
375 #endif//TRACE_INTO_FILE |
|
376 |
|
377 /** |
|
378 * Traces current secure id and thread |
|
379 */ |
|
380 #define CURRENT_CLIENT( aMsg )\ |
|
381 {\ |
|
382 TName name( RThread().Name() );\ |
|
383 TSecureId sid( RThread().SecureId() );\ |
|
384 CLIENT_TRACE_2( aMsg, sid.iId, &name );\ |
|
385 } |
|
386 |
|
387 /** |
|
388 * Traces secure id and thread from RMessage2 |
|
389 */ |
|
390 #define CLIENT( aRMessage2 )\ |
|
391 {\ |
|
392 RThread thread;\ |
|
393 TInt err = aRMessage2.Client( thread );\ |
|
394 if( err == KErrNone )\ |
|
395 {\ |
|
396 TName name( thread.Name() );\ |
|
397 TSecureId sid( thread.SecureId() );\ |
|
398 CLIENT_TRACE_2( "", sid.iId, &name );\ |
|
399 }\ |
|
400 thread.Close();\ |
|
401 } |
|
402 |
|
403 /** |
|
404 * Traces secure id and thread from RMessage2 |
|
405 */ |
|
406 #define CLIENT_1( aRMessage2, aMsg )\ |
|
407 {\ |
|
408 RThread thread;\ |
|
409 TInt err = aRMessage2.Client( thread );\ |
|
410 if( err == KErrNone )\ |
|
411 {\ |
|
412 TName name( thread.Name() );\ |
|
413 TSecureId sid( thread.SecureId() );\ |
|
414 CLIENT_TRACE_2( aMsg, sid.iId, &name );\ |
|
415 }\ |
|
416 thread.Close();\ |
|
417 } |
|
418 |
|
419 #else |
|
420 |
|
421 #define CURRENT_CLIENT( aMsg ) |
|
422 #define CLIENT( aRMessage2 ) |
|
423 #define CLIENT_1( aRMessage2, aMsg ) |
|
424 |
|
425 #endif |
|
426 |
|
427 //----------------------------------------------------------------------------- |
|
428 // Trace current heap usage |
|
429 //----------------------------------------------------------------------------- |
|
430 // |
|
431 #ifdef HEAP_TRACE |
|
432 |
|
433 #define _PREFIX_HEAP( aMsg ) _PREFIX_TRACE( "[HEAP: %d bytes] " L##aMsg ) |
|
434 |
|
435 #ifdef TRACE_INTO_FILE |
|
436 |
|
437 #define HEAP( aMsg )\ |
|
438 {\ |
|
439 TInt totalAllocSpace = 0;\ |
|
440 User::AllocSize( totalAllocSpace );\ |
|
441 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
442 EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace );\ |
|
443 } |
|
444 #define HEAP_1( aMsg, aP1 )\ |
|
445 {\ |
|
446 TInt totalAllocSpace = 0;\ |
|
447 User::AllocSize( totalAllocSpace );\ |
|
448 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
449 EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\ |
|
450 } |
|
451 #define HEAP_2( aMsg, aP1, aP2 )\ |
|
452 {\ |
|
453 TInt totalAllocSpace = 0;\ |
|
454 User::AllocSize( totalAllocSpace );\ |
|
455 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
456 EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\ |
|
457 } |
|
458 #define HEAP_3( aMsg, aP1, aP2, aP3 )\ |
|
459 {\ |
|
460 TInt totalAllocSpace = 0;\ |
|
461 User::AllocSize( totalAllocSpace );\ |
|
462 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
463 EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\ |
|
464 } |
|
465 #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\ |
|
466 {\ |
|
467 TInt totalAllocSpace = 0;\ |
|
468 User::AllocSize( totalAllocSpace );\ |
|
469 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
470 EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\ |
|
471 } |
|
472 |
|
473 #else//TRACE_INTO_FILE not defined |
|
474 |
|
475 #define HEAP( aMsg )\ |
|
476 {\ |
|
477 TInt totalAllocSpace = 0;\ |
|
478 User::AllocSize( totalAllocSpace );\ |
|
479 RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace );\ |
|
480 } |
|
481 #define HEAP_1( aMsg, aP1 )\ |
|
482 {\ |
|
483 TInt totalAllocSpace = 0;\ |
|
484 User::AllocSize( totalAllocSpace );\ |
|
485 RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\ |
|
486 } |
|
487 #define HEAP_2( aMsg, aP1, aP2 )\ |
|
488 {\ |
|
489 TInt totalAllocSpace = 0;\ |
|
490 User::AllocSize( totalAllocSpace );\ |
|
491 RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\ |
|
492 } |
|
493 #define HEAP_3( aMsg, aP1, aP2, aP3 )\ |
|
494 {\ |
|
495 TInt totalAllocSpace = 0;\ |
|
496 User::AllocSize( totalAllocSpace );\ |
|
497 RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\ |
|
498 } |
|
499 #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\ |
|
500 {\ |
|
501 TInt totalAllocSpace = 0;\ |
|
502 User::AllocSize( totalAllocSpace );\ |
|
503 RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\ |
|
504 } |
|
505 |
|
506 #endif//TRACE_INTO_FILE |
|
507 |
|
508 #else//HEAP_TRACE not defined |
|
509 |
|
510 #define HEAP( aMsg ) |
|
511 #define HEAP_1( aMsg, aP1 ) |
|
512 #define HEAP_2( aMsg, aP1, aP2 ) |
|
513 #define HEAP_3( aMsg, aP1, aP2, aP3 ) |
|
514 #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 ) |
|
515 |
|
516 #endif//HEAP_TRACE |
|
517 |
|
518 |
|
519 //----------------------------------------------------------------------------- |
|
520 // Function trace macros |
|
521 //----------------------------------------------------------------------------- |
|
522 // |
|
523 #ifdef FUNC_TRACE |
|
524 |
|
525 #include <e32base.h> // TCleanupItem |
|
526 |
|
527 /** |
|
528 * Function logging definitions. |
|
529 */ |
|
530 #ifdef TRACE_INTO_FILE |
|
531 |
|
532 #define FUNC( aMsg, aP1 )\ |
|
533 {\ |
|
534 TPtrC8 trace( _S8( aMsg ) );\ |
|
535 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
536 EFileLoggingModeAppend, trace, aP1 );\ |
|
537 } |
|
538 |
|
539 #define FUNC2( aMsg, aP1, aP2 )\ |
|
540 {\ |
|
541 TPtrC8 trace( _S8( aMsg ) );\ |
|
542 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
543 EFileLoggingModeAppend, trace, aP1, aP2 );\ |
|
544 } |
|
545 |
|
546 #define FUNC_2( aMsg, aP1, aP2, aP3 )\ |
|
547 {\ |
|
548 TPtrC8 trace( _S8( aMsg ) );\ |
|
549 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
550 EFileLoggingModeAppend, trace, aP1, aP2, aP3 );\ |
|
551 } |
|
552 |
|
553 #else//TRACE_INTO_FILE not defined |
|
554 |
|
555 #define FUNC( aMsg, aP1 )\ |
|
556 {\ |
|
557 RDebug::Printf( aMsg, aP1 );\ |
|
558 } |
|
559 |
|
560 #define FUNC2( aMsg, aP1, aP2 )\ |
|
561 {\ |
|
562 RDebug::Printf( aMsg, aP1, aP2 );\ |
|
563 } |
|
564 |
|
565 #define FUNC_2( aMsg, aP1, aP2, aP3 )\ |
|
566 {\ |
|
567 RDebug::Printf( aMsg, aP1, aP2, aP3 );\ |
|
568 } |
|
569 |
|
570 #endif//TRACE_INTO_FILE |
|
571 |
|
572 /** |
|
573 * Function trace helper class. |
|
574 */ |
|
575 const TText KFuncNameTerminator = '('; |
|
576 const TText KFuncLeaveIndicator = 'L'; |
|
577 const TInt KFuncCanLeave = 0x1; |
|
578 const TInt KFuncLeft = 0x2; |
|
579 const TInt KFuncLogClient = 0x4; |
|
580 |
|
581 class TFuncLog |
|
582 { |
|
583 public: |
|
584 static void Cleanup( TAny* aPtr ) |
|
585 { |
|
586 TFuncLog* self = static_cast< TFuncLog* >( aPtr ); |
|
587 self->iFlags |= KFuncLeft; |
|
588 self->LogLeave(); |
|
589 } |
|
590 |
|
591 inline void LogStart() |
|
592 { |
|
593 if ( iFlags & KFuncLogClient ) |
|
594 { |
|
595 TBuf8<KMaxName> name8; |
|
596 name8.Copy( RThread().Name() ); |
|
597 TSecureId sid( RThread().SecureId() ); |
|
598 FUNC_2( _PREFIX_TRACE8("%S() -> ENTER(sid [0x%x] thread [%S])"), |
|
599 &iFunc, sid.iId, &name8 ); |
|
600 } |
|
601 else |
|
602 { |
|
603 if(!iAddr) |
|
604 { |
|
605 FUNC( _PREFIX_TRACE8("%S() -> ENTER"), &iFunc ); |
|
606 } |
|
607 else |
|
608 { |
|
609 FUNC2( _PREFIX_TRACE8("%S() [0x%x] -> ENTER"), &iFunc, iAddr ); |
|
610 } |
|
611 } |
|
612 } |
|
613 |
|
614 inline void LogLeave() |
|
615 { |
|
616 if ( iFlags & KFuncLogClient ) |
|
617 { |
|
618 TBuf8<KMaxName> name8; |
|
619 name8.Copy( RThread().Name() ); |
|
620 TSecureId sid( RThread().SecureId() ); |
|
621 FUNC_2( _PREFIX_TRACE8("%S() - LEAVE(sid [0x%x] thread [%S])"), |
|
622 &iFunc, sid.iId, &name8 ); |
|
623 } |
|
624 else |
|
625 { |
|
626 if(!iAddr) |
|
627 { |
|
628 FUNC( _PREFIX_TRACE8("%S() - LEAVE"), &iFunc ); |
|
629 } |
|
630 else |
|
631 { |
|
632 FUNC2( _PREFIX_TRACE8("%S() [0x%x] - LEAVE"), &iFunc, iAddr ); |
|
633 } |
|
634 } |
|
635 } |
|
636 |
|
637 inline void LogEnd() |
|
638 { |
|
639 if ( iFlags & KFuncLogClient ) |
|
640 { |
|
641 TBuf8<KMaxName> name8; |
|
642 name8.Copy( RThread().Name() ); |
|
643 TSecureId sid( RThread().SecureId() ); |
|
644 FUNC_2( _PREFIX_TRACE8("%S() <- OUT(sid [0x%x] thread [%S])"), |
|
645 &iFunc, sid.iId, &name8 ); |
|
646 } |
|
647 else |
|
648 { |
|
649 if(!iAddr) |
|
650 { |
|
651 FUNC( _PREFIX_TRACE8("%S() <- OUT"), &iFunc ); |
|
652 } |
|
653 else |
|
654 { |
|
655 FUNC2( _PREFIX_TRACE8("%S() [0x%x] <- OUT"), &iFunc, iAddr ); |
|
656 } |
|
657 } |
|
658 } |
|
659 |
|
660 // For non leaving and L methods |
|
661 inline TFuncLog( const char* aFunc, TUint aFlags ) : |
|
662 iAddr(0), iFunc( aFunc ? _S8( aFunc ) : _S8("") ), |
|
663 iFlags( aFlags ), |
|
664 iCleanupItem( Cleanup, this ), |
|
665 iLCPtr( NULL ) |
|
666 { |
|
667 TInt pos( iFunc.Locate( KFuncNameTerminator ) ); |
|
668 if( pos >= 0 && pos < iFunc.Length() ) |
|
669 { |
|
670 iFunc.Set( iFunc.Left( pos ) ); |
|
671 TInt len( iFunc.Length() ); |
|
672 if( len > 0 && iFunc[ len - 1 ] == KFuncLeaveIndicator ) |
|
673 { |
|
674 iFlags |= KFuncCanLeave; |
|
675 CleanupStack::PushL( iCleanupItem ); // Ignore warnings |
|
676 } |
|
677 } |
|
678 LogStart(); |
|
679 } |
|
680 |
|
681 // For non leaving and L methods |
|
682 inline TFuncLog( TUint aAddr, const char* aFunc, TUint aFlags ) : |
|
683 iAddr(aAddr), iFunc( aFunc ? _S8( aFunc ) : _S8("") ), |
|
684 iFlags( aFlags ), |
|
685 iCleanupItem( Cleanup, this ), |
|
686 iLCPtr( NULL ) |
|
687 { |
|
688 TInt pos( iFunc.Locate( KFuncNameTerminator ) ); |
|
689 if( pos >= 0 && pos < iFunc.Length() ) |
|
690 { |
|
691 iFunc.Set( iFunc.Left( pos ) ); |
|
692 TInt len( iFunc.Length() ); |
|
693 if( len > 0 && iFunc[ len - 1 ] == KFuncLeaveIndicator ) |
|
694 { |
|
695 iFlags |= KFuncCanLeave; |
|
696 CleanupStack::PushL( iCleanupItem ); // Ignore warnings |
|
697 } |
|
698 } |
|
699 LogStart(); |
|
700 } |
|
701 |
|
702 // For LC methods only |
|
703 inline TFuncLog( const char* aFunc, TUint aFlags, TAny** aLCPtr ) : |
|
704 iAddr(0), iFunc( aFunc ? _S8( aFunc ) : _S8("") ), |
|
705 iFlags( aFlags ), |
|
706 iCleanupItem( Cleanup, this ), |
|
707 iLCPtr( NULL ) |
|
708 { |
|
709 TInt pos( iFunc.Locate( KFuncNameTerminator ) ); |
|
710 if( pos >= 0 && pos < iFunc.Length() ) |
|
711 { |
|
712 iFunc.Set( iFunc.Left( pos ) ); |
|
713 iFlags |= KFuncCanLeave; |
|
714 iLCPtr = aLCPtr; |
|
715 CleanupStack::PushL( iCleanupItem ); // Ignore warnings |
|
716 } |
|
717 LogStart(); |
|
718 } |
|
719 |
|
720 inline ~TFuncLog() |
|
721 { |
|
722 if ( !( iFlags & KFuncLeft ) ) |
|
723 { |
|
724 if ( iFlags & KFuncCanLeave ) |
|
725 { |
|
726 if ( iLCPtr && *iLCPtr) |
|
727 { |
|
728 CleanupStack::Pop(); // Pop LC ptr first |
|
729 CleanupStack::Pop( this ); // Pop the cleanup item |
|
730 CleanupStack::PushL( *iLCPtr ); // Push LC ptr back |
|
731 } |
|
732 else |
|
733 { |
|
734 CleanupStack::Pop( this ); // Pop the cleanup item |
|
735 } |
|
736 } |
|
737 LogEnd(); // Normally finished |
|
738 } |
|
739 } |
|
740 |
|
741 private: // Data |
|
742 TPtrC8 iFunc; |
|
743 TUint iFlags; |
|
744 TCleanupItem iCleanupItem; |
|
745 TAny** iLCPtr; |
|
746 TUint iAddr; |
|
747 }; |
|
748 |
|
749 /* |
|
750 * Use with non leaving and L methods |
|
751 * |
|
752 * CMyClass* CMyClass::DoL() |
|
753 * { |
|
754 * FUNC_LOG; |
|
755 * CMyClass* ret = new (ELeave) CMyClass(); |
|
756 * ... |
|
757 * return ret; |
|
758 * } |
|
759 * |
|
760 * CMyClass* CMyClass::Do() |
|
761 * { |
|
762 * FUNC_LOG; |
|
763 * return iMyClass; |
|
764 * } |
|
765 * |
|
766 */ |
|
767 #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__, 0 ); |
|
768 |
|
769 /** |
|
770 * Use this to log memory address. |
|
771 */ |
|
772 #define FUNC_LOG_ADDR(P1) TFuncLog _fl2( (int)P1, __PRETTY_FUNCTION__, 0 ); |
|
773 |
|
774 /* |
|
775 * Use with LC methods |
|
776 * |
|
777 * CMyClass* CMyClass::DoLC() |
|
778 * { |
|
779 * CMyClass* ret = NULL; |
|
780 * FUNC_LOG_LC( ret ); |
|
781 * ... |
|
782 * return ret; |
|
783 * } |
|
784 */ |
|
785 #define FUNC_LOG_LC( aPtr ) TFuncLog _fl( __PRETTY_FUNCTION__, 0, (TAny**)&aPtr ); |
|
786 |
|
787 #ifdef CLIENT_TRACE |
|
788 |
|
789 /* |
|
790 * Used like FUNC_LOG. Prints client info useful for client side executed API methods. |
|
791 */ |
|
792 #define FUNC_LOG_WITH_CLIENT TFuncLog _fl( __PRETTY_FUNCTION__, KFuncLogClient ); |
|
793 |
|
794 /* |
|
795 * Used like FUNC_LOG_LC. Prints client info useful for client side executed API methods. |
|
796 */ |
|
797 #define FUNC_LOG_WITH_CLIENT_LC( aPtr )\ |
|
798 TFuncLog _fl( __PRETTY_FUNCTION__, KFuncLogClient, (TAny**)&aPtr ); |
|
799 |
|
800 #else //CLIENT_TRACE not defined |
|
801 |
|
802 #define FUNC_LOG_WITH_CLIENT FUNC_LOG |
|
803 #define FUNC_LOG_WITH_CLIENT_LC( aPtr ) FUNC_LOG_LC( aPtr ) |
|
804 |
|
805 #endif //CLIENT_TRACE |
|
806 |
|
807 #else//FUNC_TRACE not defined |
|
808 |
|
809 #define FUNC_LOG |
|
810 #define FUNC_LOG_ADDR(P1) |
|
811 #define FUNC_LOG_LC( ptr ) |
|
812 #define FUNC_LOG_WITH_CLIENT |
|
813 #define FUNC_LOG_WITH_CLIENT_LC( ptr ) |
|
814 |
|
815 #endif//FUNC_TRACE |
|
816 |
|
817 //----------------------------------------------------------------------------- |
|
818 // Timestamp trace macros |
|
819 //----------------------------------------------------------------------------- |
|
820 // |
|
821 #ifdef TIMESTAMP_TRACE |
|
822 |
|
823 #define PREFIX_TIMESTAMP( aCaption )\ |
|
824 _PREFIX_TRACE_2("[TIMESTAMP] (%d:%02d:%02d.%06d us) ",aCaption) |
|
825 #define CURRENT_TIME( aDt ) TDateTime aDt; { TTime t; t.HomeTime(); aDt = t.DateTime(); } |
|
826 #define EXTRACT_TIME( aDt ) aDt.Hour(), aDt.Minute(), aDt.Second(), aDt.MicroSecond() |
|
827 |
|
828 #ifdef TRACE_INTO_FILE |
|
829 |
|
830 #define TIMESTAMP( aCaption )\ |
|
831 {\ |
|
832 CURRENT_TIME( dt );\ |
|
833 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
834 EFileLoggingModeAppend,\ |
|
835 PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\ |
|
836 } |
|
837 |
|
838 #define TIMESTAMP_1( aCaption, aP1 )\ |
|
839 {\ |
|
840 CURRENT_TIME( dt );\ |
|
841 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
842 EFileLoggingModeAppend,\ |
|
843 PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\ |
|
844 } |
|
845 |
|
846 #define TIMESTAMP_2( aCaption, aP1, aP2 )\ |
|
847 {\ |
|
848 CURRENT_TIME( dt );\ |
|
849 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
850 EFileLoggingModeAppend,\ |
|
851 PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\ |
|
852 } |
|
853 |
|
854 #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\ |
|
855 {\ |
|
856 CURRENT_TIME( dt );\ |
|
857 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
858 EFileLoggingModeAppend,\ |
|
859 PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\ |
|
860 } |
|
861 |
|
862 #else//TRACE_INTO_FILE not defined |
|
863 |
|
864 #define TIMESTAMP( aCaption )\ |
|
865 {\ |
|
866 CURRENT_TIME( dt );\ |
|
867 RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\ |
|
868 } |
|
869 |
|
870 #define TIMESTAMP_1( aCaption, aP1 )\ |
|
871 {\ |
|
872 CURRENT_TIME( dt );\ |
|
873 RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\ |
|
874 } |
|
875 |
|
876 #define TIMESTAMP_2( aCaption, aP1, aP2 )\ |
|
877 {\ |
|
878 CURRENT_TIME( dt );\ |
|
879 RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\ |
|
880 } |
|
881 |
|
882 #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\ |
|
883 {\ |
|
884 CURRENT_TIME( dt );\ |
|
885 RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\ |
|
886 } |
|
887 |
|
888 #endif//TRACE_INTO_FILE |
|
889 |
|
890 #else//TIMESTAMP_TRACE not defined |
|
891 |
|
892 #define TIMESTAMP( aCaption ) |
|
893 #define TIMESTAMP_1( aCaption, aP1 ) |
|
894 #define TIMESTAMP_2( aCaption, aP1, aP2 ) |
|
895 #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 ) |
|
896 |
|
897 #endif//TIMESTAMP_TRACE |
|
898 |
|
899 //----------------------------------------------------------------------------- |
|
900 // Trace assert macros |
|
901 //----------------------------------------------------------------------------- |
|
902 // |
|
903 #if ( (defined(_DEBUG) || UREL_TRACE == 1) && DISABLE_TRACE == 0 ) |
|
904 |
|
905 #ifdef TRACE_INTO_FILE |
|
906 |
|
907 #define PANIC_TRACE_2( aMsg, aP1, aP2 )\ |
|
908 {\ |
|
909 TPtrC8 trace( _S8( aMsg ) );\ |
|
910 RFileLogger::WriteFormat( KTracePath, KTraceFile,\ |
|
911 EFileLoggingModeAppend, trace, aP1, aP2 );\ |
|
912 } |
|
913 |
|
914 #else//TRACE_INTO_FILE not defined |
|
915 |
|
916 #define PANIC_TRACE_2( aMsg, aP1, aP2 )\ |
|
917 {\ |
|
918 RDebug::Printf( aMsg, aP1, aP2 );\ |
|
919 } |
|
920 |
|
921 #endif //TRACE_INTO_FILE not define |
|
922 |
|
923 static void Panic( const TDesC8& aFileName, const TInt aLineNum ) |
|
924 { |
|
925 PANIC_TRACE_2( "Assertion failed in file=%S, line=%d", &aFileName, aLineNum ); |
|
926 User::Invariant(); |
|
927 } |
|
928 |
|
929 #define ASSERT_ALWAYS_TRACE Panic( _L8(__FILE__), __LINE__ ); |
|
930 #define ASSERT_TRACE( _s ) if ( !( _s ) ) { ASSERT_ALWAYS_TRACE; } |
|
931 |
|
932 #else // TRACING DISABLED |
|
933 |
|
934 #define ASSERT_ALWAYS_TRACE |
|
935 #define ASSERT_TRACE( _s ) |
|
936 |
|
937 #endif // TRACING ENABLED |
|
938 |
|
939 |
|
940 #endif // VIDEOCOLLETIONTRACE_H |