]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhancements to aid testing and debugging:
authordrh <drh@noemail.net>
Thu, 2 Jan 2020 14:42:42 +0000 (14:42 +0000)
committerdrh <drh@noemail.net>
Thu, 2 Jan 2020 14:42:42 +0000 (14:42 +0000)
In PRAGMA vdbe_trace=on output, show pScopyFrom dependencies on register
values.  Add the sqlite3VdbeRegisterDump() procedure, callable from a
debugger, that shows the values of all registers.  Pass the VDBE pointer
into test_trace_breakpoint() so that sqlite3VdbeRegisterDump() is callable
from the breakpoint.

FossilOrigin-Name: 9886cb4b7987f720aa9d701222ab0987caa0ab8c5d216cb6e523c4a45366dfe5

manifest
manifest.uuid
src/vdbe.c
src/vdbemem.c

index 3a79ec66f34d806c754e9c4b870be0be9e1ebfeb..7ebefd3b60ce54e3f16358db605414fc3589c395 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\stest_trace_breakpoint()\ssubroutine\sthat\sis\sinvoked\safter\seach\ninstruction\sis\sprinted\swhile\srunning\sPRAGMA\svdbe_trace=on.\s\sOnly\sworks\sfor\nSQLITE_DEBUG\sbuilds.\s\sAlso\sadd\sparameters\s"pc"\sand\s"pOp"\sto\s\ntest_addop_breakpoint()\sto\smake\sit\seasier\sto\sset\sconditionals.
-D 2020-01-02T13:26:49.943
+C Enhancements\sto\said\stesting\sand\sdebugging:\nIn\sPRAGMA\svdbe_trace=on\soutput,\sshow\spScopyFrom\sdependencies\son\sregister\nvalues.\s\sAdd\sthe\ssqlite3VdbeRegisterDump()\sprocedure,\scallable\sfrom\sa\ndebugger,\sthat\sshows\sthe\svalues\sof\sall\sregisters.\s\sPass\sthe\sVDBE\spointer\ninto\stest_trace_breakpoint()\sso\sthat\ssqlite3VdbeRegisterDump()\sis\scallable\nfrom\sthe\sbreakpoint.
+D 2020-01-02T14:42:42.874
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -600,13 +600,13 @@ F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78
 F src/utf.c 2f0fac345c7660d5c5bd3df9e9d8d33d4c27f366bcfb09e07443064d751a0507
 F src/util.c 2c92bc706bbdb1c45a25180291e7e05a56e297aa5dd7b2bcd2b1c47e8bb05b17
 F src/vacuum.c 82dcec9e7b1afa980288718ad11bc499651c722d7b9f32933c4d694d91cb6ebf
-F src/vdbe.c 9d432abf6c7979dc8661572ed5d61773be72a6b7475c0e97901309dc611fe4bd
+F src/vdbe.c 62f0a6d1d5685b65530f93e5ad4fc852fe7ce8225b8852c67f7177f4748c72d0
 F src/vdbe.h 3f068f00b23aebf392df142312ab5874588371c6d83e60d953f6d6b6453491c5
 F src/vdbeInt.h e02ccac0334f7c71c952210657e6e18de1917605887c7bc6167a80a17f62da18
 F src/vdbeapi.c 1252d80c548711e47a6d84dae88ed4e95d3fbb4e7bd0eaa1347299af7efddf02
 F src/vdbeaux.c 83b666882a55bd2762cec9dc32cd71b71d053890253a3d7c9646d59abfcb3381
 F src/vdbeblob.c 253ed82894924c362a7fa3079551d3554cd1cdace39aa833da77d3bc67e7c1b1
-F src/vdbemem.c 4029cb6a5a4d94f95e63e29c998791534788ce64ffb0f3bdfd373aba04a7169f
+F src/vdbemem.c e5c0fbadf3ad9e45623a63825dc45a30ef0b9b9137ba5351b57d15a3a17aff5d
 F src/vdbesort.c a3be032cc3fee0e3af31773af4a7a6f931b7230a34f53282ccf1d9a2a72343be
 F src/vdbetrace.c fa3bf238002f0bbbdfb66cc8afb0cea284ff9f148d6439bc1f6f2b4c3b7143f0
 F src/vtab.c a2fead3e97fca54fcf3f3db784e17c9ee2d39a0c5ad323e9d514855106300a86
@@ -1853,7 +1853,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 435c272dcf6ed5f3acb564b8f959557145f117b869547b670258cf5a1908ab6b
-R 012a47d79081ec029afe02cb3190d8b3
+P 49a6368c384178653cb3ccb58cc8eff93327c16929bf79eeefeb13a4ce897153
+R cbc77bfc0e90f07a788c6fc62ef01b63
 U drh
-Z 44bc6f6389cf28eb8f2cfc35d7778fbb
+Z 908b39c48323f7d785aae70d03f5f0a5
index 06232d4889e8a0b0039c2a8eb3c014350a5f55ed..4406375c59b9f46fa59d417d5acb5528fd02974b 100644 (file)
@@ -1 +1 @@
-49a6368c384178653cb3ccb58cc8eff93327c16929bf79eeefeb13a4ce897153
\ No newline at end of file
+9886cb4b7987f720aa9d701222ab0987caa0ab8c5d216cb6e523c4a45366dfe5
\ No newline at end of file
index ca737ffccbeab884de0f120cf507eef3f9792c00..ab5e4c80484a7ade2e27502f3c37126057865c7f 100644 (file)
@@ -131,7 +131,7 @@ int sqlite3_found_count = 0;
 **   sqlite3MisuseError(lineno)
 **   sqlite3CantopenError(lineno)
 */
-static void test_trace_breakpoint(int pc, Op *pOp){
+static void test_trace_breakpoint(int pc, Op *pOp, Vdbe *v){
   static int n = 0;
   n++;
 }
@@ -586,13 +586,28 @@ static void memTracePrint(Mem *p){
   if( p->flags & MEM_Subtype ) printf(" subtype=0x%02x", p->eSubtype);
 }
 static void registerTrace(int iReg, Mem *p){
-  printf("REG[%d] = ", iReg);
+  printf("R[%d] = ", iReg);
   memTracePrint(p);
+  if( p->pScopyFrom ){
+    printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
+  }
   printf("\n");
   sqlite3VdbeCheckMemInvariants(p);
 }
 #endif
 
+#ifdef SQLITE_DEBUG
+/*
+** Show the values of all registers in the virtual machine.  Used for
+** interactive debugging.
+*/
+void sqlite3VdbeRegisterDump(Vdbe *v){
+  int i;
+  for(i=1; i<v->nMem; i++) registerTrace(i, v->aMem+i);
+}
+#endif /* SQLITE_DEBUG */
+
+
 #ifdef SQLITE_DEBUG
 #  define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)
 #else
@@ -758,7 +773,7 @@ int sqlite3VdbeExec(
 #ifdef SQLITE_DEBUG
     if( db->flags & SQLITE_VdbeTrace ){
       sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);
-      test_trace_breakpoint((int)(pOp - aOp),pOp);
+      test_trace_breakpoint((int)(pOp - aOp),pOp,p);
     }
 #endif
       
index faf555af907037bb9a1ebc244d5fb68a57efd8f4..aaeda24253c03ee33d09a2baa2b35c96d82a58c6 100644 (file)
@@ -956,6 +956,10 @@ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
   Mem *pX;
   for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){
     if( pX->pScopyFrom==pMem ){
+      if( pVdbe->db->flags & SQLITE_VdbeTrace ){
+        sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
+          (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
+      }
       /* If pX is marked as a shallow copy of pMem, then verify that
       ** no significant changes have been made to pX since the OP_SCopy.
       ** A significant change would indicated a missed call to this
@@ -980,7 +984,6 @@ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
 }
 #endif /* SQLITE_DEBUG */
 
-
 /*
 ** Make an shallow copy of pFrom into pTo.  Prior contents of
 ** pTo are freed.  The pFrom->z field is not duplicated.  If