Marek Schwarz
Marek Schwarz

Reputation: 608

How to check if sqlite3 is compiled with HAVE_USLEEP

I would like to verify if my sqlite3 binary is compiled with HAVE_USLEEP option.

The compilation option is referred here and here.

I wanted to check it with PRAGMA compile_options; but It does not return HAVE_USLEEP on any of my compilation attempts.

To compile the sqlite I run:

export CFLAGS="-DHAVE_USLEEP"
./configure
make

which gives me a lot of output ending with libtool report which appears to include the -DHAVE_USLEEP

libtool: link: gcc -DHAVE_USLEEP -DSQLITE_OS_UNIX=1 ....

configure also reports usleep present.

However the session with the compiled binary is as follows:

user@pc:~/Downloads/sqlite$ ./sqlite3 
SQLite version 3.31.0 2020-01-07 09:06:43
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> PRAGMA compile_options;
COMPILER=gcc-4.8.4
ENABLE_DBSTAT_VTAB
ENABLE_FTS4
ENABLE_JSON1
ENABLE_RTREE
ENABLE_STMTVTAB
ENABLE_UNKNOWN_SQL_FUNCTION
HAVE_ISNAN
THREADSAFE=1
sqlite> 

I've tried both -DHAVE_USLEEP and -DHAVE_USLEEP=1.

At this point I don't know how to approach this - the DHAVE_USLEEP appears to be passed to the libtool but the option is missing from the report. I've either compiled it without the option (somehow), or the PRAGMA compiled_options does not return the DHAVE_USLEEP. I'm looking for a way to differentiate the states to be able to debug it further.

Thanks for any idea regarding this.

Upvotes: 5

Views: 816

Answers (2)

Alya Gomaa
Alya Gomaa

Reputation: 61

here's how

  1. install GDB (a linux debugger) https://www.tutorialspoint.com/gnu_debugger/installing_gdb.htm
  2. run python3 REPL and leave it open

in another terminal,

  1. get the PID of the running REPL: ps aux | grep python3
  2. in another terminal, attach GDB to the running python REPL (make sure you're root) sudo gdb -p <PID>
  3. try disass __sleep. if you can't find the __sleep function, try this gdb command info functions and try to find a function with "sleep" in it then disass <function_name_you_found>
  4. look for a call to __GI___nanosleep, if you find it, then USLEEP is enabled.

Upvotes: 0

Shawn
Shawn

Reputation: 52589

Just see if the symbol exists in the sqlite library:

$ nm /path/to/your/libsqlite3.a | grep usleep
             U usleep

Upvotes: 1

Related Questions