Debugging and Testing
We have imported the debugging system from the old test suite into the
new interface to aid in debugging problems. There are several variables
that are available both in gdb as globals to the C code, and variables
in Tcl that the user can set. These variables are linked together
so that changes in one venue are reflected in the other. The names
of the variables have been modified a bit to reduce the likelihood
of namespace trampling. We have added a double underscore to
all the names.
The variables are all initialized to zero (0) thus resulting in debugging
being turned off. The purpose of the debugging, fundamentally, is
to allow the user to set a breakpoint prior to making a DB call.
This breakpoint is set in the __db_loadme() function. The
user may selectively turn on various debugging areas each controlled by
a separate variable (note they all have two (2) underscores prepended to
the name):
-
__debug_on - Turns on the debugging system. This must be on
for any debugging to occur
-
__debug_print - Turns on printing a debug count statement on each
call
-
__debug_test - Hits the breakpoint in __db_loadme on the
specific iteration
-
__debug_stop - Hits the breakpoint in __db_loadme on every
(or the next) iteration
Note to developers: Anyone extending this interface must place
a call to _debug_check() (no arguments) before every call into the
DB library.
There is also a command available that will force a call to the _debug_check
function.
> berkdb debug_check
For testing purposes we have added several hooks into the DB library
and a small interface into the environment and/or database commands to
manipulate the hooks. This command interface and the hooks and everything
that goes with it is only enabled when the test option is configured into
DB.
> <env> test copy location
> <db> test copy location
> <env> test abort location
> <db> test abort location
In order to test recovery we need to be able to abort the creation or
deletion process at various points. Also we want to invoke a copy
function to copy the database file(s) at various points as well so
that we can obtain before/after snapshots of the databases. The interface
provides the test command to specify a location where we
wish to invoke a copy or an abort. The command is available
from either the environment or the database for convenience. The
location
can be one of the following:
-
none - Clears the location
-
preopen - Sets the location prior to the __os_open call in the creation
process
-
postopen - Sets the location to immediately following the __os_open
call in creation
-
postlogmeta - Sets the location to immediately following the __db_log_page
call to log the meta data in creation. Only valid for Btree.
-
postlog - Sets the location to immediately following the last (or
only) __db_log_page call in creation.
-
postsync - Sets the location to immediately following the sync of
the log page in creation.
-
prerename - Sets the location prior to the __os_rename call in the
deletion process.
-
postrename - Sets the location to immediately following the __os_rename
call in deletion