[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-debug-dev] AW: getting current debug session
|
Thank you for your response,
but in my CDT installation there is no class called MISessionObserver,
or i could not import it correctly. In which package is it?
Regards.
Ploett, Norbert wrote:
>
> Hi,
>
> I did this a while ago for a custom made view to see the content of the
> mailboxes on my target system. I started with a new plug-in which
> implemented a view (this is something that the new project wizard can
> generate for you out of the box). Then I took the following steps:
>
> Step 1) Register for debug events when the view was created:
>
>
> org.eclipse.debug.core.DebugPlugin.getDefault().addDebugEventListener(ha
> ndler);
>
> where handler is a class you implement yourself.
>
> Step 2) Evaluate debug events in your handler class
>
> public void handleDebugEvents(DebugEvent[] events) {
> for (int i = 0; i < events.length; i++) {
> DebugEvent event = events[i];
> Object eventSource = event.getSource();
> if (eventSource instanceof CDebugTarget) {
> CDebugTarget debugTarget =
> (CDebugTarget) eventSource;
> handleCDebugTarget(debugTarget);
> if (event.getKind()==event.SUSPEND) {
> handleCDebugTargetSuspend();
> }
> }
> }
> }
>
> If the event comes from a CDebugTarget then it is from a CDT debug
> session. The above snippet contains two further function calls:
> handleCDebugTarget() and handleCDebugTargetSuspend():
>
> Step 3) Get the debug session from the CDebugTarget:
>
> private CDebugTarget target ;
> private MISession session ;
>
> private void handleCDebugTarget(CDebugTarget debugTarget) {
>
> target = debugTarget ;
> ICDISession cdiSession =
> debugTarget.getCDISession();
> ICDITarget[] targets = cdiSession.getTargets();
>
> ICDITarget cdiTarget = null ;
> for (int i = 0; i < targets.length; i++) {
> ICDITarget cdiTargetCandidate =
> targets[i];
> if (cdiTargetCandidate instanceof
> Target) {
> cdiTarget = cdiTargetCandidate ;
> break ;
> }
> }
> if (cdiTarget!=null) {
> Target miTarget = (Target) cdiTarget;
> session = miTarget.getMISession();
>
> observer = new MISessionObserver();
> session.addObserver(observer);
>
> }
> }
> }
>
> Step 4) Send some commands to the session when the session suspends e.g.
> to refresh your view (here it is the info signals command):
>
> private void handleCDebugTargetSuspend() {
>
> if ((target != null) && (session != null)) {
>
> final CLIInfoSignals c =
> session.getCommandFactory().createCLIInfoSignals();
>
> try {
> session.postCommand(c);
> CLIInfoSignalsInfo info =
> c.getMIInfoSignalsInfo();
> MISigHandle handles[] =
> info.getMISignals();
> // and now do something with the results
> here ...
> } catch (MIException e) {
> EcosmboxviewPlugin.say(e);
> }
> session.toString();
> }
> }
>
>
> If this works for you you owe me something :-) It was a bit of work to
> find this out when I did it.
>
> Hope this helps, anyway.
>
>
> Norbert
>
>
> _______________________________________________
> cdt-debug-dev mailing list
> cdt-debug-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-debug-dev
>
>
--
View this message in context: http://www.nabble.com/getting-current-debug-session-tf2144741.html#a5923557
Sent from the Eclipse CDT - debug forum at Nabble.com.