Improved tracing capabilities in fuzzcheck.

FossilOrigin-Name: 864bfdbfe7b196cc9df2136b15a28e2a0f2713cb
This commit is contained in:
drh 2015-05-25 22:17:06 +00:00
parent 15b3128656
commit 4ab31475dc
3 changed files with 24 additions and 29 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\s--native-vfs\soption\son\sfuzzcheck.
D 2015-05-25T21:59:05.654
C Improved\stracing\scapabilities\sin\sfuzzcheck.
D 2015-05-25T22:17:06.593
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0a6ae26396ec696221021780dffbb894ff3cead7
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -651,7 +651,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
F test/fuzz3.test efd384b896c647b61a2c1848ba70d42aad60a7b3
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26
F test/fuzzcheck.c f411c6be09bfec22fcc0b8757b6adae7ed8dafaf
F test/fuzzcheck.c e751524648c8cba541ecaefe102dfb32012a447b
F test/fuzzdata1.txt 9fceb50868e0b798160e83742bd7e44e457176a0
F test/fuzzdata2.txt ba9b4467d7ec46cc85d32c0d031540cd727ae6ad
F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36
@ -1279,7 +1279,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P f3cd8cecf4f7aa3429e3ebc90ed31c4e8fff7bc2
R dc13cc2996e1b64ebe5fbea1ce4d46c4
P 12e95e3f178b89d649bc7e30db731df439ae1653
R df913344b7d3616e49af599608d3d74e
U drh
Z c989f194cb51739e915cc1a31986dfac
Z 7099e69332034b78c8602623e54bc3b8

View File

@ -1 +1 @@
12e95e3f178b89d649bc7e30db731df439ae1653
864bfdbfe7b196cc9df2136b15a28e2a0f2713cb

View File

@ -506,25 +506,11 @@ static void inmemVfsRegister(void){
sqlite3_vfs_register(&inmemVfs, 0);
};
#ifndef SQLITE_OMIT_TRACE
/*
** This callback is invoked by sqlite3_trace() as each SQL statement
** starts.
*/
static void traceCallback(void *NotUsed, const char *zMsg){
printf("TRACE: %s\n", zMsg);
fflush(stdout);
}
static void traceNoop(void *NotUsed, const char *zMsg){
return;
}
#endif
/*
** Run multiple commands of SQL. Similar to sqlite3_exec(), but does not
** stop if an error is encountered.
*/
static void runSql(sqlite3 *db, const char *zSql){
static void runSql(sqlite3 *db, const char *zSql, int traceFlag){
const char *zMore;
sqlite3_stmt *pStmt;
@ -532,12 +518,24 @@ static void runSql(sqlite3 *db, const char *zSql){
zMore = 0;
pStmt = 0;
sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);
if( zMore==zSql ) break;
if( traceFlag ){
const char *z = zSql;
int n;
while( z<zMore && isspace(z[0]) ) z++;
n = (int)(zMore - z);
while( n>0 && isspace(z[n-1]) ) n--;
if( n==0 ) break;
if( pStmt==0 ){
printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db));
}else{
printf("TRACE: %.*s\n", n, z);
}
}
zSql = zMore;
if( pStmt ){
while( SQLITE_ROW==sqlite3_step(pStmt) );
while( SQLITE_ROW==sqlite3_step(pStmt) ){}
sqlite3_finalize(pStmt);
}else{
break;
}
}
}
@ -729,11 +727,8 @@ int main(int argc, char **argv){
zVfs = 0;
}
rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs);
#ifndef SQLITE_OMIT_TRACE
sqlite3_trace(db, verboseFlag ? traceCallback : traceNoop, 0);
#endif
if( rc ) fatalError("cannot open inmem database");
runSql(db, (char*)pSql->a);
runSql(db, (char*)pSql->a, verboseFlag);
sqlite3_close(db);
if( sqlite3_memory_used()>0 ) fatalError("memory leak");
reformatVfs();