Eclipse 插件 - 在步进或中断时处理事件 [英] Eclipse plugin - handling events when stepping or breaking

查看:27
本文介绍了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.

我已经在 J​​DT 中进行了这项工作(请参阅我的其他问题: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 插件 - 在步进或中断时处理事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆