some bug fix in oprofile, valgrind
authorjaewon81.lim <jaewon81.lim@samsung.com>
Mon, 13 Jun 2011 09:31:58 +0000 (18:31 +0900)
committerjaewon81.lim <jaewon81.lim@samsung.com>
Mon, 13 Jun 2011 09:31:58 +0000 (18:31 +0900)
org.eclipse.linuxtools.oprofile.core/src/com/samsung/linuxplatform/oprofile/core/OprofileComm.java
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/LinuxOpcontrolProvider.java
org.eclipse.linuxtools.oprofile.launch.exe/src/com/samsung/linuxplatform/oprofile/launch/SLPOprofileLaunchDelegate.java
org.eclipse.linuxtools.oprofile.launch.exe/src/com/samsung/linuxplatform/oprofile/launch/configuration/NormalOprofileLaunchConfigurationTabGroup.java
org.eclipse.linuxtools.oprofile.launch/src/com/samsung/linuxplatform/oprofile/launch/listen/OProfileTargetConnectionListener.java
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/SLPValgrindLaunchDelegate.java

index 111468c..5fa4cfe 100644 (file)
@@ -18,6 +18,8 @@ import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
 import org.eclipse.swt.widgets.Display;
 
 import com.samsung.linuxplatform.oprofile.core.provider.OpcontrolDataProvider;
+import com.samsung.freshide.connection.machine.DeviceMachine;
+import com.samsung.freshide.connection.machine.IMachine;
 import com.samsung.freshide.connection.session.ISession;
 import com.samsung.freshide.connection.session.SessionManager;
 import com.samsung.freshide.connection.device.DeviceManager;
@@ -112,7 +114,11 @@ public abstract class OprofileComm {
        public static ISession getSession() throws InterruptedException{
                ISession session = null;
                try {
-                       session = SessionManager.getSession("OPROFILER_CONTROL", DeviceManager.getSelectedDevice(), new NullProgressMonitor());
+                       DeviceMachine selected = DeviceManager.getSelectedDevice();
+                       if(selected.getMachineType().equals(IMachine.VIRTUAL_DEVICE))
+                               session = SessionManager.getSession("OPROFILER_CONTROL_VIRTUAL", selected, new NullProgressMonitor());
+                       else
+                               session = SessionManager.getSession("OPROFILER_CONTROL_REAL", selected, new NullProgressMonitor());
                } catch (Exception e) {
 
                }
index 48622e5..b76d67b 100644 (file)
@@ -22,6 +22,7 @@ import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonOptions;
 
 import com.samsung.linuxplatform.oprofile.core.OprofileComm;
 import com.samsung.linuxplatform.oprofile.core.OprofileCommonConstants;
+import com.samsung.freshide.connection.device.DeviceManager;
 import com.samsung.freshide.connection.session.ISession;
 
 /**
@@ -369,7 +370,8 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
 //                     result = session.run(str);
                        session.run(str, null);
                } catch (Exception e) {
-                       throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun", e)); //$NON-NLS-1$
+                       throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun (" +
+                                       DeviceManager.getSelectedDevice().getMachineType() + ")", e)); //$NON-NLS-1$
                }
                //-----------------------------------
                
index d0b80d2..2521278 100644 (file)
@@ -20,7 +20,9 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 
+import com.samsung.freshide.connection.device.DeviceManager;
 import com.samsung.freshide.common.properties.InstallPathConfig;
+import com.samsung.freshide.connection.machine.IMachine;
 import com.samsung.freshide.connection.session.ISession;
 import com.samsung.freshide.launch.SLPLaunchDelegate;
 import com.samsung.freshide.launch.SLPLaunchMessages;
@@ -73,20 +75,12 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
                try {
                        setEnvironments(config, session);
 
-                       // find oprofile
-                       String oprofileCmd = "/usr/bin/oprofile";
-                       String cmd = "ls " + oprofileCmd + CMD_RESULT_CHECK ;
-                       String resultRsp = session.run(cmd, null);
-                       if(!resultRsp.contains("0"))
-                       {
-                               transferProfilingToolPackage(monitor, session);
-                               installProfilingToolPackage(monitor, session);
-//                             newCoreException(SLPLaunchMessages.CANNOT_LAUNCH, new Exception("No oprofile in this target (/usr/bin/oprofile). "));
-                       }
+                       // check oprofile tool
+                       checkProfilingTool(monitor, session);
                        
                        String remoteExePath = getRemoteExePath(config); 
-                       cmd = "cd " + remoteExePath + CMD_RESULT_CHECK;
-                       resultRsp = session.run(cmd, null);
+                       String cmd = "cd " + remoteExePath + CMD_RESULT_CHECK;
+                       String resultRsp = session.run(cmd, null);
                        if(!resultRsp.contains("0"))
                                newCoreException(SLPLaunchMessages.CANNOT_LAUNCH, new Exception("Cannot change to run-directory : " + ". (Return Code: " + resultRsp + ")"));
 
@@ -211,6 +205,26 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
                lmgr.addLaunchListener(new LaunchTerminationWatcher(launch));
        }
 
+       
+       public static void checkProfilingTool(IProgressMonitor monitor, ISession session) throws Exception {
+               // find oprofile
+               String oprofileCmd = "/usr/bin/opcontrol";
+               String cmd = "ls " + oprofileCmd + CMD_RESULT_CHECK ;
+               String resultRsp = session.run(cmd, null);
+               if(!resultRsp.contains("0"))
+               {
+                       if(DeviceManager.getSelectedDevice().getMachineType().equals(IMachine.VIRTUAL_DEVICE))
+                       {
+                               throw new Exception(SLPLaunchMessages.CANNOT_LAUNCH, new Exception("No oprofile in this target (/usr/bin/opcontrol)."));
+                       }
+                       else
+                       {
+                               transferProfilingToolPackage(monitor, session);
+                               installProfilingToolPackage(monitor, session);
+                       }
+               }
+       }
+       
        /**
         * Transfer oprofile package to the target
         * 
@@ -222,7 +236,7 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
         * @exception CoreException
         *                if unable to transfer a package
         */
-       public void transferProfilingToolPackage(IProgressMonitor monitor, ISession session) throws CoreException {
+       public static void transferProfilingToolPackage(IProgressMonitor monitor, ISession session) throws Exception {
                try {
                        monitor.beginTask(Messages.getString("ProfileLaunch.TRANSFER_PROFILING_TOOL"), 1);
 
@@ -231,7 +245,8 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
                        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"), null);
+                               throw new Exception(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
+                                               new Exception("Tool package path (" + toolPkgPath + ") is not available."));
                        
                        String destDirectoryPath = TEMPORARY_PKG_PATH;
 
@@ -239,20 +254,20 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
                                String command = MAKE_DIRECTORY_CMD + destDirectoryPath + CMD_RESULT_CHECK;
                                String result = session.run(command, null);
                                if(!result.contains("0"))
-                                       newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), null);
+                                       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 + packageFile.getAbsoluteFile().getName();
+                       String destFilePath = destDirectoryPath + toolPkg.getAbsoluteFile().getName();
 
                        boolean isSuccess = session.transferFile(srcFilePath, destFilePath);
 
                        if (isSuccess == false)
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), null);
-               } catch (CoreException e) {
-                       throw e;
+                               throw new Exception(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
+                                               new Exception("source path (" + srcFilePath + "), dest path (" + destFilePath +")"));
                } catch (Exception e) {
-                       newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), e);                      
+                       throw e;                        
                } finally {
                        monitor.done();
                }
@@ -270,7 +285,7 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
         * @exception CoreException
         *                if unable to install a package
         */
-       public void installProfilingToolPackage(IProgressMonitor monitor, ISession session) throws CoreException {
+       public static void installProfilingToolPackage(IProgressMonitor monitor, ISession session) throws Exception {
                try {
                        monitor.beginTask(Messages.getString("ProfileLaunch.INSTALL_PROFILING_TOOL"), 2);
 
@@ -278,25 +293,23 @@ public class SLPOprofileLaunchDelegate extends SLPLaunchDelegate {
                        String command = CHANGE_DIRECTORY_CMD + packageDirectory + CMD_RESULT_CHECK;
                        String result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null);
+                               throw new Exception(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), new Exception("command is " + command));
 
                        // remove old application
                        command = PKG_TOOL_CMD + PKG_TOOL_REMOVE_OPTION + PACKAGE_NAME + CMD_RESULT_CHECK ;
                        result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null); 
+                               throw new Exception(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), new Exception("command is " + command));
                        monitor.worked(1);
 
                        // install new application
                        command = PKG_TOOL_CMD + PKG_TOOL_INSTALL_OPTION + PACKAGE_FILENAME_ARM + CMD_RESULT_CHECK;
                        result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null); 
+                               throw new Exception(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), new Exception("command is " + command));
                        monitor.worked(1);
-               } catch (CoreException e) {
-                       throw e;
                } catch (Exception e) {
-                       newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), e);
+                       throw e;
                } finally {
                        monitor.done();
                }
index 82b704d..bd1c039 100644 (file)
@@ -7,18 +7,24 @@ package com.samsung.linuxplatform.oprofile.launch.configuration;
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+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.ProfileLaunchConfigurationTabGroup;
 
+import com.samsung.freshide.connection.session.ISession;
 import com.samsung.freshide.launch.ui.SLPMainTab;
 import com.samsung.freshide.launch.ui.SLPEnvironmentTab;
 import com.samsung.freshide.launch.ui.SLPArgumentsTab;
+import com.samsung.linuxplatform.oprofile.core.OprofileComm;
+import com.samsung.linuxplatform.oprofile.launch.SLPOprofileLaunchDelegate;
+
 import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
 
 public class NormalOprofileLaunchConfigurationTabGroup extends ProfileLaunchConfigurationTabGroup {
-       
+
        public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
                ArrayList<AbstractLaunchConfigurationTab> tabs = new ArrayList<AbstractLaunchConfigurationTab>();
                tabs.add(new SLPMainTab());
@@ -34,6 +40,18 @@ public class NormalOprofileLaunchConfigurationTabGroup extends ProfileLaunchConf
        public AbstractLaunchConfigurationTab[] getProfileTabs() {
                //jinu modified at 20090602
                //return new AbstractLaunchConfigurationTab[] { new OprofileSetupTab(), new OprofileEventConfigTab() };
+
+               // added by greatim at 20110613
+               try{
+                       ISession session = OprofileComm.getSession();
+                       IProgressMonitor monitor = new NullProgressMonitor();
+                       
+                       SLPOprofileLaunchDelegate.checkProfilingTool(monitor, session);
+               } catch(Exception e) {
+                       
+               }
+               
                return new AbstractLaunchConfigurationTab[] { new OprofileEventConfigTab() };
        }
+
 }
index 39fe52a..3abaa03 100644 (file)
@@ -12,11 +12,6 @@ import com.samsung.freshide.connection.device.IDeviceListener;
 public class OProfileTargetConnectionListener implements IDeviceListener{
 
        @Override
-       public void StatusChanged(int Event) {
-               
-       }
-
-       @Override
        public void ConnectionChanged() {
                try {
                        if(DeviceManager.hasSelectedDevice() == false ||
index 1a56484..2869a35 100644 (file)
@@ -27,6 +27,9 @@ import org.eclipse.linuxtools.profiling.launch.Messages;
 import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
 import org.eclipse.linuxtools.valgrind.core.ValgrindCommand;
 import org.eclipse.linuxtools.valgrind.core.utils.LaunchConfigurationConstants;
+
+import com.samsung.freshide.connection.device.DeviceManager;
+import com.samsung.freshide.connection.machine.IMachine;
 import com.samsung.freshide.connection.session.ISession;
 import com.samsung.freshide.launch.SLPLaunchDelegate;
 import com.samsung.freshide.launch.SLPLaunchMessages;
@@ -88,9 +91,15 @@ public class SLPValgrindLaunchDelegate extends SLPLaunchDelegate {
                        String resultRsp = session.run(cmd, null);
                        if(!resultRsp.contains("0"))
                        {
-                               transferProfilingToolPackage(monitor, session);
-                               installProfilingToolPackage(monitor, session);
-//                             newCoreException(SLPLaunchMessages.CANNOT_LAUNCH, new Exception("No valgrind in this target (/usr/bin/valgrind). "));
+                               if(DeviceManager.getSelectedDevice().getMachineType().equals(IMachine.VIRTUAL_DEVICE))
+                               {
+                                       newCoreException(SLPLaunchMessages.CANNOT_LAUNCH, new Exception("No valgrind in this target (/usr/bin/valgrind). "));
+                               }
+                               else
+                               {
+                                       transferProfilingToolPackage(monitor, session);
+                                       installProfilingToolPackage(monitor, session);
+                               }
                        }
                        
                        String remoteExePath = getRemoteExePath(config); 
@@ -266,7 +275,8 @@ public class SLPValgrindLaunchDelegate extends SLPLaunchDelegate {
                        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"), null);
+                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"),
+                                               new Exception("Tool package path (" + toolPkgPath + ") is not available."));
                        
                        String destDirectoryPath = TEMPORARY_PKG_PATH;
 
@@ -274,16 +284,18 @@ public class SLPValgrindLaunchDelegate extends SLPLaunchDelegate {
                                String command = MAKE_DIRECTORY_CMD + destDirectoryPath + CMD_RESULT_CHECK;
                                String result = session.run(command, null);
                                if(!result.contains("0"))
-                                       newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), null);
+                                       newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), 
+                                                       new Exception("Destination path (" + destDirectoryPath + ") in not exist."));
                        }
 
                        String srcFilePath = toolPkg.getAbsoluteFile().getCanonicalPath();
-                       String destFilePath = destDirectoryPath + packageFile.getAbsoluteFile().getName();
-
+                       String destFilePath = destDirectoryPath + toolPkg.getAbsoluteFile().getName();
+                       
                        boolean isSuccess = session.transferFile(srcFilePath, destFilePath);
-
+                       
                        if (isSuccess == false)
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), null);
+                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_TRANSFER"), 
+                                               new Exception("source path (" + srcFilePath + "), dest path (" + destFilePath +")"));
                } catch (CoreException e) {
                        throw e;
                } catch (Exception e) {
@@ -313,20 +325,23 @@ public class SLPValgrindLaunchDelegate extends SLPLaunchDelegate {
                        String command = CHANGE_DIRECTORY_CMD + packageDirectory + CMD_RESULT_CHECK;
                        String result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null);
+                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), 
+                                               new Exception("command is " + command));
 
                        // remove old application
                        command = PKG_TOOL_CMD + PKG_TOOL_REMOVE_OPTION + PACKAGE_NAME + CMD_RESULT_CHECK ;
                        result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null); 
+                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), 
+                                               new Exception("command is " + command)); 
                        monitor.worked(1);
 
                        // install new application
                        command = PKG_TOOL_CMD + PKG_TOOL_INSTALL_OPTION + PACKAGE_FILENAME_ARM + CMD_RESULT_CHECK;
                        result = session.run(command, null);
                        if(!result.contains("0"))
-                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), null); 
+                               newCoreException(Messages.getString("ProfileLaunch.FAIL_TO_INSTALL"), 
+                                               new Exception("command is " + command)); 
                        monitor.worked(1);
                } catch (CoreException e) {
                        throw e;