From 7d105f87fc66a37e2d859fee600543e592caa881 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 Aug 2010 15:26:49 +0000 Subject: [PATCH] Update the "showdb" debug utility to handle 64K page database and with extra options to decode the freelist structure. FossilOrigin-Name: 1070918e3b68c0ba5bfab11a97214b87c601f93c --- manifest | 18 ++++++------- manifest.uuid | 2 +- tool/showdb.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 25d786d2ff..59005ebd85 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Version\s3.7.1\srelease\scandidate -D 2010-08-21T16:01:46 +C Update\sthe\s"showdb"\sdebug\sutility\sto\shandle\s64K\spage\sdatabase\sand\swith\nextra\soptions\sto\sdecode\sthe\sfreelist\sstructure. +D 2010-08-23T15:26:50 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 543f91f24cd7fee774ecc0a61c19704c0c3e78fd F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -836,7 +836,7 @@ F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94 -F tool/showdb.c 01c20e8181941b714fe07f72c64a7560fee17ff9 +F tool/showdb.c c7a978cf525ef0f8bc2fd29cd52108dd1dfa605a F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -848,14 +848,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 44de3cab9c89eb28485c0dc36d791b1c61d56b34 -R ba75d512677d6cf0802a70f734aafd6f +P 3613b0695a5e990905ab146fadcab34dd04d5874 +R 058fa6e3ab648ae5ff66e22c57c21a88 U drh -Z 9eb9cc7f3392e65cec0523ad38099f7c +Z 4b496641e3aad55cb1970e3775c32e6e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFMb/huoxKgR168RlERAp5nAJ9bQ/OZp/nGB/mbch5eawtJ3xzNqQCdH2LV -awMpPL8qm3hJm5LCIu8Eivk= -=ZYFd +iD8DBQFMcpM9oxKgR168RlERAiQ4AKCNTq26d6guoArVL/8XVQDv9ujn6gCbB8sK +0u6T4zf+ph77zjra1ytd08E= +=CUDO -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 761b671e6c..1be9cbc9ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3613b0695a5e990905ab146fadcab34dd04d5874 \ No newline at end of file +1070918e3b68c0ba5bfab11a97214b87c601f93c \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index a54eea8a96..f313b1aff9 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -35,6 +35,13 @@ static int decodeVarint(const unsigned char *z, i64 *pVal){ return 9; } +/* +** Extract a big-endian 32-bit integer +*/ +static unsigned int decodeInt32(const unsigned char *z){ + return (z[0]<<24) + (z[1]<<16) + (z[2]<<8) + z[3]; +} + /* Report an out-of-memory error and die. */ static void out_of_memory(void){ @@ -246,11 +253,64 @@ static void decode_btree_page(unsigned char *a, int pgno, int hdrSize){ } } +/* +** Decode a freelist trunk page. +*/ +static void decode_trunk_page( + int pgno, /* The page number */ + int pagesize, /* Size of each page */ + int detail, /* Show leaf pages if true */ + int recursive /* Follow the trunk change if true */ +){ + int n, i, k; + unsigned char *a; + while( pgno>0 ){ + a = getContent((pgno-1)*pagesize, pagesize); + printf("Decode of freelist trunk page %d:\n", pgno); + print_decode_line(a, 0, 4, "Next freelist trunk page"); + print_decode_line(a, 4, 4, "Number of entries on this page"); + if( detail ){ + n = (int)decodeInt32(&a[4]); + for(i=0; i