import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
-import org.eclipse.ptp.remotetools.core.IRemoteExecutionTools;
-import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
-import org.eclipse.ptp.remotetools.exception.CancelException;
-import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
-import org.eclipse.ptp.remotetools.exception.RemoteExecutionException;
-import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
IPath hostPath = getHostPath(appPath, config);
if (hostPath != null) {
- if (!PlatformFileUtil.existsFile(hostPath.toString())) {
- newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ if (!PlatformFileUtil.existsFile(hostPath.toString())) {
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
null);
- }
+ }
}
}
protected ICDISession getDebugSession(ILaunch launch, ILaunchConfiguration config,
IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
- TizenPlatformDebugger debugger = new TizenPlatformDebugger();
+ TizenPlatformDebugger debugger = new TizenPlatformDebugger();
if (OSChecker.isWindows()) {
- String appPath = config
- .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
- String rootstrapId = target.getRootstrap().getId();
- String rootstrapPath = RootstrapUtil.getRemoteRootstrapScratchPath(rootstrapId);
- //File exec = new Path(rootstrapPath).append(appPath).toFile();
- File exec = new Path(appPath).toFile();
- return ((ICDIDebugger2) debugger).createSession(launch, exec, new SubProgressMonitor(monitor, 1));
+ String appPath = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ File exec = new Path(appPath).toFile();
+ return ((ICDIDebugger2) debugger).createSession(launch, exec, new SubProgressMonitor(
+ monitor, 1));
} else {
return ((ICDIDebugger2) debugger).createSession(launch, getGDBClientArgument(exeFile),
new SubProgressMonitor(monitor, 1));
}
-
+
}
- /*
- public static ILaunchConfiguration createForward(ILaunchConfiguration config, IDevice device) throws CoreException, NumberFormatException, TimeoutException, SdbCommandRejectedException, IOException {
+
+ public static ILaunchConfiguration createForward(ILaunchConfiguration config, IDevice device)
+ throws CoreException, NumberFormatException, TimeoutException,
+ SdbCommandRejectedException, IOException {
int gdbPort = 0;
int gdbserverPort = 0;
ILaunchConfiguration newConfiguration = config;
-
- gdbPort = Integer.parseInt(config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ gdbPort = Integer.parseInt(config.getAttribute(
+ IGDBServerMILaunchConfigurationConstants.ATTR_PORT,
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
if (!LocalPortChecker.isPortAvailable(gdbPort)) {
gdbPort = LaunchUtils.getDefaultDebugPort(device);
if (gdbPort < 0) {
- LaunchUtils.newCoreException(TizenLaunchMessages.CANNOT_SET_DEBUG_LOCAL_PORT_TO_NEGATIVE, null);
+ LaunchUtils.newCoreException(
+ TizenLaunchMessages.CANNOT_SET_DEBUG_LOCAL_PORT_TO_NEGATIVE, null);
}
String localPort = Integer.valueOf(gdbPort).toString();
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, localPort);
- newConfiguration = wc.doSave();
gdbPort = Integer.parseInt(localPort);
}
-
- gdbserverPort = Integer.parseInt(config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
- IRemoteExecutionTools exectool = RemoteConnectionManager.getRemoteTools().getExecTool();
- try {
-
- //exectool.executeBashCommand("/home/sdk/tizen-sdk/tools/sdb connect 172.21.111.40");
- String cmd = String.format("/home/sdk/tizen-sdk/tools/sdb forward tcp:%d tcp:%d", gdbPort, gdbserverPort);
- exectool.executeWithOutput("/home/sdk/tizen-sdk/tools/sdb connect 172.21.111.40");
- String output = exectool.executeWithOutput(cmd);
- System.out.print(output);
- } catch (RemoteExecutionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (RemoteConnectionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CancelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //device.createForward(gdbPort, gdbserverPort);
+ /*
+ * InetAddress.getLocalHost() should give you the IP address of this
+ * host. The problem is that a host could have lots of network
+ * interfaces, and an interface could be bound to more than one IP
+ * address.
+ */
+ InetAddress hostIp = InetAddress.getLocalHost();
+ wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostIp.getHostAddress());
+ newConfiguration = wc.doSave();
+ gdbserverPort = Integer.parseInt(config.getAttribute(
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
+ device.createForward(gdbPort, gdbserverPort);
return newConfiguration;
}
- */
protected void launchApplicationWithGDBClient(ILaunch launch, ILaunchConfiguration config,
IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
monitor.beginTask("", 2);
monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT);
- LaunchUtils.createForward(config, currentDevice);
- //createForward(config, currentDevice);
+ if (OSChecker.isWindows()) {
+ createForward(config, currentDevice);
+ } else {
+ LaunchUtils.createForward(config, currentDevice);
+ }
try {
debugSession = getDebugSession(launch, config, exeFile, monitor);
} catch (CoreException e) {
rootstrapPath = rootstrapPath.concat(exePath);
}
}
- } else {
+ } else {
rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
if (rootstrapPath != null && !rootstrapPath.isEmpty()) {
if (canonicalPath != null && !canonicalPath.isEmpty()) {