[virtmach] break / watch points

Durchholz, Joachim Joachim.Durchholz@halstenbach.de
Tue, 18 Apr 2000 19:42:37 +0200

Thad wrote:
> Who's responsibility, the VM or the debugger?
> That is, should: 
> a) the VM keep a list of break condition objects and pass 
> control to the
> debugger when one evaluates to "true", or
> b) the VM poll the debugger after every instruction, and let it do the
> checking.

If VM and debugger run in the same memory space, this is just a question of
which directory is going to house the sources for breakpoint checking.

If you expect that others may want to write their own debugger, then it
depends on how general the breakpoint logic is. Place into the VM what's
useful for all debuggers, and place in the debugger that's specific for your
debugger. (This is a useful criterion even if you don't plan to open your VM
for foreign debuggers.)

If debugger and VM run in different processes (or even on different
machines, possibly compiled for different CPUs), you'll want to make that
interface as narrow as possible. One way to achieve this is to "download"
breakpoint conditions into the VM and let it check these on its own,
signalling the debugger only when a breakpoint happens. If the breakpoint
logic is in the VM, a CPU-specific implementation may be able to make use of
hardware debug registers.

I don't think there's a single Right Way to distribute the logic. Set your
design goals, then pick the implementations that suits them best. If you
don't want to decide now, set the design up so that you can move the
breakpoint logic easily from debugger to VM and vice versa. Or postpone the
decision until other elements of your design have shifted the balance far
enough that you feel secure about where the breakpoint logic should go.

Disclaimer: This advice isn't backed by practical experience. YMMV

This is not an official statement from my employer or from NICE.