|
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: Debug file of AlarmUI. |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 * |
|
20 **/ |
|
21 #ifndef PIM_TRACE_H |
|
22 #define PIM_TRACE_H |
|
23 |
|
24 /** |
|
25 * Define our own trap and assert macros to prevent compiler warnings. |
|
26 */ |
|
27 #ifdef _DEBUG |
|
28 #define PIM_TRAP_ASSERT( err, _s ) \ |
|
29 { \ |
|
30 TRAP( _err, _s; ); \ |
|
31 if( _err ) RDebug::Print( _L("### alarmui assert: %d"), _err ); \ |
|
32 ASSERT( !_err ); \ |
|
33 } |
|
34 #define PIM_TRAPD_ASSERT( _s ) \ |
|
35 { \ |
|
36 TRAPD( _err, _s; ); \ |
|
37 if( _err ) RDebug::Print( _L("### alarmui assert: %d"), _err ); \ |
|
38 ASSERT( !_err ); \ |
|
39 } |
|
40 #define PIM_ASSERT( _s ) \ |
|
41 { \ |
|
42 const TInt _err = _s; \ |
|
43 if( _err ) RDebug::Print( _L("### alarmui assert: %d"), _err ); \ |
|
44 ASSERT( !_err ); \ |
|
45 } |
|
46 #else // urel |
|
47 #define PIM_TRAP_ASSERT( _err, _s ) TRAP_IGNORE( _s; ); |
|
48 #define PIM_TRAPD_ASSERT( _s ) TRAP_IGNORE( _s; ); |
|
49 #define PIM_ASSERT( _s ) _s; |
|
50 #endif // _DEBUG |
|
51 |
|
52 |
|
53 /** |
|
54 * Trace. |
|
55 */ |
|
56 #ifdef _DEBUG |
|
57 /********************************************************************************************************************/ |
|
58 //Inlude & define common data |
|
59 #include <e32base.h> |
|
60 #include <e32std.h> |
|
61 #include <e32svr.h> |
|
62 |
|
63 const TInt KMaxLogLineLength = 512; |
|
64 |
|
65 /********************************************************************************************************************/ |
|
66 |
|
67 #if defined( TRACE_MODULE_ALMALERT ) // MACRO IN MMP FILE |
|
68 _LIT8( KModuleName8, "AlmAlert" ); |
|
69 #elif defined( TRACE_ENTRY_AKNALARMSERVICE ) // MACRO IN MMP FILE |
|
70 _LIT8( KModuleName8, "AlarmService" ); |
|
71 #else // default |
|
72 _LIT8( KModuleName8, "AlarmUI" ); |
|
73 #endif |
|
74 |
|
75 // traces |
|
76 // [module_name]_ENTR;[thread_id];[function_name];[filename]:[line_number]; |
|
77 _LIT8( KFuncEntryFormat8, ";%S_ENTR;%d;%S;%S:%d;"); |
|
78 // [module_name]_EXIT;[thread_id];[function_name];[filename]:[line_number]; |
|
79 _LIT8( KFuncExitFormat8, ";%S_EXIT;%d;%S;%S:%d;"); |
|
80 |
|
81 /********************************************************************************************************************/ |
|
82 NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow |
|
83 { |
|
84 public: |
|
85 void Overflow(TDes8& /*aDes*/) {} |
|
86 }; |
|
87 |
|
88 //Trace macro 8bit |
|
89 inline void TraceDebugPrint( TRefByValue<const TDesC8> aFmt, ...) |
|
90 { |
|
91 VA_LIST list; |
|
92 VA_START( list, aFmt ); |
|
93 |
|
94 TOverflowTruncate8 overflow; |
|
95 TBuf8<KMaxLogLineLength> buf8; |
|
96 buf8.AppendFormatList( aFmt, list, &overflow ); |
|
97 TBuf16<KMaxLogLineLength> buf16( buf8.Length() ); |
|
98 buf16.Copy( buf8 ); |
|
99 TRefByValue<const TDesC> tmpFmt( _L("%S") ); |
|
100 RDebug::Print( tmpFmt, &buf16 ); |
|
101 } |
|
102 |
|
103 /********************************************************************************************************************/ |
|
104 //Debug print |
|
105 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE |
|
106 #ifdef __ARMCC__ |
|
107 #define TRACE_FUNC_ENTRY_DEBUG_PRINT \ |
|
108 { \ |
|
109 const TUint threadId( RThread().Id() ); \ |
|
110 TPtrC8 ptr8File( (TUint8*)__MODULE__ ); \ |
|
111 TPtrC8 ptr8PF( (TUint8*)__FUNCTION__ ); \ |
|
112 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
113 } |
|
114 #define TRACE_FUNC_EXIT_DEBUG_PRINT \ |
|
115 { \ |
|
116 const TUint threadId( RThread().Id() ); \ |
|
117 TPtrC8 ptr8File( (TUint8*)__MODULE__ ); \ |
|
118 TPtrC8 ptr8PF( (TUint8*)__FUNCTION__ ); \ |
|
119 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
120 } |
|
121 #else // __WINS__ |
|
122 #define TRACE_FUNC_ENTRY_DEBUG_PRINT \ |
|
123 { \ |
|
124 const TUint threadId( RThread().Id() ); \ |
|
125 TPtrC8 ptr8File( (TUint8*)__FILE__ ); \ |
|
126 TPtrC8 ptr8PF( (TUint8*)__FUNCTION__ ); \ |
|
127 TraceDebugPrint( KFuncEntryFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
128 } |
|
129 #define TRACE_FUNC_EXIT_DEBUG_PRINT \ |
|
130 { \ |
|
131 const TUint threadId( RThread().Id() ); \ |
|
132 TPtrC8 ptr8File( (TUint8*)__FILE__ ); \ |
|
133 TPtrC8 ptr8PF( (TUint8*)__FUNCTION__ ); \ |
|
134 TraceDebugPrint( KFuncExitFormat8, &KModuleName8, threadId, &ptr8PF, &ptr8File, __LINE__ ); \ |
|
135 } |
|
136 #endif |
|
137 #endif |
|
138 |
|
139 /********************************************************************************************************************/ |
|
140 //Check if trace should be activated |
|
141 #ifdef TRACE_ENTRY_EXIT_POINT // MACRO IN MMP FILE |
|
142 #define TRACE_ENTRY_POINT TRACE_FUNC_ENTRY_DEBUG_PRINT |
|
143 #define TRACE_EXIT_POINT TRACE_FUNC_EXIT_DEBUG_PRINT |
|
144 #else |
|
145 #define TRACE_ENTRY_POINT |
|
146 #define TRACE_EXIT_POINT |
|
147 #endif |
|
148 |
|
149 #else |
|
150 #define TRACE_ENTRY_POINT |
|
151 #define TRACE_EXIT_POINT |
|
152 |
|
153 #endif // _DEBUG |
|
154 |
|
155 #endif // PIM_TRACE_H |
|
156 |
|
157 |
|
158 // End of File |