os/persistentdata/persistentstorage/sql/SRC/Common/SqlAssert.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Common/SqlAssert.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,191 @@
     1.4 +// Copyright (c) 2005-2010 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 __SQLASSERT_H__
    1.20 +#define __SQLASSERT_H__
    1.21 +
    1.22 +#include <e32std.h>
    1.23 +#include "SqlPanic.h"   //TSqlPanic
    1.24 +
    1.25 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.26 +
    1.27 +//Enable _SQLPROFILER if you want to use the TSqlResourceProfiler functions. Do not forget the same macro declaration in os_symbian.cpp file.
    1.28 +
    1.29 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.30 +
    1.31 +//All macros in this header will have a non-void definition only if the OST_TRACE_COMPILER_IN_USE macro
    1.32 +//is defined. 
    1.33 +//In order to get the traces enabled, the OST_TRACE_COMPILER_IN_USE macro has to be defined in
    1.34 +//OstTraceDefinitions.h file. 
    1.35 +//After that, the trace output can be redirected by defining _SQL_RDEBUG_PRINT or specific categories
    1.36 +//of traces can be enabled/disabled.
    1.37 +
    1.38 +//Enable _SQL_RDEBUG_PRINT if you want to redirect the tracing output via RDebug::Print()
    1.39 +//#define _SQL_RDEBUG_PRINT
    1.40 +
    1.41 +//Enable _SQL_BORDER_TRACE_ENABLED if you want to get the entry/exit traces compiled in the binary
    1.42 +//#define _SQL_BORDER_TRACE_ENABLED
    1.43 +
    1.44 +//Enable _SQL_INTERNALS_TRACE_ENABLED if you want to get the internal traces compiled in the binary
    1.45 +//#define _SQL_INTERNALS_TRACE_ENABLED
    1.46 +
    1.47 +//Enable _SQL_BUR_TRACE_ENABLED if you want to get the backup&restore traces compiled in the binary
    1.48 +//#define _SQL_BUR_TRACE_ENABLED
    1.49 +
    1.50 +//Enable _SQL_COMPACT_TRACE_ENABLED if you want to get the background compaction traces compiled in the binary
    1.51 +//#define _SQL_COMPACT_TRACE_ENABLED
    1.52 +
    1.53 +//Enable _SQL_SESSION_TRACE_ENABLED if you want to get the client and server sessions traces compiled in the binary
    1.54 +//#define _SQL_SESSION_TRACE_ENABLED
    1.55 +
    1.56 +//Enable _SQL_AUTHORIZER_TRACE_ENABLED if you want to trace the authorizer parameters
    1.57 +//#define _SQL_AUTHORIZER_TRACE_ENABLED
    1.58 +
    1.59 +//Enable _SQL_BLOB_TRACE_ENABLED if you want to trace the server side BLOB calls
    1.60 +//#define _SQL_BLOB_TRACE_ENABLED
    1.61 +
    1.62 +#ifdef _DEBUG
    1.63 +    //Enable _SQL_PANIC_TRACE_ENABLED if you want to get more detailed output regarding panics
    1.64 +    //#define _SQL_PANIC_TRACE_ENABLED
    1.65 +
    1.66 +    //Enable _SQL_LEAVE_TRACE_ENABLED if you want to get more detailed output regarding leaving locations
    1.67 +    //#define _SQL_LEAVE_TRACE_ENABLED
    1.68 +#endif
    1.69 +
    1.70 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.71 +
    1.72 +//Wrap every string (file name, file path, etc.) you want to trace, in a __SQLPRNSTR()/__SQLPRNSTR8() macro. 
    1.73 +//There is a difference how RDebug::Print() and OstTraceExt<n>() work.
    1.74 +#if defined _SQL_RDEBUG_PRINT
    1.75 +    const TInt KSqlMaxPrnStrLen = 512;    
    1.76 +    #define __SQLPRNSTR(des)  &des
    1.77 +    const TDesC* SqlDes8to16Ptr(const TDesC8& aDes, TDes& aOut);
    1.78 +	#define __SQLPRNSTR8(des, out)  SqlDes8to16Ptr(des, out) 
    1.79 +#else
    1.80 +    #define __SQLPRNSTR(des)  des
    1.81 +    #define __SQLPRNSTR8(des, out) des
    1.82 +#endif
    1.83 +
    1.84 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.85 +
    1.86 +//Forward declarations
    1.87 +class RMessage2;
    1.88 +
    1.89 +/**
    1.90 +Set of useful functions to print diagnostic messages on the console when an error/leaving occurs.
    1.91 +
    1.92 +@internalComponent
    1.93 +*/
    1.94 +class TSqlUtil
    1.95 +	{
    1.96 +	friend void UtilFileNameTest();
    1.97 +	
    1.98 +public:
    1.99 +	static void GetTimeStr(TDes& aWhere);
   1.100 +	static TInt Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle);
   1.101 +	static void Leave(const TText* aFile, TInt aLine, TInt aError, TUint aHandle);
   1.102 +	static TInt LeaveIfError(const TText* aFile, TInt aLine, TInt aError, TUint aHandle);
   1.103 +	static void* LeaveIfNull(const TText* aFile, TInt aLine, void* aPtr, TUint aHandle);
   1.104 +	static TInt PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode, TUint aHandle);
   1.105 +	
   1.106 +private:
   1.107 +	static TPtrC FileName(const TText* aFile);
   1.108 +	
   1.109 +	};
   1.110 +
   1.111 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.112 +
   1.113 +#define __SQLSTRING(str) _S(str)
   1.114 +
   1.115 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.116 +
   1.117 +//__SQLPANIC/__SQLPANIC2 macro is used for printing out additional information when panic occurs in SQL:
   1.118 +//source file name, line number, "this" pointer, panic category.
   1.119 +#define __SQLPANIC(aPanicCode)      TSqlUtil::Panic(__SQLSTRING(__FILE__), __LINE__, aPanicCode, (TUint)this)
   1.120 +#define __SQLPANIC2(aPanicCode)     TSqlUtil::Panic(__SQLSTRING(__FILE__), __LINE__, aPanicCode, 0)
   1.121 +
   1.122 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.123 +
   1.124 +//This macro should be used to leave with "err" error code.
   1.125 +//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
   1.126 +//In release mode only leaves.
   1.127 +#define __SQLLEAVE(err)             TSqlUtil::Leave(__SQLSTRING(__FILE__), __LINE__, err, (TUint)this)
   1.128 +#define __SQLLEAVE2(err)            TSqlUtil::Leave(__SQLSTRING(__FILE__), __LINE__, err, 0)
   1.129 +
   1.130 +//This macro should be used to leave with "err" error code, if the error code is negative.
   1.131 +//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
   1.132 +//In release mode only leaves.
   1.133 +#define __SQLLEAVE_IF_ERROR(err)    TSqlUtil::LeaveIfError(__SQLSTRING(__FILE__), __LINE__, err, (TUint)this)
   1.134 +#define __SQLLEAVE_IF_ERROR2(err)   TSqlUtil::LeaveIfError(__SQLSTRING(__FILE__), __LINE__, err, 0)
   1.135 +
   1.136 +//This macro should be used to leave with KErrNoMemory if "ptr" argument is NULL.
   1.137 +//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
   1.138 +//In release mode only leaves.
   1.139 +#define __SQLLEAVE_IF_NULL(ptr)     TSqlUtil::LeaveIfNull(__SQLSTRING(__FILE__), __LINE__, ptr, (TUint)this)
   1.140 +
   1.141 +//This macro should be used to panic the client and leave if "expr" condition is not satisfied.
   1.142 +//In debug mode prints the file name and the line number where the leaving occurs and then 
   1.143 +//panics the client and leaves.
   1.144 +//In release mode only panics the client and leaves.
   1.145 +#define __SQLPANIC_CLIENT(expr, msg, panicCode)  (void)((expr) || TSqlUtil::PanicClientL(__SQLSTRING(__FILE__), __LINE__, msg, panicCode, (TUint)this))
   1.146 +#define __SQLPANIC_CLIENT2(expr, msg, panicCode) (void)((expr) || TSqlUtil::PanicClientL(__SQLSTRING(__FILE__), __LINE__, msg, panicCode, 0))
   1.147 +
   1.148 +//===================================================================================
   1.149 +
   1.150 +#ifdef _SQL_BORDER_TRACE_ENABLED
   1.151 +    #define SQL_TRACE_BORDER(trace)   trace
   1.152 +#else
   1.153 +    #define SQL_TRACE_BORDER(trace)   do {} while(0)
   1.154 +#endif
   1.155 +
   1.156 +#ifdef _SQL_INTERNALS_TRACE_ENABLED
   1.157 +    #define SQL_TRACE_INTERNALS(trace)   trace
   1.158 +#else
   1.159 +    #define SQL_TRACE_INTERNALS(trace)   do {} while(0)
   1.160 +#endif
   1.161 +
   1.162 +#ifdef _SQL_BUR_TRACE_ENABLED
   1.163 +    #define SQL_TRACE_BUR(trace)   trace
   1.164 +#else
   1.165 +    #define SQL_TRACE_BUR(trace)   do {} while(0)
   1.166 +#endif
   1.167 +
   1.168 +#ifdef _SQL_COMPACT_TRACE_ENABLED
   1.169 +    #define SQL_TRACE_COMPACT(trace)   trace
   1.170 +#else
   1.171 +    #define SQL_TRACE_COMPACT(trace)   do {} while(0)
   1.172 +#endif
   1.173 +
   1.174 +#ifdef _SQL_SESSION_TRACE_ENABLED
   1.175 +    #define SQL_TRACE_SESSION(trace)   trace
   1.176 +#else
   1.177 +    #define SQL_TRACE_SESSION(trace)   do {} while(0)
   1.178 +#endif
   1.179 +
   1.180 +#ifdef _SQL_AUTHORIZER_TRACE_ENABLED
   1.181 +    #define SQL_TRACE_AUTHORIZER(trace)   trace
   1.182 +#else
   1.183 +    #define SQL_TRACE_AUTHORIZER(trace)   do {} while(0)
   1.184 +#endif
   1.185 +
   1.186 +#ifdef _SQL_BLOB_TRACE_ENABLED
   1.187 +    #define SQL_TRACE_BLOB(trace)   trace
   1.188 +#else
   1.189 +    #define SQL_TRACE_BLOB(trace)   do {} while(0)
   1.190 +#endif
   1.191 +
   1.192 +//===================================================================================
   1.193 +
   1.194 +#endif//__SQLASSERT_H__