This topic applies to Java version only.
If you are interested in internal db4o debugging you can make use of com.db4o.DTrace class. DTrace is basically a logging agent, which gets called for db4o core events, which can provide information valuable for debugging. The list of currently available events can be found in DTrace class, they are represented by DTrace type static variables, for example:
public
static DTrace ADD_TO_CLASS_INDEX;
public
static DTrace BEGIN_TOP_LEVEL_CALL;
DTrace information is not enabled by default, as it can make the system really slow. In order to enable DTrace make the following changes in DTrace class and rebuild the core:
public static final boolean enabled = true
configure
method to tell DTrace that you are interested in all ranges and IDs addRangeWithLength(0,Integer.MAX_VALUE);
turnAllOffExceptFor
method is called in the configure()
methodWith this DTrace setup you will basically see everything that is happening logged to the console in detail. However, this information can be excessive and difficult to handle. That is why DTrace provides different configurations, allowing to limit the range of information you are interested in.
turnAllOffExceptFor(DTrace[] these)
This method allows you to pass an array of DTrace events, which you want to see in the console. For example:
turnAllOffExceptFor(new DTrace[] { ADD_TO_CLASS_INDEX , BEGIN_TOP_LEVEL_CALL
})
addRange(long)
addRangeWithEnd(long start, long
end)
addRangeWithLength(long start, long
length)
These methods allow to specify a range of addresses in a database file that you are interested in. addRange methods are especially useful for debugging a database file structure. Note, that in db4o internal object ID corresponds to the object's address in the file.
trackEventsWithoutRange()
These method will allow all events with no range specified to log their information.
The format of the output message is the following:
: [event number] : [start address] : [start address] :[information]
event number - sequential event number
start address -start of the event address range (optional)
end address - end of the event address range (optional)
information - informational message from the event
If DTrace log messages are not enough for you to
track the problem, you can use DTrace in debug mode. Use breakOnEvent(long)
method to specify on which address DTrace must break and put a
breakpoint inside breakPoint()
method.
As it was mentioned before DTrace events
are already created in the most important execution points of db4o core.
However, if you need more events, feel free to add them, encapsulating the
calls with if (DTrace.enabled)
to make sure that your code is
removed from distributions by the compiler.