1 /* |
1 /* |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This material, including documentation and any related computer |
4 * This component and the accompanying materials are made available |
5 * programs, is protected by copyright controlled by Nokia. All |
5 * under the terms of "Eclipse Public License v1.0" |
6 * rights are reserved. Copying, including reproducing, storing |
6 * which accompanies this distribution, and is available |
7 * adapting or translating, any or all of this material requires the |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * prior written consent of Nokia. This material also contains |
|
9 * confidential information which may not be disclosed to others |
|
10 * without the prior written consent of Nokia. |
|
11 * |
8 * |
12 * Initial Contributors: |
9 * Initial Contributors: |
13 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
14 * |
11 * |
15 * Contributors: |
12 * Contributors: |
16 * |
13 * |
17 * Description: Debug macros and declarations. |
14 * Description: Debug macros and declarations. |
18 * |
15 * |
19 */ |
16 */ |
|
17 |
20 |
18 |
21 #ifndef DEBUG_H |
19 #ifndef DEBUG_H |
22 #define DEBUG_H |
20 #define DEBUG_H |
23 |
21 |
24 ////////////////////////////////////////////////////////////////////////////// |
22 ////////////////////////////////////////////////////////////////////////////// |
95 } |
93 } |
96 private: |
94 private: |
97 TPtrC8 iFuncName; |
95 TPtrC8 iFuncName; |
98 }; |
96 }; |
99 // =========================================================================== |
97 // =========================================================================== |
100 #else //Real-time logging |
98 #else //LOG_TO_FILE not defined |
101 // =========================================================================== |
99 // =========================================================================== |
102 #include <e32debug.h> |
100 #include <e32debug.h> |
103 |
101 |
104 // Paramters same as above. |
102 // Paramters same as above. |
105 #define LOG( str ) { RDebug::Printf( "["MODULE_NAME"] %s", str ); } |
103 #define LOG( str ) { RDebug::Printf( "["MODULE_NAME"] %s", str ); } |
125 private: |
123 private: |
126 TPtrC8 iFuncName; |
124 TPtrC8 iFuncName; |
127 }; |
125 }; |
128 #endif // LOG_TO_FILE |
126 #endif // LOG_TO_FILE |
129 |
127 |
130 #define LEAVE( exp ) {volatile TInt err = exp; \ |
128 #define LEAVE( exp ) {volatile TInt err_ = exp; \ |
131 LOG3( "LEAVE(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ |
129 LOG3( "LEAVE(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\ |
132 User::Leave( err );} |
130 User::Leave( err_ );} |
133 |
131 |
134 #define LEAVEIFERROR( exp ) {volatile TInt err = exp; if(err < 0) LEAVE(err);} |
132 #define LEAVEIFERROR( exp ) {volatile TInt err__ = exp; \ |
|
133 if(err__ < 0) LEAVE(err__);} |
135 |
134 |
136 #define PANIC( exp ) {volatile TInt err = exp; \ |
135 #define PANIC( exp ) {volatile TInt err_ = exp; \ |
137 LOG3( "PANIC(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ |
136 LOG3( "PANIC(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\ |
138 User::Panic( KUsbPanicModule, err );} |
137 User::Panic( KUsbPanicModule, err_ );} |
139 |
|
140 |
138 |
141 #define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__)); |
139 #define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__)); |
142 |
140 |
143 #else // _DEBUG |
141 #define ASSERT_PANIC( exp, code ) {if(!(exp)) PANIC(code)} |
|
142 |
|
143 #else // _DEBUG not defined |
144 // =========================================================================== |
144 // =========================================================================== |
145 |
145 |
146 #define LOG( s ) |
146 #define LOG( s ) |
147 #define LOG1( s, v ) |
147 #define LOG1( s, v ) |
148 #define LOG2( s, v1, v2 ) |
148 #define LOG2( s, v1, v2 ) |
149 #define LOG3( s, v1, v2, v3 ) |
149 #define LOG3( s, v1, v2, v3 ) |
150 #define LOG_FUNC_ENTRY |
150 #define LOG_FUNC_ENTRY |
151 #define LOG_FUNC_EXIT |
151 #define LOG_FUNC_EXIT |
152 #define LEAVE( exp ) User::Leave( exp ); |
152 #define LEAVE( exp ) User::Leave( exp ); |
153 #define LEAVEIFERROR( exp ) User::LeaveIfError( exp ); |
153 #define LEAVEIFERROR( exp ) User::LeaveIfError( exp ); |
154 #define PANIC( err ) User::Panic( KUsbPanicModule, err ); |
154 #define PANIC( err ) // in non-debug builds PANICs are silent |
155 #define LOG_FUNC |
155 #define LOG_FUNC |
|
156 #define ASSERT_PANIC( exp, code ) |
156 // =========================================================================== |
157 // =========================================================================== |
157 #endif // _DEBUG |
158 #endif // _DEBUG |
158 // =========================================================================== |
159 // =========================================================================== |
159 #endif // DEBUG_H |
160 #endif // DEBUG_H |
160 |
161 |