Alan Spark
Alan Spark

Reputation: 8302

Creating an Eclipse debug view

I am working on a custom debug view in an Eclipse plugin. In this view, I need to know when we are in debug mode and if a breakpoint is currently hit.

At the moment I have this working when my view is active by listening for the various debug events in DebugPlugin and IBreakpointManager. This works when my view has already been opened and the plugin is activated, but if my view is opened during a debug session then it has no way of knowing if a debug session has started or not.

Is there any way to explicitly check if a debug session is in progress? One possibility is to force my plugin to start automatically when Eclipse loads but I would rather avoid that.

Any ideas?

Thanks, Alan

Upvotes: 3

Views: 549

Answers (1)

katsharp
katsharp

Reputation: 2551

When your plug-in activates you can get a hold of the launch manager:

ILaunchManager = DebugPlugin.getDefault().getLaunchManager();

An ILaunchManager can gives you an array of ILaunch:

ILaunch[] launches = launchManager.getLaunches();

Each ILaunch has some debug targets:

IDebugTarget[] debugTargets = launch.getDebugTargets();

...and each IDebugTarget can tell you if it is currently suspended:

debugTarget.isSuspended();

I would suggest reading these APIs and doing a bit of debugging to determine exactly how to work out if a debug session is active and a breakpoint is currently hit. I haven't got time just now to check that for you.

Note: if the debug plug-in is not being used then its default will be null.

Upvotes: 4

Related Questions