|
1 /* |
|
2 * Copyright (c) 2006 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: This module contains the implementation of RRubyDebug class |
|
15 * member functions. |
|
16 * %version: 3 % |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 #ifdef _DEBUG |
|
35 _LIT( KRubyDebugStart, "START" ); |
|
36 _LIT( KRubyDebugStop, "EXIT" ); |
|
37 _LIT( KRubyDebugLeave, "LEAVE!!!" ); |
|
38 _LIT( KRubyDebugStr, "%S%S %S [F:%S][L:%d][TId:%d]" ); |
|
39 #endif |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 #ifdef _DEBUG |
|
50 // ----------------------------------------------------------------------------- |
|
51 // RRubyDebug::RRubyDebug |
|
52 // C++ constructor |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 |
|
56 inline RRubyDebug::RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL, |
|
57 const TText8* aFunctionName ) |
|
58 : iMsg( aMsg ), iFileName( aFileName ), iLine ( aLine ), iCalledFromL ( aCalledFromL ), iLeave ( EFalse ) |
|
59 { |
|
60 #ifndef RUBY_DISABLE_FUNCTION_NAMES |
|
61 iFunctionName = NULL; |
|
62 // If function name is defined, use it instead of aMsg |
|
63 if( aFunctionName ) |
|
64 { |
|
65 TPtrC8 ptr8Name( aFunctionName ); |
|
66 iFunctionName = HBufC::New( ptr8Name.Length() ); |
|
67 if( iFunctionName ) |
|
68 { |
|
69 // If memory for a 16-bit copy has been allocated successfully |
|
70 iFunctionName->Des().Copy( ptr8Name ); |
|
71 iMsg.Set( *iFunctionName ); |
|
72 } |
|
73 } |
|
74 #endif // RUBY_DISABLE_FUNCTION_NAMES |
|
75 TInt id = RThread().Id(); |
|
76 iCalledFromL = aCalledFromL; |
|
77 if( !iCalledFromL) |
|
78 { |
|
79 RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id ); |
|
80 } |
|
81 else { |
|
82 #ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL |
|
83 // For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL |
|
84 RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id ); |
|
85 #endif |
|
86 } |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // RRubyDebug::~RRubyDebug |
|
91 // Destructor |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 inline RRubyDebug::~RRubyDebug() |
|
95 { |
|
96 if ( !iLeave ) |
|
97 { |
|
98 // This is done only if destructor is NOT called from Release(). |
|
99 // Otherwise the cleanup stack pops this item automatically. |
|
100 TInt id = RThread().Id(); |
|
101 if (!iCalledFromL) |
|
102 { |
|
103 RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStop, &iFileName, iLine, id ); |
|
104 } |
|
105 else |
|
106 { |
|
107 #ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL |
|
108 // For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL |
|
109 RUBY_DEBUG_METHOD( KRubyDebugStr, &KRubyDebugPrefix, &iMsg, &KRubyDebugStop, &iFileName, iLine, id ); |
|
110 #endif |
|
111 } |
|
112 #ifndef RUBY_DISABLE_FUNCTION_NAMES |
|
113 delete iFunctionName; // if any |
|
114 #endif // RUBY_DISABLE_FUNCTION_NAMES |
|
115 CleanupStack::Pop( this ); // E32USER-CBase 90 panic is raised if |
|
116 // this is not the topmost item |
|
117 } |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // RRubyDebug::Release() |
|
122 // Method that makes it possible to push this object into the cleanup stack. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 inline void RRubyDebug::Release() |
|
126 { |
|
127 iLeave = ETrue; |
|
128 TInt id = RThread().Id(); |
|
129 RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugLeave, &iFileName, iLine, id ); |
|
130 #ifndef RUBY_DISABLE_FUNCTION_NAMES |
|
131 delete iFunctionName; // if any |
|
132 #endif // RUBY_DISABLE_FUNCTION_NAMES |
|
133 this->~RRubyDebug(); |
|
134 } |
|
135 #endif |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // RRubyDebug::TTruncateOverflow::Overflow() |
|
139 // Method for ignoring the overflowing part of a debug message. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 inline void RRubyDebug::TTruncateOverflow::Overflow( TDes& /*aDes*/ ) |
|
143 { |
|
144 // We ignore the overflowing part of the descriptor... |
|
145 } |
|
146 |
|
147 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
148 |
|
149 // End of File |