|
1 // Copyright (c) 2010 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 #ifndef SQLITEUTIL_H |
|
16 #define SQLITEUTIL_H |
|
17 |
|
18 #include <e32std.h> |
|
19 |
|
20 /** |
|
21 Panic codes - used by asserts in the OS porting layer and the file buffer. |
|
22 |
|
23 @see KPanicCategory |
|
24 |
|
25 @internalComponent |
|
26 */ |
|
27 enum TSqlitePanic |
|
28 { |
|
29 ESqliteOsPanicFsCreationError = 1, |
|
30 ESqliteOsPanicMutexCreationError = 2, |
|
31 ESqliteOsPanicInvalidFs = 3, |
|
32 ESqliteOsPanicNullPls1 = 4, |
|
33 ESqliteOsPanicNullPls2 = 5, |
|
34 ESqliteOsPanicNullPls3 = 6, |
|
35 ESqliteOsPanicNullPls4 = 7, |
|
36 ESqliteOsPanicAssert = 8, |
|
37 ESqliteOsPanicMaxKeysExceeded = 9, |
|
38 ESqliteOsPanicBufferSizeExceeded =10, |
|
39 ESqliteOsPanicNullKey =11, |
|
40 ESqliteOsPanicWsdBufSize =12, |
|
41 ESqliteOsPanicWsdEntryCount =13, |
|
42 ESqliteOsPanicInternalError =19, |
|
43 ESqliteOsPanicNullDbFilePtr =20, |
|
44 ESqliteOsPanicInvalidLock =21, |
|
45 ESqliteOsPanicInvalidMutexType =22, |
|
46 ESqliteOsPanicMutexLockCounter =23, |
|
47 ESqliteOsPanicMutexOwner =24, |
|
48 // |
|
49 EFBufPanicCapacity =101, |
|
50 EFBufPanicNullBuf =102, |
|
51 EFBufPanicBufLen =103, |
|
52 EFBufPanicFilePos =104, |
|
53 EFBufPanicFileSize =105, |
|
54 EFBufPanicFileHandle =106, |
|
55 EFBufPanicFsHandle =107, |
|
56 EFBufPanicMsgHandle =108, |
|
57 EFBufPanicMsgIndex =109, |
|
58 EFBufPanicFileNameLen =110, |
|
59 EFBufPanicNullThis =111, |
|
60 EFBufPanicDirty =112, |
|
61 EFBufPanicNextReadFilePos =113, |
|
62 EFBufPanicNextReadFilePosHits =114, |
|
63 EFBufPanicFileBlockSize =115, |
|
64 }; |
|
65 |
|
66 //////////////////////////////////////////////////////////////////////////////////////////// |
|
67 |
|
68 //All macros in this header will have a non-void definition only if the OST_TRACE_COMPILER_IN_USE macro |
|
69 //is defined. |
|
70 //In order to get the traces enabled, the OST_TRACE_COMPILER_IN_USE macro has to be defined in |
|
71 //OstTraceDefinitions.h file. |
|
72 //After that, the trace output can be redirected by defining _SQL_RDEBUG_PRINT or specific categories |
|
73 //of traces can be enabled/disabled. |
|
74 |
|
75 //Enable _SQLITE_RDEBUG_PRINT if you want to redirect the OS porting layer and file buffer tracing output via RDebug::Print() |
|
76 //#define _SQLITE_RDEBUG_PRINT |
|
77 |
|
78 //Enable _SQLITE_OS_TRACE_ENABLED if you get the OS porting layer traces compiled in the binary |
|
79 //#define _SQLITE_OS_TRACE_ENABLED |
|
80 |
|
81 //Enable _SQLITE_FBUF_TRACE_ENABLED if you get the file buffer traces compiled in the binary |
|
82 //#define _SQLITE_FBUF_TRACE_ENABLED |
|
83 |
|
84 #ifdef _DEBUG |
|
85 //Enable _SQLITE_PANIC_TRACE_ENABLED if you want to get more detailed output regarding panics |
|
86 //#define _SQLITE_PANIC_TRACE_ENABLED |
|
87 #endif |
|
88 |
|
89 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
90 |
|
91 //Wrap every string (file name, file path, etc.) you want to trace, in a __SQLITEPRNSTR()/__SQLITEPRNSTR8() macro. |
|
92 //There is a difference how RDebug::Print() and OstTraceExt<n>() work. |
|
93 #if defined _SQLITE_RDEBUG_PRINT |
|
94 const TInt KSqliteMaxPrnStrLen = 512; |
|
95 #define __SQLITEPRNSTR(des) &des |
|
96 #else |
|
97 #define __SQLITEPRNSTR(des) des |
|
98 #endif |
|
99 |
|
100 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
101 |
|
102 /** |
|
103 Set of useful functions to print diagnostic messages on the console when a panic occurs. |
|
104 |
|
105 @internalComponent |
|
106 */ |
|
107 class TSqliteUtil |
|
108 { |
|
109 public: |
|
110 static TInt Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle); |
|
111 |
|
112 private: |
|
113 static TPtrC FileName(const TText* aFile); |
|
114 |
|
115 }; |
|
116 |
|
117 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 |
|
119 #define __SQLITESTRING(str) _S(str) |
|
120 |
|
121 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 |
|
123 //__SQLITEPANIC/__SQLITEPANIC2 macro is used for printing out additional information when panic occurs in SQLite OS porting layer and the file buffer: |
|
124 //source file name, line number, "this" pointer, panic category. |
|
125 #define __SQLITEPANIC(aPanicCode) TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, (TUint)this) |
|
126 #define __SQLITEPANIC2(aPanicCode) TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, 0) |
|
127 |
|
128 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
129 |
|
130 #ifdef _SQLITE_OS_TRACE_ENABLED |
|
131 #define SQLITE_TRACE_OS(trace) trace |
|
132 #else |
|
133 #define SQLITE_TRACE_OS(trace) do {} while(0) |
|
134 #endif |
|
135 |
|
136 #ifdef _SQLITE_FBUF_TRACE_ENABLED |
|
137 #define SQLITE_TRACE_FBUF(trace) trace |
|
138 #else |
|
139 #define SQLITE_TRACE_FBUF(trace) do {} while(0) |
|
140 #endif |
|
141 |
|
142 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
143 |
|
144 #endif //SQLITEUTIL_H |