diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 67268fbb0e5..470aafa91f3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -51,6 +51,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IDisconnect; import org.eclipse.debug.core.model.IMemoryBlockRetrieval; +import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.ITerminate; @@ -153,7 +154,10 @@ public class GdbLaunch extends DsfLaunch } }).get(); - DebugPlugin.newProcess(this, inferiorProc, label); + IProcess inferior = DebugPlugin.newProcess(this, inferiorProc, label); + // Register the model adapter so that the inferior console becomes visible + // when we select a debug context for this debug session. + getSession().registerModelAdapter(IProcess.class, inferior); } catch (InterruptedException e) { throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$ } catch (ExecutionException e) { @@ -180,6 +184,18 @@ public class GdbLaunch extends DsfLaunch GDBProcess gdbProcess = new GDBProcess(this, cliProc, label, null); addProcess(gdbProcess); + + Object existingAdapter = getSession().getModelAdapter(IProcess.class); + if (existingAdapter == null) { + // Register the model adapter to the gdbProcess only if there is no other one + // registered already; if there is already one, it is from our inferior process + // and it takes precedence because we want the inferior console to show + // when we select a debug context of this debug session. + // If the inferior process is added later, it will properly overwrite this model adapter. + // Note that we don't always have an inferior console, so it is important to register + // this adapter for those cases. + getSession().registerModelAdapter(IProcess.class, gdbProcess); + } } catch (InterruptedException e) { throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$ } catch (ExecutionException e) { @@ -283,7 +299,7 @@ public class GdbLaunch extends DsfLaunch fExecutor.execute(shutdownSeq); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") @Override public Object getAdapter(Class adapter) { // Must force adapters to be loaded. diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/launch/StandardProcessVMNode.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/launch/StandardProcessVMNode.java index f637b8697e6..9ce08a5ab48 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/launch/StandardProcessVMNode.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/launch/StandardProcessVMNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. + * Copyright (c) 2006, 2010 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,17 +11,13 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider; import org.eclipse.cdt.dsf.ui.viewmodel.IVMContext; -import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode; import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; import org.eclipse.debug.core.DebugEvent; -import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IProcess; -import org.eclipse.debug.core.model.IStreamsProxy; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; @@ -39,52 +35,6 @@ import org.eclipse.jface.viewers.TreePath; @SuppressWarnings("restriction") public class StandardProcessVMNode extends AbstractVMNode { - /** - * VMC element implementation, it is a proxy for the IProcess class, to - * allow the standard label adapter to be used with this object. - */ - private class VMC extends AbstractVMContext - implements IProcess - { - private final IProcess fProcess; - - VMC(IProcess process) { - super(StandardProcessVMNode.this); - fProcess = process; - } - - @Override - public IVMNode getVMNode() { return StandardProcessVMNode.this; } - @Override - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) { - Object vmcAdapter = super.getAdapter(adapter); - if (vmcAdapter != null) { - return vmcAdapter; - } - return fProcess.getAdapter(adapter); - } - @Override - public String toString() { return "IProcess " + fProcess.toString(); } //$NON-NLS-1$ - - public String getAttribute(String key) { return fProcess.getAttribute(key); } - public int getExitValue() throws DebugException { return fProcess.getExitValue(); } - public String getLabel() { return fProcess.getLabel(); } - public ILaunch getLaunch() { return fProcess.getLaunch(); } - public IStreamsProxy getStreamsProxy() { return fProcess.getStreamsProxy(); } - public void setAttribute(String key, String value) { fProcess.setAttribute(key, value); } - public boolean canTerminate() { return fProcess.canTerminate(); } - public boolean isTerminated() { return fProcess.isTerminated(); } - public void terminate() throws DebugException { fProcess.terminate(); } - - @Override - public boolean equals(Object other) { - return other instanceof VMC && fProcess.equals(((VMC)other).fProcess); - } - @Override - public int hashCode() { return fProcess.hashCode(); } - } - public StandardProcessVMNode(AbstractVMProvider provider) { super(provider); } @@ -111,7 +61,7 @@ public class StandardProcessVMNode extends AbstractVMNode { */ IProcess[] processes = launch.getProcesses(); for (int i = 0; i < processes.length; i++) { - update.setChild(new VMC(processes[i]), i); + update.setChild(processes[i], i); } update.done(); } @@ -209,7 +159,7 @@ public class StandardProcessVMNode extends AbstractVMNode { } protected void handleChange(DebugEvent event, ModelDelta parent) { - parent.addNode(new VMC((IProcess)event.getSource()), IModelDelta.STATE); + parent.addNode(event.getSource(), IModelDelta.STATE); } protected void handleCreate(DebugEvent event, ModelDelta parent) {