Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the -memtrace option to dbfuzz2. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
67fecbc79d3e927a7e22f3589be31841 |
User & Date: | drh 2019-02-04 19:50:44.697 |
Context
2019-02-04
| ||
19:52 | Mention the new -memtrace command-line option in the -help output of the CLI. (check-in: ada91aefe3 user: drh tags: trunk) | |
19:50 | Add the -memtrace option to dbfuzz2. (check-in: 67fecbc79d user: drh tags: trunk) | |
19:45 | Enhance dbfuzz2 so that with the -v option it shows the return code and error message for any failing SQL statements. (check-in: 3a127ef9f7 user: drh tags: trunk) | |
Changes
Changes to test/dbfuzz2.c.
︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* True to activate PRAGMA vdbe_debug=on */ static int bVdbeDebug = 0; /* Maximum size of the in-memory database file */ static sqlite3_int64 szMax = 104857600; /* libFuzzer invokes this routine with fuzzed database files (in aData). ** This routine run SQLite against the malformed database to see if it ** can provoke a failure or malfunction. */ int LLVMFuzzerTestOneInput(const uint8_t *aData, size_t nByte){ unsigned char *a; sqlite3 *db; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 68 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /* True to activate PRAGMA vdbe_debug=on */ static int bVdbeDebug = 0; /* Maximum size of the in-memory database file */ static sqlite3_int64 szMax = 104857600; /***** Copy/paste from ext/misc/memtrace.c ***************************/ /* The original memory allocation routines */ static sqlite3_mem_methods memtraceBase; static FILE *memtraceOut; /* Methods that trace memory allocations */ static void *memtraceMalloc(int n){ if( memtraceOut ){ fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n", memtraceBase.xRoundup(n)); } return memtraceBase.xMalloc(n); } static void memtraceFree(void *p){ if( p==0 ) return; if( memtraceOut ){ fprintf(memtraceOut, "MEMTRACE: free %d bytes\n", memtraceBase.xSize(p)); } memtraceBase.xFree(p); } static void *memtraceRealloc(void *p, int n){ if( p==0 ) return memtraceMalloc(n); if( n==0 ){ memtraceFree(p); return 0; } if( memtraceOut ){ fprintf(memtraceOut, "MEMTRACE: resize %d -> %d bytes\n", memtraceBase.xSize(p), memtraceBase.xRoundup(n)); } return memtraceBase.xRealloc(p, n); } static int memtraceSize(void *p){ return memtraceBase.xSize(p); } static int memtraceRoundup(int n){ return memtraceBase.xRoundup(n); } static int memtraceInit(void *p){ return memtraceBase.xInit(p); } static void memtraceShutdown(void *p){ memtraceBase.xShutdown(p); } /* The substitute memory allocator */ static sqlite3_mem_methods ersaztMethods = { memtraceMalloc, memtraceFree, memtraceRealloc, memtraceSize, memtraceRoundup, memtraceInit, memtraceShutdown }; /* Begin tracing memory allocations to out. */ int sqlite3MemTraceActivate(FILE *out){ int rc = SQLITE_OK; if( memtraceBase.xMalloc==0 ){ rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memtraceBase); if( rc==SQLITE_OK ){ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &ersaztMethods); } } memtraceOut = out; return rc; } /* Deactivate memory tracing */ int sqlite3MemTraceDeactivate(void){ int rc = SQLITE_OK; if( memtraceBase.xMalloc!=0 ){ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memtraceBase); if( rc==SQLITE_OK ){ memset(&memtraceBase, 0, sizeof(memtraceBase)); } } memtraceOut = 0; return rc; } /***** End copy/paste from ext/misc/memtrace.c ***************************/ /* libFuzzer invokes this routine with fuzzed database files (in aData). ** This routine run SQLite against the malformed database to see if it ** can provoke a failure or malfunction. */ int LLVMFuzzerTestOneInput(const uint8_t *aData, size_t nByte){ unsigned char *a; sqlite3 *db; |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 168 169 170 | if( z[0]=='v' && (n = numberOfVChar(z))>0 ){ eVerbosity += n; continue; } if( strcmp(z,"vdbe-debug")==0 ){ bVdbeDebug = 1; continue; } if( strcmp(z,"max-db-size")==0 ){ if( i+1==argc ){ fprintf(stderr, "missing argument to %s\n", argv[i]); exit(1); } szMax = strtol(argv[++i], 0, 0); | > > > > > > > > | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | if( z[0]=='v' && (n = numberOfVChar(z))>0 ){ eVerbosity += n; continue; } if( strcmp(z,"vdbe-debug")==0 ){ bVdbeDebug = 1; continue; } if( strcmp(z,"memtrace")==0 ){ sqlite3MemTraceActivate(stdout); continue; } if( strcmp(z,"mem")==0 ){ bVdbeDebug = 1; continue; } if( strcmp(z,"max-db-size")==0 ){ if( i+1==argc ){ fprintf(stderr, "missing argument to %s\n", argv[i]); exit(1); } szMax = strtol(argv[++i], 0, 0); |
︙ | ︙ |