问题描述
是否有通用的方法来接收来自Eclipse调试器的事件通知。具体来说,我只想知道用户何时跳过/当断点被击中时。我已经在JDT中工作了(见我的另一个问题: )但是同样的技术在CDT中不起作用(我正在使用DebugPlugin.addDebugEventListener)
如果没有通用的方法,那么有没有办法在JDT中运行时避免CDT依赖破坏插件?
谢谢,
Alan
一种可能对其他人有用的替代方案。您可以使用上述方法在创建和终止会话时监听调试事件。
对于任何步进事件,我发现的一种方法是将IExecutionListener注册到通知在Eclipse工作区中发生的所有命令。您可以通过获取ICommandService注册执行侦听器,如下所示:
ICommandService commandService =(ICommandService)PlatformUI.getWorkbench() .getService(ICommandService.class)
然后添加执行侦听器:
commandService.addExecutionListener(this);
这将为您提供各种可以过滤的事件处理程序(notHandled,postExecuteFailure,postExecuteSuccess,preExecute)通过commandId值。
我希望这有助于别人。
Alan
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.
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).
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?
Thanks,Alan
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.
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);
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.
Alan
这篇关于Eclipse插件 - 处理或打破事件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!