Implementing a stepping debugger with method handles
Mark Roos
mroos at roos.com
Fri Feb 17 14:34:54 PST 2012
Along the line of doing unusual things with method handles ( and because I
get good suggestions )
here is an implementation of a stepping debugger. It can step over or
into and resume.
In Smalltalk the IDE and the application are collocated in the same
process. The debugger is one
thread which monitors the application threads. I looked at using jvmti to
handle the stepping but
its outside looking in and does slow down the process. Since I want to
step at a granularity of
my callsites anyway I tried a mh based implementation.
Not much code and it works. So another nice use of the tools. Again not
much impact on execution time.
mark
At the entry to each callsite target I add
MethodType mt=MethodType.methodType(void.class, RtObject.class);
debugEntry = lookup.findStatic(RtDebugger.class, "debugEntry", mt);
invoker = MethodHandles.foldArguments(invoker , debugEntry); //
does nothing except suspend if necessary
the check is this for thread and level with a notification to the debugger
of the step
if(_debugThread == Thread.currentThread()){
if(getStackSize(_debugThread) <= _debugDepth){ // jni call to jvmti
to get the stack depth
// send debugger update notice async
notifyDebugStep();
suspendThreadPrim(_debugThread); //_jni version of
debugThread.suspend();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20120217/709672fa/attachment.html
More information about the mlvm-dev
mailing list