|
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: Header file defining all debug related functions for calendar engine. Macros, funtions |
|
15 * defined here can be used to debug calendar engines. |
|
16 * |
|
17 */ |
|
18 |
|
19 /** |
|
20 * |
|
21 **/ |
|
22 #ifndef PIM_TRACE_H |
|
23 #define PIM_TRACE_H |
|
24 |
|
25 #ifdef _DEBUG |
|
26 #define PIM_TRAPD_HANDLE(_s) TRAPD(leave,_s); ASSERT(!leave) |
|
27 #define PIM_ASSERT_DEBUG(_s) TInt err = _s; ASSERT(!err) |
|
28 #else // _DEBUG |
|
29 #define PIM_TRAPD_HANDLE(_s) TRAP_IGNORE(_s) |
|
30 #define PIM_ASSERT_DEBUG(_s) _s |
|
31 #endif // _DEBUG |
|
32 |
|
33 |
|
34 #ifdef _DEBUG |
|
35 /********************************************************************************************************************/ |
|
36 //Inlude & define common data |
|
37 #include <e32base.h> |
|
38 #include <e32std.h> |
|
39 #include <flogger.h> |
|
40 #include <e32svr.h> |
|
41 |
|
42 const TInt KMaxLogLineLength = 512; |
|
43 |
|
44 /********************************************************************************************************************/ |
|
45 |
|
46 #if defined( TRACE_MODULE_AGNVERSIT2 ) // MACRO IN MMP FILE |
|
47 _LIT8( KModuleName8, "AgnVersit2" ); |
|
48 #elif defined( TRACE_ENTRY_CALENIMP ) // MACRO IN MMP FILE |
|
49 _LIT8( KModuleName8, "CalenImp" ); |
|
50 #elif defined ( TRACE_ENTRY_CALENINTERIMUTILS2 ) |
|
51 _LIT8( KModuleName8, "CalenInterimUtils2" ); |
|
52 #elif defined ( TRACE_ENTRY_VERSIT2 ) |
|
53 _LIT8( KModuleName8, "Versit2" ); |
|
54 #else // default |
|
55 _LIT8( KModuleName8, "CalendarEngines" ); |
|
56 #endif |
|
57 |
|
58 // traces |
|
59 // [module_name]_ENTRY_POINT;[thread_id];[function_name];[filename]:[line_number]; |
|
60 _LIT8( KFuncEntryFormat8, ";%S_ENTRY_POINT;%d;%S;%S:%d;"); |
|
61 // [module_name]_EXIT_POINT;[thread_id];[function_name];[filename]:[line_number]; |
|
62 _LIT8( KFuncExitFormat8, ";%S_EXIT_POINT;%d;%S;%S:%d;"); |
|
63 |
|
64 /********************************************************************************************************************/ |
|
65 NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow |
|
66 { |
|
67 public: |
|
68 void Overflow(TDes8& /*aDes*/) {} |
|
69 }; |
|
70 |
|
71 //Trace macro 8bit |
|
72 inline void TraceDebugPrint( TRefByValue<const TDesC8> aFmt, ...) |
|
73 { |
|
74 VA_LIST list; |
|
75 VA_START( list, aFmt ); |
|
76 |
|
77 TOverflowTruncate8 overflow; |
|
78 TBuf8<KMaxLogLineLength> buf8; |
|
79 buf8.AppendFormatList( aFmt, list, &overflow ); |
|
80 TBuf16<KMaxLogLineLength> buf16( buf8.Length() ); |
|
81 buf16.Copy( buf8 ); |
|
82 TRefByValue<const TDesC> tmpFmt( _L("%S") ); |
|
83 RDebug::Print( tmpFmt, &buf16 ); |
|
84 } |
|
85 |
|
86 /********************************************************************************************************************/ |
|
87 //Debug print |
|
88 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE |
|
89 #ifdef __ARMCC__ |
|
90 #define TRACE_FUNC_ENTRY_DEBUG_PRINT \ |
|
91 { \ |
|
92 const TUint threadId( RThread().Id() ); \ |
|
93 TPtrC8 ptr8File( (TUint8*)__MODULE__ ); \ |
|
94 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ ); \ |
|
95 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
96 } |
|
97 #define TRACE_FUNC_EXIT_DEBUG_PRINT \ |
|
98 { \ |
|
99 const TUint threadId( RThread().Id() ); \ |
|
100 TPtrC8 ptr8File( (TUint8*)__MODULE__ ); \ |
|
101 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ ); \ |
|
102 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
103 } |
|
104 #else // __WINS__ |
|
105 #define TRACE_FUNC_ENTRY_DEBUG_PRINT \ |
|
106 { \ |
|
107 const TUint threadId( RThread().Id() ); \ |
|
108 TPtrC8 ptr8File( (TUint8*)__FILE__ ); \ |
|
109 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ ); \ |
|
110 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
111 } |
|
112 #define TRACE_FUNC_EXIT_DEBUG_PRINT \ |
|
113 { \ |
|
114 const TUint threadId( RThread().Id() ); \ |
|
115 TPtrC8 ptr8File( (TUint8*)__FILE__ ); \ |
|
116 TPtrC8 ptr8PF( (TUint8*)__PRETTY_FUNCTION__ ); \ |
|
117 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
118 } |
|
119 #endif |
|
120 #endif |
|
121 |
|
122 /********************************************************************************************************************/ |
|
123 //Check if trace should be activated |
|
124 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE |
|
125 #define TRACE_ENTRY_POINT TRACE_FUNC_ENTRY_DEBUG_PRINT |
|
126 #define TRACE_EXIT_POINT TRACE_FUNC_EXIT_DEBUG_PRINT |
|
127 #else |
|
128 #define TRACE_ENTRY_POINT |
|
129 #define TRACE_EXIT_POINT |
|
130 #endif |
|
131 |
|
132 #else |
|
133 #define TRACE_ENTRY_POINT |
|
134 #define TRACE_EXIT_POINT |
|
135 |
|
136 #endif // _DEBUG |
|
137 |
|
138 #endif // PIM_TRACE_H |
|
139 |
|
140 |
|
141 // End of File |