mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
use new debug target creation methods
This commit is contained in:
parent
75201f7a47
commit
103c42de84
2 changed files with 59 additions and 70 deletions
|
@ -32,9 +32,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
*/
|
||||
public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||
|
||||
|
||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -59,28 +57,21 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
}
|
||||
try {
|
||||
dsession = debugConfig.getDebugger().createCoreSession(config, exe, corefile);
|
||||
}
|
||||
catch (CDIException e) {
|
||||
} catch (CDIException e) {
|
||||
abort("Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
ICDITarget dtarget = dsession.getTargets()[0];
|
||||
Process process = dtarget.getProcess();
|
||||
|
||||
IProcess iprocess =
|
||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(projectPath.toOSString()));
|
||||
CDebugModel.newDebugTarget(
|
||||
CDebugModel.newCoreFileDebugTarget(
|
||||
launch,
|
||||
dsession.getTargets()[0],
|
||||
dsession.getCurrentTarget(),
|
||||
renderTargetLabel(debugConfig),
|
||||
iprocess,
|
||||
exe.getProject(),
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
null,
|
||||
exe.getProject());
|
||||
}
|
||||
|
||||
private IPath getCoreFilePath(final IProject project) throws CoreException {
|
||||
protected IPath getCoreFilePath(final IProject project) throws CoreException {
|
||||
final Shell shell = LaunchUIPlugin.getShell();
|
||||
final String res[] = { null };
|
||||
if (shell == null) {
|
||||
|
@ -95,8 +86,7 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
String initPath = null;
|
||||
try {
|
||||
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
||||
}
|
||||
catch (CoreException e) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
if (initPath == null || initPath.equals("")) {
|
||||
initPath = project.getLocation().toString();
|
||||
|
|
|
@ -76,18 +76,6 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
dsession = debugConfig.getDebugger().createLaunchSession(config, exe);
|
||||
}
|
||||
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
int pid = getProcessID();
|
||||
if ( pid == -1 ) {
|
||||
cancel("No Process ID selected", ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID);
|
||||
}
|
||||
dsession = debugConfig.getDebugger().createAttachSession(config, exe, pid);
|
||||
}
|
||||
}
|
||||
catch (CDIException e) {
|
||||
abort( "Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
|
||||
opt.setArguments(getProgramArgumentsArray(config));
|
||||
File wd = getWorkingDir(config);
|
||||
|
@ -97,20 +85,35 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
opt.setEnvironment(getEnvironmentProperty(config));
|
||||
ICDITarget dtarget = dsession.getTargets()[0];
|
||||
Process process = dtarget.getProcess();
|
||||
IProcess iprocess =
|
||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||
IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||
CDebugModel.newDebugTarget(
|
||||
launch,
|
||||
dsession.getTargets()[0],
|
||||
dsession.getCurrentTarget(),
|
||||
renderTargetLabel(debugConfig),
|
||||
iprocess,
|
||||
exe.getProject(),
|
||||
true,
|
||||
false,
|
||||
stopInMain);
|
||||
|
||||
} else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
int pid = getProcessID();
|
||||
if (pid == -1) {
|
||||
cancel("No Process ID selected", ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID);
|
||||
}
|
||||
else {
|
||||
dsession = debugConfig.getDebugger().createAttachSession(config, exe, pid);
|
||||
CDebugModel.newAttachDebugTarget(
|
||||
launch,
|
||||
dsession.getCurrentTarget(),
|
||||
renderTargetLabel(debugConfig),
|
||||
null,
|
||||
exe.getProject());
|
||||
}
|
||||
} catch (CDIException e) {
|
||||
abort("Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
} else {
|
||||
Process process = exec(commandArray, getEnvironmentArray(config), getWorkingDir(config));
|
||||
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||
}
|
||||
|
@ -149,7 +152,6 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
return pid[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs a runtime exec on the given command line in the context
|
||||
* of the specified working directory, and returns
|
||||
|
@ -169,18 +171,15 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
try {
|
||||
if (workingDirectory == null) {
|
||||
p = Runtime.getRuntime().exec(cmdLine, envp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
p = Runtime.getRuntime().exec(cmdLine, envp, workingDirectory);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
if (p != null) {
|
||||
p.destroy();
|
||||
}
|
||||
abort("Error starting process", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
catch (NoSuchMethodError e) {
|
||||
} catch (NoSuchMethodError e) {
|
||||
//attempting launches on 1.2.* - no ability to set working directory
|
||||
|
||||
IStatus status =
|
||||
|
|
Loading…
Add table
Reference in a new issue