LAUNCH: Fix to use LaunchUtils to find available port. 08/15008/1
authorhyunsik.noh <hyunsik.noh@samsung.com>
Wed, 15 Jan 2014 04:26:07 +0000 (13:26 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Wed, 15 Jan 2014 04:26:07 +0000 (13:26 +0900)
Change-Id: Ida951ff106b251f1359fdbe46c3d935608ee0c2d
Signed-off-by: hyunsik.noh <hyunsik.noh@samsung.com>
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java

index a90aff6..626c96c 100644 (file)
@@ -45,7 +45,6 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.ICDISession;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
@@ -63,7 +62,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -73,7 +71,6 @@ import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PartInitException;
@@ -83,28 +80,21 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.sdb.command.SdbCommand;
-import org.tizen.common.sdb.command.message.PkgcmdErrorType;
 import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.LocalPortChecker;
 import org.tizen.common.util.SWTUtil;
 import org.tizen.common.util.StringUtil;
 import org.tizen.common.util.log.UserInteraction;
 import org.tizen.common.util.log.UserLogger;
-import org.tizen.nativecommon.ProjectUtil;
 import org.tizen.nativecommon.build.CommonBuildMessages;
 import org.tizen.nativecommon.build.CommonConfigurationManager;
-import org.tizen.nativecommon.build.CommonProjectDependentBuilder;
-import org.tizen.nativecommon.build.ProjectTypeManager;
 import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativecommon.launch.IProjectLaunchCommand;
 import org.tizen.nativecommon.launch.LaunchUtils;
 import org.tizen.nativecommon.launch.TizenDebugger;
 import org.tizen.nativecommon.launch.TizenLaunchCommand;
 import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativecommon.launch.TizenUIThreadForConfirmMessage;
-import org.tizen.nativecommon.launch.ui.LaunchConfigurationLinkDialog;
 import org.tizen.nativecommon.launch.ui.TizenLaunchDeviceSelectionDialog;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
@@ -821,7 +811,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException,
             OperationCanceledException {
         try {
-            if (!gdbServerPortIsAvailable(launch, config)) {
+            if (!LaunchUtils.setAvailableGdbServerPort(launch, config, currentDevice)) {
                 return;
             }
             monitor.beginTask("", 2);
@@ -834,33 +824,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
     }
 
-    private boolean gdbServerPortIsAvailable(ILaunch launch, final ILaunchConfiguration config)
-            throws NumberFormatException, CoreException {
-        boolean result = true;
-        final int gdbserverPort = Integer.parseInt(config.getAttribute(
-                TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
-                TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
-        boolean isRemotePortAvailable = LaunchUtils.isRemotePortAvailable(currentDevice,
-                gdbserverPort);
-        if (!isRemotePortAvailable) {
-            SWTUtil.asyncExec(new Runnable() {
-                @Override
-                public void run() {
-                    String title = TizenLaunchMessages.LAUNCH_ERROR;
-                    String message = NLS.bind(TizenLaunchMessages.GDBSERVER_PORT_ALREADY_USED, gdbserverPort);
-                    LaunchConfigurationLinkDialog dialog = new LaunchConfigurationLinkDialog(
-                            SWTUtil.getShell(), config, title, message);
-                    dialog.open();
-                }
-            });
-
-            logger.error("RemoteGDBServerPort: " + gdbserverPort + " is busy");
-            launch.terminate();
-            result = false;
-        }
-        return result;
-    }
-
     protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config,
             IProgressMonitor monitor) throws CoreException {