private final String OPCONTROL_PROGRAM;
// Initialize the Oprofile kernel module and oprofilefs
- private static final String _OPD_INIT_MODULE = "--init"; //$NON-NLS-1$
+ private static final String _OPD_INIT_MODULE = "init"; //$NON-NLS-1$
// Setup daemon collection arguments
- private static final String _OPD_SETUP = "--setup"; //$NON-NLS-1$
- private static final String _OPD_SETUP_SEPARATE = "--separate="; //$NON-NLS-1$
+ private static final String _OPD_SETUP = "setup"; //$NON-NLS-1$
+ private static final String _OPD_SETUP_SEPARATE = "separate="; //$NON-NLS-1$
private static final String _OPD_SETUP_SEPARATE_SEPARATOR = ","; //$NON-NLS-1$
// private static final String _OPD_SETUP_SEPARATE_NONE = "none"; //$NON-NLS-1$
private static final String _OPD_SETUP_SEPARATE_LIBRARY = "library"; //$NON-NLS-1$
private static final String _OPD_SETUP_SEPARATE_THREAD = "thread"; //$NON-NLS-1$
private static final String _OPD_SETUP_SEPARATE_CPU = "cpu"; //$NON-NLS-1$
- private static final String _OPD_SETUP_EVENT = "--event="; //$NON-NLS-1$
+ private static final String _OPD_SETUP_EVENT = "event="; //$NON-NLS-1$
private static final String _OPD_SETUP_EVENT_SEPARATOR = ":"; //$NON-NLS-1$
private static final String _OPD_SETUP_EVENT_TRUE = "1"; //$NON-NLS-1$
private static final String _OPD_SETUP_EVENT_FALSE = "0"; //$NON-NLS-1$
private static final String _OPD_SETUP_EVENT_DEFAULT = "default"; //$NON-NLS-1$
- private static final String _OPD_SETUP_IMAGE = "--image="; //$NON-NLS-1$
+ private static final String _OPD_SETUP_IMAGE = "image="; //$NON-NLS-1$
- private static final String _OPD_CALLGRAPH_DEPTH = "--callgraph="; //$NON-NLS-1$
+ private static final String _OPD_CALLGRAPH_DEPTH = "callgraph="; //$NON-NLS-1$
// Kernel image file options
- private static final String _OPD_KERNEL_NONE = "--no-vmlinux"; //$NON-NLS-1$
- private static final String _OPD_KERNEL_FILE = "--vmlinux="; //$NON-NLS-1$
+ private static final String _OPD_KERNEL_NONE = "vmlinux=no"; //$NON-NLS-1$
+ private static final String _OPD_KERNEL_FILE = "vmlinux="; //$NON-NLS-1$
// Logging verbosity
// private static final String _OPD_VERBOSE_LOGGING = "--verbose=";
// private static final String _OPD_VERBOSE_MISC = "misc"; //$NON-NLS-1$
// Start the daemon process without starting data collection
- private static final String _OPD_START_DAEMON = "--start-daemon"; //$NON-NLS-1$
+ private static final String _OPD_START_DAEMON = "startdaemon"; //$NON-NLS-1$
// Start collecting profiling data
- private static final String _OPD_START_COLLECTION = "--start"; //$NON-NLS-1$
+ private static final String _OPD_START_COLLECTION = "start"; //$NON-NLS-1$
// Flush the collected profiling data to disk
- private static final String _OPD_DUMP = "--dump"; //$NON-NLS-1$
+ private static final String _OPD_DUMP = "dump"; //$NON-NLS-1$
// Stop data collection
- private static final String _OPD_STOP_COLLECTION = "--stop"; //$NON-NLS-1$
+ private static final String _OPD_STOP_COLLECTION = "stop"; //$NON-NLS-1$
// Stop data collection and stop daemon
- private static final String _OPD_SHUTDOWN = "--shutdown"; //$NON-NLS-1$
+ private static final String _OPD_SHUTDOWN = "shutdown"; //$NON-NLS-1$
// Clear out data from current session
- private static final String _OPD_RESET = "--reset"; //$NON-NLS-1$
+ private static final String _OPD_RESET = "reset"; //$NON-NLS-1$
// Save data from the current session
- private static final String _OPD_SAVE_SESSION = "--save="; //$NON-NLS-1$
+ private static final String _OPD_SAVE_SESSION = "save "; //$NON-NLS-1$
// Unload the oprofile kernel module and oprofilefs
- private static final String _OPD_DEINIT_MODULE = "--deinit"; //$NON-NLS-1$
+ private static final String _OPD_DEINIT_MODULE = "deinit"; //$NON-NLS-1$
// Logging verbosity. Specified with setupDaemon.
// --verbosity=all generates WAY too much stuff in the log
public LinuxOpcontrolProvider() throws OpcontrolException {
// jinu modified at 20090526
// OPCONTROL_PROGRAM = _findOpcontrol();
- OPCONTROL_PROGRAM = OprofileCommonConstants.COMMAND_OPCONTROL;
+ OPCONTROL_PROGRAM = OprofileCommonConstants.OPROFILE_SCRIPT;
}
/**
// jinu added at 20090528
public void removeDaemonSetting() throws OpcontrolException {
final String[] _OPD_REMOVE_SETTING = { "rm", "-rf",
- "/root/.oprofile/daemonrc" };
+ "/home/developer/sdk_tools/.oprofile/daemonrc" };
runCommand(_OPD_REMOVE_SETTING);
}
// try {
// result = session.run(str);
// session.run(str, null);
- if(str.contains(_OPD_START_COLLECTION)){
- str = str + " && echo start_ok";
- }
CommandManager.runShell(str);
/*
} catch (Exception e) {
// }
// return path;
// }
-
- public static SdbShellProcess runApplication(String command){
+
+ public static Process runApplication(String command){
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- SdbShellProcess sdbShellProc = null;
+ Process sdbShellProc = null;
//command = getRealTargetPath(command);
try {
- sdbShellProc = device.executeShellCommand(command);
+ sdbShellProc = device.executeShellCommand(command, false);
} catch (IOException e) {
e.printStackTrace();
}
return sdbShellProc;
}
-
+
public static void runShell(String command) {
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- SdbShellProcess sdbShellProc = null;
+ Process sdbShellProc = null;
BufferedReader br = null;
//command = getRealTargetPath(command);
try {
- sdbShellProc = device.executeShellCommand(command);
+ sdbShellProc = device.executeShellCommand(command, false);
br = new BufferedReader(new InputStreamReader(
sdbShellProc.getInputStream()));
public abstract class OprofileCommonConstants {
private static final String COMMAND_PATH = TizenPlatformConstants.TOOLS_TARGET_PATH + "/oprofile/usr/bin/";
+
+ public static final String OPROFILE_SCRIPT = "/usr/bin/oprofile_command";
public static final String COMMAND_OPCONTROL = COMMAND_PATH+"opcontrol";
public static final String COMMAND_OPREPORT = "LD_LIBRARY_PATH=" + COMMAND_PATH + " " + COMMAND_PATH + "opreport";
- public static final String COMMAND_OPHELP = COMMAND_PATH+"ophelp";
+ public static final String COMMAND_OPHELP = OPROFILE_SCRIPT+" ophelp";
public static final String COMMAND_OPXML = COMMAND_PATH+"opxml";
public class CheckEventsProcessor {
- private final String COMMAND_CHECK_EVENT = OprofileCommonConstants.COMMAND_OPHELP
- + " -e";
+ private final String COMMAND_CHECK_EVENT = OprofileCommonConstants.COMMAND_OPHELP;
public void parse(String event, int count, int unitmask, int[] result)
throws InterruptedException {
}
}
- private static final String COMMAND_EVENT_LIST = OprofileCommonConstants.COMMAND_OPCONTROL
- + " -l 2> /dev/null";
+ private static final String COMMAND_EVENT_LIST = OprofileCommonConstants.OPROFILE_SCRIPT + " list";
+
//Add by yangang.han(yangangx.han@intel.com) 2013.03.06 to fix the bug TDIS-4049.
//In IA device the event pattern like "CPU_CLK_UNHALTED: (counter: all)" and in ARM device it like "ISS_NO_DISP1: (counter: 1, 2, 3, 4, 5, 6)"
//So change this RegExp to match this two type.
import org.tizen.oprofile.core.CommandManager;
+import org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.oprofile.core.OpcontrolException;
+import org.tizen.oprofile.core.OprofileCommonConstants;
+
public class OpInfoProcessor {
private OpInfo info;
* Solution:Set nmi_watchdog 0 to switch off timer_moder. In this case, IA device can run Oprofile.
*/
- private static final String COMMAND_PATH = "/home/developer/sdk_tools/oprofile/usr/bin/";
- public static final String COMMAND_OPCONTROL = COMMAND_PATH+"opcontrol";
- private final String COMMAND_INIT = " --init";
- private final String COMMAND_START = " --start";
- private final String COMMAND_DEINIT = " --deinit";
- private final String COMMAND_DUMP = " --dump";
- private final String COMMAND_WATCHDOG = "echo 0 > /proc/sys/kernel/nmi_watchdog";
+ private final String COMMAND_WATCHDOG = OprofileCommonConstants.OPROFILE_SCRIPT + " watchdogoff";
public void parse() throws InterruptedException {
String[] resultStr = null;
resultStr = CommandManager.runCommandReturningResultArray(COMMAND_COUNTER_NO);
- if (null == resultStr || resultStr.length <= 1) {
- CommandManager.runCommand(COMMAND_OPCONTROL+COMMAND_INIT);
- CommandManager.runCommand(COMMAND_OPCONTROL+COMMAND_DEINIT);
- CommandManager.runCommand(COMMAND_WATCHDOG);
- CommandManager.runCommand(COMMAND_OPCONTROL+COMMAND_INIT);
- resultStr = CommandManager.runCommandReturningResultArray(COMMAND_COUNTER_NO);
- CommandManager.runCommand(COMMAND_OPCONTROL+COMMAND_DEINIT);
+ try {
+ if (null == resultStr || resultStr.length <= 1) {
+ OprofileCorePlugin.getDefault().getOpcontrolProvider().initModule();
+ OprofileCorePlugin.getDefault().getOpcontrolProvider().deinitModule();
+ CommandManager.runShell(COMMAND_WATCHDOG);
+ OprofileCorePlugin.getDefault().getOpcontrolProvider().initModule();
+ resultStr = CommandManager.runCommandReturningResultArray(COMMAND_COUNTER_NO);
+ OprofileCorePlugin.getDefault().getOpcontrolProvider().deinitModule();
+ }
+ } catch (OpcontrolException oe) {
+ OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe);
}
/*End Yangang.han*/
private final String DEFAULT_SESSION_NAME = "current";
private final String TIMER_EVENT = "TIMER";
- private final String COMMAND_SESSION_EVENT =OprofileCommonConstants.COMMAND_OPCONTROL+" --status 2> /dev/null | grep ^Event";
+ private final String COMMAND_SESSION_EVENT =OprofileCommonConstants.OPROFILE_SCRIPT+" status";
public void parse(ArrayList<OpModelEvent> eventList) throws InterruptedException{
if(Oprofile.getTimerMode()){
<with variable="selection">
<count value="1"/>
<iterate>
- <or>
- <instanceof value="org.eclipse.cdt.core.model.IBinary"/>
- <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
- <test
- forcePluginActivation="true"
- property="org.eclipse.cdt.launch.isExecutable"/>
- <test
- forcePluginActivation="true"
- property="org.eclipse.cdt.launch.isCProject"/>
- <and>
- <instanceof value="org.eclipse.ui.IFileEditorInput"/>
- <adapt type="org.eclipse.core.resources.IResource">
- <adapt type="org.eclipse.cdt.core.model.ICElement"/>
- </adapt>
- </and>
- </or>
+ <and>
+ <or>
+ <instanceof
+ value="org.eclipse.cdt.core.model.IBinary">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.cdt.core.model.ICProject">
+ </instanceof>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.cdt.launch.isExecutable">
+ </test>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.cdt.launch.isCProject">
+ </test>
+ <and>
+ <instanceof
+ value="org.eclipse.ui.IFileEditorInput">
+ </instanceof>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <adapt
+ type="org.eclipse.cdt.core.model.ICElement">
+ </adapt>
+ </adapt>
+ </and>
+ </or>
+ <not>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.tizen.tizentest.nature">
+ </test>
+ </adapt>
+ </not>
+ </and>
</iterate>
</with>
</enablement>
import org.tizen.oprofile.core.CommandManager;
import org.tizen.sdblib.SdbShellProcess;
import org.tizen.nativecommon.Activator;
+import org.tizen.nativecommon.IXMLStore;
import org.tizen.nativecommon.ProjectUtil;
public class TizenOprofileLaunchDelegate extends TizenLaunchDelegate {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
+ // check for IME app
+ IXMLStore store = ProjectUtil.getAppXmlStore(ProjectUtil.getProject(config));
+ if(store.isImeCategory())
+ {
+ newCoreException("Profiling of IME application is not supported.", null);
+ }
monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 30);
try {
// check oprofile tool
checkProfilingTool(monitor);
+
+ String remoteExePath = getDebugLaunchCommand(config);
- String remoteExePath = ProjectUtil.getAppDirectory(ProjectUtil.getProject(config), currentDevice) + "/bin/";
+// String remoteExePath = ProjectUtil.getAppDirectory(ProjectUtil.getProject(config), currentDevice) + "/bin/";
+// remoteExePath = remoteExePath.replace("/opt/usr/apps/", "/opt/apps/");
+// IPath exeFile = CDebugUtils.verifyProgramPath(config);
+// remoteExePath += exeFile.toFile().getName();
+
// String cmd = "cd " + remoteExePath + CMD_RESULT_CHECK;
// // String resultRsp = session.run(cmd, null);
// String[] resultRsp = CommandManager
if (monitor.isCanceled())
throw new OperationCanceledException();
- IPath exeFile = CDebugUtils.verifyProgramPath(config);
- remoteExePath += exeFile.toFile().getName();
-
// for bada application
// execute non-exe file instead of .exe file
if(remoteExePath.endsWith(BADA_EXT))
{
remoteExePath = remoteExePath.substring(0, remoteExePath.length() - BADA_EXT.length());
}
-
- String cmd = "ls " + remoteExePath + TizenPlatformConstants.CMD_SUFFIX;
+ String cmd;
+// String cmd = "ls " + remoteExePath + TizenPlatformConstants.CMD_SUFFIX;
// resultRsp = session.run(cmd, null);
- String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
- if (!CommandManager.isRunSeccessfuly(resultRsp))
- newCoreException(
- TizenLaunchMessages.CANNOT_LAUNCH,
- new Exception(
- "Executable does not exist on a valid path. You must install your application before running it."));
+// String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
+// if (!CommandManager.isRunSeccessfuly(resultRsp))
+// newCoreException(
+// TizenLaunchMessages.CANNOT_LAUNCH,
+// new Exception(
+// "Executable does not exist on a valid path. You must install your application before running it."));
if (monitor.isCanceled())
throw new OperationCanceledException();
if (monitor.isCanceled())
throw new OperationCanceledException();
- postProcedure(config, launch, monitor);
+ postProcedure(config, launch, monitor, remoteExePath);
if (monitor.isCanceled())
throw new OperationCanceledException();
private void runApplication(ILaunchConfiguration config, ILaunch launch,
String command) {
- SdbShellProcess oprofileProc = CommandManager.runApplication(command);
+
+ Process oprofileProc = CommandManager.runApplication(command);
IPath exeFile = null;
try {
exeFile = CDebugUtils.verifyProgramPath(config);
}
private void postProcedure(ILaunchConfiguration config, ILaunch launch,
- IProgressMonitor monitor) throws CoreException {
+ IProgressMonitor monitor, String remoteExePath) throws CoreException {
// ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager();
// lmgr.addLaunchListener(new LaunchTerminationWatcher(launch));
+
+ // terminate application when stop button clicked
+ String cmd = "/usr/bin/oprofile_command killapp " + remoteExePath;
+ CommandManager.runShell(cmd);
+
OprofileCorePlugin.getDefault().getOpcontrolProvider().dumpSamples();
OprofileCorePlugin.getDefault().getOpcontrolProvider().shutdownDaemon();
public static void checkProfilingTool(IProgressMonitor monitor)
throws CoreException {
// find oprofile
- String oprofileCmd = TizenPlatformConstants.TOOLS_TARGET_PATH + "/oprofile/usr/bin/opcontrol";
+ String oprofileCmd = "/usr/bin/opcontrol";
String cmd = "ls " + oprofileCmd + TizenPlatformConstants.CMD_SUFFIX;
// String resultRsp = session.run(cmd, null);
String[] resultRsp = CommandManager.runCommandReturningResultArray(cmd);
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.linuxtools.oprofile.launch.configuration.OprofileEventConfigTab;
+import org.eclipse.linuxtools.profiling.launch.ProfileConfigurationMainTab;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
import org.tizen.nativecommon.launch.ui.TizenMainTab;
import org.tizen.oprofile.launch.TizenOprofileLaunchDelegate;
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
- tabs.add(new TizenMainTab());
+ tabs.add(new ProfileConfigurationMainTab());
// tabs.add(new TizenArgumentsTab());
tabs.addAll(Arrays.asList(getProfileTabs()));
// tabs.add(new TizenEnvironmentTab());
}
private static final String[] basicSetting = {
- "Bottleneck Analysis", "--event=default"
+ "Bottleneck Analysis", "event=default"
};
private static final String[][] settingForARMv7 = {
basicSetting,
- {"Instruction Cache Efficiency Analysis", "--event=IFETCH_MISS:10000:0:1:1 --event=INSTR_EXECUTED:10000:0:1:1"}
+ {"Instruction Cache Efficiency Analysis", "event=IFETCH_MISS:10000:0:1:1 event=INSTR_EXECUTED:10000:0:1:1"}
};
private static final String[][] settingForCore2 = {
org.tizen.common,
org.tizen.common.connection
Bundle-ActivationPolicy: lazy
-Import-Package: org.eclipse.cdt.core.model,
+Import-Package: org.eclipse.cdt.core,
+ org.eclipse.cdt.core.model,
+ org.eclipse.cdt.core.settings.model,
org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.debug.internal.ui.launch,
org.eclipse.cdt.launch,
+ org.eclipse.cdt.launch.internal.ui,
org.eclipse.cdt.launch.ui,
org.eclipse.cdt.managedbuilder.core,
org.eclipse.cdt.ui,
org.eclipse.debug.core,
org.eclipse.debug.ui,
org.eclipse.debug.ui.sourcelookup,
+ org.tizen.nativecommon,
+ org.tizen.nativecommon.build,
+ org.tizen.nativecommon.launch,
+ org.tizen.nativecommon.launch.ui,
org.tizen.sdblib
Export-Package: org.eclipse.linuxtools.profiling.launch
Bundle-Localization: plugin
--- /dev/null
+/*
+ * Profile Configuration Main Tab
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Wonhyoung Park <wonhyoung2.park@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * 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:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.eclipse.linuxtools.profiling.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.tizen.nativecommon.build.CommonBuildConstants;
+import org.tizen.nativecommon.launch.ui.TizenMainTab;
+
+public class ProfileConfigurationMainTab extends TizenMainTab {
+
+ @Override
+ @SuppressWarnings("restriction")
+ protected void updateProgramFromConfig(ILaunchConfiguration config) {
+ if (fProgText != null) {
+ String programName = EMPTY_STRING;
+
+ try {
+ if (!isUnitTestProject(config)) {
+ programName = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
+ EMPTY_STRING);
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ fProgText.setText(programName);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("restriction")
+ protected void updateProjectFromConfig(ILaunchConfiguration config) {
+ String projectName = EMPTY_STRING;
+ String configName = EMPTY_STRING;
+ try {
+ if (!isUnitTestProject(config)) {
+ projectName = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ EMPTY_STRING);
+ configName = config
+ .getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+ EMPTY_STRING);
+ }
+ } catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+
+ if (!fProjText.getText().equals(projectName))
+ fProjText.setText(projectName);
+ updateBuildConfigCombo(configName);
+ }
+
+ @Override
+ @SuppressWarnings("restriction")
+ protected ICProject chooseCProject() {
+ try {
+ ICProject[] projects = getCProjects();
+ ArrayList<ICProject> filteredProjects = new ArrayList<ICProject>();
+
+ for (ICProject project : projects) {
+ String[] natures = project.getProject().getDescription()
+ .getNatureIds();
+ boolean isUnittestProject = false;
+
+ for (String nature : natures) {
+ if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) {
+ isUnittestProject = true;
+ break;
+ }
+ }
+ if (!isUnittestProject) {
+ filteredProjects.add(project);
+ }
+ }
+
+ ILabelProvider labelProvider = new CElementLabelProvider();
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(
+ getShell(), labelProvider);
+ dialog.setTitle(LaunchMessages.CMainTab_Project_Selection);
+ dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program);
+ dialog.setElements(filteredProjects.toArray());
+
+ ICProject cProject = getCProject();
+ if (cProject != null) {
+ dialog.setInitialSelections(new Object[] { cProject });
+ }
+ if (dialog.open() == Window.OK) {
+ return (ICProject) dialog.getFirstResult();
+ }
+ } catch (CModelException e) {
+ LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @SuppressWarnings("restriction")
+ public static boolean isUnitTestProject(ILaunchConfiguration config) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+
+ try {
+ String pName = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ EMPTY_STRING);
+
+ if (!pName.equals(EMPTY_STRING)) {
+ String[] natures = root.getProject(pName).getDescription()
+ .getNatureIds();
+
+ for (String nature : natures) {
+ if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) {
+ return true;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ return false;
+ }
+
+ return false;
+ }
+
+}
*******************************************************************************/
package org.eclipse.linuxtools.profiling.launch;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
+import org.tizen.common.util.ViewUtil;
+import org.tizen.nativecommon.ProjectUtil;
+import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
+import org.tizen.nativecommon.launch.LaunchUtils;
+import org.tizen.sdblib.IDevice;
public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
public static void showErrorDialog(final String errorMessage, final String reasonMessage, final Exception ex) {
- final String dialogTitle = "Valgrind Error";
+ final String dialogTitle = "Profile Error";
final String toolname = Messages.getString("ProfileLaunchShortcut.targetcheck");
final IStatus status = new Status(IStatus.ERROR, toolname, IStatus.OK, reasonMessage, ex);
* @return a re-useable config or <code>null</code> if none
*/
protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
+ if(bin == null)
+ {
+ IWorkbenchWindow workbenchWindow = ViewUtil.getWorkbenchWindow();
+ if(workbenchWindow != null && workbenchWindow.getSelectionService() != null)
+ {
+ ISelection selection = workbenchWindow.getSelectionService().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object[] obj = ((IStructuredSelection)selection).toArray();
+ if (obj.length == 1) {
+ IProject project = (IProject)obj[0];
+ return createConfiguration(project, mode);
+ }
+ }
+ }
+ showErrorDialog("Cannot find a project name.", "Cannot find a project name.", null);
+ }
+
ILaunchConfiguration configuration = null;
ILaunchConfigurationType configType = getLaunchConfigType();
+ IDevice device = LaunchUtils.getCurrentDeployDevice();
List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
try {
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
for (int i = 0; i < configs.length; i++) {
ILaunchConfiguration config = configs[i];
+ String device_serial = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_CONFIG_DEVICE_SERIALNO,
+ TizenLaunchConfigurationConstants.ATTR_CONFIG_NO_DEVICE);
IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
String projectName = AbstractCLaunchDelegate.getProjectName(config);
IPath binPath = bin.getResource().getProjectRelativePath();
if (programPath != null && programPath.equals(binPath)) {
- if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
+ if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())
+ && device_serial.equals(device.getSerialNumber()))
+ {
candidateConfigs.add(config);
}
}
try {
String projectName = bin.getResource().getProjectRelativePath().toString();
ILaunchConfigurationType configType = getLaunchConfigType();
+ IDevice device = LaunchUtils.getCurrentDeployDevice();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
setDefaultProfileAttributes(wc);
+
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(bin.getCProject().getProject());
+ if (projDes != null) {
+ String buildConfigID = projDes.getActiveConfiguration().getId();
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
+ String buildConfigName = projDes.getActiveConfiguration().getName();
+ wc.setAttribute(TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, buildConfigName);
+ wc.setAttribute(TizenLaunchConfigurationConstants.ATTR_CONFIG_DEVICE_SERIALNO, device.getSerialNumber());
+ }
config = wc.doSave();
} catch (CoreException e) {
return config;
}
+ private ILaunchConfiguration createConfiguration(IProject prj, String mode) {
+ ILaunchConfiguration config = null;
+ try {
+ String projectName = prj.getName();
+ ILaunchConfigurationType configType = getLaunchConfigType();
+ IDevice device = LaunchUtils.getCurrentDeployDevice();
+
+ IProject project = prj;
+ String configName = ProjectUtil.getLaunchConfigurationName(project);
+ ILaunchConfigurationWorkingCopy wc =
+ configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(configName));
+
+ String programName = ProjectUtil.getDefaultConfiguration(prj).getName() + File.separatorChar + ProjectUtil.getBinaryName(prj);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
+ wc.setMappedResources(new IResource[] {prj});
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+
+ setDefaultProfileAttributes(wc);
+
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(prj);
+ if (projDes != null) {
+ String buildConfigID = projDes.getActiveConfiguration().getId();
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
+ String buildConfigName = projDes.getActiveConfiguration().getName();
+ wc.setAttribute(TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, buildConfigName);
+ wc.setAttribute(TizenLaunchConfigurationConstants.ATTR_CONFIG_DEVICE_SERIALNO, device.getSerialNumber());
+ }
+ config = wc.doSave();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return config;
+ }
+
protected ILaunchManager getLaunchManager() {
return DebugPlugin.getDefault().getLaunchManager();
}
<with variable="selection">
<count value="1"/>
<iterate>
- <or>
- <instanceof value="org.eclipse.cdt.core.model.IBinary"/>
- <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
- <test
- forcePluginActivation="true"
- property="org.eclipse.cdt.launch.isExecutable"/>
- <test
- forcePluginActivation="true"
- property="org.eclipse.cdt.launch.isCProject"/>
- <and>
- <instanceof value="org.eclipse.ui.IFileEditorInput"/>
- <adapt type="org.eclipse.core.resources.IResource">
- <adapt type="org.eclipse.cdt.core.model.ICElement"/>
- </adapt>
- </and>
- </or>
+ <and>
+ <or>
+ <instanceof
+ value="org.eclipse.cdt.core.model.IBinary">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.cdt.core.model.ICProject">
+ </instanceof>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.cdt.launch.isExecutable">
+ </test>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.cdt.launch.isCProject">
+ </test>
+ <and>
+ <instanceof
+ value="org.eclipse.ui.IFileEditorInput">
+ </instanceof>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <adapt
+ type="org.eclipse.cdt.core.model.ICElement">
+ </adapt>
+ </adapt>
+ </and>
+ </or>
+ <not>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.tizen.tizentest.nature">
+ </test>
+ </adapt>
+ </not>
+ </and>
</iterate>
</with>
</enablement>
public class CommandManager {
- public static SdbShellProcess runApplication(String command){
+ public static Process runApplication(String command){
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- SdbShellProcess sdbShellProc = null;
+ Process sdbShellProc = null;
try {
- sdbShellProc = device.executeShellCommand(command);
+ sdbShellProc = device.executeShellCommand(command, false);
} catch (IOException e) {
e.printStackTrace();
}
return lastOut;
}
+ public static String runShellRoot(String command) {
+ IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+ Process sdbShellProc = null;
+ BufferedReader br = null;
+
+ try {
+ sdbShellProc = device.executeShellCommand(command, false);
+ br = new BufferedReader(new InputStreamReader(
+ sdbShellProc.getInputStream()));
+
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ String out = null;
+ String lastOut = null;
+ try {
+ while (null != (out = br.readLine())) {
+ lastOut = out;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return lastOut;
+ }
+
public static String[] runCommandReturningResult(String command) {
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
CommonReceiver commonReceiver = new CommonReceiver();
import org.eclipse.ui.PlatformUI;
import org.tizen.common.TizenPlatformConstants;
import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.nativecommon.IXMLStore;
import org.tizen.nativecommon.ProjectUtil;
import org.tizen.nativecommon.launch.IProjectLaunchCommand;
import org.tizen.nativecommon.launch.TizenLaunchCommand;
monitor = new NullProgressMonitor();
try {
+ // check for real device
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
if(!device.isEmulator())
{
newCoreException("Valgrind profiling is available in emulator only.", null);
}
+ // check for IME app
+ IXMLStore store = ProjectUtil.getAppXmlStore(ProjectUtil.getProject(config));
+ if(store.isImeCategory())
+ {
+ newCoreException("Profiling of IME application is not supported.", null);
+ }
+
monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 30);
activateProgressView();
throw new OperationCanceledException();
// verify target app path
- String remoteExePath = ProjectUtil.getAppDirectory(ProjectUtil.getProject(config), currentDevice) + "/bin/";
- IPath exeFile = CDebugUtils.verifyProgramPath(config);
- remoteExePath += exeFile.toFile().getName();
+ String remoteExePath = getDebugLaunchCommand(config);
+// String remoteExePath = ProjectUtil.getAppDirectory(ProjectUtil.getProject(config), currentDevice) + "/bin/";
+// IPath exeFile = CDebugUtils.verifyProgramPath(config);
+// remoteExePath += exeFile.toFile().getName();
// for bada application
// execute non-exe file instead of .exe file
String[] opts = getValgrindArgumentsArray(config);
String[] arguments = getProgramArgumentsArray(config);
+ // for sciprt usage
+ valgrindCmd = "/usr/bin/oprofile_command valgrind";
ArrayList<String> cmdLine = new ArrayList<String>(1 + arguments.length);
cmdLine.add(valgrindCmd);
cmdLine.addAll(Arrays.asList(opts));
if (monitor.isCanceled())
throw new OperationCanceledException();
-
+
// run application with valgrind
runApplication(config, launch, fullcommand, monitor);
monitor.worked(2);
+
+ CommandManager.runShellRoot(valgrindCmd + "_chmod");
// process = DebugPlugin.newProcess(launch, remoteShellProcess, "valgrind");
private void runApplication(ILaunchConfiguration config, ILaunch launch,
String command, IProgressMonitor monitor) throws ValgrindCanceledException
{
- SdbShellProcess valgrindProc = CommandManager.runApplication(command);
+ Process valgrindProc = CommandManager.runApplication(command);
IPath exeFile = null;
try {
exeFile = CDebugUtils.verifyProgramPath(config);
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.linuxtools.profiling.launch.ProfileConfigurationMainTab;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
import org.tizen.nativecommon.launch.ui.TizenMainTab;
//
// }
ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
- tabs.add(new TizenMainTab());
+ tabs.add(new ProfileConfigurationMainTab());
// tabs.add(new TizenArgumentsTab());
tabs.addAll(Arrays.asList(getProfileTabs()));
// tabs.add(new TizenEnvironmentTab());
public boolean isValid(ILaunchConfiguration launchConfig) {
// added by Jaewon Lim at 20120904
if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
- setErrorMessage(Messages.getString("ValgrindOptionsTab.noemul"));
+ setErrorMessage(Messages.getString("ValgrindOptionsTab.noemul_option"));
return false;
}
ValgrindOptionsTab.memps=Memory Usage data
ValgrindOptionsTab.inemul=Please note that valgrind profiling is available in emulator only.
ValgrindOptionsTab.noemul=Emulator isn't connected or activated.
+ValgrindOptionsTab.noemul_option=Emulator isn't activated.(valgrind is supported in emulator only)
ValgrindOptionsTab.cannotrun=Cannot run valgrind profiling.