gpt4 book ai didi

java - 使用JDT远程控制Eclipse Debug

转载 作者:行者123 更新时间:2023-11-30 11:09:18 24 4
gpt4 key购买 nike

我正在编写一个需要使用 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 调试器发送 step over 和 step into 命令;

最佳答案

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

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

JDIDebugModel.createLineBreakpoint(...)

resumestepOver 方法是在 Debug模式下执行的线程的一部分。所以我必须保存 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();

关于java - 使用JDT远程控制Eclipse Debug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28197727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com