From: drh Date: Fri, 15 Jun 2007 20:29:20 +0000 (+0000) Subject: Make arrangements to optionally print a debug message at the point X-Git-Tag: version-3.4.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d7f17b6a827d839a8d388d6bd6a55499c71ee2d;p=thirdparty%2Fsqlite.git Make arrangements to optionally print a debug message at the point of a simulated malloc() failure when SQLITE_MEMDEBUG is defined. (CVS 4077) FossilOrigin-Name: 7d3c1f08a34fcf2ca5c79d6e58f713ae6a4b34e8 --- diff --git a/manifest b/manifest index 3cd04f78b1..a8c4557c9f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smore\sdocumentation\stypos.\s\sTicket\s#2416.\s(CVS\s4076) -D 2007-06-15T18:59:09 +C Make\sarrangements\sto\soptionally\sprint\sa\sdebug\smessage\sat\sthe\spoint\nof\sa\ssimulated\smalloc()\sfailure\swhen\sSQLITE_MEMDEBUG\sis\sdefined.\s(CVS\s4077) +D 2007-06-15T20:29:20 F Makefile.in b9971ab07868cf2b3209fe3bf8c52e7e25af4193 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -81,7 +81,7 @@ F src/legacy.c 388c71ad7fbcd898ba1bcbfc98a3ac954bfa5d01 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35 F src/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2 F src/main.c 797dc983716c1480f6af78a36be3add8806211a1 -F src/malloc.c 07790014b4b126016ce3c94885a215e45eb07ad5 +F src/malloc.c fa9bbccc4e6d099cd04c2518d238a1669c9d1020 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 F src/os.c 1f10b47acc1177fb9225edb4f5f0d25ed716f9cb F src/os.h 213dd1f8f7ab9159c04a893eadc0cdd52515df16 @@ -99,7 +99,7 @@ F src/pager.h 94110a5570dca30d54a883e880a3633b2e4c05ae F src/parse.y 2ed1d91fdcb4ae7ae7d1f4674544297807c7cc26 F src/pragma.c 0d25dad58bdfd6789943a10f1b9663c2eb85b96d F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089 -F src/printf.c cd91e057fa7e2661673eecd4eeecf4900b1e5cfe +F src/printf.c 711908d6ff3385f9882df8ff405b9e0a2a4d04df F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88 F src/select.c 33a258fc9c9dccb28ae2d3a02f1e1148d6433148 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 @@ -109,7 +109,7 @@ F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890 F src/sqliteInt.h 208c40b6e11925a321ec159d889e0ec06b618359 F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d F src/tclsqlite.c 9f96385c5047b24afa7601ea4055aae97c3e25e3 -F src/test1.c d2535b40abb1f2ec0070a3f5eb03bfe3ac4c4c12 +F src/test1.c a83c097ee1353e8982745ee1b78612fea7425602 F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88 F src/test3.c a280931fb40222b7c90da45eea926459beee8904 F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25 @@ -506,7 +506,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P c8beb8674e5a1effc2785f205124628fbdaf57e0 -R 1c19b10ce422ff514f733944e8c84cba +P b55318b12d026abd5a32469a19c36abbd6250137 +R 9fb9378a6131ef971724f58e359aa823 U drh -Z a0e8fa84b47c4c74690f8c8b97b7bd9f +Z 9b3a097433469bac22ff4239e6205986 diff --git a/manifest.uuid b/manifest.uuid index 6c58992c46..d26467e010 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b55318b12d026abd5a32469a19c36abbd6250137 \ No newline at end of file +7d3c1f08a34fcf2ca5c79d6e58f713ae6a4b34e8 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index e8124a34df..2ae3a55ad4 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** Memory allocation functions used throughout sqlite. ** ** -** $Id: malloc.c,v 1.2 2007/05/16 17:28:43 danielk1977 Exp $ +** $Id: malloc.c,v 1.3 2007/06/15 20:29:20 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -203,6 +203,7 @@ int sqlite3_mallocDisallowed = 0; /* assert() in sqlite3Malloc() if set */ int sqlite3_isFail = 0; /* True if all malloc calls should fail */ const char *sqlite3_zFile = 0; /* Filename to associate debug info with */ int sqlite3_iLine = 0; /* Line number for debug info */ +int sqlite3_mallocfail_trace = 0; /* Print a msg on malloc fail if true */ /* ** Check for a simulated memory allocation failure. Return true if @@ -217,6 +218,9 @@ int sqlite3TestMallocFail(){ if( sqlite3_iMallocFail==0 ){ sqlite3_iMallocFail = sqlite3_iMallocReset; sqlite3_isFail = 1; + if( sqlite3_mallocfail_trace ){ + sqlite3DebugPrintf("###_malloc_fails_###\n"); + } return 1; } } diff --git a/src/printf.c b/src/printf.c index 92073991d8..e910650fe7 100644 --- a/src/printf.c +++ b/src/printf.c @@ -862,7 +862,7 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ return z; } -#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) +#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) || defined(SQLITE_MEMDEBUG) /* ** A version of printf() that understands %lld. Used for debugging. ** The printf() built into some versions of windows does not understand %lld diff --git a/src/test1.c b/src/test1.c index 14c1120ce8..1454cd64e3 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.255 2007/06/15 18:53:15 drh Exp $ +** $Id: test1.c,v 1.256 2007/06/15 20:29:20 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -4445,7 +4445,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; extern int sqlite3_memUsed; - extern char *sqlite3_malloc_id; extern int sqlite3_memMax; extern int sqlite3_like_count; extern int sqlite3_tsd_count; @@ -4516,8 +4515,14 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY); #endif #ifdef SQLITE_MEMDEBUG - Tcl_LinkVar(interp, "sqlite_malloc_id", - (char*)&sqlite3_malloc_id, TCL_LINK_STRING); + { + extern char *sqlite3_malloc_id; + extern int sqlite3_mallocfail_trace; + Tcl_LinkVar(interp, "sqlite_malloc_id", + (char*)&sqlite3_malloc_id, TCL_LINK_STRING); + Tcl_LinkVar(interp, "sqlite3_mallocfail_trace", + (char*)&sqlite3_mallocfail_trace, TCL_LINK_INT); + } #endif #if OS_WIN Tcl_LinkVar(interp, "sqlite_os_type",