Search code examples
eclipsedebuggingeventseclipse-plugineclipse-cdt

Eclipse plugin - handling events when stepping or breaking


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


Solution

  • 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