【问题标题】:Remote control Eclipse Debug using JDT使用JDT远程控制Eclipse Debug
【发布时间】:2015-03-27 16:13:36
【问题描述】:

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

添加断点:

  IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(...)

要删除断点:

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

列出所有断点:

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

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

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

我需要知道的是:

  • 如何向 Eclipse 调试器发送单步执行和单步执行命令;

【问题讨论】:

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


    【解决方案1】:

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

    诀窍是不像我在创建断点时那样使用静态方法

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      • 2012-08-22
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多