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