diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java index d3eb825e129..f50d84f1021 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java @@ -8,6 +8,7 @@ * Contributors: * Ericsson - initial implementation * Anton Gorenkov - Need to use a process factory (Bug 210366) + * Marc Khouzam (Ericsson) - Support for factory to create the gdb process (Bug 210366) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb; @@ -43,7 +44,16 @@ public interface IGdbDebugConstants { * (which is used by default). * @since 4.1 */ - public static final String INFERIOR_CREATION_VALUE = PREFIX + "inferiorProcess"; //$NON-NLS-1$ + public static final String INFERIOR_PROCESS_CREATION_VALUE = PREFIX + "inferiorProcess"; //$NON-NLS-1$ + + /** + * Attribute value of PROCESS_TYPE_CREATION_ATTR to be passed to DebugPlugin.newProcess to + * require the creation of an GdbProcess instead of a RuntimeProcess + * (which is used by default). + * @since 4.1 + */ + public static final String GDB_PROCESS_CREATION_VALUE = PREFIX + "gdbProcess"; //$NON-NLS-1$ + } 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 11db047ca37..70d33d94110 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 @@ -8,9 +8,12 @@ * Contributors: * Wind River Systems - initial API and implementation * Marc Khouzam (Ericsson) - Fix NPE for partial launches (Bug 368597) + * Marc Khouzam (Ericsson) - Create the gdb process through the process factory (Bug 210366) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.launching; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; @@ -33,6 +36,7 @@ import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent; +import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.memory.GdbMemoryBlockRetrieval; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; @@ -173,8 +177,14 @@ public class GdbLaunch extends DsfLaunch } }).get(); - GDBProcess gdbProcess = new GDBProcess(this, cliProc, label, null); - addProcess(gdbProcess); + // Need to go through DebugPlugin.newProcess so that we can use + // the overrideable process factory to allow others to override. + // First set attribute to specify we want to create the gdb process. + // Bug 210366 + Map attributes = new HashMap(); + attributes.put(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR, + IGdbDebugConstants.GDB_PROCESS_CREATION_VALUE); + DebugPlugin.newProcess(this, cliProc, label, attributes); } 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) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java index 68c39e08ecd..befcfed461f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java @@ -7,6 +7,7 @@ * * Contributors: * Anton Gorenkov - initial API and implementation (Bug 210366) + * Marc Khouzam (Ericsson) - Add support to create the gdb process as well (Bug 210366) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.launching; @@ -29,10 +30,15 @@ public class GdbProcessFactory implements IProcessFactory { @Override public IProcess newProcess(ILaunch launch, Process process, String label, Map attributes) { if (attributes != null) { - if (IGdbDebugConstants.INFERIOR_CREATION_VALUE.equals(attributes.get(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR))) { + if (IGdbDebugConstants.GDB_PROCESS_CREATION_VALUE.equals(attributes.get(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR))) { + return new GDBProcess(launch, process, label, attributes); + } + + if (IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE.equals(attributes.get(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR))) { return new InferiorRuntimeProcess(launch, process, label, attributes); } - } + } + return new RuntimeProcess(launch, process, label, attributes); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java index 165659d1e58..923a7af4b7c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java @@ -552,7 +552,7 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses { // Bug 210366 Map attributes = new HashMap(); attributes.put(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR, - IGdbDebugConstants.INFERIOR_CREATION_VALUE); + IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE); IProcess runtimeInferior = DebugPlugin.newProcess(launch, inferior, label, attributes); // Now set the inferior groupId runtimeInferior.setAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR, MIProcesses.UNIQUE_GROUP_ID); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java index 989d5939d24..6f8a2fd69fd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java @@ -370,7 +370,7 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { // Bug 210366 Map attributes = new HashMap(); attributes.put(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR, - IGdbDebugConstants.INFERIOR_CREATION_VALUE); + IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE); IProcess runtimeInferior = DebugPlugin.newProcess(launch, inferior, label, attributes); // Now set the inferior groupId runtimeInferior.setAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR, groupId);