How to abort long running DebuggerCommand?

Answered

I have my custom DebuggerCommand which is run when a breakpoint is hit. It basically calls the toString method on some objects then it resumes execution with:

suspendManager.resume(suspendContext);

The only problem is that, from time to time, my DebuggerCommand freezes when it calls the toString method (for example this happens on Double objects, also no breakpoint is set in the toString() method). I'd like to provide a timeout, so that after some time, execution is resumed again and my DebuggerCommand is stopped. This is how I call my DebuggerCommand:

managerThread.invokeCommand(myCommand);

and this is what I tried to stop it with a timeout:

managerThread.terminateAndInvoke(new StopCommand(suspendContext), 100);

where StopCommand just resumes execution:

protected class StopCommand extends DebuggerCommandImpl {
private SuspendContextImpl suspendContext;

public StopCommand(SuspendContextImpl suspendContext) {
this.suspendContext = suspendContext;
}

@Override
public Priority getPriority() {
return Priority.HIGH;
}

@Override
protected void action() {
suspendContext.getDebugProcess().getSuspendManager().resume(suspendContext);
}
}

This does not work at all. My initial DebuggerCommand still freezes.

Update: My DebugListener only does this:

@Override
public void paused(@NotNull SuspendContext suspendContext) {
myCommand = new ....
managerThread.invokeCommand(myCommand);
managerThread.terminateAndInvoke(new StopCommand(suspendContext), 100);
}

And this is how I call the toString method, it never exits for some objects:

ObjectReference object = ...
object.invokeMethod(threadRef, method,
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
0
2 comments

Hi, there's no way to interrupt method invocation (toString for example) in debugger fo now

0
Avatar
Permanently deleted user

OK. Thank you very much!

0

Please sign in to leave a comment.