使用JDT远程控制Eclipse Debug

Remote control Eclipse Debug using JDT

我正在编写一个需要使用 eclipse JDT 进行远程调试的应用程序。我的应用程序和 eclipse 之间的通信很好,我正在使用以下方法来管理断点:

添加断点:

  IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(...)

删除断点:

  IJavaLineBreakpoint breakpoint = JDIDebugModel.lineBreakpointExists(...);
  breakpoint.delete();

列出所有断点:

 IBreakpointManager mgr = DebugPlugin.getDefault().getBreakpointManager();
 mgr.getBreakpoints();

但现在我的项目 "suspended" 在我以编程方式创建的断点中,我不知道如何触发操作(STEP_OVER、STEP_INTO、RESUME)。我已尝试以下但不起作用:

DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(getResource(projectId, fullClassName), DebugEvent.STEP_OVER)});

我需要知道的是:

我在 eclipse 源代码中做一些研究解决了这个问题。

诀窍是,而不是像我在创建 breakponts 时那样使用静态方法

JDIDebugModel.createLineBreakpoint(...)

resumestepOver 方法是在调试模式下执行的线程的一部分。所以我必须保存 ILauch 对象,因为这样我就可以访问调试线程。

    // 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();