[Esbox-commits] r343 - in trunk/org.indt.esbox.launch: META-INF src/org/indt/esbox/launch src/org/indt/esbox/launch/internal src/org/indt/esbox/launch/internal/ui src/org/indt/esbox/launch/local src/org/indt/esbox/launch/remote

raul at garage.maemo.org raul at garage.maemo.org
Fri Dec 7 14:18:36 EET 2007


Author: raul
Date: 2007-12-07 14:18:33 +0200 (Fri, 07 Dec 2007)
New Revision: 343

Added:
   trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/IESboxCDTLaunchConfigurationConstants.java
Removed:
   trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/IESboxCDTLaunchConfigurationConstants.java
Modified:
   trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF
   trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ESboxCMainTab.java
   trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/local/ESboxLocalRunLaunchDelegate.java
   trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java
Log:
final fixies. C/C++ debugger is finally ok.

Modified: trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF	2007-12-07 12:12:09 UTC (rev 342)
+++ trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF	2007-12-07 12:18:33 UTC (rev 343)
@@ -14,3 +14,4 @@
  org.eclipse.debug.ui,
  org.indt.esbox.core
 Eclipse-LazyStart: true
+Export-Package: org.indt.esbox.launch

Copied: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/IESboxCDTLaunchConfigurationConstants.java (from rev 340, trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/IESboxCDTLaunchConfigurationConstants.java)
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/IESboxCDTLaunchConfigurationConstants.java	                        (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/IESboxCDTLaunchConfigurationConstants.java	2007-12-07 12:18:33 UTC (rev 343)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.launch;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+
+/**
+ * 
+ *
+ */
+public interface IESboxCDTLaunchConfigurationConstants extends ICDTLaunchConfigurationConstants {
+
+	public static final String ATTR_RUN_STANDALONE = ICDTLaunchConfigurationConstants.CDT_LAUNCH_ID + ".run_standalone"; //$NON-NLS-1$
+
+	public static final boolean RUN_STANDALONE_DEFAULT = true;
+}

Deleted: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/IESboxCDTLaunchConfigurationConstants.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/IESboxCDTLaunchConfigurationConstants.java	2007-12-07 12:12:09 UTC (rev 342)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/IESboxCDTLaunchConfigurationConstants.java	2007-12-07 12:18:33 UTC (rev 343)
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 INdT.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
- *******************************************************************************/
-package org.indt.esbox.launch.internal;
-
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-
-/**
- * 
- *
- */
-public interface IESboxCDTLaunchConfigurationConstants extends ICDTLaunchConfigurationConstants {
-
-	public static final String ATTR_RUN_STANDALONE = ICDTLaunchConfigurationConstants.CDT_LAUNCH_ID + ".run_standalone"; //$NON-NLS-1$
-
-	public static final boolean RUN_STANDALONE_DEFAULT = true;
-}

Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ESboxCMainTab.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ESboxCMainTab.java	2007-12-07 12:12:09 UTC (rev 342)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ESboxCMainTab.java	2007-12-07 12:18:33 UTC (rev 343)
@@ -24,8 +24,8 @@
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
 import org.indt.esbox.launch.LaunchActivator;
-import org.indt.esbox.launch.internal.IESboxCDTLaunchConfigurationConstants;
 
 /**
  * 

Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/local/ESboxLocalRunLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/local/ESboxLocalRunLaunchDelegate.java	2007-12-07 12:12:09 UTC (rev 342)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/local/ESboxLocalRunLaunchDelegate.java	2007-12-07 12:18:33 UTC (rev 343)
@@ -20,6 +20,8 @@
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.ICDIDebugger;
+import org.eclipse.cdt.debug.core.ICDIDebugger2;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
 import org.eclipse.cdt.debug.core.cdi.CDIException;
@@ -51,9 +53,8 @@
 import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
 import org.indt.esbox.core.scratchbox.ScratchboxException;
 import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
 import org.indt.esbox.launch.LaunchActivator;
-import org.indt.esbox.launch.internal.IESboxCDTLaunchConfigurationConstants;
-import org.indt.esbox.launch.internal.ui.ESboxCMainTab;
 
 /**
  * 
@@ -117,7 +118,7 @@
 				String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
 						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
 				if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
-					dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
+					dsession = createCDISession(config, launch, debugConfig,
 							new SubProgressMonitor(monitor, 8));
 					try {
 						try {
@@ -150,8 +151,9 @@
 							if (process != null) {
 								iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()), getDefaultProcessMap());
 							}
-							CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig),
-									iprocess, exeFile, true, false, stopSymbol, true);
+							CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
+														 renderTargetLabel(debugConfig), iprocess,
+														 exeFile, true, false, stopSymbol, true);
 						}
 					} catch (CoreException e) {
 						try {
@@ -220,6 +222,40 @@
 				
 	}
 	
+	private ICDISession createCDISession(ILaunchConfiguration config,
+			ILaunch launch, ICDebugConfiguration debugConfig,
+			IProgressMonitor monitor) throws CoreException {
+		ICDISession session = null;
+		ICDIDebugger debugger = debugConfig.createDebugger();
+		if (debugger instanceof ICDIDebugger2)
+			session = launchDebugSession(config, launch,
+					(ICDIDebugger2) debugger, monitor);
+		else
+			// support old debugger types
+			session = launchOldDebugSession(config, launch, debugger, monitor);
+		return session;
+	}
+
+	private ICDISession launchOldDebugSession(ILaunchConfiguration config,
+			ILaunch launch, ICDIDebugger debugger, IProgressMonitor monitor)
+			throws CoreException {
+		IBinaryObject exeFile = null;
+		IPath exePath = verifyProgramPath(config);
+		ICProject project = verifyCProject(config);
+		if (exePath != null) {
+			exeFile = verifyBinary(project, exePath);
+		}
+		return debugger.createDebuggerSession(launch, exeFile, monitor);
+	}
+
+	private ICDISession launchDebugSession(ILaunchConfiguration config,
+			ILaunch launch, ICDIDebugger2 debugger, IProgressMonitor monitor)
+			throws CoreException {
+		IPath path = verifyProgramPath(config);
+		File exeFile = path != null ? path.toFile() : null;
+		return debugger.createSession(launch, exeFile, monitor);
+	}
+	
 	/**
 	 *
 	 */

Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java	2007-12-07 12:12:09 UTC (rev 342)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java	2007-12-07 12:18:33 UTC (rev 343)
@@ -20,6 +20,8 @@
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.ICDIDebugger;
+import org.eclipse.cdt.debug.core.ICDIDebugger2;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
 import org.eclipse.cdt.debug.core.cdi.CDIException;
@@ -46,17 +48,17 @@
 import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
 import org.indt.esbox.core.scratchbox.ScratchboxException;
 import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
 import org.indt.esbox.launch.LaunchActivator;
-import org.indt.esbox.launch.internal.IESboxCDTLaunchConfigurationConstants;
 import org.indt.esbox.launch.internal.ui.ESboxCMainTab;
 
 /**
  * 
  */
 public class ESboxRemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
-	
+
 	public static final String ESBOX_CONFIG_TYPE = "esboxRemoteLaunchType";
-	
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -67,7 +69,7 @@
 		if (monitor == null) {
 			monitor = new NullProgressMonitor();
 		}
-		
+
 		monitor.beginTask("Launching the application inside Scratchbox", 10);
 		// check for cancellation
 		if (monitor.isCanceled()) {
@@ -75,19 +77,22 @@
 		}
 		try {
 			monitor.worked(1);
-			
-			boolean isRunStandalone = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
-			
+
+			boolean isRunStandalone = config
+					.getAttribute(
+							IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE,
+							IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+
 			IPath exePath = verifyProgramPath(config);
 			ICProject project = verifyCProject(config);
 			IBinaryObject exeFile = verifyBinary(project, exePath);
 			String arguments[] = getProgramArgumentsArray(config);
-			
+
 			verifySbrshConfiguration(project.getProject());
-			
+
 			// set the default source locator if required
 			setDefaultSourceLocator(launch, config);
-			
+
 			// The launcher for running commands inside the Scratchbox
 			// environment
 			InnerCommandLauncher launcher = new InnerCommandLauncher();
@@ -95,34 +100,33 @@
 			if (wd == null) {
 				wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
 			}
-			
-			if (mode.equals(ILaunchManager.DEBUG_MODE)) {				
+
+			if (mode.equals(ILaunchManager.DEBUG_MODE)) {
 				ICDebugConfiguration debugConfig = getDebugConfig(config);
 				ICDISession dsession = null;
 				String debugMode = config
-				.getAttribute(
-						ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
-						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+						.getAttribute(
+								ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+								ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
 				if (debugMode
 						.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
-					
-					dsession = debugConfig.createDebugger()
-					.createDebuggerSession(launch, exeFile,
+
+					dsession = createCDISession(config, launch, debugConfig,
 							new SubProgressMonitor(monitor, 8));
 					try {
 						try {
 							ICDITarget[] dtargets = dsession.getTargets();
 							for (int i = 0; i < dtargets.length; ++i) {
 								ICDIRuntimeOptions opt = dtargets[i]
-								                                  .getRuntimeOptions();
+										.getRuntimeOptions();
 								opt.setArguments(arguments);
-								
+
 								if (wd != null) {
 									opt.setWorkingDirectory(wd
 											.getAbsolutePath());
 								}
 								opt
-								.setEnvironment(getEnvironmentAsProperty(config));
+										.setEnvironment(getEnvironmentAsProperty(config));
 							}
 						} catch (CDIException e) {
 							e.printStackTrace();
@@ -133,24 +137,34 @@
 						}
 						monitor.worked(1);
 						boolean stopInMain = config
-						.getAttribute(
-								ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
-								false);
-						
+								.getAttribute(
+										ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
+										false);
+
+						String stopSymbol = null;
+						if (stopInMain)
+							stopSymbol = launch
+									.getLaunchConfiguration()
+									.getAttribute(
+											ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
+											ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
+
 						ICDITarget[] targets = dsession.getTargets();
 						for (int i = 0; i < targets.length; i++) {
 							Process process = targets[i].getProcess();
-							
 							IProcess iprocess = null;
 							if (process != null) {
 								iprocess = DebugPlugin.newProcess(launch,
 										process, renderProcessLabel(exePath
-												.toOSString()));
+												.toOSString()),
+										getDefaultProcessMap());
 							}
-							CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
+							CDIDebugModel.newDebugTarget(launch, project
+									.getProject(), targets[i],
 									renderTargetLabel(debugConfig), iprocess,
-									exeFile, true, false, stopInMain, true);
+									exeFile, true, false, stopSymbol, true);
 						}
+
 					} catch (CoreException e) {
 						e.printStackTrace();
 						try {
@@ -162,27 +176,28 @@
 					}
 				}
 			} else {
-				
+
 				monitor.worked(5);
-				
+
 				String[] env = null;
-				ArrayList envList = new ArrayList();					
+				ArrayList envList = new ArrayList();
 				Properties props = launcher.getEnvironment();
 				props.putAll(getEnvironmentAsProperty(config));
 				Enumeration names = props.propertyNames();
 				if (names != null) {
 					while (names.hasMoreElements()) {
 						String key = (String) names.nextElement();
-						envList.add(key + "=" + props.getProperty(key)); 
+						envList.add(key + "=" + props.getProperty(key));
 					}
-					env = (String[]) envList.toArray(new String[envList.size()]);
-				}			
-						
+					env = (String[]) envList
+							.toArray(new String[envList.size()]);
+				}
+
 				Process process;
 				// if standalone is disabled run commands normally
-				process = launcher.execute(exePath, arguments,
-						env, new Path(wd.getAbsolutePath()), isRunStandalone);		
-				
+				process = launcher.execute(exePath, arguments, env, new Path(wd
+						.getAbsolutePath()), isRunStandalone);
+
 				monitor.worked(3);
 				DebugPlugin.newProcess(launch, process,
 						renderProcessLabel(exePath.toOSString()));
@@ -191,62 +206,104 @@
 			monitor.done();
 		}
 	}
-	
+
 	private void verifySbrshConfiguration(IProject project) {
 		String targetName = "";
 		try {
 			targetName = ScratchboxFacade.getInstance().getCurrentTarget();
 		} catch (ScratchboxException e) {
-			ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+			ErrorLogger errorLogger = LaunchActivator.getDefault()
+					.getErrorLogger();
 			errorLogger.logAndShowError("Scratchbox error", e);
-		}		
+		}
 		// we have to configure and mount the sbrsh for the target
-			
+
 	}
 
 	/*
-	 *  (non-Javadoc)
+	 * (non-Javadoc)
+	 * 
 	 * @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#getPluginID()
 	 */
 	protected String getPluginID() {
 		return LaunchUIPlugin.getUniqueIdentifier();
 	}
-	
+
+	private ICDISession createCDISession(ILaunchConfiguration config,
+			ILaunch launch, ICDebugConfiguration debugConfig,
+			IProgressMonitor monitor) throws CoreException {
+		ICDISession session = null;
+		ICDIDebugger debugger = debugConfig.createDebugger();
+		if (debugger instanceof ICDIDebugger2)
+			session = launchDebugSession(config, launch,
+					(ICDIDebugger2) debugger, monitor);
+		else
+			// support old debugger types
+			session = launchOldDebugSession(config, launch, debugger, monitor);
+		return session;
+	}
+
+	private ICDISession launchOldDebugSession(ILaunchConfiguration config,
+			ILaunch launch, ICDIDebugger debugger, IProgressMonitor monitor)
+			throws CoreException {
+		IBinaryObject exeFile = null;
+		IPath exePath = verifyProgramPath(config);
+		ICProject project = verifyCProject(config);
+		if (exePath != null) {
+			exeFile = verifyBinary(project, exePath);
+		}
+		return debugger.createDebuggerSession(launch, exeFile, monitor);
+	}
+
+	private ICDISession launchDebugSession(ILaunchConfiguration config,
+			ILaunch launch, ICDIDebugger2 debugger, IProgressMonitor monitor)
+			throws CoreException {
+		IPath path = verifyProgramPath(config);
+		File exeFile = path != null ? path.toFile() : null;
+		return debugger.createSession(launch, exeFile, monitor);
+	}
+
 	/**
-	 *
+	 * 
 	 */
 	class InnerCommandLauncher extends ScratchboxCommandLauncher {
-		
+
 		/**
 		 * Constructor
 		 */
-		InnerCommandLauncher() {			
-			super();			
+		InnerCommandLauncher() {
+			super();
 		}
-		
+
 		/*
-		 *  (non-Javadoc)
-		 * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+		 * (non-Javadoc)
+		 * 
+		 * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath,
+		 *      java.lang.String[], java.lang.String[],
+		 *      org.eclipse.core.runtime.IPath)
 		 */
-		public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, boolean isRunStandalone) {		
+		public Process execute(IPath commandPath, String[] args, String[] env,
+				IPath changeToDirectory, boolean isRunStandalone) {
 			try {
-				String command = isRunStandalone ? "run-standalone.sh " : ""; 
+				String command = isRunStandalone ? "run-standalone.sh " : "";
 				command += commandPath.toOSString();
-				fCommandArgs = constructCommandArray(command,args, env, changeToDirectory);
-				// exec command				
-		
-				PTY pty = new PTY();				
-				fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
-			
-				fErrorMessage = ""; 				
-				
+				fCommandArgs = constructCommandArray(command, args, env,
+						changeToDirectory);
+				// exec command
+
+				PTY pty = new PTY();
+				fProcess = ProcessFactory.getFactory().exec(fCommandArgs,
+						new String[] {}, changeToDirectory.toFile(), new PTY());
+
+				fErrorMessage = "";
+
 			} catch (IOException e) {
 				e.printStackTrace();
 				setErrorMessage(e.getMessage());
 				fProcess = null;
 			}
-			
+
 			return fProcess;
-		}		
-	}	
+		}
+	}
 }
\ No newline at end of file



More information about the Esbox-commits mailing list