import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
import org.eclipse.linuxtools.valgrind.core.utils.LaunchConfigurationConstants;
import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
import org.tizen.common.TizenPlatformConstants;
import org.tizen.common.TizenProjectType;
+import org.tizen.common.connection.debugtools.OnDemandInstallMessages;
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.util.RootJob;
import org.tizen.common.util.SWTUtil;
+import org.tizen.common.util.SdbCommandUtil;
import org.tizen.common.util.log.UserInteraction;
import org.tizen.common.util.log.UserLogger;
import org.tizen.nativecommon.IXMLStore;
protected static final String LAUNCHPAD_LAUNCHER = "launch_app ";
protected static final String LAUNCHPAD_SYNCMODE = " __AUL_SDK__ VALGRIND __DLP_VALGRIND_ARG__ ";
- private static final String VALGRIND_ERROR_MESSAGE = "This target does not support profiling with valgrind for low HW specifications.";
+ private static final String LD_FILE_PATH = "/usr/lib/debug/lib/ld-2.13.so.debug";
+ private static final String VALGRIND_EXECUTABLE_PATH = "/valgrind/usr/bin/valgrind";
+ private static final String VALGRIND_BINARY_PATH = "/platforms/common/user-demand";
+ private static final String MOVE_WORKING_DIR_COMMAND = "cd "
+ + TizenPlatformConstants.TOOLS_TARGET_PATH;
+ private static final String REMOVE_TOOL_COMMAND = "rm -f %s";
+ private static final String TAR_INSTALL_COMMAND = MOVE_WORKING_DIR_COMMAND + " && tar -xf %s"
+ + " && " + REMOVE_TOOL_COMMAND;
+ private boolean userAnswer = false;
protected String toolID;
protected int confirmMsg = 0;
Messages.getString("ValgrindOptionsTab.nodevice"), null);
return;
}
+
+ // check for ld-2.13.so.debug file
+ if (!CommandManager.isExist(LD_FILE_PATH)) {
+ monitor.done();
+ ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+ Messages.getString("TizenValgrindLaunchDelegate.ld_file_doesnt_exist"), null);
+ return;
+ }
+
+ // check for Valgrind executable
+ if (!CommandManager.isExist(TizenPlatformConstants.TOOLS_TARGET_PATH + VALGRIND_EXECUTABLE_PATH)) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ userAnswer = MessageDialog.openQuestion(null,
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_warning"),
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_doesnt_exist"));
+ }
+ });
+
+ if (!userAnswer) {
+ monitor.done();
+ return;
+ } else {
+ // install valgrind
+ if (!installValgrind()) {
+ monitor.done();
+ return;
+ }
+ }
+ }
try {
ProfileLaunchPlugin.startProfiling();
if (mode.equals(ILaunchManager.PROFILE_MODE)) {
launchPlatformApplicationWithValgrind(launch, config, monitor);
} else {
- newCoreException(VALGRIND_ERROR_MESSAGE, null);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), null);
}
} else {
if (ProjectUtil.getTizenProjectType(project) != null) {
launchApplicationWithValgrind(launch, config, monitor);
} else {
- newCoreException(VALGRIND_ERROR_MESSAGE, null);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), null);
}
} else if (ProjectUtil.getTizenProjectType(project).isWebProject()){
/** web project */
}
}
+ private boolean installValgrind() {
+ // push & unzip (references. OnDemandInstall - deployPackage())
+
+ // check for valgrind binary
+ File binaryDir = null;
+ String[] binaryFiles = null;
+ String binaryPath = InstallPathConfig.getSDKPath() + VALGRIND_BINARY_PATH;
+ try {
+ binaryDir = new File(binaryPath);
+ if (binaryDir.isDirectory()) {
+ binaryFiles = binaryDir.list();
+ if (binaryFiles == null || binaryFiles.length != 2)
+ newCoreException(null, null);
+ } else {
+ newCoreException(null, null);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ ProfileLaunchShortcut.showErrorDialog(
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_warning"),
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_binary_doesnt_exist"),
+ null);
+ return false;
+ }
+
+ String binaryName = null;
+ if (CommandManager.isEmulator()) {
+ for (String fileName : binaryFiles) {
+ if (fileName.contains("i386")) {
+ binaryName = String.valueOf(fileName);
+ break;
+ }
+ }
+ } else {
+ for (String fileName : binaryFiles) {
+ if (fileName.contains("armel")) {
+ binaryName = String.valueOf(fileName);
+ break;
+ }
+ }
+ }
+
+ // push valgrind binary file to the target
+ if (!CommandManager.push(binaryPath + File.separator + binaryName,
+ TizenPlatformConstants.TOOLS_TARGET_PATH)) {
+ ProfileLaunchShortcut
+ .showErrorDialog(
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_warning"),
+ Messages.getString("TizenValgrindLaunchDelegate.failed_to_valgrind_installation"),
+ null);
+ return false;
+ }
+
+ // unzip & remove valgrin binary file
+ final String unzipCmd = String.format(TAR_INSTALL_COMMAND, binaryName, binaryName
+ + TizenPlatformConstants.CMD_SUFFIX);
+
+ class InstallJob implements RootJob {
+ private boolean isSuccess = false;
+ @Override
+ public void run() {
+ try {
+ if (CommandManager.isRunSuccessfuly(CommandManager
+ .runCommandReturningResult(unzipCmd))) {
+ isSuccess = true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ isSuccess = false;
+ return;
+ }
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+ }
+
+ InstallJob installJob = new InstallJob();
+ installJob.run();
+
+ if (installJob.isSuccess()) {
+ return true;
+ } else {
+ ProfileLaunchShortcut
+ .showErrorDialog(
+ Messages.getString("TizenValgrindLaunchDelegate.valgrind_warning"),
+ Messages.getString("TizenValgrindLaunchDelegate.failed_to_valgrind_installation"),
+ null);
+ return false;
+ }
+ }
+
protected void verifyDeviceReachabilityForPlatform(ILaunchConfiguration config, IProgressMonitor monitor)
throws CoreException {
try {
// Process remoteShellProcess = null;
try {
- // find Valgrind executable
- String valgrindCmd = TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind";
- String cmd = "ls " + valgrindCmd + TizenPlatformConstants.CMD_SUFFIX;
- String[] resultRsp = CommandManager.runCommandReturningResult(cmd);
- if (!CommandManager.isRunSuccessfuly(resultRsp)) {
- newCoreException(VALGRIND_ERROR_MESSAGE, new Exception(
- "No valgrind in this target (" + TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind)."));
- }
-
if (monitor.isCanceled())
throw new OperationCanceledException();
remoteExePath = remoteExePath.substring(0, remoteExePath.length() - BADA_EXT.length());
}
- cmd = ValgrindCommand.OPROFILE_SCRIPT + " lsapp " + remoteExePath;
- resultRsp = CommandManager.runHostCommandReturningResult(cmd);
+ String cmd = ValgrindCommand.OPROFILE_SCRIPT + " lsapp " + remoteExePath;
+ String[] resultRsp = CommandManager.runHostCommandReturningResult(cmd);
if (!CommandManager.isRunSuccessfuly(resultRsp))
{
- newCoreException(VALGRIND_ERROR_MESSAGE, new Exception(
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), new Exception(
"Executable does not exist on a valid path. You must install your application before running it."));
}
}
fullcommand = LAUNCHPAD_LAUNCHER + getPackageName(config) + "." + getExecutableName(config) + LAUNCHPAD_SYNCMODE;
}
} catch (CoreException e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e.getCause());
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e.getCause());
}
// for (int i = 0; i < commandArray.length; i++) {
}
});
} catch (CoreException e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e.getCause());
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e.getCause());
} catch (IOException e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e);
} catch (Exception e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e);
} finally {
monitor.done();
ProfileLaunchPlugin.stopProfiling();
// Process remoteShellProcess = null;
try {
- // find Valgrind executable
- String valgrindCmd = TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind";
- String cmd = "ls " + valgrindCmd + TizenPlatformConstants.CMD_SUFFIX;
- String[] resultRsp = CommandManager.runCommandReturningResult(cmd);
- if (!CommandManager.isRunSuccessfuly(resultRsp)) {
- newCoreException(VALGRIND_ERROR_MESSAGE, new Exception(
- "No valgrind in this target (" + TizenPlatformConstants.TOOLS_TARGET_PATH + "/valgrind/usr/bin/valgrind)."));
- }
-
if (monitor.isCanceled())
throw new OperationCanceledException();
}
});
} catch (CoreException e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e.getCause());
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e.getCause());
} catch (IOException e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e);
} catch (Exception e) {
- newCoreException(VALGRIND_ERROR_MESSAGE, e);
+ newCoreException(Messages.getString("TizenValgrindLaunchDelegate.valgrind_error_message"), e);
} finally {
monitor.done();
ProfileLaunchPlugin.stopProfiling();