1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 210366: Use a process factory so as to allow others to override.

This commit is contained in:
Anton Gorenkov 2012-02-06 09:44:13 -05:00 committed by Marc Khouzam
parent a4538dbc3a
commit ddb64447b2
7 changed files with 118 additions and 9 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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