persistentstorage/sql/SRC/Common/Trace/UTraceSql.h
branchRCL_3
changeset 24 cc28652e0254
parent 0 08ec8eefde2f
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
       
     1 // Copyright (c) 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 UTRACESQL_H
       
    17 #define UTRACESQL_H
       
    18 
       
    19 #if defined  SQLSRV_ENABLE_TRACE
       
    20 //If this header is included from Sqlsrv.exe then use the UID3 from that process
       
    21 #define EXECUTABLE_DEFAULT_MODULEUID 0x10281E17
       
    22 #define SQL_ENABLE_TRACE
       
    23 
       
    24 #elif defined SQLDB_ENABLE_TRACE  
       
    25 //If this header is included from Sqldb.dll then use the UID3 from that process
       
    26 #define EXECUTABLE_DEFAULT_MODULEUID 0x10281E18
       
    27 #define SQL_ENABLE_TRACE
       
    28 
       
    29 #elif defined SQLITELIB_ENABLE_TRACE
       
    30 //If this header is included from Sqlite.lib then use the UID3 from that process
       
    31 #define EXECUTABLE_DEFAULT_MODULEUID 0x10281E19
       
    32 #define SQL_ENABLE_TRACE
       
    33 
       
    34 #endif //SQLSRV_ENABLE_TRACE, SQLDB_ENABLE_TRACE, SQLITELIB_ENABLE_TRACE 
       
    35 
       
    36 #ifdef SQL_ENABLE_TRACE
       
    37 
       
    38 //The UTF header can only be included after EXECUTABLE_DEFAULT_MODULEUID is defined  
       
    39 #include <e32utf.h>
       
    40 
       
    41 /**
       
    42 Enable this macro to compile in the SQL trace points that trace function leaves and panics.  
       
    43 These traces can be used to assist debugging in client applications and the Symbian SQL.
       
    44 
       
    45 @SymTraceMacro
       
    46 */
       
    47 #undef SYMBIAN_TRACE_SQL_ERR
       
    48 
       
    49 /**
       
    50 Enable this macro to compile in the SQL trace points that trace exported functions and certain 
       
    51 porting layer functions entry and exit. From the timestamps of these trace, the total time spent 
       
    52 in these functions can be worked out. 
       
    53 These traces are particularly useful for performance investigations.
       
    54 
       
    55 @SymTraceMacro
       
    56 */
       
    57 #undef SYMBIAN_TRACE_SQL_FUNC
       
    58 
       
    59 /**
       
    60 Enable this macro to compile in the SQL trace points that trace the following internal events. 
       
    61 	-	IPC calls send to and serviced by the SQL Server
       
    62 	- 	SQL Server's startup and close
       
    63 	- 	No. of full table scans and sort operation performed by a RSqlStatement object
       
    64 	-	Extra internal information for certain exported and porting layer functions
       
    65 These traces can be used to assist performance and debug investigations
       
    66 
       
    67 @SymTraceMacro
       
    68 */
       
    69 #undef SYMBIAN_TRACE_SQL_EVENTS
       
    70 
       
    71 #endif //SQL_ENABLE_TRACE	
       
    72 
       
    73 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    74 //////////                      		UTrace Related Strings                      //////////////////////////
       
    75 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    76 #ifdef SQL_ENABLE_TRACE
       
    77 
       
    78 #ifdef __SQLTRACE_STRINGS__
       
    79 	#define CONST_LIT8(var, val) extern const TLitC8<sizeof(val)> var = {sizeof(val) - 1, val}
       
    80 	#define CONST_LIT16(var, val) extern const TLitC16<sizeof(L##val)/2> var = {sizeof(L##val)/2 - 1, L##val}
       
    81 #else
       
    82 	#define CONST_LIT8(var, val) extern const TLitC8<sizeof(val)> var
       
    83 	#define CONST_LIT16(var, val) extern const TLitC16<sizeof(L##val)/2> var
       
    84 #endif
       
    85 
       
    86 //File I/O trace format strings
       
    87 CONST_LIT8(KFileRead, 			"Sqlite: Size - %d bytes, File Offset Position - %d,");
       
    88 CONST_LIT8(KFileWrite,			"Sqlite: Size - %d bytes, File Offset Position - %d,");
       
    89 CONST_LIT8(KFileTruncate,		"Sqlite: Size - %d bytes");
       
    90 CONST_LIT8(KFileFileCtr,		"Sqlite: Opeartion Called - %d");
       
    91 CONST_LIT16(KFileOpen,			"Sqlite: Sqlite3_file - 0x%x, Filename - \"%S\"");
       
    92 CONST_LIT16(KFileName,			"Sqlite: Filename - \"%S\"");
       
    93 
       
    94 //Input pararmeter format strings 
       
    95 CONST_LIT8(KStrParam,			"SqlDb: Parameter %d  - \"%S\"");
       
    96 CONST_LIT8(KHexStrParam,		"SqlDb: Parameter 1 - 0x%x, Parameter 2 - \"%S\"");
       
    97 CONST_LIT8(KHexIntParam,		"SqlDb: Parameter 1 - 0x%x, Parameter 2 - %d");
       
    98 CONST_LIT8(KIntParam,			"SqlDb: Parameter 1  - %d");
       
    99 CONST_LIT8(KIntSizeParam,		"SqlDb: Parameter 1 - %d, Parameter %d  - %d bytes");
       
   100 
       
   101 CONST_LIT16(KStrParam16,		"SqlDb: Parameter %d  - \"%S\"");
       
   102 CONST_LIT16(KStrStrParam16,		"SqlDb: Parameter 1 - \"%S\", Parameter 2 - \"%S\"");
       
   103 CONST_LIT16(KHexStrParam16,		"SqlDb: Parameter 1 - 0x%x, Parameter 2 - \"%S\"");
       
   104 CONST_LIT16(KSizeStrParam16,	"SqlDb: Parameter %d - %d bytes, Parameter %d - \"%S\"");
       
   105 CONST_LIT16(KRSqlBlobParam16,	"SqlDb: Parameter 1 - 0x%x, Parameter 2 - \"%S\", Parameter 3 - \"%S\", Parameter 4 - %d, Parameter 5 - \"%S\"");	
       
   106 
       
   107 //IPC request trace format strings
       
   108 CONST_LIT8(KDbMsgStr, 			"SqlDb:  Request - %S Sent to SQL Server");
       
   109 CONST_LIT8(KSrvMsgStr, 			"SqlSrv: Request - %S Recieved by SQL Server");
       
   110 CONST_LIT8(KSrvStmtCreated, 	"SqlSrv: sqlite3_stmt Object 0x%x Created");
       
   111 CONST_LIT8(KSrvStmtStatus,		"SqlSrv: sqlite3_stmt Object 0x%x Destroyed, %d Full Table Scan Performed, %d Sort Performed");
       
   112 
       
   113 //Server startup and close trace format strings
       
   114 CONST_LIT8(KSqlSrvStart,		"SqlSrv: SQL Server Startup");
       
   115 CONST_LIT8(KSqlSrvClose,		"SqlSrv: SQL Server Close");
       
   116 
       
   117 //TSqlUTraceProfiler trace format strings, used to display function entry and exit
       
   118 CONST_LIT8(KProfilerBegin,			"Function Entry:\"%S\", Address - 0x%x");
       
   119 CONST_LIT8(KProfilerEnd,			"Function Exit:\"%S\",  Address - 0x%x");
       
   120 
       
   121 //Panic and leave trace format strings
       
   122 CONST_LIT16(KSqlPanic,			"Sql: Panic %d at %S(%d)");
       
   123 CONST_LIT16(KSqlPanicClient,		"Sql: Panic client %d at %S(%d)");
       
   124 CONST_LIT16(KSqlLeave,			"Sql: Leave error %d at %S(%d)");
       
   125 CONST_LIT8(KSqlSrvPanicClient, 	"SqlSrv ServiceError: Panic Client %d");
       
   126 CONST_LIT8(KSqlSrvError, 		"SqlSrv ServiceError: Error %d");
       
   127 
       
   128 #endif //SQL_ENABLE_TRACE	
       
   129 
       
   130 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   131 //////////              UTrace Related Macro Functions and Class Declarations           ////////////////////
       
   132 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   133 #ifdef SYMBIAN_TRACE_SQL_ERR
       
   134 
       
   135 //This macro should be used to trace errors occurring within Symbian SQL.
       
   136 //To use the macro, insert the full UTF statement as the macro parameter
       
   137 //Works only when SYMBIAN_TRACE_SQL_ERR is enabled. Otherwise it evaluates to zero
       
   138 #define SYMBIAN_TRACE_SQL_ERR_ONLY(c) c
       
   139 
       
   140 #else
       
   141 
       
   142 #define SYMBIAN_TRACE_SQL_ERR_ONLY(c) do {} while(0)
       
   143 #endif //SYMBIAN_TRACE_SQL_ERR
       
   144 
       
   145 
       
   146 #ifdef SYMBIAN_TRACE_SQL_FUNC
       
   147 
       
   148 /**
       
   149 This class is used to help trace function entry and exits within Symbian SQL 
       
   150 Exist only when SYMBIAN_TRACE_SQL_FUNC is enabled.
       
   151 
       
   152 @internalComponent
       
   153 */
       
   154 class TSqlUTraceProfiler
       
   155 	{
       
   156 	public:
       
   157 		TSqlUTraceProfiler(const TAny* aObj, const char* aFunctionStr);
       
   158 		~TSqlUTraceProfiler();
       
   159 	private: 
       
   160 		const TAny* iObj;
       
   161 		TPtrC8 iFunctionStr;
       
   162 	};
       
   163 
       
   164 //This macro should be used to trace function entry and exits within Symbian SQL 
       
   165 //Works only when SYMBIAN_TRACE_SQL_FUNC is enabled. Otherwise it evaluates to zero
       
   166 #define SQLUTRACE_PROFILER(x) TSqlUTraceProfiler _profiler(x, __PRETTY_FUNCTION__)
       
   167 
       
   168 #else
       
   169 
       
   170 #define SQLUTRACE_PROFILER(x) do {} while(0)
       
   171 #endif //SYMBIAN_TRACE_SQL_FUNC
       
   172 
       
   173 #ifdef SYMBIAN_TRACE_SQL_EVENTS
       
   174 
       
   175 //This macro should be used to trace events occurring within Symbian SQL.
       
   176 //To use the macro, insert the full UTF statement as the macro parameter
       
   177 //Works only when SYMBIAN_TRACE_SQL_EVENTS is enabled. Otherwise it evaluates to zero
       
   178 #define SYMBIAN_TRACE_SQL_EVENTS_ONLY(c) c
       
   179 const TPtrC8 GetIPCFuncStr(TInt aFunction);
       
   180 
       
   181 #else
       
   182 
       
   183 #define SYMBIAN_TRACE_SQL_EVENTS_ONLY(c) do {} while(0)
       
   184 #endif //SYMBIAN_TRACE_SQL_EVENTS
       
   185 ////////////////////////////////////////////////////////////////////////////////////////////////////////////	
       
   186 #endif // UTRACESQL_H