Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-debug-dev] Projectless debugging of Linux apps

With this change, I can debug local Linux apps w/CDT even if they are
outside a CDT project. 

This is especially nice since Insight is busted on my Debian box(don't
know why, don't care now that CDT works :-)

All I did was to remove the restrictions on the Browse button to look
only inside CDT projects. GDB can put up error messages if I try to
debug a non-binary, I don't need CDT to do that.

It doesn't work under Windows/CygWin, since there is no binary parser.
Why does CDT need a binary parser to debug w/GDB anyway? I can accept
that it might be useful to add extra features, but why is it insisted
upon?


-- 
Øyvind Harboe
http://www.zylin.com
Index: src/org/eclipse/cdt/launch/ui/CMainTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java,v
retrieving revision 1.44
diff -u -r1.44 CMainTab.java
--- src/org/eclipse/cdt/launch/ui/CMainTab.java	6 Dec 2004 23:23:09 -0000	1.44
+++ src/org/eclipse/cdt/launch/ui/CMainTab.java	4 Feb 2005 23:03:46 -0000
@@ -52,6 +52,7 @@
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
@@ -368,59 +369,24 @@
 	 * the specified project.
 	 */
 	protected void handleBinaryBrowseButtonSelected() {
-		final ICProject cproject = getCProject();
-		if (cproject == null) {
-			MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
-					LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
-			return;
-		}
-
-		ElementTreeSelectionDialog dialog;
-		WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
-		WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
-		dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
-		dialog.setTitle(LaunchMessages.getString("CMainTab.Program_selection")); //$NON-NLS-1$
-		dialog.setMessage(LaunchMessages.getFormattedString(
-				"CMainTab.Choose_program_to_run_from_NAME", cproject.getResource().getName())); //$NON-NLS-1$
-		dialog.setBlockOnOpen(true);
-		dialog.setAllowMultiple(false);
-		dialog.setInput(cproject.getResource());
-		dialog.setValidator(new ISelectionStatusValidator() {
-
-			public IStatus validate(Object[] selection) {
-				if (selection.length == 0 || !(selection[0] instanceof IFile)) {
-					return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchMessages
-							.getString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
-				}
-				try {
-					ICElement celement = cproject.findElement(((IFile) selection[0]).getProjectRelativePath());
-					if (celement == null
-							|| (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
-						return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchMessages
-								.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
-					}
-
-					return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource()
-							.getName(), null);
-				} catch (Exception ex) {
-					return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchMessages
-							.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
-				}
-			}
-		});
+	    FileDialog dialog=new FileDialog(getShell());
 
-		if (dialog.open() == Window.CANCEL) {
-			return;
+	    final ICProject cproject = getCProject();
+		if (cproject != null) {
+		    dialog.setFilterPath(cproject.getPath().toOSString());
 		}
 
-		Object[] results = dialog.getResult();
-
-		try {
-			fProgText.setText(((IResource) results[0]).getProjectRelativePath().toString());
-		} catch (Exception ex) {
-			/* Make sure it is a file */
+		String fileName;
+		fileName=dialog.open();
+		if (fileName.length()==0)
+		{
+		    return;
 		}
 
+		// it is the debuggers job to put up an error message. The binary might not
+		// even exist yet at this point.
+		fProgText.setText(fileName);
+
 	}
 
 	/**
@@ -554,23 +520,6 @@
 		}
 		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
 
-		name = fProgText.getText().trim();
-		if (name.length() == 0) {
-			setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
-			return false;
-		}
-		if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
-			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
-			return false;
-		}
-		if (!project.isOpen()) {
-			setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
-			return false;
-		}
-		if (!project.getFile(name).exists()) {
-			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
-			return false;
-		}
 		return true;
 	}
 

Back to the top