diff -r 5f8e5adbbed9 -r 29cda98b007e engine/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/engine/inc/debug.h Thu Feb 25 14:29:19 2010 +0000 @@ -0,0 +1,419 @@ +/* +* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB +* +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* EmbedDev AB - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// dbg_dp.h +// debug printouts + +/************************************************* + + USAGE + DP("Hi there"); + DP1("My name is %S", &name); + DPV1("My detailed info is %S", &detailedInfo); + DP_MSG(aMsg); + DP_MSG_COMPL(aMsg, r); + DP_EXC(aType); + + CUSTOMISATION + With SUPPORT_DP_CLIENT_SERVER_V2 defined, a + proper opcode type (default TOpcode) needs to + be specified. + + NOTE + This file may be included by many components + within one application and defining something + here will affect all such components. In such + cases it might be better to state a MACRO in + the intended component's MMP file. + +**************************************************/ + +#ifndef ___DBG_DP_H +#define ___DBG_DP_H + +// This file may be included butThese defines may be individual + +//#if defined (_DEBUG) && (__WINS__) +//#if defined _DEBUG +# define SUPPORT_DP_STANDARD +# define SUPPORT_DP_FILE +//#endif + +// #define SUPPORT_RDEBUG_PRINT +// #define SUPPORT_DP_VERBOSE +// #define SUPPORT_DP_THREAD_NAME +// #define SUPPORT_DP_CLIENT_SERVER_V2 +// #define SUPPORT_DP_EXCEPTION +// #define SUPPORT_DP_COMMDB + +// ------------------------------------------------- no need to modify + +#if defined (SUPPORT_RDEBUG_PRINT)\ + || defined (SUPPORT_DP_VERBOSE)\ + || defined(SUPPORT_DP_CLIENT_SERVER_V2)\ + || defined(SUPPORT_DP_EXCEPTION) +# define SUPPORT_DP_STANDARD +#endif + +#if defined(SUPPORT_RDEBUG_PRINT) +# include // RDebug +#endif + +#if defined(SUPPORT_DP_FILE) +# include +#endif + +#if defined(SUPPORT_DP_CLIENT_SERVER_V2) +# include "dbg_cmn.h" // TOpcode +#endif + +#if defined(SUPPORT_DP_COMMDB) +# include // TCommDbConnPref +#endif + +namespace Dbg +{ + +// ------------------------------------------------- file output +#ifdef SUPPORT_DP_FILE +_LIT(KLogDir, "podcatcher"); +_LIT(KLogFile, "debug.log"); +# define DPF(a); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S %s"), &s, L##a); +# define DPF1(a,b); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b); +# define DPF2(a,b,c); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b,c); +# define DPF3(a,b,c,d); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b,c,d); +# define DPF4(a,b,c,d,e); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b,c,d,e); +# define DPF5(a,b,c,d,e,f); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b,c,d,e,f); +# define DPF6(a,b,c,d,e,f,g); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("%S " L##a), &s, b, c, d,e,f,g); +# define HEXDUMP(aHeader, aMargin, aPtr, aLen); RFileLogger::HexDump(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, aHeader, aMargin, aPtr, aLen); +# define DPDT(dt); RFileLogger::WriteFormat(Dbg::KLogDir, Dbg::KLogFile, EFileLoggingModeAppend, _L("DateTime: %d-%d-%d %d:%d:%d "), dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second() ); + +#else +# define DPF(a); +# define DPF1(a,b); +# define DPF2(a,b,c); +# define DPF3(a,b,c,d); +# define DPF4(a,b,c,d,e); +# define DPF5(a,b,c,d,e,f); +# define DPF6(a,b,c,d,e,f,g); +# define HEXDUMP(aHeader, aMargin, aPtr, aLen); +# define DPDT(dt); +#endif +// ------------------------------------------------- standard debugprint +#ifdef SUPPORT_DP_STANDARD + +inline void FormatThreadName(TFullName& aName) +{ + const TChar KLeftBracket('['); + const TChar KScope(':'); + TInt a = aName.LocateReverse(KLeftBracket); + if (a==KErrNotFound) + { return; } + TInt b = aName.Locate(KScope); + if (b==KErrNotFound || b