1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/debuglog/DEBUGLOG.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,190 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __DEBUGLOG_H__
1.20 +#define __DEBUGLOG_H__
1.21 +
1.22 +#pragma warning( disable : 4710 ) //function abc not expanded
1.23 +
1.24 +#include "../SERVER/w32cmd.h"
1.25 +
1.26 +typedef TBuf<32> TShortBuf;
1.27 +typedef TBuf<64> TLongBuf;
1.28 +
1.29 +enum {LogTBufSize=0xA0};
1.30 +
1.31 +
1.32 +class TDebugLogOverflow : public TDes16Overflow
1.33 + {
1.34 +public:
1.35 + inline TDebugLogOverflow();
1.36 + inline void Reset();
1.37 + inline TBool IsError();
1.38 + //Pure virtual function from TDesNnOverflow
1.39 + void Overflow(TDes &aDes);
1.40 +private:
1.41 + TBool iError;
1.42 + };
1.43 +
1.44 +class TWsDecoder
1.45 + {
1.46 +public:
1.47 + enum {ENewClientClass=0x9999};
1.48 + union TWsCmdUnion
1.49 + {
1.50 + const TAny *any;
1.51 + TWsClCmdUnion client;
1.52 + TWsWinCmdUnion window;
1.53 + TWsGcCmdUnion gc;
1.54 + TWsSdCmdUnion sd;
1.55 + TWsAnimDllCmdUnion anim;
1.56 + };
1.57 + TDesC &CommandBuf(TInt aApp);
1.58 + TDesC &Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.59 + TDesC &CommandReply(TInt aData);
1.60 + TDesC &CommandReplyBuf(const TDesC8 &aDes);
1.61 + TDesC &CommandReplyBuf(const TDesC16 &aDes);
1.62 + TDesC &NewClient(TUint aConnectionHandle);
1.63 + TDesC &SignalEvent(TInt aApp);
1.64 + TDesC &Panic(TInt aApp, TInt aReason);
1.65 + TDesC &MiscMessage(const TDesC &aFormat,TInt aParam);
1.66 + void Disable();
1.67 + void Enable();
1.68 +private:
1.69 + void UnKnown();
1.70 + void UnKnownOpcode(TBuf<LogTBufSize> &aText, TInt aOpcode);
1.71 + void UnKnownReplyBuf(TBuf<LogTBufSize> &aText, TInt aOpcode);
1.72 + void AppendPoint(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8);
1.73 + void AppendRect(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8);
1.74 + void AppendDesc(TBuf<LogTBufSize> &aText, const TDesC8 *aReplyDes8);
1.75 + void AppendDesc(TBuf<LogTBufSize> &aText, const TDesC16 *aReplyDes16);
1.76 + void decodeWindow(TBuf<LogTBufSize> &aText,TInt aOpcode,const TAny *aCmdData);
1.77 + void DecodeWindowGroup(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.78 + void DecodeClient(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.79 + void DecodeWindow(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.80 + void DecodeGc(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.81 + void DecodeGc1(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData);
1.82 + void DecodeGc2(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData);
1.83 + void DecodeGc3(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData);
1.84 + void DecodeScreenDevice(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.85 + void DecodeAnimDll(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.86 + void DecodeSpriteBase(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.87 + void DecodeBitmap(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.88 + void DecodeDirect(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.89 + void DecodeClick(TBuf<LogTBufSize> &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.90 + void ReplyBufWindowGroup(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText);
1.91 + void ReplyBufWindow(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText);
1.92 + void ReplyBufClient(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText);
1.93 + void ReplyBufScreenDevice(TBuf<LogTBufSize> &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText);
1.94 + TDesC &commandDetails(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.95 + TDesC &eventDetails(const TWsEvent *aWsEvent);
1.96 + TDesC &eventDetails(const TRawEvent *aEvent);
1.97 + TDesC &replyBufDetails(TInt aClass, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText);
1.98 +private:
1.99 + TBuf<LogTBufSize> iEventDetailsText;
1.100 + TBuf<LogTBufSize> iCommandDetailsText;
1.101 + TBuf<LogTBufSize> iText;
1.102 + TUint iCommandCount;
1.103 + TUint iEventCount;
1.104 + TInt iRequestFuncClass;
1.105 + TInt iHandle;
1.106 + TInt iPrevOpcode;
1.107 + TDebugLogOverflow iOverflowHandler;
1.108 + };
1.109 +
1.110 +class TDebugLogTextHandler
1.111 + {
1.112 +public:
1.113 + enum TArrayType
1.114 + {
1.115 + EInt,
1.116 + ERgb
1.117 + };
1.118 + static void Append(TDes &aBuf1, const TDesC &aBuf2);
1.119 + static void TestAppend();
1.120 + static TBuf<20> FormatBool(TBool aBool);
1.121 + static TBuf<32> FormatPoint(const TPoint &aPoint);
1.122 + static TBuf<32> FormatSize(const TSize &aSize);
1.123 + static TBuf<64> FormatRect(const TRect &aRect);
1.124 + static TBuf<40> FormatRgb(const TRgb &aRgb);
1.125 + static TBuf<20> PointerEventType(TPointerEvent::TType aType);
1.126 + static TBuf<LogTBufSize> FormatArray(TArrayType aArrayType, const TUint8 *aArrayPtr, TUint aNumElems);
1.127 +private:
1.128 + static TBuf<0x20> formatArrayElement(TArrayType aArrayType, const TUint8 *aArrayPtr);
1.129 + static void panic(TInt aReason);
1.130 + };
1.131 +
1.132 +class CDebugLogDevice : public CBase
1.133 + {
1.134 +public:
1.135 + virtual void ConstructL(TBool aIsFirst, TDesC &aParams)=0;
1.136 + virtual void WriteToLogL(const TDesC &aDes, const TDesC &aDes2)=0;
1.137 + virtual void WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)=0;
1.138 + };
1.139 +
1.140 +class CDebugLog: public CDebugLogBase
1.141 + {
1.142 +private:
1.143 + enum {KNumProfiles=10};
1.144 +public:
1.145 + IMPORT_C CDebugLog(CDebugLogDevice *aDevice);
1.146 + ~CDebugLog();
1.147 + IMPORT_C void ConstructL(TBool aIsFirst, TDesC &aParams);
1.148 + //Pure virtual functions from CDebugLogBase
1.149 + void CommandBuf(TInt aApp);
1.150 + void Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle);
1.151 + void NewClient(TUint aConnectionHandle);
1.152 + void Reply(TInt aData);
1.153 + void ReplyBuf(const TDesC8 &aDes);
1.154 + void ReplyBuf(const TDesC16 &aDes);
1.155 + void SignalEvent(TInt aApp);
1.156 + void Panic(TInt aApp, TInt aReason);
1.157 + void MiscMessage(TInt aPriority,const TDesC &aFmt,TInt aParam=0);
1.158 + void HeapDump();
1.159 + void SetLoggingLevel(TInt aLevel);
1.160 + void IniFileSettingRead(TInt aScreen, const TDesC& aVarName, TBool aFound, const TDesC& aResult);
1.161 +
1.162 +private:
1.163 + void AppendProfileNum(TDes &aDes, TInt aNum);
1.164 + void AppendProfileCount(TDes &aDes, TInt aNum);
1.165 + void LogProfiles();
1.166 + void WriteToLog(const TDesC &aDes,TInt aLevel=ELogEverything);
1.167 + void MiscMessage(const TDesC &aFmt,TInt aParam=0);
1.168 +
1.169 +private:
1.170 + CDebugLogDevice *iDevice;
1.171 + TWsDecoder iWsDecoder;
1.172 + TBool iIsDisabled;
1.173 + TInt iErr;
1.174 + TTime iPrevTime;
1.175 + TInt iExtraLen;
1.176 + TInt iLevel; //The current logging level
1.177 + TInt iLastApp;
1.178 + };
1.179 +
1.180 +GLREF_C TInt hHandleToValue(TUint32 handle);
1.181 +
1.182 +
1.183 +// Inline functions
1.184 +/*TDebugLogOverflow*/
1.185 +inline TDebugLogOverflow::TDebugLogOverflow() :iError(EFalse)
1.186 + {}
1.187 +inline void TDebugLogOverflow::Reset()
1.188 + {iError=EFalse;}
1.189 +inline TBool TDebugLogOverflow::IsError()
1.190 + {return iError;}
1.191 +
1.192 +#endif
1.193 +