What I did the shim for, was Linux system (x86/x86-64) and libsqlite3.so.0 
version 3.26/3.27

Not logging API calls, but logging executed SQL statements (something 
mysql/maria/postgre/oracle/... provide in form of query-log)

My main interest was to inspect SQL statements executed by 3rd party 
application, in environment, where I cannot modify system-provided 
libsqlite3.so.0, closely related to reverse-engineering.

I kind-of expected something as ENV configured DEBUG/LOGGING settings, that 
would apply to the library, but I found nothing like that.

sqlite3_trace_v2 looks promising, I could probably modify the shim to configure 
the trace and use the callback to log API calls where it'd be appropriate.

Still injecting sqlite3_trace_v2 configuration through LD_PRELOAD seems as a 
lot of work, for something, that one could expect from existing library 
implementation.
On 2/13/19 11:00 PM, Warren Young wrote:
On Feb 13, 2019, at 2:10 PM, Marek Sebera <marek.seb...@gmail.com> wrote:

re-compiling system provided library is not an option

What version and system are we talking about?  It matters greatly.  If we’re 
talking about the epochal 3.7.x series, the answers are very different than if 
we’re talking about a version shipped last year.

to log sqlite commands

Every single API call, or only *certain* calls?  And if the latter, which ones?

For example, if you only want to log SQL errors, you can do it with

    sqlite3_config(SQLITE_CONFIG_LOG, …);

If you’re on SQLite v3.14 or higher, you can use the tracing mechanism:

    https://sqlite.org/c3ref/trace_v2.html

That plus sqlite3_expanded_sql() lets you “decompile” the parsed SQL for 
logging purposes.

There are antecedents to those mechanisms, but they don’t work as well.  In old 
versions of SQLite, it’s basically impossible to recover the SQL post hoc, and 
the precompiled SQL is often parameterized in C programs based on SQLite, so 
preaching didn’t work very well, either.

If none of those satisfy, then there are often platform-specific API tracing 
mechanisms for dynamic libraries and such, but that gets you back to my first 
question.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to