SQLite

Check-in [85c54a16c7]
Login

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

Overview
Comment:Modify logging code in test_osinst.c. No changes to production code. (CVS 5120)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 85c54a16c7aecea3e0e5040ee8aca06d8b6a2b2b
User & Date: danielk1977 2008-05-12 07:42:20.000
Context
2008-05-12
10:57
Make test function do_ioerr_test more robust. No code changes. (CVS 5121) (check-in: f532692ec9 user: danielk1977 tags: trunk)
07:42
Modify logging code in test_osinst.c. No changes to production code. (CVS 5120) (check-in: 85c54a16c7 user: danielk1977 tags: trunk)
00:32
Use short timeout for locking operations by default to be more in sync with the other platforms. (CVS 5119) (check-in: d00a015dbc user: pweilbacher tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_osinst.c.
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
static void instDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
static void *instDlSym(sqlite3_vfs*,void*, const char *zSymbol);
static void instDlClose(sqlite3_vfs*, void*);
static int instRandomness(sqlite3_vfs*, int nByte, char *zOut);
static int instSleep(sqlite3_vfs*, int microseconds);
static int instCurrentTime(sqlite3_vfs*, double*);

static void binarylog_blob(sqlite3_vfs *, const char *, int); 

static sqlite3_vfs inst_vfs = {
  1,                      /* iVersion */
  sizeof(inst_file),      /* szOsFile */
  INST_MAX_PATHNAME,      /* mxPathname */
  0,                      /* pNext */
  0,                      /* zName */







|







177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
static void instDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
static void *instDlSym(sqlite3_vfs*,void*, const char *zSymbol);
static void instDlClose(sqlite3_vfs*, void*);
static int instRandomness(sqlite3_vfs*, int nByte, char *zOut);
static int instSleep(sqlite3_vfs*, int microseconds);
static int instCurrentTime(sqlite3_vfs*, double*);

static void binarylog_blob(sqlite3_vfs *, const char *, int, int); 

static sqlite3_vfs inst_vfs = {
  1,                      /* iVersion */
  sizeof(inst_file),      /* szOsFile */
  INST_MAX_PATHNAME,      /* mxPathname */
  0,                      /* pNext */
  0,                      /* zName */
280
281
282
283
284
285
286


287

288
289
290
291
292
293
294
295
296
297
298


299


300
301
302
303
304
305
306
*/
static int instRead(
  sqlite3_file *pFile, 
  void *zBuf, 
  int iAmt, 
  sqlite_int64 iOfst
){


  OS_TIME_IO(OS_READ, iAmt, iOfst, p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst));

}

/*
** Write data to an inst-file.
*/
static int instWrite(
  sqlite3_file *pFile,
  const void *z,
  int iAmt,
  sqlite_int64 iOfst
){


  OS_TIME_IO(OS_WRITE, iAmt, iOfst, p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst));


}

/*
** Truncate an inst-file.
*/
static int instTruncate(sqlite3_file *pFile, sqlite_int64 size){
  OS_TIME_IO(OS_TRUNCATE, 0, (int)size, 







>
>
|
>











>
>
|
>
>







280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
*/
static int instRead(
  sqlite3_file *pFile, 
  void *zBuf, 
  int iAmt, 
  sqlite_int64 iOfst
){
  sqlite3_vfs *pVfs = (sqlite3_vfs *)(((inst_file *)pFile)->pInstVfs);
  OS_TIME_IO(OS_READ, iAmt, (binarylog_blob(pVfs, zBuf, iAmt, 1), iOfst), 
      p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst)
  );
}

/*
** Write data to an inst-file.
*/
static int instWrite(
  sqlite3_file *pFile,
  const void *z,
  int iAmt,
  sqlite_int64 iOfst
){
  sqlite3_vfs *pVfs = (sqlite3_vfs *)(((inst_file *)pFile)->pInstVfs);
  binarylog_blob(pVfs, z, iAmt, 1);
  OS_TIME_IO(OS_WRITE, iAmt, iOfst, 
      p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst)
  );
}

/*
** Truncate an inst-file.
*/
static int instTruncate(sqlite3_file *pFile, sqlite_int64 size){
  OS_TIME_IO(OS_TRUNCATE, 0, (int)size, 
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
  pFile->pMethods = &inst_io_methods;
  p->pReal = (sqlite3_file *)&p[1];
  p->pInstVfs = (InstVfs *)pVfs;
  p->zName = zName;
  p->flags = flags;
  p->iFileId = ++p->pInstVfs->iNextFileId;

  binarylog_blob(pVfs, zName, -1);
  OS_TIME_VFS(OS_OPEN, zName, flags, p->iFileId, 0,
    REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags)
  );
}

/*
** Delete the file located at zPath. If the dirSync argument is true,
** ensure the file-system modifications are synced to disk before
** returning.
*/
static int instDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
  binarylog_blob(pVfs, zPath, -1);
  OS_TIME_VFS(OS_DELETE, zPath, 0, dirSync, 0,
    REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync) 
  );
}

/*
** Test for access permissions. Return true if the requested permission
** is available, or false otherwise.
*/
static int instAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){
  binarylog_blob(pVfs, zPath, -1);
  OS_TIME_VFS(OS_ACCESS, zPath, 0, flags, 0, 
    REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags) 
  );
}

/*
** Populate buffer zBufOut with a pathname suitable for use as a 







|











|










|







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
  pFile->pMethods = &inst_io_methods;
  p->pReal = (sqlite3_file *)&p[1];
  p->pInstVfs = (InstVfs *)pVfs;
  p->zName = zName;
  p->flags = flags;
  p->iFileId = ++p->pInstVfs->iNextFileId;

  binarylog_blob(pVfs, zName, -1, 0);
  OS_TIME_VFS(OS_OPEN, zName, flags, p->iFileId, 0,
    REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags)
  );
}

/*
** Delete the file located at zPath. If the dirSync argument is true,
** ensure the file-system modifications are synced to disk before
** returning.
*/
static int instDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
  binarylog_blob(pVfs, zPath, -1, 0);
  OS_TIME_VFS(OS_DELETE, zPath, 0, dirSync, 0,
    REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync) 
  );
}

/*
** Test for access permissions. Return true if the requested permission
** is available, or false otherwise.
*/
static int instAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){
  binarylog_blob(pVfs, zPath, -1, 0);
  OS_TIME_VFS(OS_ACCESS, zPath, 0, flags, 0, 
    REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags) 
  );
}

/*
** Populate buffer zBufOut with a pathname suitable for use as a 
612
613
614
615
616
617
618
619
620
621
622
623
624

625
626
627
628
629
630
631
  }

  *pzEvent = sqlite3_instvfs_name(eEvent);
  *pnClick = p->aTime[eEvent];
  *pnCall = p->aCount[eEvent];
}

#define BINARYLOG_BUFFERSIZE 1024

struct InstVfsBinaryLog {
  int nBuf;
  char *zBuf;
  sqlite3_int64 iOffset;

  sqlite3_file *pOut;
  char *zOut;                       /* Log file name */
};
typedef struct InstVfsBinaryLog InstVfsBinaryLog;

static void put32bits(unsigned char *p, unsigned int v){
  p[0] = v>>24;







|





>







619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
  }

  *pzEvent = sqlite3_instvfs_name(eEvent);
  *pnClick = p->aTime[eEvent];
  *pnCall = p->aCount[eEvent];
}

#define BINARYLOG_BUFFERSIZE 8192

struct InstVfsBinaryLog {
  int nBuf;
  char *zBuf;
  sqlite3_int64 iOffset;
  int log_data;
  sqlite3_file *pOut;
  char *zOut;                       /* Log file name */
};
typedef struct InstVfsBinaryLog InstVfsBinaryLog;

static void put32bits(unsigned char *p, unsigned int v){
  p[0] = v>>24;
703
704
705
706
707
708
709
710

711
712
713
714
715
716
717
718
719
720
721




722
723
724
725
726
727
728
729
730
731
732
733
734

735
736

737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752

753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771

772
773
774
775
776
777
778
  sqlite3_free(pLog->zBuf);
  sqlite3_free(pLog);
}

static void binarylog_blob(
  sqlite3_vfs *pVfs,
  const char *zBlob,
  int nBlob

){
  unsigned char *zRec;
  int nWrite;
  InstVfs *pInstVfs = (InstVfs *)pVfs;
  InstVfsBinaryLog *pLog;

  if( pVfs->xOpen!=instOpen || pInstVfs->xCall!=binarylog_xcall ){
    return;
  }

  pLog = (InstVfsBinaryLog *)pInstVfs->pClient;




  if( nBlob<0 ){
    nBlob = strlen(zBlob);
  }
  nWrite = nBlob + 28;

  if( (nWrite+pLog->nBuf)>BINARYLOG_BUFFERSIZE ){
    binarylog_flush(pLog);
  }

  zRec = (unsigned char *)&pLog->zBuf[pLog->nBuf];
  memset(zRec, 0, nWrite);
  put32bits(&zRec[0], BINARYLOG_STRING);
  put32bits(&zRec[4], (int)nBlob);

  memcpy(&zRec[28], zBlob, nBlob);
  pLog->nBuf += nWrite;

}

void sqlite3_instvfs_binarylog_marker(
  sqlite3_vfs *pVfs,
  const char *zMarker
){
  InstVfs *pInstVfs = (InstVfs *)pVfs;
  InstVfsBinaryLog *pLog = (InstVfsBinaryLog *)pInstVfs->pClient;
  binarylog_blob(pVfs, zMarker, -1);
  binarylog_xcall(pLog, BINARYLOG_MARKER, 0, 0, 0, 0, 0, 0, 0);
}

sqlite3_vfs *sqlite3_instvfs_binarylog(
  const char *zVfs,
  const char *zParentVfs, 
  const char *zLog

){
  InstVfsBinaryLog *p;
  sqlite3_vfs *pVfs;
  sqlite3_vfs *pParent;
  int nByte;
  int flags;
  int rc;

  pParent = sqlite3_vfs_find(zParentVfs);
  if( !pParent ){
    return 0;
  }

  nByte = sizeof(InstVfsBinaryLog) + pParent->mxPathname+1;
  p = (InstVfsBinaryLog *)sqlite3_malloc(nByte);
  memset(p, 0, nByte);
  p->zBuf = sqlite3_malloc(BINARYLOG_BUFFERSIZE);
  p->zOut = (char *)&p[1];
  p->pOut = (sqlite3_file *)sqlite3_malloc(pParent->szOsFile);

  pParent->xFullPathname(pParent, zLog, pParent->mxPathname, p->zOut);
  flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MASTER_JOURNAL;
  pParent->xDelete(pParent, p->zOut, 0);
  rc = pParent->xOpen(pParent, p->zOut, p->pOut, flags, &flags);
  if( rc==SQLITE_OK ){
    memcpy(p->zBuf, "sqlite_ostrace1.....", 20);
    p->iOffset = 0;







|
>

<
|

<




<

>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
>








|






|
>



















>







711
712
713
714
715
716
717
718
719
720

721
722

723
724
725
726

727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
  sqlite3_free(pLog->zBuf);
  sqlite3_free(pLog);
}

static void binarylog_blob(
  sqlite3_vfs *pVfs,
  const char *zBlob,
  int nBlob,
  int isBinary
){

  InstVfsBinaryLog *pLog;
  InstVfs *pInstVfs = (InstVfs *)pVfs;


  if( pVfs->xOpen!=instOpen || pInstVfs->xCall!=binarylog_xcall ){
    return;
  }

  pLog = (InstVfsBinaryLog *)pInstVfs->pClient;
  if( !isBinary || pLog->log_data ){
    unsigned char *zRec;
    int nWrite;

    if( nBlob<0 ){
      nBlob = strlen(zBlob);
    }
    nWrite = nBlob + 28;
  
    if( (nWrite+pLog->nBuf)>BINARYLOG_BUFFERSIZE ){
      binarylog_flush(pLog);
    }
  
    zRec = (unsigned char *)&pLog->zBuf[pLog->nBuf];
    memset(zRec, 0, nWrite);
    put32bits(&zRec[0], BINARYLOG_STRING);
    put32bits(&zRec[4], (int)nBlob);
    put32bits(&zRec[8], (int)isBinary);
    memcpy(&zRec[28], zBlob, nBlob);
    pLog->nBuf += nWrite;
  }
}

void sqlite3_instvfs_binarylog_marker(
  sqlite3_vfs *pVfs,
  const char *zMarker
){
  InstVfs *pInstVfs = (InstVfs *)pVfs;
  InstVfsBinaryLog *pLog = (InstVfsBinaryLog *)pInstVfs->pClient;
  binarylog_blob(pVfs, zMarker, -1, 0);
  binarylog_xcall(pLog, BINARYLOG_MARKER, 0, 0, 0, 0, 0, 0, 0);
}

sqlite3_vfs *sqlite3_instvfs_binarylog(
  const char *zVfs,
  const char *zParentVfs, 
  const char *zLog,
  int log_data
){
  InstVfsBinaryLog *p;
  sqlite3_vfs *pVfs;
  sqlite3_vfs *pParent;
  int nByte;
  int flags;
  int rc;

  pParent = sqlite3_vfs_find(zParentVfs);
  if( !pParent ){
    return 0;
  }

  nByte = sizeof(InstVfsBinaryLog) + pParent->mxPathname+1;
  p = (InstVfsBinaryLog *)sqlite3_malloc(nByte);
  memset(p, 0, nByte);
  p->zBuf = sqlite3_malloc(BINARYLOG_BUFFERSIZE);
  p->zOut = (char *)&p[1];
  p->pOut = (sqlite3_file *)sqlite3_malloc(pParent->szOsFile);
  p->log_data = log_data;
  pParent->xFullPathname(pParent, zLog, pParent->mxPathname, p->zOut);
  flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MASTER_JOURNAL;
  pParent->xDelete(pParent, p->zOut, 0);
  rc = pParent->xOpen(pParent, p->zOut, p->pOut, flags, &flags);
  if( rc==SQLITE_OK ){
    memcpy(p->zBuf, "sqlite_ostrace1.....", 20);
    p->iOffset = 0;
887
888
889
890
891
892
893

894
895

896
897
898
899
900
901
902

903



904


905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
    }
    case IV_BINARYLOG: {
      char *zName = 0;
      char *zLog = 0;
      char *zParent = 0;
      sqlite3_vfs *p;
      int isDefault = 0;

      int argbase = 2;


      if( objc>2 && 0==strcmp("-default", Tcl_GetString(objv[argbase])) ){
        isDefault = 1;
        argbase++;
      }
      if( objc>(argbase+1) 
       && 0==strcmp("-parent", Tcl_GetString(objv[argbase])) 
      ){

        zParent = Tcl_GetString(objv[argbase+1]);



        argbase += 2;


      }

      if( (objc-argbase)!=2 ){
        Tcl_WrongNumArgs(
            interp, 2, objv, "?-default? ?-parent VFS? NAME LOGFILE"
        );
        return TCL_ERROR;
      }
      zName = Tcl_GetString(objv[argbase]);
      zLog = Tcl_GetString(objv[argbase+1]);
      p = sqlite3_instvfs_binarylog(zName, zParent, zLog);
      if( !p ){
        Tcl_AppendResult(interp, "error creating vfs ", 0);
        return TCL_ERROR;
      }
      if( isDefault ){
        sqlite3_vfs_register(p, 1);
      }







>


>
|
|
<
|
<
|
<
>
|
>
>
>
|
>
>




|





|







901
902
903
904
905
906
907
908
909
910
911
912
913

914

915

916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
    }
    case IV_BINARYLOG: {
      char *zName = 0;
      char *zLog = 0;
      char *zParent = 0;
      sqlite3_vfs *p;
      int isDefault = 0;
      int isLogdata = 0;
      int argbase = 2;

      for(argbase=2; argbase<(objc-2); argbase++){
        if( 0==strcmp("-default", Tcl_GetString(objv[argbase])) ){
          isDefault = 1;

        }

        else if( 0==strcmp("-parent", Tcl_GetString(objv[argbase])) ){

          argbase++;
          zParent = Tcl_GetString(objv[argbase]);
        }
        else if( 0==strcmp("-logdata", Tcl_GetString(objv[argbase])) ){
          isLogdata = 1;
        }else{
          break;
        }
      }

      if( (objc-argbase)!=2 ){
        Tcl_WrongNumArgs(
            interp, 2, objv, "?-default? ?-parent VFS? ?-logdata? NAME LOGFILE"
        );
        return TCL_ERROR;
      }
      zName = Tcl_GetString(objv[argbase]);
      zLog = Tcl_GetString(objv[argbase+1]);
      p = sqlite3_instvfs_binarylog(zName, zParent, zLog, isLogdata);
      if( !p ){
        Tcl_AppendResult(interp, "error creating vfs ", 0);
        return TCL_ERROR;
      }
      if( isDefault ){
        sqlite3_vfs_register(p, 1);
      }
Changes to test/incrblob_err.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2007 May 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: incrblob_err.test,v 1.8 2007/09/12 17:01:45 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable {!incrblob  || !memdebug || !tclvar} {
  finish_test











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2007 May 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: incrblob_err.test,v 1.9 2008/05/12 07:42:20 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable {!incrblob  || !memdebug || !tclvar} {
  finish_test
67
68
69
70
71
72
73

74
75
76
77
78
79
80
    error "Bad data read..."
  }
  set rc [catch {close $::blob}]
  if {$rc} { 
    error "out of memory" 
  }
} 


do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {
  CREATE TABLE blobs(k, v BLOB);
  INSERT INTO blobs VALUES(1, $::data);
} -tclbody {
  set ::blob [db incrblob blobs v 1]
  read $::blob







>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    error "Bad data read..."
  }
  set rc [catch {close $::blob}]
  if {$rc} { 
    error "out of memory" 
  }
} 


do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {
  CREATE TABLE blobs(k, v BLOB);
  INSERT INTO blobs VALUES(1, $::data);
} -tclbody {
  set ::blob [db incrblob blobs v 1]
  read $::blob
Changes to test/tester.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.121 2008/05/08 16:51:12 danielk1977 Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.122 2008/05/12 07:42:20 danielk1977 Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96



97
98

99
100
101
102
103
104
105
    sqlite3_memdebug_backtrace $value
    set argv [lreplace $argv $i $i]
  }
}


proc ostrace_call {zCall nClick zFile i32 i64} {
  set s "INSERT INTO ostrace VALUES( '$zCall', $nClick, '$zFile', $i32, $i64);"
  puts $::ostrace_fd $s
}

for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[lindex $argv $i] eq "--ossummary" || [lindex $argv $i] eq "--ostrace"} {
    sqlite3_instvfs create -default ostrace
    set tester_do_ostrace 1
    set ostrace_fd [open ostrace.sql w]
    puts $ostrace_fd "BEGIN;"
    if {[lindex $argv $i] eq "--ostrace"} {
      set    s "CREATE TABLE ostrace"
      append s "(method TEXT, clicks INT, file TEXT, i32 INT, i64 INT);"
      puts $ostrace_fd $s
      sqlite3_instvfs configure ostrace ostrace_call
      sqlite3_instvfs configure ostrace ostrace_call
    }
    set argv [lreplace $argv $i $i]
  }
  if {[lindex $argv $i] eq "--binarylog"} {
    set tester_do_binarylog 1



    sqlite3_instvfs binarylog -default binarylog ostrace.bin
    set argv [lreplace $argv $i $i]

  }
}

# 
# Check the command-line arguments to set the maximum number of
# errors tolerated before halting.
#







|




















>
>
>


>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    sqlite3_memdebug_backtrace $value
    set argv [lreplace $argv $i $i]
  }
}


proc ostrace_call {zCall nClick zFile i32 i64} {
  set s "INSERT INTO ostrace VALUES('$zCall', $nClick, '$zFile', $i32, $i64);"
  puts $::ostrace_fd $s
}

for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[lindex $argv $i] eq "--ossummary" || [lindex $argv $i] eq "--ostrace"} {
    sqlite3_instvfs create -default ostrace
    set tester_do_ostrace 1
    set ostrace_fd [open ostrace.sql w]
    puts $ostrace_fd "BEGIN;"
    if {[lindex $argv $i] eq "--ostrace"} {
      set    s "CREATE TABLE ostrace"
      append s "(method TEXT, clicks INT, file TEXT, i32 INT, i64 INT);"
      puts $ostrace_fd $s
      sqlite3_instvfs configure ostrace ostrace_call
      sqlite3_instvfs configure ostrace ostrace_call
    }
    set argv [lreplace $argv $i $i]
  }
  if {[lindex $argv $i] eq "--binarylog"} {
    set tester_do_binarylog 1

    # sqlite3_simulate_device -char safe_append
    # sqlite3_instvfs binarylog -default -parent devsym binarylog ostrace.bin
    sqlite3_instvfs binarylog -default binarylog ostrace.bin
    set argv [lreplace $argv $i $i]
    sqlite3_instvfs marker binarylog "$argv0 $argv"
  }
}

# 
# Check the command-line arguments to set the maximum number of
# errors tolerated before halting.
#