I'm writing an application that needs to remote debug using eclipse JDT. The communication between my app and eclipse is fine and I'm using the following methods to manage breakpoints:
To add a breakpoint:
IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(...)
To remove a breakpoint:
IJavaLineBreakpoint breakpoint = JDIDebugModel.lineBreakpointExists(...);
breakpoint.delete();
To list all breakpoints:
IBreakpointManager mgr = DebugPlugin.getDefault().getBreakpointManager();
mgr.getBreakpoints();
But now my project is "suspended" in the breakpoints I've programatically created and I don't know how to fire actions (STEP_OVER, STEP_INTO,RESUME).I have tried the following but it doesn't work:
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(getResource(projectId, fullClassName), DebugEvent.STEP_OVER)});
What I need to know is:
I solved the problem doing some research in the eclipse source code.
The trick is that instead of using static methods like I have done on creating breakponts
JDIDebugModel.createLineBreakpoint(...)
The resume and stepOver methods are part of the Thread which is beeing executed on debug mode. So I have to save the ILauch object because then it will give me access to debug threads.
// I have to store it in a field for late use.
ILaunch launch = new Launch(null, ILaunchManager.DEBUG_MODE, null);
...
// Then I can access the thread and call stepover or resume methods
IDebugTarget target = launch.getDebugTarget();
IThread[] threads = target.getThreads();
threads[0].stepOver();
threads[0].resume();
threads[0].stepInto();