|
1 /* |
|
2 * Copyright (c) 2002 - 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedPartner |
|
22 @released |
|
23 |
|
24 This header file contains three macros for outputing logs to a number of |
|
25 different locations. |
|
26 |
|
27 There are three macros: |
|
28 |
|
29 JAVA_RDEBUG |
|
30 enables logging to the serial port. |
|
31 JAVA_FILELOG |
|
32 writes a log to c:\logs\java\midp.txt if the directory exists. |
|
33 JAVA_PRINTF |
|
34 enables printf logging. |
|
35 |
|
36 The default behaviour for UDEB builds is to have only JAVA_FILELOG enabled. |
|
37 |
|
38 To enable UREL file logging, the ifdef clause surrounding JAVA_FILELOG must |
|
39 be removed, and one of the |
|
40 /j2me/vms/extensions/src/epoc/native/util/include/enable_flogger*.bat files |
|
41 must be executed before attempting to build These batch files modify the |
|
42 flogger include to be a standard library rather than a debuglibrary. |
|
43 |
|
44 Please see /j2me/vms/extensions/src/epoc/native/util/include/readme.txt for |
|
45 more details. |
|
46 */ |
|
47 |
|
48 #ifndef JDEBUG_H |
|
49 #define JDEBUG_H |
|
50 |
|
51 ////////////////////////////////////////////////////////////////////////////// |
|
52 // Customisation should only be required in the below section // |
|
53 //#define JAVA_RDEBUG |
|
54 //#define JAVA_PRINTF |
|
55 //#define JAVA_PROFILE |
|
56 #ifdef _DEBUG // only on UDEB builds |
|
57 #define JAVA_FILELOG |
|
58 #endif |
|
59 |
|
60 // Customisation should only be required in the above section // |
|
61 ////////////////////////////////////////////////////////////////////////////// |
|
62 |
|
63 #include <e32std.h> |
|
64 |
|
65 // Debugging headers |
|
66 #if defined (JAVA_RDEBUG) || defined (JAVA_PROFILE) |
|
67 #include <e32svr.h> |
|
68 #endif |
|
69 |
|
70 #ifdef JAVA_FILELOG |
|
71 #include <flogger.h> |
|
72 #endif |
|
73 |
|
74 #ifdef JAVA_PRINTF |
|
75 #include <libc/stdio.h> |
|
76 #endif |
|
77 |
|
78 |
|
79 // Strings for flogger directory and file names |
|
80 _LIT(KLogDirectory, "java\\full"); |
|
81 _LIT(KLogFileName, "midplegacy.log"); |
|
82 |
|
83 /** |
|
84 Custom Component Logging |
|
85 Add extra component literals here to use in components. |
|
86 To add component logging into the main log change the |
|
87 "<component>.txt" to "midp.txt" |
|
88 */ |
|
89 |
|
90 /** |
|
91 To force all logging into main log file (midp.txt) |
|
92 uncomment the following line */ |
|
93 //#define ONE_LOG |
|
94 |
|
95 #if defined(JAVA_RDEBUG) || defined(JAVA_PRINTF) || defined(JAVA_FILELOG) || defined (JAVA_PROFILE) |
|
96 |
|
97 // to fix compiler warnings |
|
98 inline void Dummy(TBool /*aBool*/) |
|
99 { |
|
100 } |
|
101 inline void Dummy(const TDesC& /*aComponentLogName*/) |
|
102 { |
|
103 } |
|
104 |
|
105 //Splits the logging into multiple files , aComponentLogName is the log file associated |
|
106 //with specific components eg |
|
107 //http.txt will go into \logs\java\http.txt |
|
108 |
|
109 inline void Debug(const TDesC& aComponentLogName, const TDesC& aMsg, const TBool aBool) |
|
110 { |
|
111 #ifdef JAVA_FILELOG |
|
112 // Print to log file |
|
113 #ifdef ONE_LOG |
|
114 const TDesC& ignore = aComponentLogName; |
|
115 RFileLogger::Write(KLogDirectory, KLogFileName, EFileLoggingModeAppend, aMsg); |
|
116 #else |
|
117 RFileLogger::Write(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, aMsg); |
|
118 #endif |
|
119 Dummy(aBool); |
|
120 #endif |
|
121 |
|
122 #ifdef JAVA_PRINTF |
|
123 { |
|
124 if (aBool) |
|
125 { |
|
126 // Print to standard out |
|
127 TBuf8<0x100> msg; |
|
128 msg.Copy(aMsg); |
|
129 printf("C_DEBUG: "); |
|
130 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
131 printf(msgPtr); |
|
132 printf("\n"); |
|
133 } |
|
134 } |
|
135 #endif |
|
136 |
|
137 #ifdef JAVA_RDEBUG |
|
138 // Print to debugger (WINS only) |
|
139 RDebug::Print(aMsg); |
|
140 Dummy(aComponentLogName); |
|
141 Dummy(aBool); |
|
142 #endif |
|
143 } |
|
144 |
|
145 _LIT(KJavaProfile , "Java_profile:: low: %u , high: %u :%S"); |
|
146 |
|
147 #ifdef JAVA_PROFILE |
|
148 inline void DebugProfile(const TDesC& aMsg) |
|
149 { |
|
150 TTime time; |
|
151 time.UniversalTime(); |
|
152 RDebug::Print(KJavaProfile , I64LOW(time.Int64()), I64HIGH(time.Int64()), &aMsg); |
|
153 } |
|
154 #else |
|
155 inline void DebugProfile(const TDesC&) |
|
156 { |
|
157 } |
|
158 #endif |
|
159 |
|
160 |
|
161 inline void DebugString(const TDesC& aComponentLogName, const TDesC& aMsg, const TDesC& aString, const TBool aBool) |
|
162 { |
|
163 // Print to log file |
|
164 #ifdef JAVA_FILELOG |
|
165 #ifdef ONE_LOG |
|
166 const TDesC& ignore = aComponentLogName; |
|
167 RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend, aMsg, &aString); |
|
168 #else |
|
169 RFileLogger::WriteFormat(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, aMsg, &aString); |
|
170 #endif |
|
171 Dummy(aBool); |
|
172 #endif |
|
173 |
|
174 #ifdef JAVA_PRINTF |
|
175 // Locally scope the code because temporary variables are defined and inlined |
|
176 { |
|
177 if (aBool) |
|
178 { |
|
179 // Print to standard out |
|
180 TBuf8<0x100> msg; |
|
181 msg.Copy(aMsg); |
|
182 printf("C_DEBUG: "); |
|
183 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
184 TBuf8<0x100> tmpString(0xFF); |
|
185 tmpString.Copy(aString.Left(0xFF)); |
|
186 printf(msgPtr); |
|
187 printf("tring:\"%s\"\n", tmpString.PtrZ()); |
|
188 } |
|
189 } |
|
190 #endif |
|
191 |
|
192 #ifdef JAVA_RDEBUG |
|
193 // Print to debugger (WINS only) |
|
194 RDebug::Print(aMsg, &aString); |
|
195 Dummy(aComponentLogName); |
|
196 Dummy(aBool); |
|
197 #endif |
|
198 } |
|
199 |
|
200 inline void DebugInt(const TDesC& aComponentLogName, const TDesC& aMsg, TInt aNum, const TBool aBool) |
|
201 { |
|
202 // Print to log file |
|
203 #ifdef JAVA_FILELOG |
|
204 #ifdef ONE_LOG |
|
205 const TDesC& ignore = aComponentLogName; |
|
206 RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend, aMsg, aNum); |
|
207 #else |
|
208 RFileLogger::WriteFormat(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, aMsg, aNum); |
|
209 #endif |
|
210 Dummy(aBool); |
|
211 #endif |
|
212 |
|
213 #ifdef JAVA_PRINTF |
|
214 { |
|
215 if (aBool) |
|
216 { |
|
217 // Print to standard out |
|
218 TBuf8<0x100> msg; |
|
219 msg.Copy(aMsg); |
|
220 printf("C_DEBUG: "); |
|
221 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
222 printf(msgPtr, aNum); |
|
223 printf("\n"); |
|
224 } |
|
225 } |
|
226 #endif |
|
227 |
|
228 #ifdef JAVA_RDEBUG |
|
229 // Print to debugger (WINS only) |
|
230 RDebug::Print(aMsg, aNum); |
|
231 Dummy(aComponentLogName); |
|
232 Dummy(aBool); |
|
233 #endif |
|
234 } |
|
235 |
|
236 inline void DebugInt2(const TDesC& aComponentLogName, const TDesC& aMsg, TInt aNum, TInt aNum2, const TBool aBool) |
|
237 { |
|
238 // Print to log file |
|
239 #ifdef JAVA_FILELOG |
|
240 #ifdef ONE_LOG |
|
241 const TDesC& ignore = aComponentLogName; |
|
242 RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend, |
|
243 aMsg, aNum, aNum2); |
|
244 #else |
|
245 RFileLogger::WriteFormat(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, |
|
246 aMsg, aNum, aNum2); |
|
247 #endif |
|
248 Dummy(aBool); |
|
249 #endif |
|
250 |
|
251 #ifdef JAVA_PRINTF |
|
252 { |
|
253 if (aBool) |
|
254 { |
|
255 // Print to standard out |
|
256 TBuf8<0x100> msg; |
|
257 msg.Copy(aMsg); |
|
258 printf("C_DEBUG: "); |
|
259 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
260 printf(msgPtr, aNum, aNum2); |
|
261 printf("\n"); |
|
262 } |
|
263 } |
|
264 #endif |
|
265 |
|
266 #ifdef JAVA_RDEBUG |
|
267 // Print to debugger (WINS only) |
|
268 RDebug::Print(aMsg, aNum, aNum2); |
|
269 Dummy(aComponentLogName); |
|
270 Dummy(aBool); |
|
271 #endif |
|
272 } |
|
273 |
|
274 inline void DebugInt3(const TDesC& aComponentLogName, const TDesC& aMsg, TInt aNum, TInt aNum2, TInt aNum3, const TBool aBool) |
|
275 { |
|
276 // Print to log file |
|
277 #ifdef JAVA_FILELOG |
|
278 #ifdef ONE_LOG |
|
279 const TDesC& ignore = aComponentLogName; |
|
280 RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend, |
|
281 aMsg, aNum, aNum2, aNum3); |
|
282 #else |
|
283 RFileLogger::WriteFormat(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, |
|
284 aMsg, aNum, aNum2, aNum3); |
|
285 #endif |
|
286 Dummy(aBool); |
|
287 #endif |
|
288 |
|
289 #ifdef JAVA_PRINTF |
|
290 { |
|
291 if (aBool) |
|
292 { |
|
293 // Print to standard out |
|
294 TBuf8<0x100> msg; |
|
295 msg.Copy(aMsg); |
|
296 printf("C_DEBUG: "); |
|
297 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
298 printf(msgPtr, aNum, aNum2, aNum3); |
|
299 printf("\n"); |
|
300 } |
|
301 } |
|
302 #endif |
|
303 |
|
304 #ifdef JAVA_RDEBUG |
|
305 // Print to debugger (WINS only) |
|
306 RDebug::Print(aMsg, aNum, aNum2, aNum3); |
|
307 Dummy(aComponentLogName); |
|
308 Dummy(aBool); |
|
309 #endif |
|
310 } |
|
311 |
|
312 |
|
313 |
|
314 inline void DebugInt4(const TDesC& aComponentLogName, const TDesC& aMsg, TInt aNum, TInt aNum2, TInt aNum3, TInt aNum4, const TBool aBool) |
|
315 { |
|
316 // Print to log file |
|
317 #ifdef JAVA_FILELOG |
|
318 #ifdef ONE_LOG |
|
319 const TDesC& ignore = aComponentLogName; |
|
320 RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend, |
|
321 aMsg, aNum, aNum2, aNum3, aNum4); |
|
322 #else |
|
323 RFileLogger::WriteFormat(KLogDirectory, aComponentLogName, EFileLoggingModeAppend, |
|
324 aMsg, aNum, aNum2, aNum3, aNum4); |
|
325 #endif |
|
326 Dummy(aBool); |
|
327 #endif |
|
328 |
|
329 #ifdef JAVA_PRINTF |
|
330 { |
|
331 if (aBool) |
|
332 { |
|
333 // Print to standard out |
|
334 TBuf8<0x100> msg; |
|
335 msg.Copy(aMsg); |
|
336 printf("C_DEBUG: "); |
|
337 const char* msgPtr = reinterpret_cast<const char*>(msg.PtrZ()); |
|
338 printf(msgPtr, aNum, aNum2, aNum3, aNum4); |
|
339 printf("\n"); |
|
340 } |
|
341 } |
|
342 #endif |
|
343 |
|
344 #ifdef JAVA_RDEBUG |
|
345 // Print to debugger (WINS only) |
|
346 RDebug::Print(aMsg, aNum, aNum2, aNum3, aNum4); |
|
347 Dummy(aComponentLogName); |
|
348 Dummy(aBool); |
|
349 #endif |
|
350 } |
|
351 |
|
352 |
|
353 |
|
354 inline void DebugString8(const TDesC& aComponentLogName, const TDesC& aMsg, const TDesC8& aString, const TBool aBool) |
|
355 { |
|
356 TRAPD(error, |
|
357 HBufC16* expandedMessage = HBufC16::NewLC(aString.Length()); |
|
358 expandedMessage->Des().Copy(aString); |
|
359 DebugString(aComponentLogName,aMsg, *expandedMessage, aBool); |
|
360 CleanupStack::PopAndDestroy(expandedMessage); |
|
361 ) |
|
362 if (error != KErrNone) |
|
363 { |
|
364 _LIT(KError, "jdebug.h: Error expanding 8 bit String"); |
|
365 DebugString(aComponentLogName, aMsg, KError, aBool); |
|
366 _LIT(KMsg, "jdebug.h: Error=%D Length=%D"); |
|
367 DebugInt2(aComponentLogName, KMsg, error, aString.Length(), aBool); |
|
368 } |
|
369 } |
|
370 |
|
371 |
|
372 |
|
373 inline void DebugAssert(TBool aCondition, const TDesC& aMsg) |
|
374 { |
|
375 if (!aCondition) |
|
376 { |
|
377 DebugString(KLogFileName, _L("ASSERT: %S"), aMsg, ETrue); |
|
378 ASSERT(EFalse); |
|
379 } |
|
380 } |
|
381 |
|
382 // these macros are documented below. |
|
383 #define DEBUG( msg ) Debug( KLogFileName, _L( msg ), ETrue) |
|
384 #define DEBUGCOMP( comp, msg ) Debug( comp, _L( msg ), ETrue) |
|
385 #define DEBUG_ASSERT( condition, msg ) DebugAssert( condition, _L( msg ) ) |
|
386 #define DEBUG_STR( msg, string ) DebugString( KLogFileName, _L( msg ), string, ETrue ) |
|
387 #define DEBUGCOMP_STR( comp, msg, string ) DebugString( comp , _L( msg ), string, ETrue ) |
|
388 #define DEBUG_STR8( msg, string ) DebugString8( KLogFileName, _L( msg ), string, ETrue ) |
|
389 #define DEBUGCOMP_STR8( comp, msg, string ) DebugString8( comp, _L( msg ), string, ETrue ) |
|
390 #define DEBUG_INT( msg, num ) DebugInt( KLogFileName, _L( msg ), num, ETrue ) |
|
391 #define DEBUGCOMP_INT( comp, msg, num ) DebugInt( comp , _L( msg ), num, ETrue ) |
|
392 #define DEBUG_INT2( msg, num, num2 ) DebugInt2( KLogFileName, _L( msg ), num, num2, ETrue ) |
|
393 #define DEBUGCOMP_INT2( comp, msg, num, num2 ) DebugInt2( comp, _L( msg ), num, num2, ETrue ) |
|
394 #define DEBUG_INT3( msg, num, num2, num3 ) DebugInt3( KLogFileName, _L( msg ), num, num2, num3, ETrue ) |
|
395 #define DEBUGCOMP_INT3( comp, msg, num, num2, num3 ) DebugInt3( comp , _L( msg ), num, num2, num3, ETrue ) |
|
396 #define DEBUG_INT4( msg, num, num2, num3, num4 ) DebugInt4( KLogFileName, _L( msg ), num, num2, num3, num4, ETrue ) |
|
397 #define DEBUGCOMP_INT4( comp, msg, num, num2, num3, num4 ) DebugInt4( comp , _L( msg ), num, num2, num3, num4, ETrue ) |
|
398 #define DEBUG_ERR( msg, num ) if ( num < KErrNone ) DebugInt( KLogFileName, _L( msg ), num, ETrue ) |
|
399 #define DEBUG_PROFILE(msg) DebugProfile(_L( msg )) |
|
400 |
|
401 // don't print to standard out |
|
402 #define DEBUG_NOSTDLIB( msg) Debug( KLogFileName, _L( msg ), EFalse ) |
|
403 #define DEBUG_STR_NOSTDLIB( msg, string ) DebugString( KLogFileName, _L( msg ), string, EFalse ) |
|
404 #define DEBUG_STR8_NOSTDLIB( msg, string ) DebugString8( KLogFileName, _L( msg ), string, EFalse ) |
|
405 #define DEBUG_INT_NOSTDLIB( msg, num, abool ) DebugInt( KLogFileName, _L( msg ), num, EFalse ) |
|
406 #define DEBUG_INT2_NOSTDLIB( msg, num, num2 ) DebugInt2( KLogFileName, _L( msg ), num, num2, EFalse ) |
|
407 #define DEBUG_INT3_NOSTDLIB( msg, num, num2, num3 ) DebugInt3( KLogFileName, _L( msg ), num, num2, num3, EFalse ) |
|
408 #define DEBUG_INT4_NOSTDLIB( msg, num, num2, num3, num4 ) DebugInt4( KLogFileName, _L( msg ), num, num2, num3, num4, EFalse ) |
|
409 #define DEBUG_ERR_NOSTDLIB( msg, num, ETrue ) if ( num < KErrNone ) DebugInt( KLogFileName, _L( msg ), num, EFalse ) |
|
410 |
|
411 |
|
412 #else // #if defined(JAVA_RDEBUG) || defined(JAVA_PRINTF) || defined(JAVA_FILELOG) |
|
413 |
|
414 |
|
415 /** Prints a message. */ |
|
416 #define DEBUG( msg ) |
|
417 /** comp specifies a file to put logging in eg http.txt == \logs\java\http.txt |
|
418 * Literal is defined at top of this file eg KLogFileHttp */ |
|
419 #define DEBUGCOMP( comp, msg ) |
|
420 /** Tests the specified condition, and if it evaluates to |
|
421 false, prints the message, preceded by the string "ASSERT: " |
|
422 and raises a USER 0 panic. */ |
|
423 #define DEBUG_ASSERT( condition, msg ) |
|
424 /** Prints a message with a string argument. |
|
425 |
|
426 Use a %S format character in the message to specify where the |
|
427 string should be inserted. */ |
|
428 #define DEBUG_STR( msg, string ) |
|
429 /** comp specifies a file to put logging in eg http.txt == \logs\java\http.txt */ |
|
430 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
431 #define DEBUGCOMP_STR( comp, msg, string ) |
|
432 /** Prints a message with a 8 bit string argument. |
|
433 |
|
434 Use a %S format character in the message to specify where the |
|
435 string should be inserted. */ |
|
436 #define DEBUG_STR8( msg, string ) |
|
437 /** comp specifies a file to put logging in eg http.txt == \logs\java\http.txt */ |
|
438 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
439 #define DEBUGCOMP_STR8( comp, msg, string ) |
|
440 /** Prints a message with an integer argument. |
|
441 |
|
442 Use a %D format character in the message to specify where the |
|
443 integer should be inserted. */ |
|
444 #define DEBUG_INT( msg, num ) |
|
445 /** comp specifies a fire to put logging in eg http.txt == \logs\java\http.txt */ |
|
446 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
447 #define DEBUGCOMP_INT( comp, msg, num ) |
|
448 /** Prints a message with two integer arguments. |
|
449 |
|
450 Use %D format characters in the message to specify where the |
|
451 integers should be inserted. */ |
|
452 #define DEBUG_INT2( msg, num, num2 ) |
|
453 /** comp specifies a file to put logging in eg http.txt == \logs\java\http.txt */ |
|
454 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
455 #define DEBUGCOMP_INT2( comp, msg, num, num2 ) |
|
456 /** Prints a message with three integer arguments. |
|
457 |
|
458 Use %D format characters in the message to specify where the |
|
459 integers should be inserted. */ |
|
460 #define DEBUG_INT3( msg, num, num2, num3 ) |
|
461 /** comp specifies a fire to put logging in eg http.txt == \logs\java\http.txt */ |
|
462 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
463 #define DEBUGCOMP_INT3( comp, msg, num, num2, num3 ) |
|
464 /** Prints a message with four integer arguments. |
|
465 |
|
466 Use %D format characters in the message to specify where the |
|
467 integers should be inserted. */ |
|
468 #define DEBUG_INT4( msg, num, num2, num3, num4 ) |
|
469 /** comp specifies a fire to put logging in eg http.txt == \logs\java\http.txt */ |
|
470 /* Literal is defined at top of this file eg KLogFileHttp */ |
|
471 #define DEBUGCOMP_INT4( comp, msg, num, num2, num3, num4 ) |
|
472 /** Prints a message with an integer error code argument. |
|
473 |
|
474 Use a %D format character in the message to specify where the |
|
475 error code should be inserted. |
|
476 |
|
477 Note that a message is only printed if the integer value is |
|
478 negative. */ |
|
479 #define DEBUG_ERR( msg, num ) |
|
480 /** Prints msg plus the utc time in milliseconds to allow profiling via RDebug::Print. */ |
|
481 #define DEBUG_PROFILE(msg) |
|
482 |
|
483 /** Prints a message. |
|
484 |
|
485 This is the same as DEBUG except the message is not printed |
|
486 to the standard output. */ |
|
487 #define DEBUG_NOSTDLIB( msg ) |
|
488 /** Prints a message with a string argument. |
|
489 |
|
490 This is the same as DEBUG_STR except the message is not |
|
491 printed to the standard output. */ |
|
492 #define DEBUG_STR_NOSTDLIB( msg, string ) |
|
493 /** Prints a message with a string argument. |
|
494 |
|
495 This is the same as DEBUG_STR except the message is not |
|
496 printed to the standard output. */ |
|
497 #define DEBUG_STR8_NOSTDLIB( msg, string ) |
|
498 /** Prints a message with an integer argument. |
|
499 |
|
500 This is the same as DEBUG_INT except the message is not |
|
501 printed to the standard output. */ |
|
502 #define DEBUG_INT_NOSTDLIB( msg, num ) |
|
503 /** Prints a message with two integer arguments. |
|
504 |
|
505 This is the same as DEBUG_INT2 except the message is not |
|
506 printed to the standard output. */ |
|
507 #define DEBUG_INT2_NOSTDLIB( msg, num, num2 ) |
|
508 /** Prints a message with three integer arguments. |
|
509 |
|
510 This is the same as DEBUG_INT3 except the message is not |
|
511 printed to the standard output. */ |
|
512 #define DEBUG_INT3_NOSTDLIB( msg, num, num2, num3 ) |
|
513 /** Prints a message with four integer arguments. |
|
514 |
|
515 This is the same as DEBUG_INT4 except the message is not |
|
516 printed to the standard output. */ |
|
517 #define DEBUG_INT4_NOSTDLIB( msg, num, num2, num3, num4 ) |
|
518 /** Prints a message with an integer error code argument. |
|
519 |
|
520 This is the same as DEBUG_ERR except the message is not |
|
521 printed to the standard output. */ |
|
522 #define DEBUG_ERR_NOSTDLIB( msg, num ) |
|
523 |
|
524 |
|
525 #endif // #if defined(JAVA_RDEBUG) || defined(JAVA_PRINTF) || defined(JAVA_FILELOG) |
|
526 |
|
527 |
|
528 #ifdef _DEBUG |
|
529 |
|
530 #define DEBUG_LOG_ONLY( code ) code |
|
531 #define DEBUG_ONLY( code ) code |
|
532 |
|
533 // The COMPILE_ASSERT macro is useful for ensuring that number values |
|
534 // defined in Java retain the same values as their native counterparts, |
|
535 // for example in the case of error codes |
|
536 template <TBool> struct ASSERTION_FAILURE; |
|
537 TEMPLATE_SPECIALIZATION struct ASSERTION_FAILURE<ETrue> {}; |
|
538 template <TInt> struct __assertion_test; |
|
539 #define COMPILE_ASSERT( B ) void __compile_assert(::__assertion_test<sizeof(::ASSERTION_FAILURE<(B)>)>) |
|
540 #define OOM_DEBUG_LOOP_START TInt error = KErrNoMemory; for( TInt fail = 1; error == KErrNoMemory; fail++ ) { DEBUG_INT( "create connection OOM loop: %d", fail ); __UHEAP_FAILNEXT(fail); __UHEAP_MARK; |
|
541 #define OOM_DEBUG_LOOP_END __UHEAP_MARKEND; } __UHEAP_SETFAIL(RHeap::ENone,0); |
|
542 |
|
543 #else |
|
544 |
|
545 /** Code inside the brackets is only for debug or for logging in release build */ |
|
546 #if defined(JAVA_RDEBUG) || defined(JAVA_PRINTF) || defined (JAVA_PROFILE) |
|
547 #define DEBUG_LOG_ONLY( code ) code |
|
548 #else |
|
549 #define DEBUG_LOG_ONLY( code ) |
|
550 #endif |
|
551 |
|
552 /** Marks the code inside the brackets as being for debug |
|
553 builds only. */ |
|
554 #define DEBUG_ONLY( code ) |
|
555 |
|
556 /** Asserts that the code inside the brackets must be true at |
|
557 compile time, otherwise compilation fails. |
|
558 |
|
559 This macro is useful for ensuring that numeric values defined in |
|
560 Java retain the same values as their native counterparts, for |
|
561 example in the case of error codes. */ |
|
562 #define COMPILE_ASSERT( B ) |
|
563 |
|
564 /** Marks the start of out-of-memory testing. |
|
565 |
|
566 This and OOM_DEBUG_LOOP_END are used to test that all heap memory |
|
567 allocated in the code block enclosed by the two macros is deallocated. |
|
568 The code block is called in a loop, and heap allocation failure is |
|
569 simulated each time around. If the code fails the test, a panic occurs. */ |
|
570 #define OOM_DEBUG_LOOP_START |
|
571 /** Marks the end of out-of-memory testing. */ |
|
572 #define OOM_DEBUG_LOOP_END |
|
573 |
|
574 #endif // #ifdef _DEBUG |
|
575 |
|
576 #endif // JDEBUG_H |
|
577 |
|
578 |