|
1 /* |
|
2 * Copyright (c) 2002 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: Definition of debug information. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPHSRVGDEBUGINFO_H |
|
20 #define CPHSRVGDEBUGINFO_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <e32base.h> // TInt, cbase |
|
25 #include "KPhSrvConfigure.h" // Debugging feature defines |
|
26 |
|
27 // MACROS |
|
28 //---------------------------------------------------------------------------- |
|
29 // These macros are for debugging purposes. |
|
30 // Can be enabled or disabled from KPhSrvConfigure.h |
|
31 // If disabled, macros are empty and no additionall resources used. |
|
32 // If Enabled. This class PhSrvDebugInfo is additional load. |
|
33 // Operations are quite heavy weight because use of debug prints and |
|
34 // threads local storage. |
|
35 //---------------------------------------------------------------------------- |
|
36 #ifdef __PHSRV_DEBUG_INFO__ |
|
37 #pragma message("\\PhoneServer\\Inc\\Standard\\KPhSrvConfigure.h(107): Warning: ** DEBUG PRINTS ARE ENABLED! ** ") |
|
38 // For printing only text. |
|
39 #define _DPRINT(l,t) { PhSrvDebugInfo::Print((l), _L(t) ); } |
|
40 // For printing text folloved by number. |
|
41 #define _DDPRINT(l,t,n) { \ |
|
42 TBuf<60> buf; \ |
|
43 buf.Append( _L(t) ); \ |
|
44 buf.AppendNum( (TInt)n ); \ |
|
45 PhSrvDebugInfo::Print((l), buf ); } |
|
46 // For print text followed by text |
|
47 #define _DSPRINT(l,t,s) { \ |
|
48 TBuf<60> buf; \ |
|
49 buf.Append( _L(t) ); \ |
|
50 buf.Append( s.Right(Min(s.Length(), 30 )) ); \ |
|
51 PhSrvDebugInfo::Print( (l), buf ); } |
|
52 #else |
|
53 #define _DPRINT(l,t) |
|
54 #define _DDPRINT(l,t,n) |
|
55 #define _DSPRINT(l,t,s) |
|
56 #endif |
|
57 |
|
58 #if defined __PHSRV_DEBUG_TESTER__ && defined __PhSrv_DEBUG_INFO__ |
|
59 // Init & uninit |
|
60 #ifdef __PHSRV_DEBUG_TESTER_ALWAYS__ |
|
61 #define PHSRV_TESTER_INIT() PhSrvDebugInfo::SetTestMonitorL( ETrue ) |
|
62 #define PHSRV_TESTER_UNINIT() PhSrvDebugInfo::SetTestMonitorL( EFalse ) |
|
63 #else |
|
64 #define PHSRV_TESTER_INIT() |
|
65 #define PHSRV_TESTER_UNINIT() |
|
66 #endif |
|
67 |
|
68 // Enable & disable |
|
69 #define PHSRV_TESTER_ENABLE() PhSrvDebugInfo::SetTestMonitorL( ETrue ) |
|
70 #define PHSRV_TESTER_DISABLE() PhSrvDebugInfo::SetTestMonitorL( EFalse ) |
|
71 |
|
72 // Leave if set. |
|
73 #define PHSRV_TESTER_LEAVE( c, e ) \ |
|
74 { \ |
|
75 PhSrvDebugInfo::TPhSrvDebugTestData _i; PhSrvDebugInfo::GetTestData( _i ); \ |
|
76 if ( _i.iCase == (c) ) \ |
|
77 { \ |
|
78 _i.iDone++; \ |
|
79 PhSrvDebugInfo::SetTestData( _i ); \ |
|
80 User::Leave( (e) ); \ |
|
81 } \ |
|
82 } |
|
83 |
|
84 // Leave if set, reset also. |
|
85 #define PHSRV_TESTER_LEAVERESET( c, e ) \ |
|
86 { \ |
|
87 PhSrvDebugInfo::TPhSrvDebugTestData _i; PhSrvDebugInfo::GetTestData( _i ); \ |
|
88 if ( _i.iCase == (c) ) \ |
|
89 { \ |
|
90 _i.iCase = _i.iDone = 0; \ |
|
91 PhSrvDebugInfo::SetTestData( _i ); \ |
|
92 User::Leave( (e) ); \ |
|
93 } \ |
|
94 } |
|
95 |
|
96 // Leave if set, reset if amounts reached |
|
97 #define PHSRV_TESTER_LEAVERESET3( c, e, a ) \ |
|
98 { \ |
|
99 PhSrvDebugInfo::TPhSrvDebugTestData _i; PhSrvDebugInfo::GetTestData( _i ); \ |
|
100 if ( _i.iCase == (c) ) \ |
|
101 { \ |
|
102 _i.iDone++; \ |
|
103 if ( _i.iDone > (a) ) \ |
|
104 { \ |
|
105 _i.iCase = _i.iDone = 0; \ |
|
106 PhSrvDebugInfo::SetTestData( _i ); \ |
|
107 } \ |
|
108 User::Leave( (e) ); \ |
|
109 } \ |
|
110 } |
|
111 |
|
112 // Set failnext if set, reset |
|
113 #define PHSRV_TESTER_FAILNEXT( c ) \ |
|
114 { \ |
|
115 PhSrvDebugInfo::TPhSrvDebugTestData _i; PhSrvDebugInfo::GetTestData( _i ); \ |
|
116 if ( _i.iCase == (c) ) \ |
|
117 { \ |
|
118 User::__DbgSetAllocFail( RHeap::EUser, RHeap::EFailNext, 1 ); \ |
|
119 } \ |
|
120 } |
|
121 |
|
122 // Reset fail next |
|
123 #define PHSRV_TESTER_FAILNEXT_RESET() User::__DbgSetAllocFail( RHeap::EUser, RHeap::ENone, 1 ) |
|
124 |
|
125 #else |
|
126 |
|
127 // Init & uninit |
|
128 #define PHSRV_TESTER_INIT() |
|
129 #define PHSRV_TESTER_UNINIT() |
|
130 |
|
131 // Enable & disable |
|
132 #define PHSRV_TESTER_ENABLE() |
|
133 #define PHSRV_TESTER_DISABLE() |
|
134 |
|
135 // Leave |
|
136 #define PHSRV_TESTER_LEAVE( c, e ) |
|
137 #define PHSRV_TESTER_LEAVERESET( c, e ) |
|
138 #define PHSRV_TESTER_LEAVERESET3( c, e, a ) |
|
139 #define PHSRV_TESTER_FAILNEXT( c ) |
|
140 #define PHSRV_TESTER_FAILNEXT_RESET() |
|
141 |
|
142 #endif |
|
143 |
|
144 // FORWARD DECLARATIONS |
|
145 class RFs; |
|
146 class RFile; |
|
147 //class CPhSrvDebugTestMonitor; |
|
148 |
|
149 // CLASS DECLARATION |
|
150 |
|
151 /** |
|
152 * Debugging level. From 0-. |
|
153 * 00 None |
|
154 * 01 PhoneEngine, Call |
|
155 * 02 PhoneEngine, Audio |
|
156 * 03 PhoneEngine, Indicators, Services & others |
|
157 * 04 PhoneServer |
|
158 * 05 Phone, logging |
|
159 * 06 Phone, autom. redial. |
|
160 * 07 Phone, |
|
161 * 08 Phone, |
|
162 * 09 |
|
163 * 10 Phone, recovery system & indicators |
|
164 * 11 Phone, ui |
|
165 * |
|
166 * @lib phoneengine |
|
167 * @since 1.2 |
|
168 */ |
|
169 class PhSrvDebugInfo : public CBase |
|
170 { |
|
171 private: |
|
172 NONSHARABLE_CLASS( CPhSrvDebugData ) : public CBase |
|
173 { |
|
174 public: |
|
175 ~CPhSrvDebugData(); |
|
176 |
|
177 void CreateFile(); |
|
178 void ReleaseFile(); |
|
179 TBool IsFile() const; |
|
180 void WriteFile( const TDesC8& aDes ); |
|
181 |
|
182 private: |
|
183 RFs* iFs; |
|
184 RFile* iFile; |
|
185 |
|
186 }; |
|
187 |
|
188 public: // Constructors and destructor |
|
189 |
|
190 |
|
191 /** |
|
192 * Prints text if area set. |
|
193 * |
|
194 * @param aArea area of text. |
|
195 * @param aText text to be printed. |
|
196 */ |
|
197 static void Print( TInt aArea, const TDesC& aText ); |
|
198 |
|
199 |
|
200 |
|
201 private: |
|
202 |
|
203 // Creates debug data. |
|
204 static CPhSrvDebugData* CreateData(); |
|
205 |
|
206 |
|
207 |
|
208 }; |
|
209 #endif |
|
210 // End of File |