|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __DEBUGLOG_H__ |
|
17 #define __DEBUGLOG_H__ |
|
18 |
|
19 #pragma warning( disable : 4710 ) //function abc not expanded |
|
20 |
|
21 #include "../SERVER/w32cmd.h" |
|
22 |
|
23 typedef TBuf<32> TShortBuf; |
|
24 typedef TBuf<64> TLongBuf; |
|
25 |
|
26 enum {LogTBufSize=0xA0}; |
|
27 |
|
28 |
|
29 class TDebugLogOverflow : public TDes16Overflow |
|
30 { |
|
31 public: |
|
32 inline TDebugLogOverflow(); |
|
33 inline void Reset(); |
|
34 inline TBool IsError(); |
|
35 //Pure virtual function from TDesNnOverflow |
|
36 void Overflow(TDes &aDes); |
|
37 private: |
|
38 TBool iError; |
|
39 }; |
|
40 |
|
41 class TWsDecoder |
|
42 { |
|
43 public: |
|
44 enum {ENewClientClass=0x9999}; |
|
45 union TWsCmdUnion |
|
46 { |
|
47 const TAny *any; |
|
48 TWsClCmdUnion client; |
|
49 TWsWinCmdUnion window; |
|
50 TWsGcCmdUnion gc; |
|
51 TWsSdCmdUnion sd; |
|
52 TWsAnimDllCmdUnion anim; |
|
53 }; |
|
54 TDesC &CommandBuf(TInt aApp); |
|
55 TDesC &Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
56 TDesC &CommandReply(TInt aData); |
|
57 TDesC &CommandReplyBuf(const TDesC8 &aDes); |
|
58 TDesC &CommandReplyBuf(const TDesC16 &aDes); |
|
59 TDesC &NewClient(TUint aConnectionHandle); |
|
60 TDesC &SignalEvent(TInt aApp); |
|
61 TDesC &Panic(TInt aApp, TInt aReason); |
|
62 TDesC &MiscMessage(const TDesC &aFormat,TInt aParam); |
|
63 void Disable(); |
|
64 void Enable(); |
|
65 private: |
|
66 void UnKnown(); |
|
67 void UnKnownOpcode(TBuf<LogTBufSize> &aText, TInt aOpcode); |
|
68 void UnKnownReplyBuf(TBuf<LogTBufSize> &aText, TInt aOpcode); |
|
69 void AppendPoint(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8); |
|
70 void AppendRect(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8); |
|
71 void AppendDesc(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8); |
|
72 void AppendDesc(TBuf<LogTBufSize> &aText, const TDesC16 *aReplyDes16); |
|
73 void decodeWindow(TBuf<LogTBufSize> &aText,TInt aOpcode,const TAny *aCmdData); |
|
74 void DecodeWindowGroup(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
75 void DecodeClient(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
76 void DecodeWindow(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
77 void DecodeGc(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
78 void DecodeGc1(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData); |
|
79 void DecodeGc2(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData); |
|
80 void DecodeGc3(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData); |
|
81 void DecodeScreenDevice(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
82 void DecodeAnimDll(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
83 void DecodeSpriteBase(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
84 void DecodeBitmap(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
85 void DecodeDirect(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
86 void DecodeClick(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
87 void ReplyBufWindowGroup(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); |
|
88 void ReplyBufWindow(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); |
|
89 void ReplyBufClient(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); |
|
90 void ReplyBufScreenDevice(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); |
|
91 TDesC &commandDetails(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
92 TDesC &eventDetails(const TWsEvent *aWsEvent); |
|
93 TDesC &eventDetails(const TRawEvent *aEvent); |
|
94 TDesC &replyBufDetails(TInt aClass, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); |
|
95 private: |
|
96 TBuf<LogTBufSize> iEventDetailsText; |
|
97 TBuf<LogTBufSize> iCommandDetailsText; |
|
98 TBuf<LogTBufSize> iText; |
|
99 TUint iCommandCount; |
|
100 TUint iEventCount; |
|
101 TInt iRequestFuncClass; |
|
102 TInt iHandle; |
|
103 TInt iPrevOpcode; |
|
104 TDebugLogOverflow iOverflowHandler; |
|
105 }; |
|
106 |
|
107 class TDebugLogTextHandler |
|
108 { |
|
109 public: |
|
110 enum TArrayType |
|
111 { |
|
112 EInt, |
|
113 ERgb |
|
114 }; |
|
115 static void Append(TDes &aBuf1, const TDesC &aBuf2); |
|
116 static void TestAppend(); |
|
117 static TBuf<20> FormatBool(TBool aBool); |
|
118 static TBuf<32> FormatPoint(const TPoint &aPoint); |
|
119 static TBuf<32> FormatSize(const TSize &aSize); |
|
120 static TBuf<64> FormatRect(const TRect &aRect); |
|
121 static TBuf<40> FormatRgb(const TRgb &aRgb); |
|
122 static TBuf<20> PointerEventType(TPointerEvent::TType aType); |
|
123 static TBuf<LogTBufSize> FormatArray(TArrayType aArrayType, const TUint8 *aArrayPtr, TUint aNumElems); |
|
124 private: |
|
125 static TBuf<0x20> formatArrayElement(TArrayType aArrayType, const TUint8 *aArrayPtr); |
|
126 static void panic(TInt aReason); |
|
127 }; |
|
128 |
|
129 class CDebugLogDevice : public CBase |
|
130 { |
|
131 public: |
|
132 virtual void ConstructL(TBool aIsFirst, TDesC &aParams)=0; |
|
133 virtual void WriteToLogL(const TDesC &aDes, const TDesC &aDes2)=0; |
|
134 virtual void WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)=0; |
|
135 }; |
|
136 |
|
137 class CDebugLog: public CDebugLogBase |
|
138 { |
|
139 private: |
|
140 enum {KNumProfiles=10}; |
|
141 public: |
|
142 IMPORT_C CDebugLog(CDebugLogDevice *aDevice); |
|
143 ~CDebugLog(); |
|
144 IMPORT_C void ConstructL(TBool aIsFirst, TDesC &aParams); |
|
145 //Pure virtual functions from CDebugLogBase |
|
146 void CommandBuf(TInt aApp); |
|
147 void Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); |
|
148 void NewClient(TUint aConnectionHandle); |
|
149 void Reply(TInt aData); |
|
150 void ReplyBuf(const TDesC8 &aDes); |
|
151 void ReplyBuf(const TDesC16 &aDes); |
|
152 void SignalEvent(TInt aApp); |
|
153 void Panic(TInt aApp, TInt aReason); |
|
154 void MiscMessage(TInt aPriority,const TDesC &aFmt,TInt aParam=0); |
|
155 void HeapDump(); |
|
156 void SetLoggingLevel(TInt aLevel); |
|
157 void IniFileSettingRead(TInt aScreen, const TDesC& aVarName, TBool aFound, const TDesC& aResult); |
|
158 |
|
159 private: |
|
160 void AppendProfileNum(TDes &aDes, TInt aNum); |
|
161 void AppendProfileCount(TDes &aDes, TInt aNum); |
|
162 void LogProfiles(); |
|
163 void WriteToLog(const TDesC &aDes,TInt aLevel=ELogEverything); |
|
164 void MiscMessage(const TDesC &aFmt,TInt aParam=0); |
|
165 |
|
166 private: |
|
167 CDebugLogDevice *iDevice; |
|
168 TWsDecoder iWsDecoder; |
|
169 TBool iIsDisabled; |
|
170 TInt iErr; |
|
171 TTime iPrevTime; |
|
172 TInt iExtraLen; |
|
173 TInt iLevel; //The current logging level |
|
174 TInt iLastApp; |
|
175 }; |
|
176 |
|
177 GLREF_C TInt hHandleToValue(TUint32 handle); |
|
178 |
|
179 |
|
180 // Inline functions |
|
181 /*TDebugLogOverflow*/ |
|
182 inline TDebugLogOverflow::TDebugLogOverflow() :iError(EFalse) |
|
183 {} |
|
184 inline void TDebugLogOverflow::Reset() |
|
185 {iError=EFalse;} |
|
186 inline TBool TDebugLogOverflow::IsError() |
|
187 {return iError;} |
|
188 |
|
189 #endif |
|
190 |