/ Check-in [ca43812b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved support for OSTRACE on Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ca43812bde499a23244e2860d3ceddc97d29f09e
User & Date: drh 2015-04-29 00:35:07
Context
2015-04-29
16:50
Use sqlite3_malloc64() in place of sqlite3_malloc() internally. check-in: 48f553b0 user: drh tags: trunk
00:35
Improved support for OSTRACE on Windows. check-in: ca43812b user: drh tags: trunk
2015-04-28
23:34
Revise when the sqlite3ErrName() function is defined. Closed-Leaf check-in: 9e593fb3 user: mistachkin tags: winTest
14:49
Update the test/fuzzdata1.txt file with the latest cases discovered by AFL. check-in: f2063f53 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.msc.

   143    143   !ENDIF
   144    144   
   145    145   # Set this to non-0 to use the Win32 native heap subsystem.
   146    146   #
   147    147   !IFNDEF WIN32HEAP
   148    148   WIN32HEAP = 0
   149    149   !ENDIF
          150  +
          151  +# Set this to non-0 to enable OSTRACE() macros, which can be useful when
          152  +# debugging.
          153  +#
          154  +!IFNDEF OSTRACE
          155  +OSTRACE = 0
          156  +!ENDIF
   150    157   
   151    158   # Set this to one of the following values to enable various debugging
   152    159   # features.  Each level includes the debugging options from the previous
   153    160   # levels.  Currently, the recognized values for DEBUG are:
   154    161   #
   155    162   # 0 == NDEBUG: Disables assert() and other runtime diagnostics.
   156    163   # 1 == SQLITE_ENABLE_API_ARMOR: extra attempts to detect misuse of the API.
................................................................................
   490    497   !ENDIF
   491    498   
   492    499   !IF $(DEBUG)>2
   493    500   TCC = $(TCC) -DSQLITE_DEBUG
   494    501   RCC = $(RCC) -DSQLITE_DEBUG
   495    502   !ENDIF
   496    503   
   497         -!IF $(DEBUG)>4
   498         -TCC = $(TCC) -DSQLITE_DEBUG_OS_TRACE=1
   499         -RCC = $(RCC) -DSQLITE_DEBUG_OS_TRACE=1
          504  +!IF $(DEBUG)>4 || $(OSTRACE)!=0
          505  +TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
          506  +RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
   500    507   !ENDIF
   501    508   
   502    509   !IF $(DEBUG)>5
   503    510   TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE
   504    511   RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE
   505    512   !ENDIF
   506    513   

Changes to src/main.c.

    51     51   
    52     52   /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
    53     53   ** zero if and only if SQLite was compiled with mutexing code omitted due to
    54     54   ** the SQLITE_THREADSAFE compile-time option being set to 0.
    55     55   */
    56     56   int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
    57     57   
           58  +/*
           59  +** When compiling the test fixture or with debugging enabled (on Win32),
           60  +** this variable being set to non-zero will cause OSTRACE macros to emit
           61  +** extra diagnostic information.
           62  +*/
           63  +#ifdef SQLITE_HAVE_OS_TRACE
           64  +# ifndef SQLITE_DEBUG_OS_TRACE
           65  +#   define SQLITE_DEBUG_OS_TRACE 0
           66  +# endif
           67  +  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
           68  +#endif
           69  +
    58     70   #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
    59     71   /*
    60     72   ** If the following function pointer is not NULL and if
    61     73   ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
    62     74   ** I/O active are written using this function.  These messages
    63     75   ** are intended for debugging activity only.
    64     76   */
................................................................................
  1190   1202     }
  1191   1203   }
  1192   1204   
  1193   1205   /*
  1194   1206   ** Return a static string containing the name corresponding to the error code
  1195   1207   ** specified in the argument.
  1196   1208   */
  1197         -#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || defined(SQLITE_TEST)
         1209  +#if defined(SQLITE_NEED_ERR_NAME)
  1198   1210   const char *sqlite3ErrName(int rc){
  1199   1211     const char *zName = 0;
  1200   1212     int i, origRc = rc;
  1201   1213     for(i=0; i<2 && zName==0; i++, rc &= 0xff){
  1202   1214       switch( rc ){
  1203   1215         case SQLITE_OK:                 zName = "SQLITE_OK";                break;
  1204   1216         case SQLITE_ERROR:              zName = "SQLITE_ERROR";             break;

Changes to src/os_common.h.

    25     25   ** macro to SQLITE_DEBUG and some older makefiles have not yet made the
    26     26   ** switch.  The following code should catch this problem at compile-time.
    27     27   */
    28     28   #ifdef MEMORY_DEBUG
    29     29   # error "The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead."
    30     30   #endif
    31     31   
    32         -#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
    33         -# ifndef SQLITE_DEBUG_OS_TRACE
    34         -#   define SQLITE_DEBUG_OS_TRACE 0
    35         -# endif
    36         -  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
    37         -# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
    38         -#else
    39         -# define OSTRACE(X)
    40         -#endif
    41         -
    42     32   /*
    43     33   ** Macros for performance tracing.  Normally turned off.  Only works
    44     34   ** on i486 hardware.
    45     35   */
    46     36   #ifdef SQLITE_PERFORMANCE_TRACE
    47     37   
    48     38   /* 

Changes to src/os_unix.c.

   637    637   #ifdef SQLITE_DEBUG
   638    638   static int unixMutexHeld(void) {
   639    639     return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
   640    640   }
   641    641   #endif
   642    642   
   643    643   
   644         -#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
          644  +#ifdef SQLITE_HAVE_OS_TRACE
   645    645   /*
   646    646   ** Helper function for printing out trace information from debugging
   647    647   ** binaries. This returns the string representation of the supplied
   648    648   ** integer lock-type.
   649    649   */
   650    650   static const char *azFileLock(int eFileLock){
   651    651     switch( eFileLock ){

Changes to src/os_win.c.

  2753   2753   #ifndef SQLITE_NO_SYNC
  2754   2754     /*
  2755   2755     ** Used only when SQLITE_NO_SYNC is not defined.
  2756   2756      */
  2757   2757     BOOL rc;
  2758   2758   #endif
  2759   2759   #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \
  2760         -    (defined(SQLITE_TEST) && defined(SQLITE_DEBUG))
         2760  +    defined(SQLITE_HAVE_OS_TRACE)
  2761   2761     /*
  2762   2762     ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or
  2763   2763     ** OSTRACE() macros.
  2764   2764      */
  2765   2765     winFile *pFile = (winFile*)id;
  2766   2766   #else
  2767   2767     UNUSED_PARAMETER(id);
................................................................................
  3430   3430       void *pMap;
  3431   3431     } *aRegion;
  3432   3432     DWORD lastErrno;           /* The Windows errno from the last I/O error */
  3433   3433   
  3434   3434     int nRef;                  /* Number of winShm objects pointing to this */
  3435   3435     winShm *pFirst;            /* All winShm objects pointing to this */
  3436   3436     winShmNode *pNext;         /* Next in list of all winShmNode objects */
  3437         -#ifdef SQLITE_DEBUG
         3437  +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  3438   3438     u8 nextShmId;              /* Next available winShm.id value */
  3439   3439   #endif
  3440   3440   };
  3441   3441   
  3442   3442   /*
  3443   3443   ** A global array of all winShmNode objects.
  3444   3444   **
................................................................................
  3461   3461   */
  3462   3462   struct winShm {
  3463   3463     winShmNode *pShmNode;      /* The underlying winShmNode object */
  3464   3464     winShm *pNext;             /* Next winShm with the same winShmNode */
  3465   3465     u8 hasMutex;               /* True if holding the winShmNode mutex */
  3466   3466     u16 sharedMask;            /* Mask of shared locks held */
  3467   3467     u16 exclMask;              /* Mask of exclusive locks held */
  3468         -#ifdef SQLITE_DEBUG
         3468  +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  3469   3469     u8 id;                     /* Id of this connection with its winShmNode */
  3470   3470   #endif
  3471   3471   };
  3472   3472   
  3473   3473   /*
  3474   3474   ** Constants used for locking
  3475   3475   */
................................................................................
  3652   3652         rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
  3653   3653       }
  3654   3654       if( rc ) goto shm_open_err;
  3655   3655     }
  3656   3656   
  3657   3657     /* Make the new connection a child of the winShmNode */
  3658   3658     p->pShmNode = pShmNode;
  3659         -#ifdef SQLITE_DEBUG
         3659  +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  3660   3660     p->id = pShmNode->nextShmId++;
  3661   3661   #endif
  3662   3662     pShmNode->nRef++;
  3663   3663     pDbFd->pShm = p;
  3664   3664     winShmLeaveMutex();
  3665   3665   
  3666   3666     /* The reference count on pShmNode has already been incremented under

Changes to src/printf.c.

  1055   1055     if( sqlite3GlobalConfig.xLog ){
  1056   1056       va_start(ap, zFormat);
  1057   1057       renderLogMsg(iErrCode, zFormat, ap);
  1058   1058       va_end(ap);
  1059   1059     }
  1060   1060   }
  1061   1061   
  1062         -#if defined(SQLITE_DEBUG)
         1062  +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  1063   1063   /*
  1064   1064   ** A version of printf() that understands %lld.  Used for debugging.
  1065   1065   ** The printf() built into some versions of windows does not understand %lld
  1066   1066   ** and segfaults if you give it a long long int.
  1067   1067   */
  1068   1068   void sqlite3DebugPrintf(const char *zFormat, ...){
  1069   1069     va_list ap;

Changes to src/sqliteInt.h.

   358    358   # define ALWAYS(X)      ((X)?1:(assert(0),0))
   359    359   # define NEVER(X)       ((X)?(assert(0),1):0)
   360    360   #else
   361    361   # define ALWAYS(X)      (X)
   362    362   # define NEVER(X)       (X)
   363    363   #endif
   364    364   
          365  +/*
          366  +** Declarations used for tracing the operating system interfaces.
          367  +*/
          368  +#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
          369  +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
          370  +  extern int sqlite3OSTrace;
          371  +# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
          372  +# define SQLITE_HAVE_OS_TRACE
          373  +#else
          374  +# define OSTRACE(X)
          375  +# undef  SQLITE_HAVE_OS_TRACE
          376  +#endif
          377  +
          378  +/*
          379  +** Is the sqlite3ErrName() function needed in the build?  Currently,
          380  +** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
          381  +** OSTRACE is enabled), and by several "test*.c" files (which are
          382  +** compiled using SQLITE_TEST).
          383  +*/
          384  +#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
          385  +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
          386  +# define SQLITE_NEED_ERR_NAME
          387  +#else
          388  +# undef  SQLITE_NEED_ERR_NAME
          389  +#endif
          390  +
   365    391   /*
   366    392   ** Return true (non-zero) if the input is an integer that is too large
   367    393   ** to fit in 32-bits.  This macro is used inside of various testcase()
   368    394   ** macros to verify that we have tested SQLite for large-file support.
   369    395   */
   370    396   #define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)
   371    397   
................................................................................
  3149   3175   #define SQLITE_PRINTF_INTERNAL 0x01
  3150   3176   #define SQLITE_PRINTF_SQLFUNC  0x02
  3151   3177   void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
  3152   3178   void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
  3153   3179   char *sqlite3MPrintf(sqlite3*,const char*, ...);
  3154   3180   char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
  3155   3181   char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
  3156         -#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
         3182  +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  3157   3183     void sqlite3DebugPrintf(const char*, ...);
  3158   3184   #endif
  3159   3185   #if defined(SQLITE_TEST)
  3160   3186     void *sqlite3TestTextToPtr(const char*);
  3161   3187   #endif
  3162   3188   
  3163   3189   #if defined(SQLITE_DEBUG)
................................................................................
  3496   3522   int sqlite3DecOrHexToI64(const char*, i64*);
  3497   3523   void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
  3498   3524   void sqlite3Error(sqlite3*,int);
  3499   3525   void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
  3500   3526   u8 sqlite3HexToInt(int h);
  3501   3527   int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
  3502   3528   
  3503         -#if defined(SQLITE_TEST) 
         3529  +#if defined(SQLITE_NEED_ERR_NAME)
  3504   3530   const char *sqlite3ErrName(int);
  3505   3531   #endif
  3506   3532   
  3507   3533   const char *sqlite3ErrStr(int);
  3508   3534   int sqlite3ReadSchema(Parse *pParse);
  3509   3535   CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
  3510   3536   CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);