Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-debug-dev] Debugging native apps in Eclipse

Why does the Browse button for selecting binary image limit itself to
binaries within a CDT project?

For ARM elf binaries(embedded development) it was sufficient to simply
disable the checks.

After 'einigen flüchtigen vergeblichen Versuchen' for CygWin binaries, I
decided to look at this later because it wasn't necessary for my
immediate objectives. :-)


-- 
Øyvind Harboe
http://www.zylin.com
Index: 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
--- CMainTab.java	6 Dec 2004 23:23:09 -0000	1.44
+++ CMainTab.java	4 Feb 2005 13:35:50 -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,58 +369,23 @@
 	 * 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);
 
 	}
 

Back to the top