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