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