Eclipse plugin - handling events when stepping or breaking(Eclipse 插件 - 在步进或中断时处理事件)
问题描述
是否有从 Eclipse 调试器接收事件通知的通用方法.具体来说,我只想知道用户何时跨入/进入以及何时遇到断点.
Is there a generic way of receiving event notifications from the Eclipse debugger. Specifically I would just like to know when the user steps over/into and when a breakpoint is hit.
我已经在 JDT 中进行了这项工作(请参阅我的其他问题:Eclipse 调试器事件)但是同样的技术在 CDT 中不起作用(我使用的是 DebugPlugin.addDebugEventListener).
I have already got this working in JDT (see my other question: Eclipse Debugger Events) but the same technique doesn't work in CDT (I am using DebugPlugin.addDebugEventListener).
如果没有通用的方法来做到这一点,那么有没有办法避免在 JDT 中运行时 CDT 依赖项破坏插件?
If there is no generic way of doing this, then is there a way to avoid the CDT dependencies from breaking the plugin when it is run in JDT?
谢谢,艾伦
推荐答案
好的,我找到了可能对其他人有用的替代方案.您可以使用上述方法在会话创建和终止时侦听调试事件.
OK, I've found an alternative that may be of use for others. You can use the method outlined above to listen for debug events when the session is created and terminated.
对于任何步进事件,我发现的一种方法是注册一个 IExecutionListener 以通知发生在 Eclipse 工作区中的所有命令.您可以通过获取 ICommandService 来注册执行侦听器,如下所示:
For any stepping events, one way I found was to register an IExecutionListener to be notified of all commands that take place in the Eclipse workspace. You can register an execution listener by getting hold of an ICommandService as follows:
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class)
然后添加一个执行监听器:
Then add an execution listener:
commandService.addExecutionListener(this);
这将为您提供各种事件处理程序(notHandled、postExecuteFailure、postExecuteSuccess、preExecute),您可以从中按 commandId 值进行过滤.
This will give you various event handlers (notHandled, postExecuteFailure, postExecuteSuccess, preExecute) from which you can filter by the commandId value.
我希望这对其他人有帮助.
I hope this helps someone else.
艾伦
这篇关于Eclipse 插件 - 在步进或中断时处理事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Eclipse 插件 - 在步进或中断时处理事件
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01