package com.samsung.tizen.oprofile.launch;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.linuxtools.oprofile.launch.configuration.OprofileCounter;
import org.eclipse.linuxtools.oprofile.ui.OprofileUiPlugin;
import org.eclipse.linuxtools.oprofile.ui.view.OprofileView;
-import org.eclipse.linuxtools.profiling.launch.Messages;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import com.samsung.tizen.common.properties.InstallPathConfig;
import com.samsung.tizen.nativeapp.launch.TizenLaunchDelegate;
import com.samsung.tizen.nativeapp.launch.TizenLaunchMessages;
import com.samsung.tizen.oprofile.core.CommandManager;
-import com.samsung.tizen.oprofile.launch.DefaultSettingConstants;
import com.samsung.tizen.sdblib.SdbShellProcess;
public class TizenOprofileLaunchDelegate extends TizenLaunchDelegate {
protected static final String PACKAGE_NAME = "oprofile";
protected static final String PACKAGE_FILENAME_ARM = "oprofile_armel.deb";
-
+
protected static String appName = null;
public static String getAppName() {
IPath exeFile = null;
try {
exeFile = CDebugUtils.verifyProgramPath(config);
- OprofileDebugPlugin.newProcess(launch, oprofileProc, exeFile.toFile()
- .getName());
+ OprofileDebugPlugin.newProcess(launch, oprofileProc, exeFile
+ .toFile().getName());
BufferedReader br = new BufferedReader(new InputStreamReader(
oprofileProc.getInputStream()));
while (null != br.readLine()) {
// String resultRsp = session.run(cmd, null);
String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
if (!CommandManager.isRunSeccessfuly(resultRsp)) {
- if (CommandManager.isEmulator()) {
- throw new Exception(
- TizenLaunchMessages.CANNOT_LAUNCH,
- new Exception(
- "No oprofile in this target (/usr/bin/opcontrol)."));
- } else {
- transferProfilingToolPackage(monitor);
- installProfilingToolPackage(monitor);
- }
- }
- }
-
- /**
- * Transfer oprofile package to the target
- *
- * @param monitor
- * @param session
- * connection session to the target or simulator
- * @return void
- *
- * @exception CoreException
- * if unable to transfer a package
- */
- public static void transferProfilingToolPackage(IProgressMonitor monitor)
- throws Exception {
- try {
- monitor.beginTask(
- Messages.getString("ProfileLaunch.TRANSFER_PROFILING_TOOL"),
- 1);
-
- // test whether oprofile package exist or not
- String sdkInstallPath = InstallPathConfig.getSDKPath();
- String toolPkgPath = sdkInstallPath + "/SDK/profiling-tool/"
- + PACKAGE_FILENAME_ARM;
- File toolPkg = new File(toolPkgPath);
- if (toolPkg == null || !toolPkg.exists())
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("Tool package path (" + toolPkgPath
- + ") is not available."));
-
- String destDirectoryPath = TEMPORARY_PKG_PATH;
-
- if (!CommandManager.isPathExist(destDirectoryPath)) {
- String command = MAKE_DIRECTORY_CMD + destDirectoryPath
- + CMD_RESULT_CHECK;
- // String result = session.run(command, null);
- String[] result = CommandManager
- .runCommandReturningResultArray(command);
- if (!CommandManager.isRunSeccessfuly(result))
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("Destination path ("
- + destDirectoryPath + ") in not exist."));
- }
-
- String srcFilePath = toolPkg.getAbsoluteFile().getCanonicalPath();
- String destFilePath = destDirectoryPath
- + toolPkg.getAbsoluteFile().getName();
-
- // boolean isSuccess = session.transferFile(srcFilePath,
- // destFilePath);
- boolean isSuccess = CommandManager.push(srcFilePath, destFilePath);
-
- if (isSuccess == false)
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("source path (" + srcFilePath
- + "), dest path (" + destFilePath + ")"));
- } catch (Exception e) {
- throw e;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Install oprofile package to the target
- *
- * @param config
- * launch configuration
- * @param pkgmgr
- * instance which contains resources and control information
- * @return void
- *
- * @exception CoreException
- * if unable to install a package
- */
- public static void installProfilingToolPackage(IProgressMonitor monitor)
- throws Exception {
- try {
- monitor.beginTask(
- Messages.getString("ProfileLaunch.INSTALL_PROFILING_TOOL"),
- 2);
-
- String packageDirectory = TEMPORARY_PKG_PATH;
- String command = CHANGE_DIRECTORY_CMD + packageDirectory
- + CMD_RESULT_CHECK;
- // String result = session.run(command, null);
- String[] result = CommandManager
- .runCommandReturningResultArray(command);
- if (!CommandManager.isRunSeccessfuly(result))
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
- monitor.worked(1);
-
- // remount file system
- command = "mount -o remount,rw /" + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- result = CommandManager.runCommandReturningResultArray(command);
- if (!CommandManager.isRunSeccessfuly(result))
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
-
- // install new application
- command = PKG_TOOL_CMD + PKG_TOOL_INSTALL_OPTION
- + PACKAGE_FILENAME_ARM + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- result = CommandManager.runCommandReturningResultArray(command);
- if (!CommandManager.isRunSeccessfuly(result))
- throw new Exception(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
- monitor.worked(1);
-
- // remount file system
- command = "mount -o remount,ro /" + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- CommandManager.runCommand(command);
- } catch (Exception e) {
- throw e;
- } finally {
- monitor.done();
+ // if (CommandManager.isEmulator()) {
+ throw new Exception(TizenLaunchMessages.CANNOT_LAUNCH,
+ new Exception(
+ "No oprofile in this target (/usr/bin/opcontrol)."));
+ // } else {
+ // transferProfilingToolPackage(monitor);
+ // installProfilingToolPackage(monitor);
+ // }
}
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.linuxtools.profiling.launch.Messages;
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.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import com.samsung.tizen.common.properties.InstallPathConfig;
import com.samsung.tizen.nativeapp.launch.TizenLaunchDelegate;
import com.samsung.tizen.nativeapp.launch.TizenLaunchMessages;
import com.samsung.tizen.sdblib.SdbShellProcess;
protected static final String PACKAGE_NAME = "valgrind";
protected static final String PACKAGE_FILENAME_ARM = "valgrind_armel.deb";
-
+
protected String toolID;
@Override
// String resultRsp = session.run(cmd, null);
String[] resultRsp = CommandManager.runCommandReturningResult(cmd);
if (!CommandManager.isRunSeccessfuly(resultRsp)) {
- if (CommandManager.isEmulator()) {
- newCoreException(
- TizenLaunchMessages.CANNOT_LAUNCH,
- new Exception(
- "No valgrind in this target (/usr/bin/valgrind). "));
- } else {
- transferProfilingToolPackage(monitor);
- installProfilingToolPackage(monitor);
- }
+ // if (CommandManager.isEmulator()) {
+ newCoreException(
+ TizenLaunchMessages.CANNOT_LAUNCH,
+ new Exception(
+ "No valgrind in this target (/usr/bin/valgrind). "));
+ // } else {
+ // transferProfilingToolPackage(monitor);
+ // installProfilingToolPackage(monitor);
+ // }
}
String remoteExePath = getRemoteExePath(config);
fullcommand += commandArray[i] + " ";
}
-// if (CommandManager.isEmulator()
-// && Platform.getOS().equals(Platform.OS_WIN32)) {
-// Exception te;
-// te = new Exception(
-// "Can not use valgrind, because the host doesn't support Intel VT");
-// throw (te);
-// }
+ // if (CommandManager.isEmulator()
+ // && Platform.getOS().equals(Platform.OS_WIN32)) {
+ // Exception te;
+ // te = new Exception(
+ // "Can not use valgrind, because the host doesn't support Intel VT");
+ // throw (te);
+ // }
config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
IPath exeFile = null;
try {
exeFile = CDebugUtils.verifyProgramPath(config);
- ValgrindDebugPlugin.newProcess(launch, oprofileProc, exeFile.toFile()
- .getName());
+ ValgrindDebugPlugin.newProcess(launch, oprofileProc, exeFile
+ .toFile().getName());
BufferedReader br = new BufferedReader(new InputStreamReader(
oprofileProc.getInputStream()));
while (null != br.readLine()) {
return config.getName() + " ["
+ ValgrindLaunchPlugin.getDefault().getToolName(toolID) + "] ";
}
-
- /**
- * Transfer valgrind package to the target
- *
- * @param monitor
- * @param session
- * connection session to the target or simulator
- * @return void
- *
- * @exception CoreException
- * if unable to transfer a package
- */
- public void transferProfilingToolPackage(IProgressMonitor monitor)
- throws CoreException {
- try {
- monitor.beginTask(
- Messages.getString("ProfileLaunch.TRANSFER_PROFILING_TOOL"),
- 1);
-
- // test whether valgrind package exist or not
- String sdkInstallPath = InstallPathConfig.getSDKPath();
- String toolPkgPath = sdkInstallPath + "/SDK/profiling-tool/"
- + PACKAGE_FILENAME_ARM;
- File toolPkg = new File(toolPkgPath);
- if (toolPkg == null || !toolPkg.exists())
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("Tool package path (" + toolPkgPath
- + ") is not available."));
-
- String destDirectoryPath = TEMPORARY_PKG_PATH;
-
- if (!CommandManager.isPathExist(destDirectoryPath)) {
- String command = MAKE_DIRECTORY_CMD + destDirectoryPath
- + CMD_RESULT_CHECK;
- // String result = session.run(command, null);
- String[] result = CommandManager
- .runCommandReturningResult(command);
- if (!CommandManager.isRunSeccessfuly(result))
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("Destination path ("
- + destDirectoryPath + ") in not exist."));
- }
-
- String srcFilePath = toolPkg.getAbsoluteFile().getCanonicalPath();
- String destFilePath = destDirectoryPath
- + toolPkg.getAbsoluteFile().getName();
-
- // boolean isSuccess = session.transferFile(srcFilePath,
- // destFilePath);
- boolean isSuccess = CommandManager.push(srcFilePath, destFilePath);
-
- if (isSuccess == false)
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
- new Exception("source path (" + srcFilePath
- + "), dest path (" + destFilePath + ")"));
- } catch (CoreException e) {
- throw e;
- } catch (Exception e) {
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), e);
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Install valgrind package to the target
- *
- * @param config
- * launch configuration
- * @param pkgmgr
- * instance which contains resources and control information
- * @return void
- *
- * @exception CoreException
- * if unable to install a package
- */
- public void installProfilingToolPackage(IProgressMonitor monitor)
- throws CoreException {
- try {
- monitor.beginTask(
- Messages.getString("ProfileLaunch.INSTALL_PROFILING_TOOL"),
- 2);
-
- String packageDirectory = TEMPORARY_PKG_PATH;
- String command = CHANGE_DIRECTORY_CMD + packageDirectory
- + CMD_RESULT_CHECK;
- // String result = session.run(command, null);
- String[] result = CommandManager.runCommandReturningResult(command);
- if (null != result && result.length > 0 && !result[0].contains("0"))
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
- monitor.worked(1);
-
- // remount file system
- command = "mount -o remount,rw /" + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- result = CommandManager.runCommandReturningResult(command);
- if (null != result && result.length > 0 && !result[0].contains("0"))
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
-
- // install new application
- command = PKG_TOOL_CMD + PKG_TOOL_INSTALL_OPTION + packageDirectory
- + PACKAGE_FILENAME_ARM + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- String resultStr = CommandManager.runShell(command);
- if (null != resultStr && resultStr.length() > 0
- && !resultStr.equals("0"))
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"),
- new Exception("command is " + command));
- monitor.worked(1);
-
- // remount file system
- command = "mount -o remount,ro /" + CMD_RESULT_CHECK;
- // result = session.run(command, null);
- result = CommandManager.runCommandReturningResult(command);
- } catch (CoreException e) {
- throw e;
- } catch (Exception e) {
- newCoreException(
- Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), e);
- } finally {
- monitor.done();
- }
- }
}