mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 241985
Cleanup of GDBControl constructor
This commit is contained in:
parent
cb49d0ed44
commit
475a55a1e4
4 changed files with 59 additions and 58 deletions
|
@ -17,7 +17,6 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -88,8 +87,8 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
|
|||
return;
|
||||
}
|
||||
|
||||
SessionType sessionType = getSessionType(config);
|
||||
boolean attach = getIsAttach(config);
|
||||
SessionType sessionType = LaunchUtils.getSessionType(config);
|
||||
boolean attach = LaunchUtils.getIsAttach(config);
|
||||
|
||||
final GdbLaunch launch = (GdbLaunch)l;
|
||||
|
||||
|
@ -159,25 +158,7 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
|
|||
return new FinalLaunchSequence(executor, launch, type, attach);
|
||||
}
|
||||
|
||||
private SessionType getSessionType(ILaunchConfiguration config) {
|
||||
try {
|
||||
String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
return SessionType.LOCAL;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
return SessionType.LOCAL;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
return SessionType.CORE;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
|
||||
return SessionType.REMOTE;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH)) {
|
||||
return SessionType.REMOTE;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return SessionType.LOCAL;
|
||||
}
|
||||
|
||||
|
||||
private boolean isNonStopSession(ILaunchConfiguration config) {
|
||||
try {
|
||||
boolean nonStopMode = config.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
|
||||
|
@ -187,31 +168,12 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean getIsAttach(ILaunchConfiguration config) {
|
||||
try {
|
||||
String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
return true;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH)) {
|
||||
return true;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException {
|
||||
// no pre launch check for core file
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE) && getSessionType(config) == SessionType.CORE) return true;
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE) && LaunchUtils.getSessionType(config) == SessionType.CORE) return true;
|
||||
|
||||
return super.preLaunchCheck(config, mode, monitor);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
|
||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
||||
|
@ -227,5 +228,44 @@ public class LaunchUtils {
|
|||
|
||||
return version;
|
||||
}
|
||||
|
||||
public static boolean getIsAttach(ILaunchConfiguration config) {
|
||||
try {
|
||||
String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
return true;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
|
||||
return false;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH)) {
|
||||
return true;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SessionType getSessionType(ILaunchConfiguration config) {
|
||||
try {
|
||||
String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
return SessionType.LOCAL;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
return SessionType.LOCAL;
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
return SessionType.CORE;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
|
||||
return SessionType.REMOTE;
|
||||
} else if (debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH)) {
|
||||
return SessionType.REMOTE;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return SessionType.LOCAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,7 @@ public class ServicesLaunchSequence extends Sequence {
|
|||
// Create the connection.
|
||||
//
|
||||
fCommandControl = fLaunch.getServiceFactory().createService(fSession, GDBControl.class);
|
||||
|
||||
fCommandControl.setAttach(fAttach);
|
||||
fCommandControl.setExecPath(fExecPath);
|
||||
fCommandControl.setGdbPath(LaunchUtils.getGDBPath(fLaunch.getLaunchConfiguration()));
|
||||
fCommandControl.setSessionType(fSessionType);
|
||||
|
||||
fCommandControl.initData(fLaunch.getLaunchConfiguration());
|
||||
fCommandControl.initialize(requestMonitor);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
|
@ -43,6 +44,7 @@ import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
|||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
|
||||
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchUtils;
|
||||
import org.eclipse.dd.mi.service.command.AbstractCLIProcess;
|
||||
import org.eclipse.dd.mi.service.command.AbstractMIControl;
|
||||
import org.eclipse.dd.mi.service.command.CLIEventProcessor;
|
||||
|
@ -59,6 +61,7 @@ import org.eclipse.dd.mi.service.command.commands.MIInferiorTTYSet;
|
|||
import org.eclipse.dd.mi.service.command.output.MIBreakInsertInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
|
@ -117,15 +120,16 @@ public class GDBControl extends AbstractMIControl {
|
|||
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public void setGdbPath(IPath path) { fGdbPath = path; }
|
||||
|
||||
public void setExecPath(IPath path) { fExecPath = path; }
|
||||
|
||||
public void setSessionType(SessionType type) { fSessionType = type; }
|
||||
|
||||
public void setAttach(boolean attach) { fAttach = attach; }
|
||||
|
||||
public void setLaunchTimeout(int timeout) { fGDBLaunchTimeout = timeout; }
|
||||
public void initData(ILaunchConfiguration config) {
|
||||
fSessionType = LaunchUtils.getSessionType(config);
|
||||
fAttach = LaunchUtils.getIsAttach(config);
|
||||
fGdbPath = LaunchUtils.getGDBPath(config);
|
||||
try {
|
||||
fExecPath = LaunchUtils.verifyProgramPath(config, LaunchUtils.getCProject(config));
|
||||
} catch (CoreException e) {
|
||||
fExecPath = new Path(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GDBControl(DsfSession session, IPath gdbPath, IPath execPath, SessionType sessionType, boolean attach, int gdbLaunchTimeout) {
|
||||
|
|
Loading…
Add table
Reference in a new issue