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