使用JDT远程控制Eclipse Debug

时间:2015-01-28 16:45:22

标签: java eclipse eclipse-plugin remote-debugging eclipse-jdt

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

添加断点:

  IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(...)

删除断点:

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

列出所有断点:

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

但现在我的项目被暂停了#34;在我以编程方式创建的断点中,我不知道如何触发操作(STEP_OVER,STEP_INTO,RESUME)。我尝试了以下但是它不起作用:

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

我需要知道的是:

  • 如何发送步骤并执行命令来调试eclipse;

1 个答案:

答案 0 :(得分:1)

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

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

JDIDebugModel.createLineBreakpoint(...)

恢复 stepOver 方法是在调试模式下执行的Thread的一部分。所以我必须保存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();
相关问题