Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Gorenkov2012-02-06 14:44:13 +0000
committerMarc Khouzam2012-02-06 14:44:13 +0000
commitddb64447b2d7ae1c5e51b9d957781640d91f0ad7 (patch)
treebef3ecb2ef0799f83fc6284d402336c2894aa89b /dsf-gdb
parenta4538dbc3aac30229cf02ac93f413c5e714f4a23 (diff)
downloadorg.eclipse.cdt-ddb64447b2d7ae1c5e51b9d957781640d91f0ad7.tar.gz
org.eclipse.cdt-ddb64447b2d7ae1c5e51b9d957781640d91f0ad7.tar.xz
org.eclipse.cdt-ddb64447b2d7ae1c5e51b9d957781640d91f0ad7.zip
Bug 210366: Use a process factory so as to allow others to override.
Diffstat (limited to 'dsf-gdb')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml7
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java10
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java17
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java27
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java38
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java14
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java14
7 files changed, 118 insertions, 9 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml
index 305e3d583c7..267c285199b 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml
@@ -67,4 +67,11 @@
class="org.eclipse.cdt.dsf.gdb.internal.GdbPreferenceInitializer">
</initializer>
</extension>
+ <extension
+ point="org.eclipse.debug.core.processFactories">
+ <processFactory
+ class="org.eclipse.cdt.dsf.gdb.launching.GdbProcessFactory"
+ id="org.eclipse.cdt.dsf.gdb.GdbProcessFactory">
+ </processFactory>
+ </extension>
</plugin>
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java
index ebea21e6d59..9807ec2f5ec 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Ericsson and others.
+ * Copyright (c) 2008, 2012 Ericsson 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
@@ -8,6 +8,7 @@
* Contributors:
* Ericsson - initial API and implementation
* Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320)
+ * Anton Gorenkov - Need to use a process factory (Bug 210366)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb;
@@ -210,4 +211,11 @@ public class IGDBLaunchConfigurationConstants {
*/
public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_SLOW_ONLY;
+ /**
+ * The default value of DebugPlugin.ATTR_PROCESS_FACTORY_ID.
+ * @since 4.1
+ */
+ // Bug 210366
+ public static final String DEBUGGER_ATTR_PROCESS_FACTORY_ID_DEFAULT = "org.eclipse.cdt.dsf.gdb.GdbProcessFactory"; //$NON-NLS-1$
+
}
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 c1ecd5ee0a9..d3eb825e129 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Ericsson and others.
+ * Copyright (c) 2011, 2012 Ericsson 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Ericsson - initial implementation
+ * Anton Gorenkov - Need to use a process factory (Bug 210366)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb;
@@ -29,6 +30,20 @@ public interface IGdbDebugConstants {
*/
public static final String INFERIOR_GROUPID_ATTR = PREFIX + "inferiorGroupId"; //$NON-NLS-1$
+ /**
+ * Attribute key to be passed to DebugPlugin.newProcess to specify the type of process
+ * that should be created by our IProcessFactory.
+ * @since 4.1
+ */
+ public static final String PROCESS_TYPE_CREATION_ATTR = PREFIX + "createProcessType"; //$NON-NLS-1$
+
+ /**
+ * Attribute value of PROCESS_TYPE_CREATION_ATTR to be passed to DebugPlugin.newProcess to
+ * require the creation of an InferiorRuntimeProcess instead of a RuntimeProcess
+ * (which is used by default).
+ * @since 4.1
+ */
+ public static final String INFERIOR_CREATION_VALUE = PREFIX + "inferiorProcess"; //$NON-NLS-1$
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java
index 4cf94210bb0..18daedca30a 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 QNX Software Systems and others.
+ * Copyright (c) 2008, 2012 QNX Software 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
@@ -12,6 +12,7 @@
* Ericsson - Added support for Mac OS
* Ericsson - Added support for post-mortem trace files
* Abeer Bagul (Tensilica) - Allow to better override GdbLaunch (bug 339550)
+ * Anton Gorenkov - Need to use a process factory (Bug 210366)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
@@ -44,6 +45,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -274,6 +276,10 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
@Override
public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException {
+ // Setup default GDB Process Factory
+ // Bug 210366
+ setDefaultProcessFactory(config);
+
// Forcibly turn off non-stop for post-mortem sessions.
// Non-stop does not apply to post-mortem sessions.
// Now that we can have non-stop defaulting to enabled, it will prevent
@@ -293,6 +299,25 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
return super.preLaunchCheck(config, mode, monitor);
}
+
+ /**
+ * Modify the ILaunchConfiguration to set the DebugPlugin.ATTR_PROCESS_FACTORY_ID attribute,
+ * so as to specify the process factory to use.
+ *
+ * This attribute should only be set if it is not part of the configuration already, to allow
+ * other code to set it to something else.
+ * @since 4.1
+ */
+ protected void setDefaultProcessFactory(ILaunchConfiguration config) throws CoreException {
+ // Bug 210366
+ if (!config.hasAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID)) {
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID,
+ IGDBLaunchConfigurationConstants.DEBUGGER_ATTR_PROCESS_FACTORY_ID_DEFAULT);
+ wc.doSave();
+ }
+ }
+
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
// Need to configure the source locator before creating the launch
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
new file mode 100644
index 00000000000..68c39e08ecd
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbProcessFactory.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Anton Gorenkov
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Gorenkov - initial API and implementation (Bug 210366)
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.launching;
+
+import java.util.Map;
+
+import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.IProcessFactory;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.RuntimeProcess;
+
+/**
+ * Default GDB Process Factory creation of launch processes
+ * using DebugPlugin.newProcess()
+ * @since 4.1
+ */
+public class GdbProcessFactory implements IProcessFactory {
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @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))) {
+ 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 d6b40ea618b..165659d1e58 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Ericsson and others.
+ * Copyright (c) 2008, 2012 Ericsson 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Ericsson - initial API and implementation
+ * Anton Gorenkov - Need to use a process factory (Bug 210366)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
@@ -545,9 +546,16 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
}
// Add the inferior
- InferiorRuntimeProcess runtimeInferior = new InferiorRuntimeProcess(launch, inferior, label, null);
+ // 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 an inferior process.
+ // Bug 210366
+ Map<String, String> attributes = new HashMap<String, String>();
+ attributes.put(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR,
+ IGdbDebugConstants.INFERIOR_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);
- launch.addProcess(runtimeInferior);
rm.done();
}
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 43634a226f9..989d5939d24 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Ericsson and others.
+ * Copyright (c) 2011, 2012 Ericsson 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
@@ -8,6 +8,7 @@
* Contributors:
* Ericsson - initial API and implementation
* Sergey Prigogin (Google)
+ * Anton Gorenkov - Need to use a process factory (Bug 210366)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
@@ -363,9 +364,16 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence {
}
// Add the inferior
- InferiorRuntimeProcess runtimeInferior = new InferiorRuntimeProcess(launch, inferior, label, null);
+ // 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 an inferior process.
+ // Bug 210366
+ Map<String, String> attributes = new HashMap<String, String>();
+ attributes.put(IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR,
+ IGdbDebugConstants.INFERIOR_CREATION_VALUE);
+ IProcess runtimeInferior = DebugPlugin.newProcess(launch, inferior, label, attributes);
+ // Now set the inferior groupId
runtimeInferior.setAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR, groupId);
- launch.addProcess(runtimeInferior);
rm.done();
}

Back to the top