[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

breakpoint internals interface



I propose that we isolate the machine specific aspects of installing and
handling breakpoints in one small C module.  The reasons are this: it's
much easier to that kind of system hackery in C, and it's much easier to
express machine specific dependencies in C.

The interface consists of two C functions, and a Lisp function:

	install_breakpoint(id, code_object, pc_offset)
	int id;
	lispobj code_object;
	int pc_offset;

Installs breakpoint number id pc_offset words into code_object.

	uninstall_breakpoint(id)
	int id;

Removes breakpoint number id.

	(handle-breakpoint id)

Lisp function called by the C code when a breakpoint is hit.


I propose using a breakpoint ID number instead of some Lisp level structure
so that it doesn't have to be scavenged.


Install_breakpoint would modify the code object with the breakpoint
instruction.  The C level break handler would note that it was a
breakpoint, and call handle-breakpoint.  If handle-breakpoint returned, the
break handler would check to see if the breakpoint was still installed, and
if so replace the break instruction with the original instruction, replace
the (dynamically) next instruction with break instruction, and return.  The
second break instruction would be hit, which would dump us back in the
break handler.  The break handler would put a break instruction back at the
original place, replace the second break instruction with whatever it
displaced, and return.

Uninstall_breakpoint would just mark that breakpoint id as uninstalled.

Hm, I just realized that the breakpoint stuff have to maintain a PC->id
mapping, which will have to be fixed by GC, so a PC->obj mapping would not
be any harder.  Unless you had *gc-before* and *gc-after* hooks that
uninstalled and reinstalled all the breakpoints.

Another issue: what if you try to install two breakpoints at the same
address?  It would greatly simplify this level if it could assume that the
next level up would never try anything like that.

So how well would this interface with the higher level stuff you've been
working on?  I could crank out the necessary C code in under a day, or I
could supply Bill with the necessary pointers and he could do it.

-William