[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] CDT Launch changes
|
Uses new process list extension point to support attaching to process
with debugger
-------------
Index: src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java,v
retrieving revision 1.5
diff -u -r1.5 ICDTLaunchConfigurationConstants.java
--- src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java
28 Aug 2002 20:36:59 -0000 1.5
+++ src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java
17 Sep 2002 19:09:41 -0000
@@ -121,6 +121,9 @@
*/
public static final int ERR_DEBUGGER_NOT_INSTALLED = 102;
+ public static final int ERR_NO_PROCESSID = 103;
+ public static final int ERR_NO_COREFILE = 104;
+
/**
* Status code indicating an unexpected internal error.
*/
Index:
src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java,v
retrieving revision 1.10
diff -u -r1.10 LocalCLaunchConfigurationDelegate.java
---
src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
16 Sep 2002 19:26:49 -0000 1.10
+++
src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
17 Sep 2002 19:09:41 -0000
@@ -13,6 +13,9 @@
import java.util.Arrays;
import java.util.Date;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.cdt.core.IProcessList;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
@@ -42,9 +45,15 @@
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
/**
* Insert the type's description here.
@@ -120,29 +129,20 @@
else if
(debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
int pid = getProcessID();
if ( pid == -1 ) {
- monitor.setCanceled(true);
- return;
+ abort("No Process ID selected", null,
ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID);
}
dsession = cdebugger.createAttachSession(config,
exe, pid);
}
else if
(debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
IPath corefile =
getCoreFilePath((IProject)cproject.getResource());
if ( corefile == null ) {
- monitor.setCanceled(true);
- return;
+ abort("No Corefile selected", null,
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
}
dsession = cdebugger.createCoreSession(config, exe,
corefile);
}
}
catch (CDIException e) {
- IStatus status =
- new Status(
- 0,
- LaunchUIPlugin.getUniqueIdentifier(),
-
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
- "CDI Error",
- e);
- throw new CoreException(status);
+ abort( "Failed Launching CDI Debugger", e,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
opt.setArguments(getProgramArgumentsArray(config));
@@ -206,7 +206,34 @@
private int getProcessID() {
- return -1;
+ final Shell shell = LaunchUIPlugin.getShell();
+ final int pid[] = {-1};
+ if ( shell == null )
+ return -1;
+ Display display = shell.getDisplay();
+ display.syncExec(new Runnable() {
+ public void run() {
+ ElementListSelectionDialog dialog = new
ElementListSelectionDialog( shell, new LabelProvider() {
+ public String getText(Object element) {
+ IProcessInfo info = (IProcessInfo)element;
+ return info.getPid() + " " + info.getName();
+ }
+ } );
+ dialog.setTitle( "Select Process" );
+ dialog.setMessage("Select a Process to attach debugger
to:");
+ IProcessList plist =
CCorePlugin.getDefault().getProcessList();
+ if ( plist == null ) {
+ MessageDialog.openError(shell, "CDT Launch Error",
"Current platform does not support listing processes");
+ return;
+ }
+ dialog.setElements(plist.getProcessList());
+ if ( dialog.open() == dialog.OK ) {
+ IProcessInfo info =
(IProcessInfo)dialog.getFirstResult();
+ pid[0] = info.getPid();
+ }
+ }
+ });
+ return pid[0];
}
@@ -238,7 +265,7 @@
if (p != null) {
p.destroy();
}
- abort("Exception starting process", e,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ abort("Error starting process", e,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
catch (NoSuchMethodError e) {
//attempting launches on 1.2.* - no ability to set working
directory