1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 210366: Use the process factory so also create the gdb process.

This commit is contained in:
Marc Khouzam 2012-02-06 10:22:14 -05:00
parent ddb64447b2
commit 4fc4a8bc3b
5 changed files with 33 additions and 7 deletions

View file

@ -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$
}

View file

@ -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<String, String> attributes = new HashMap<String, String>();
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) {

View file

@ -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);
}
}

View file

@ -552,7 +552,7 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
// Bug 210366
Map<String, String> attributes = new HashMap<String, String>();
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);

View file

@ -370,7 +370,7 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
// Bug 210366
Map<String, String> attributes = new HashMap<String, String>();
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);