From 652c469cad66f09c34dea810bdea2dfb442d1617 Mon Sep 17 00:00:00 2001 From: greatim Date: Tue, 16 Apr 2013 16:34:55 +0900 Subject: [PATCH] [Title] fix for valgrind error at basic app [Desc.] [Issue] --- .../plugin.xml | 54 ++++--- .../launch/TizenOprofileLaunchDelegate.java | 7 + .../NormalOprofileLaunchConfigurationTabGroup.java | 3 +- .../META-INF/MANIFEST.MF | 3 + .../launch/ProfileConfigurationMainTab.java | 160 +++++++++++++++++++++ .../plugin.xml | 54 ++++--- .../linuxtools/valgrind/launch/CommandManager.java | 31 +++- .../launch/TizenValgrindLaunchDelegate.java | 17 ++- .../ValgrindLaunchConfigurationTabGroup.java | 3 +- .../valgrind/launch/ValgrindOptionsTab.java | 2 +- .../linuxtools/valgrind/launch/messages.properties | 1 + 11 files changed, 295 insertions(+), 40 deletions(-) create mode 100644 org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileConfigurationMainTab.java diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml b/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml index 86eb610..501d492 100644 --- a/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml +++ b/org.eclipse.linuxtools.oprofile.launch.exe/plugin.xml @@ -40,22 +40,44 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java index ffa5c36..7d379b5 100644 --- a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java +++ b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java @@ -59,6 +59,7 @@ import org.tizen.nativecommon.launch.TizenLaunchMessages; 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 { @@ -86,6 +87,12 @@ 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); diff --git a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java index 68a1e4b..10fd2bf 100644 --- a/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java +++ b/org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java @@ -29,6 +29,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; 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; @@ -37,7 +38,7 @@ public class NormalOprofileLaunchConfigurationTabGroup extends ProfileLaunchConf public void createTabs(ILaunchConfigurationDialog dialog, String mode) { ArrayList tabs = new ArrayList(); - tabs.add(new TizenMainTab()); + tabs.add(new ProfileConfigurationMainTab()); // tabs.add(new TizenArgumentsTab()); tabs.addAll(Arrays.asList(getProfileTabs())); // tabs.add(new TizenEnvironmentTab()); diff --git a/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF index c1c5f73..dd33548 100644 --- a/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Import-Package: org.eclipse.cdt.core, 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, @@ -23,7 +24,9 @@ Import-Package: org.eclipse.cdt.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 diff --git a/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileConfigurationMainTab.java b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileConfigurationMainTab.java new file mode 100644 index 0000000..14abce1 --- /dev/null +++ b/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileConfigurationMainTab.java @@ -0,0 +1,160 @@ +/* + * Profile Configuration Main Tab + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jaewon Lim + * Wonhyoung Park + * Juyoung Kim + * + * 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 filteredProjects = new ArrayList(); + + 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; + } + +} diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml b/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml index 1ab4199..549beed 100644 --- a/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml +++ b/org.eclipse.linuxtools.valgrind.launch.exe/plugin.xml @@ -42,22 +42,44 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java index d772c12..08b08dc 100644 --- a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java +++ b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/CommandManager.java @@ -30,12 +30,12 @@ class CommonReceiver extends MultiLineReceiver { 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(); } @@ -67,6 +67,31 @@ public class CommandManager { 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(); diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java index f2e2a3f..b2332dc 100644 --- a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java +++ b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java @@ -52,6 +52,7 @@ import org.eclipse.ui.PartInitException; 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; @@ -89,12 +90,20 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate { 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(); @@ -185,6 +194,8 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate { String[] opts = getValgrindArgumentsArray(config); String[] arguments = getProgramArgumentsArray(config); + // for sciprt usage + valgrindCmd = "/usr/bin/oprofile_command valgrind"; ArrayList cmdLine = new ArrayList(1 + arguments.length); cmdLine.add(valgrindCmd); cmdLine.addAll(Arrays.asList(opts)); @@ -203,11 +214,13 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate { 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"); @@ -258,7 +271,7 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate { 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); diff --git a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java index 28e7606..0e19eac 100644 --- a/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java +++ b/org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchConfigurationTabGroup.java @@ -25,6 +25,7 @@ import java.util.Arrays; 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; @@ -43,7 +44,7 @@ public class ValgrindLaunchConfigurationTabGroup extends ProfileLaunchConfigurat // // } ArrayList tabs = new ArrayList(); - tabs.add(new TizenMainTab()); + tabs.add(new ProfileConfigurationMainTab()); // tabs.add(new TizenArgumentsTab()); tabs.addAll(Arrays.asList(getProfileTabs())); // tabs.add(new TizenEnvironmentTab()); diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java index f337f9b..dc29d36 100644 --- a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java +++ b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java @@ -612,7 +612,7 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab { 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; } diff --git a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties index 02ca739..68432f2 100644 --- a/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties +++ b/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties @@ -34,5 +34,6 @@ ValgrindOptionsTab.collect_data2=Heap Memory Profiling 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. -- 2.7.4