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