mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
Replaced tabs with white space.
This commit is contained in:
parent
2d3a869931
commit
5f9445edbd
1 changed files with 74 additions and 74 deletions
|
@ -46,7 +46,7 @@ import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2;
|
||||||
* Launches PDA program on a PDA interpretter written in Perl
|
* Launches PDA program on a PDA interpretter written in Perl
|
||||||
*/
|
*/
|
||||||
public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
|
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
|
||||||
// Need to configure the source locator before creating the launch
|
// Need to configure the source locator before creating the launch
|
||||||
|
@ -54,10 +54,10 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
// the adapters will be created for the whole session, including
|
// the adapters will be created for the whole session, including
|
||||||
// the source lookup adapter.
|
// the source lookup adapter.
|
||||||
ISourceLocator locator = getSourceLocator(configuration);
|
ISourceLocator locator = getSourceLocator(configuration);
|
||||||
|
|
||||||
return new PDALaunch(configuration, mode, locator);
|
return new PDALaunch(configuration, mode, locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
|
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
|
||||||
// PDA programs do not require building.
|
// PDA programs do not require building.
|
||||||
|
@ -88,9 +88,9 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||||
String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
||||||
if (program == null) {
|
if (program == null) {
|
||||||
abort("Perl program unspecified.", null);
|
abort("Perl program unspecified.", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,21 +103,21 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
launchProcess(launch, program, requestPort, eventPort);
|
launchProcess(launch, program, requestPort, eventPort);
|
||||||
PDALaunch pdaLaunch = (PDALaunch)launch;
|
PDALaunch pdaLaunch = (PDALaunch)launch;
|
||||||
initServices(pdaLaunch, program, requestPort, eventPort);
|
initServices(pdaLaunch, program, requestPort, eventPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches PDA interpreter with the given program.
|
* Launches PDA interpreter with the given program.
|
||||||
*
|
*
|
||||||
* @param launch Launch that will contain the new process.
|
* @param launch Launch that will contain the new process.
|
||||||
* @param program PDA program to use in the interpreter.
|
* @param program PDA program to use in the interpreter.
|
||||||
* @param requestPort The port number for connecting the request socket.
|
* @param requestPort The port number for connecting the request socket.
|
||||||
* @param eventPort The port number for connecting the events socket.
|
* @param eventPort The port number for connecting the events socket.
|
||||||
*
|
*
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException {
|
private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException {
|
||||||
List<String> commandList = new ArrayList<String>();
|
List<String> commandList = new ArrayList<String>();
|
||||||
|
|
||||||
// Find Perl executable
|
// Find Perl executable
|
||||||
IValueVariable perl = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(PDAPlugin.VARIALBE_PERL_EXECUTABLE);
|
IValueVariable perl = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(PDAPlugin.VARIALBE_PERL_EXECUTABLE);
|
||||||
if (perl == null) {
|
if (perl == null) {
|
||||||
|
@ -132,50 +132,50 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
abort(MessageFormat.format("Specified Perl executable {0} does not exist. Check value of $dsfPerlExecutable.", new Object[]{path}), null);
|
abort(MessageFormat.format("Specified Perl executable {0} does not exist. Check value of $dsfPerlExecutable.", new Object[]{path}), null);
|
||||||
}
|
}
|
||||||
commandList.add(path);
|
commandList.add(path);
|
||||||
|
|
||||||
// Add PDA VM
|
// Add PDA VM
|
||||||
File vm = PDAPlugin.getFileInPlugin(new Path("pdavm/pda.pl"));
|
File vm = PDAPlugin.getFileInPlugin(new Path("pdavm/pda.pl"));
|
||||||
if (vm == null) {
|
if (vm == null) {
|
||||||
abort("Missing PDA VM", null);
|
abort("Missing PDA VM", null);
|
||||||
}
|
}
|
||||||
commandList.add(vm.getAbsolutePath());
|
commandList.add(vm.getAbsolutePath());
|
||||||
|
|
||||||
// Add PDA program
|
// Add PDA program
|
||||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program));
|
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program));
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
abort(MessageFormat.format("Perl program {0} does not exist.", new Object[] {file.getFullPath().toString()}), null);
|
abort(MessageFormat.format("Perl program {0} does not exist.", new Object[] {file.getFullPath().toString()}), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
commandList.add(file.getLocation().toOSString());
|
commandList.add(file.getLocation().toOSString());
|
||||||
|
|
||||||
// Add debug arguments - i.e. '-debug requestPort eventPort'
|
// Add debug arguments - i.e. '-debug requestPort eventPort'
|
||||||
commandList.add("-debug");
|
commandList.add("-debug");
|
||||||
commandList.add("" + requestPort);
|
commandList.add("" + requestPort);
|
||||||
commandList.add("" + eventPort);
|
commandList.add("" + eventPort);
|
||||||
|
|
||||||
// Launch the perl process.
|
// Launch the perl process.
|
||||||
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
||||||
Process process = DebugPlugin.exec(commandLine, null);
|
Process process = DebugPlugin.exec(commandLine, null);
|
||||||
|
|
||||||
// Create a debug platform process object and add it to the launch.
|
// Create a debug platform process object and add it to the launch.
|
||||||
DebugPlugin.newProcess(launch, process, path);
|
DebugPlugin.newProcess(launch, process, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the launch to initialize DSF services for this launch.
|
|
||||||
*/
|
|
||||||
private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort)
|
|
||||||
throws CoreException
|
|
||||||
{
|
|
||||||
// Synchronization object to use when waiting for the services initialization.
|
|
||||||
Query<Object> initQuery = new Query<Object>() {
|
|
||||||
@Override
|
|
||||||
protected void execute(DataRequestMonitor<Object> rm) {
|
|
||||||
pdaLaunch.initializeServices(program, requestPort, eventPort, rm);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Submit the query to the executor.
|
/**
|
||||||
|
* Calls the launch to initialize DSF services for this launch.
|
||||||
|
*/
|
||||||
|
private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort)
|
||||||
|
throws CoreException
|
||||||
|
{
|
||||||
|
// Synchronization object to use when waiting for the services initialization.
|
||||||
|
Query<Object> initQuery = new Query<Object>() {
|
||||||
|
@Override
|
||||||
|
protected void execute(DataRequestMonitor<Object> rm) {
|
||||||
|
pdaLaunch.initializeServices(program, requestPort, eventPort, rm);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Submit the query to the executor.
|
||||||
pdaLaunch.getSession().getExecutor().execute(initQuery);
|
pdaLaunch.getSession().getExecutor().execute(initQuery);
|
||||||
try {
|
try {
|
||||||
// Block waiting for query results.
|
// Block waiting for query results.
|
||||||
|
@ -185,37 +185,37 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
} catch (ExecutionException e1) {
|
} catch (ExecutionException e1) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Error in launch sequence", e1.getCause())); //$NON-NLS-1$
|
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Error in launch sequence", e1.getCause())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an exception with a new status containing the given
|
* Throws an exception with a new status containing the given
|
||||||
* message and optional exception.
|
* message and optional exception.
|
||||||
*
|
*
|
||||||
* @param message error message
|
* @param message error message
|
||||||
* @param e underlying exception
|
* @param e underlying exception
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private void abort(String message, Throwable e) throws CoreException {
|
private void abort(String message, Throwable e) throws CoreException {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, 0, message, e));
|
throw new CoreException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, 0, message, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a free port number on localhost, or -1 if unable to find a free port.
|
* Returns a free port number on localhost, or -1 if unable to find a free port.
|
||||||
*/
|
*/
|
||||||
public static int findFreePort() {
|
public static int findFreePort() {
|
||||||
ServerSocket socket= null;
|
ServerSocket socket= null;
|
||||||
try {
|
try {
|
||||||
socket= new ServerSocket(0);
|
socket= new ServerSocket(0);
|
||||||
return socket.getLocalPort();
|
return socket.getLocalPort();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
} finally {
|
} finally {
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue