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 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) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
@ -59,28 +57,21 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
dsession = debugConfig.getDebugger().createCoreSession(config, exe, corefile);
|
dsession = debugConfig.getDebugger().createCoreSession(config, exe, corefile);
|
||||||
}
|
} catch (CDIException e) {
|
||||||
catch (CDIException e) {
|
|
||||||
abort("Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
abort("Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICDITarget dtarget = dsession.getTargets()[0];
|
ICDITarget dtarget = dsession.getTargets()[0];
|
||||||
Process process = dtarget.getProcess();
|
|
||||||
|
|
||||||
IProcess iprocess =
|
CDebugModel.newCoreFileDebugTarget(
|
||||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(projectPath.toOSString()));
|
|
||||||
CDebugModel.newDebugTarget(
|
|
||||||
launch,
|
launch,
|
||||||
dsession.getTargets()[0],
|
dsession.getCurrentTarget(),
|
||||||
renderTargetLabel(debugConfig),
|
renderTargetLabel(debugConfig),
|
||||||
iprocess,
|
null,
|
||||||
exe.getProject(),
|
exe.getProject());
|
||||||
false,
|
|
||||||
true,
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath getCoreFilePath(final IProject project) throws CoreException {
|
protected IPath getCoreFilePath(final IProject project) throws CoreException {
|
||||||
final Shell shell = LaunchUIPlugin.getShell();
|
final Shell shell = LaunchUIPlugin.getShell();
|
||||||
final String res[] = { null };
|
final String res[] = { null };
|
||||||
if (shell == null) {
|
if (shell == null) {
|
||||||
|
@ -95,8 +86,7 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
String initPath = null;
|
String initPath = null;
|
||||||
try {
|
try {
|
||||||
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch (CoreException e) {
|
|
||||||
}
|
}
|
||||||
if (initPath == null || initPath.equals("")) {
|
if (initPath == null || initPath.equals("")) {
|
||||||
initPath = project.getLocation().toString();
|
initPath = project.getLocation().toString();
|
||||||
|
|
|
@ -76,18 +76,6 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||||
dsession = debugConfig.getDebugger().createLaunchSession(config, exe);
|
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();
|
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
|
||||||
opt.setArguments(getProgramArgumentsArray(config));
|
opt.setArguments(getProgramArgumentsArray(config));
|
||||||
File wd = getWorkingDir(config);
|
File wd = getWorkingDir(config);
|
||||||
|
@ -97,20 +85,35 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
opt.setEnvironment(getEnvironmentProperty(config));
|
opt.setEnvironment(getEnvironmentProperty(config));
|
||||||
ICDITarget dtarget = dsession.getTargets()[0];
|
ICDITarget dtarget = dsession.getTargets()[0];
|
||||||
Process process = dtarget.getProcess();
|
Process process = dtarget.getProcess();
|
||||||
IProcess iprocess =
|
IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
|
||||||
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||||
CDebugModel.newDebugTarget(
|
CDebugModel.newDebugTarget(
|
||||||
launch,
|
launch,
|
||||||
dsession.getTargets()[0],
|
dsession.getCurrentTarget(),
|
||||||
renderTargetLabel(debugConfig),
|
renderTargetLabel(debugConfig),
|
||||||
iprocess,
|
iprocess,
|
||||||
exe.getProject(),
|
exe.getProject(),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
stopInMain);
|
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));
|
Process process = exec(commandArray, getEnvironmentArray(config), getWorkingDir(config));
|
||||||
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,6 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
return pid[0];
|
return pid[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a runtime exec on the given command line in the context
|
* Performs a runtime exec on the given command line in the context
|
||||||
* of the specified working directory, and returns
|
* of the specified working directory, and returns
|
||||||
|
@ -169,18 +171,15 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||||
try {
|
try {
|
||||||
if (workingDirectory == null) {
|
if (workingDirectory == null) {
|
||||||
p = Runtime.getRuntime().exec(cmdLine, envp);
|
p = Runtime.getRuntime().exec(cmdLine, envp);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
p = Runtime.getRuntime().exec(cmdLine, envp, workingDirectory);
|
p = Runtime.getRuntime().exec(cmdLine, envp, workingDirectory);
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.destroy();
|
p.destroy();
|
||||||
}
|
}
|
||||||
abort("Error starting process", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
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
|
//attempting launches on 1.2.* - no ability to set working directory
|
||||||
|
|
||||||
IStatus status =
|
IStatus status =
|
||||||
|
|
Loading…
Add table
Reference in a new issue