utelle / wxsqlite3

wxSQLite3 - SQLite3 database wrapper for wxWidgets (including SQLite3 encryption extension)
http://utelle.github.io/wxsqlite3
Other
598 stars 181 forks source link

Debug mode if SQLite #7

Closed stemsin closed 7 years ago

stemsin commented 8 years ago

What about having SQLite in debug mode?

For this sqlite3secure.c needs to be compiled with -DSQLITE_DEBUG something like

set COMMON_FLAGS=--shared -Os -I. -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DHAVE_USLEEP -DHAVE_READLINE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_HAS_CODEC=1 -DCODEC_TYPE=CODEC_TYPE_AES256 -DSQLITE_CORE -DTHREADSAFE=1 -DSQLITE_DLL=1 -DSQLITE_SECURE_DELETE -DSQLITE_SOUNDEX

gcc %COMMON_FLAGS% sqlite3secure.c -o sqlite3.dll
gcc %COMMON_FLAGS% -DSQLITE_DEBUG sqlite3secure.c -o sqlite3d.dll

and then in makefile.gcc

ifeq ($(USE_DYNAMIC_SQLITE3_LOAD),0)
    ifeq ($(WX_DEBUG),0)
        __SQLITE3_DEP_p = -lsqlite3
    endif
    ifeq ($(WX_DEBUG),1)
        __SQLITE3_DEP_p = -lsqlite3d
    endif
endif

Does it make sense?

utelle commented 8 years ago

I intend to modify all wxSQLite3 build files in such a way that the SQLite library is linked statically with wxSQLite3. This has the advantage that no version mismatch can occur and that it is not possible to plant an insecure SQLite version into a wxSQLite3 application.

For the Visual Studio build files (VS 2010 and above) this has already been done via premake, but for the other build files I still need to adjust the bakefile template.

For Visual Studio the debug mode for the SQLite library is unfortunately of limited use, since the VS debugger is not capable of handling source files with more than 64k lines of code (as is the case for the SQLite amalgamation). I don't know how the situation is for the GCC debugger.

Nevertheless, it probably makes sense to define SQLITE_DEBUG in debug mode (currently missing from the VS build files mentioned above).

stemsin commented 8 years ago

Yes agreed.

Would be also good to have make files for GCC / MiniGW compiler. The version I am using from GIT is 3.0, as 3.1 is VS only.

utelle commented 8 years ago

The build files for wxWidgets 2.8 and 3.0 were generated by bakefile. I have not yet tried to generate build files for wxWidgets 3.1 with bakefile. In fact, bakefile is out-dated and I'd like to get rid of it.

The VS 2010+ build files for 3.0 and 3.1 were generated by premake (which is currently my preferred build file generator). Unfortunately premake5 supports only a limited set of tool chains. However, according to the premake documentation it should be possible to generate GNU makefiles. Maybe you could give it a try and report whether this works for you, although it might require some tweaking of the premake template.

utelle commented 7 years ago

According to the SQLite documentation the compile time option SQLITE_DEBUG enables a vast number of assertions and degrades the performance of SQLite by a factor of 3. IMHO it doesn't make much sense to always activate this option in debug mode for wxSQLite3, since this option is meant for troubleshooting the SQLite library itself.

Maybe I will add it as a configurable option, but definitely not as default.

utelle commented 7 years ago

Configurable option added in commit e0b7b784a6888cf1337151ada07ad6d119e21689.