[Title] modify valgrind profiling UI for cancelation and shortcut
authorJaewon Lim <jaewon81.lim@samsung.com>
Wed, 5 Sep 2012 12:13:30 +0000 (21:13 +0900)
committerJaewon Lim <jaewon81.lim@samsung.com>
Mon, 5 Nov 2012 03:12:15 +0000 (12:12 +0900)
[Type] bug fix
[Module] profiler eplugin
[Priority] major
[Jira#]
[Redmine#] 6748
[Problem]
[Cause]
[Solution]
[TestCase]

13 files changed:
org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
org.eclipse.linuxtools.oprofile.core/src/org/tizen/oprofile/core/OprofileComm.java
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/NormalOprofileLaunchShortcut.java
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/OprofileEventConfigTab.java
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/oprofilelaunch.properties
org.eclipse.linuxtools.profiling.launch/META-INF/MANIFEST.MF
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchPlugin.java
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/TizenValgrindLaunchDelegate.java
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindLaunchShortcut.java
org.eclipse.linuxtools.valgrind.launch/META-INF/MANIFEST.MF
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/ValgrindOptionsTab.java
org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/valgrind/launch/messages.properties

index 25b80e9..ea2eb2a 100644 (file)
@@ -7,6 +7,7 @@ Bundle-Activator: org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin
 Bundle-Vendor: Samsung Electronics
 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
  org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.linuxtools.profiling.launch,
  org.tizen.common,
  org.tizen.common.connection
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
index ec276f3..da7141f 100644 (file)
@@ -26,6 +26,7 @@ import org.xml.sax.XMLReader;
 
 import org.tizen.oprofile.core.CommandManager;
 import org.tizen.oprofile.core.OprofileComm;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
 
 /**
  * This class will run opxml.
@@ -83,7 +84,7 @@ public class OpxmlRunner {
                // Run opxml
                try {
                        //jinu added at 20090604 --------------------------
-                       if(!OprofileComm.checkTarget()) return false;
+                       if(ProfileLaunchPlugin.checkTarget() == 0) return false;
                        //ISession session =OprofileComm.getSession();
                        
                        String command = OprofileComm.getCommandString(cmdArray)+" | sed 's/^[^<]*//' | sed 's/&//'";
index 3595667..b7b3b60 100644 (file)
@@ -33,7 +33,6 @@ import org.eclipse.linuxtools.oprofile.core.model.OpModelEvent;
 import org.eclipse.linuxtools.oprofile.core.model.OpModelRoot;
 import org.eclipse.swt.widgets.Display;
 
-import org.tizen.common.connection.ConnectionPlugin;
 import org.tizen.oprofile.core.provider.OpcontrolDataProvider;
 
 public abstract class OprofileComm {
@@ -136,13 +135,5 @@ public abstract class OprofileComm {
 //             }
 //             return session;
 //     }
-       
-       // changed by greatim 2011.06.01 for fresh ide
-       public static boolean checkTarget() {
-               if(null != ConnectionPlugin.getDefault().getCurrentDevice()){
-                       return true;
-               }
-               else
-                       return false;
-       }
+
 }
index 1bc9ccc..91b94c8 100644 (file)
@@ -24,9 +24,13 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
 import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
 import org.eclipse.linuxtools.oprofile.launch.configuration.LaunchOptions;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
 import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.IEditorPart;
 
 
 /**
@@ -35,6 +39,33 @@ import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
  *   find binaries and create a default launch if one doesn't exist.
  */
 public class NormalOprofileLaunchShortcut extends ProfileLaunchShortcut {
+       
+       public void launch(IEditorPart editor, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(OprofileLaunchMessages.getString("common.cannotrun"),
+                                       OprofileLaunchMessages.getString("common.notarget"), null);
+               }
+               else
+               {
+                       super.launch(editor, mode);
+               }
+       }
+
+       public void launch(ISelection selection, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(OprofileLaunchMessages.getString("common.cannotrun"),
+                                       OprofileLaunchMessages.getString("common.notarget"), null);
+               }
+               else
+               {
+                       super.launch(selection, mode);
+               }
+       }
+       
        @Override
        protected ILaunchConfigurationType getLaunchConfigType() {
                return getLaunchManager().getLaunchConfigurationType(OprofileLaunchPlugin.ID_LAUNCH_PROFILE);
index 250cf7d..7ba1423 100644 (file)
@@ -44,6 +44,7 @@ import org.eclipse.linuxtools.oprofile.core.daemon.OpUnitMask;
 import org.eclipse.linuxtools.oprofile.core.daemon.OprofileDaemonEvent;
 import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchMessages;
 import org.eclipse.linuxtools.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.custom.StackLayout;
@@ -97,9 +98,10 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
                // TODO : have to change help context id (temporarily empty string)
                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ""); //$NON-NLS-1$
 
-
                //jinu added at 20090602----------------------
-               if(!OprofileComm.checkTarget() || Oprofile.getOpInfo()==null){
+               if(ProfileLaunchPlugin.checkTarget() == 0 || Oprofile.getOpInfo()==null){
+                       Label timerModeLabel = new Label(top, SWT.LEFT);
+                       timerModeLabel.setText(OprofileLaunchMessages.getString("common.notarget")); //$NON-NLS-1$
                        canInitialize = false;
                        return;
                }else{
@@ -254,8 +256,8 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
         */
        public boolean isValid(ILaunchConfiguration config) {
                //jinu added at 20090608--------------------------------
-               if(!canInitialize || !OprofileComm.checkTarget()){
-                       setErrorMessage("Target isn't connected. please confirm it and retry");
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       setErrorMessage(OprofileLaunchMessages.getString("common.notarget"));
                        return false;
                }
                //--------------------------------------
@@ -330,7 +332,7 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
         */
        public void performApply(ILaunchConfigurationWorkingCopy config) {
                //jinu added at 20090602-------------------------------
-               if(!canInitialize ||!OprofileComm.checkTarget()){
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
                        return;
                }
                //--------------------------------------
index fb2159f..08d8604 100644 (file)
@@ -18,7 +18,7 @@ oprofileCounter.counterString=Counter: {0,number,integer}
 
 #jinu modified at 20090602
 #tab.event.name=Events
-tab.event.name=Oprofile Options
+tab.event.name=OProfile Options
 tab.event.counterSettings.label.text=Counter settings
 tab.event.counterSettings.enabled.button.text=Enabled
 tab.event.eventDescription.label.text=Event Description:
@@ -46,6 +46,9 @@ tab.global.check.separateKernel.text=Include dependent kernel modules (also incl
 tab.global.check.separateThread.text=Separate profiles per thread
 tab.global.check.separateCpu.text=Separate profiles per CPU
 
+common.cannotrun=Cannot run oprofile profiling.
+common.notarget=Target isn't connected. Please confirm it and retry.
+
 unitmaskViewer.label.text=Unit mask:
 
 launchshortcut.no_project_error=No project associated with selected element.
index f996532..4bbff2c 100644 (file)
@@ -5,7 +5,9 @@ Bundle-SymbolicName: org.eclipse.linuxtools.profiling.launch;singleton:=true
 Bundle-Version: 1.3.18.qualifier
 Bundle-Activator: org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin
 Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.tizen.common,
+ org.tizen.common.connection
 Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.cdt.core.model,
  org.eclipse.cdt.debug.core,
index 2646420..d3c92e9 100644 (file)
@@ -13,6 +13,9 @@ package org.eclipse.linuxtools.profiling.launch;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.sdblib.IDevice;
+
 
 public class ProfileLaunchPlugin extends AbstractUIPlugin {
 
@@ -59,4 +62,23 @@ public class ProfileLaunchPlugin extends AbstractUIPlugin {
                return getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
        }
 
+       // added by Jaewon Lim at 20120904
+       // return 0 if no device is connected
+       // return 1 if current device is real target
+       // return 2 if current device is emulator
+       public static int checkTarget() {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               if(device == null)
+               {
+                       return 0;
+               }
+               else
+               {
+                        if(device.isEmulator())
+                                return 2;
+                        else
+                                return 1;
+               }
+       }
+
 }
index b8eea6b..89d4ea2 100644 (file)
@@ -39,10 +39,15 @@ import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
 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.swt.SWT;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.tizen.common.TizenPlatformConstants;
@@ -73,14 +78,15 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
        protected static final String PACKAGE_FILENAME_ARM = "valgrind_armel.deb";
 
        protected String toolID;
+       protected int confirmMsg = 0;
 
        @Override
        public void launch(ILaunchConfiguration config, String mode,
                        ILaunch launch, IProgressMonitor monitor) throws CoreException
        {
-               
                if (monitor == null)
                        monitor = new NullProgressMonitor();
+               
                try {
                        IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
                        if(!device.isEmulator())
@@ -95,8 +101,7 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
                        verifyCProjectConfigurationSettings(config);
                        verifyDeviceReachability(ProjectUtil.getProject(config),
                                        new SubProgressMonitor(monitor, 9));
-                       verifyBuildConfiguration(config, mode, new SubProgressMonitor(
-                                       monitor, 11));
+                       verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 11));
 
                        // getLaunchSession(config, new SubProgressMonitor(monitor, 1));
 
@@ -113,83 +118,73 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
                }
        }
 
-       protected void launchApplicationWithValgrind(ILaunch launch,
-                       ILaunchConfiguration config, IProgressMonitor monitor)
-                       throws CoreException {
+       protected void launchApplicationWithValgrind(ILaunch launch, ILaunchConfiguration config,
+                       IProgressMonitor monitor) throws CoreException
+       {
                // Process remoteShellProcess = null;
 
                try {
-                       // find Valgrind
+                       // find Valgrind executable
                        String valgrindCmd = "/home/developer/sdk_tools/valgrind/usr/bin/valgrind";
                        String cmd = "ls " + valgrindCmd + TizenPlatformConstants.CMD_SUFFIX;
-                       // 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 (/home/developer/sdk_tools/valgrind/usr/bin/valgrind). "));
-                               // } else {
-                               // transferProfilingToolPackage(monitor);
-                               // installProfilingToolPackage(monitor);
-                               // }
+                               newCoreException(TizenLaunchMessages.CANNOT_LAUNCH,     new Exception(
+                                               "No valgrind in this target (/home/developer/sdk_tools/valgrind/usr/bin/valgrind)."));
                        }
+
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       // verify target app path
                        IProjectLaunchCommand manifest = ProjectUtil.getProjectManifest(ProjectUtil.getProject(config));
                        String remoteExePath = TizenPlatformConstants.APP_INSTALL_PATH + "/" + manifest.getPackageName() + "/bin/";
-//                     cmd = "cd " + remoteExePath + CMD_RESULT_CHECK;
-//                     // resultRsp = session.run(cmd, null);
-//                     resultRsp = CommandManager.runCommandReturningResult(cmd);
-//                     if (!CommandManager.isRunSeccessfuly(resultRsp))
-//                             newCoreException(TizenLaunchMessages.CANNOT_LAUNCH,
-//                                             new Exception("Cannot change to run-directory : "
-//                                                             + ". (Return Code: " + resultRsp
-//                                                             + ", exepath: " + remoteExePath + ")"));
                        IPath exeFile = CDebugUtils.verifyProgramPath(config);
                        remoteExePath += exeFile.toFile().getName();
+                       
                        // for bada application
-                       // execute not .exe file instead of .exe file
+                       // execute non-exe file instead of .exe file
                        if(remoteExePath.endsWith(BADA_EXT))
                        {
                                remoteExePath = remoteExePath.substring(0, remoteExePath.length() - BADA_EXT.length());
                        }
                        
                        cmd = "ls " + remoteExePath + TizenPlatformConstants.CMD_SUFFIX;
-                       // resultRsp = session.run(cmd, null);
                        resultRsp = CommandManager.runCommandReturningResult(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."));
-
+                       {
+                               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();
+                       
                        monitor.worked(3);
 
                        // remove and remake valgrind result directory
                        cmd = "rm -rf" + " " + ValgrindLaunchPlugin.RESULT_DIR;
-                       // session.run(cmd, null);
                        CommandManager.runShell(cmd);
                        cmd = "mkdir -p" + " " + ValgrindLaunchPlugin.RESULT_DIR;
-                       // session.run(cmd, null);
                        CommandManager.runShell(cmd);
 
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
                        monitor.worked(1);
 
                        // ask tool (that was launched) extension for arguments
                        toolID = getTool(config);
-                       dynamicDelegate = ValgrindLaunchPlugin.getDefault()
-                                       .getToolDelegate(toolID);
+                       dynamicDelegate = ValgrindLaunchPlugin.getDefault().getToolDelegate(toolID);
                        String[] opts = getValgrindArgumentsArray(config);
                        String[] arguments = getProgramArgumentsArray(config);
 
-                       ArrayList<String> cmdLine = new ArrayList<String>(
-                                       1 + arguments.length);
+                       ArrayList<String> cmdLine = new ArrayList<String>(1 + arguments.length);
                        cmdLine.add(valgrindCmd);
                        cmdLine.addAll(Arrays.asList(opts));
                        cmdLine.add(remoteExePath.toString());
                        cmdLine.addAll(Arrays.asList(arguments));
-                       String[] commandArray = (String[]) cmdLine
-                                       .toArray(new String[cmdLine.size()]);
+                       String[] commandArray = (String[]) cmdLine.toArray(new String[cmdLine.size()]);
 
                        // compose full command of valgrind
                        String fullcommand = "";
@@ -197,27 +192,18 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
                                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);
-                       // }
-
-                       config.getAttribute(
-                                       ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
-                                       ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT); // what
-                                                                                                                                                       // is
-                                                                                                                                                       // this?
-                       // remoteShellProcess = session.launch(fullcommand, null);
-                       // CommandManager.runShell(fullcommand);
-                       runApplication(config, launch, fullcommand);
+                       config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
+                                       ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
+                       
+                       if (monitor.isCanceled())
+                               throw new OperationCanceledException();
+
+                       // run application with valgrind
+                       runApplication(config, launch, fullcommand, monitor);
 
                        monitor.worked(2);
 
-                       // process = DebugPlugin.newProcess(launch, remoteShellProcess,
-                       // "valgrind");
+                       // process = DebugPlugin.newProcess(launch, remoteShellProcess, "valgrind");
 
                        // create launch summary string to distinguish this launch
                        String launchStr = createLaunchStr(config);
@@ -225,134 +211,123 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
                        // create view
                        ValgrindUIPlugin.getDefault().createView(launchStr, toolID);
 
+                       monitor.worked(1);
+
                        // pass off control to extender
-                       command = new ValgrindCommand(new File(
-                                       ValgrindLaunchPlugin.RESULT_DIR));
-                       dynamicDelegate.launch(command, config, launch,
-                                       new SubProgressMonitor(monitor, 15));
+                       command = new ValgrindCommand(new File(ValgrindLaunchPlugin.RESULT_DIR));
+                       dynamicDelegate.launch(command, config, launch, new SubProgressMonitor(monitor, 15));
 
+                       monitor.worked(1);
+                       
                        // refresh view
                        ValgrindUIPlugin.getDefault().refreshView();
 
+                       monitor.worked(2);
+
                        Display.getDefault().syncExec(new Runnable() {
                                public void run() {
                                        try {
-                                               PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-                                                               .getActivePage()
+                                               PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                                                                .showView(ValgrindUIPlugin.VIEW_ID);
                                        } catch (PartInitException e) {
                                                e.printStackTrace();
                                        }
                                }
                        });
-
+               } catch (ValgrindCanceledException e) {
+                       // do nothing
+               } catch (OperationCanceledException e) {
+                       newCoreException("Operation canceled by user.", null);
                } catch (CoreException e) {
                        throw e;
                } catch (Exception e) {
                        newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
                } finally {
-                       if (monitor.isCanceled()) {
-                               throw new OperationCanceledException();
-                       } else {
-                               monitor.done();
-                       }
+                       monitor.done();
                }
        }
 
        private void runApplication(ILaunchConfiguration config, ILaunch launch,
-                       String command) {
-               SdbShellProcess oprofileProc = CommandManager.runApplication(command);
+                       String command, IProgressMonitor monitor) throws ValgrindCanceledException
+       {
+               SdbShellProcess valgrindProc = CommandManager.runApplication(command);
                IPath exeFile = null;
                try {
                        exeFile = CDebugUtils.verifyProgramPath(config);
-                       ValgrindDebugPlugin.newProcess(launch, oprofileProc, exeFile
-                                       .toFile().getName());
-                       BufferedReader br = new BufferedReader(new InputStreamReader(
-                                       oprofileProc.getInputStream()));
-                       while (null != br.readLine()) {
+                       IProcess vproc = ValgrindDebugPlugin.newProcess(launch, valgrindProc, exeFile.toFile().getName());
+//                     BufferedReader br = new BufferedReader(new InputStreamReader(valgrindProc.getInputStream()));
+                       
+                       while (true)
+                       {
+                               if (monitor.isCanceled())
+                               {
+                                       valgrindProc.destroy();
+                                       
+                                       Display.getDefault().syncExec(new Runnable() {
+                                               public void run() {
+                                                       IWorkbenchWindow wbench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                                                       MessageBox confirm = new MessageBox(wbench.getShell(), SWT.ICON_WARNING | SWT.OK);
+                                                       confirm.setMessage(Messages.getString("ValgrindLaunchPlugin.Confirm_cancel"));
+                                                       confirm.open();
+                                               }
+                                       });
+                                       
+                                       throw new ValgrindCanceledException();
+                               }
+                               else if(vproc.isTerminated())
+                               {
+                                       monitor.worked(2);
+                                       break;
+                               }
+                               
+                               Thread.sleep(250);
                        }
                } catch (CoreException e) {
-                       // TODO Auto-generated catch block
                        e.printStackTrace();
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
+               } catch (InterruptedException e) {
                        e.printStackTrace();
                }
-
        }
 
-       private String[] getValgrindArgumentsArray(ILaunchConfiguration config)
-                       throws IOException, CoreException {
+       private String[] getValgrindArgumentsArray(ILaunchConfiguration config) throws IOException, CoreException
+       {
                ArrayList<String> opts = new ArrayList<String>();
-               opts.add(ValgrindCommand.OPT_TOOL + EQUALS
-                               + ValgrindLaunchPlugin.getDefault().getToolName(toolID));
-
-               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS +
-               // ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
-               opts.add(ValgrindCommand.OPT_XMLFILE + EQUALS
-                               + ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
-               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS + "/home" +
-               // File.separator + LOG_FILE);
-
-               opts.add(ValgrindCommand.OPT_TRACECHILD
-                               + EQUALS
-                               + (config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD,
-                                               false) ? YES : NO));
-               opts.add(ValgrindCommand.OPT_CHILDSILENT + EQUALS + YES);// (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT,
-                                                                                                                                       // false) ?
-                                                                                                                                       // YES :
-                                                                                                                                       // NO));
+               opts.add(ValgrindCommand.OPT_TOOL + EQUALS + ValgrindLaunchPlugin.getDefault().getToolName(toolID));
+
+               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS + ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
+               opts.add(ValgrindCommand.OPT_XMLFILE + EQUALS + ValgrindLaunchPlugin.RESULT_DIR + LOG_FILE);
+               // opts.add(ValgrindCommand.OPT_LOGFILE + EQUALS + "/home" + File.separator + LOG_FILE);
+
+               opts.add(ValgrindCommand.OPT_TRACECHILD + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_CHILDSILENT + EQUALS + YES);
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_CHILDSILENT, false) ? YES : NO));
+               
                // opts.add(ValgrindCommand.OPT_TRACKFDS + EQUALS +
-               // (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS,
-               // false) ? YES : NO));
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TRACKFDS, false) ? YES : NO));
                // opts.add(ValgrindCommand.OPT_TIMESTAMP + EQUALS +
-               // (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP,
-               // false) ? YES : NO));
-               opts.add(ValgrindCommand.OPT_FREERES
-                               + EQUALS
-                               + (config
-                                               .getAttribute(
-                                                               LaunchConfigurationConstants.ATTR_GENERAL_FREERES,
-                                                               true) ? YES : NO));
-
-               opts.add(ValgrindCommand.OPT_DEMANGLE
-                               + EQUALS
-                               + (config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE,
-                                               true) ? YES : NO));
-               opts.add(ValgrindCommand.OPT_NUMCALLERS
-                               + EQUALS
-                               + config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS,
-                                               12));
-               opts.add(ValgrindCommand.OPT_ERRLIMIT
-                               + EQUALS
-                               + (config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT,
-                                               true) ? YES : NO));
-               opts.add(ValgrindCommand.OPT_BELOWMAIN
-                               + EQUALS
-                               + (config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN,
-                                               false) ? YES : NO));
-               opts.add(ValgrindCommand.OPT_MAXFRAME
-                               + EQUALS
-                               + config.getAttribute(
-                                               LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME,
-                                               2000000));
-
-               String strpath = config.getAttribute(
-                               LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE,
-                               EMPTY_STRING);
+                       //  (config.getAttribute(ValgrindLaunchPlugin.ATTR_GENERAL_TIMESTAMP, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_FREERES + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_FREERES, true) ? YES : NO));
+
+               opts.add(ValgrindCommand.OPT_DEMANGLE + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE, true) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_NUMCALLERS + EQUALS +
+                               config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS, 12));
+               opts.add(ValgrindCommand.OPT_ERRLIMIT + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT, true) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_BELOWMAIN + EQUALS +
+                               (config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN, false) ? YES : NO));
+               opts.add(ValgrindCommand.OPT_MAXFRAME + EQUALS +
+                               config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME, 2000000));
+
+               String strpath = config.getAttribute(LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILE, EMPTY_STRING);
                if (!strpath.equals(EMPTY_STRING)) {
-                       File suppfile = ValgrindLaunchPlugin.getDefault().parseWSPath(
-                                       strpath);
+                       File suppfile = ValgrindLaunchPlugin.getDefault().parseWSPath(strpath);
                        if (suppfile != null) {
                                String escapedPath = null;
                                try {
-                                       escapedPath = ValgrindLaunchPlugin.getDefault()
-                                                       .escapeAndQuote(suppfile.getCanonicalPath());
+                                       escapedPath = ValgrindLaunchPlugin.getDefault().escapeAndQuote(suppfile.getCanonicalPath());
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }
@@ -360,30 +335,40 @@ public class TizenValgrindLaunchDelegate extends TizenLaunchDelegate {
                        }
                }
 
-               opts.addAll(Arrays.asList(dynamicDelegate.getCommandArray(command,
-                               config)));
+               opts.addAll(Arrays.asList(dynamicDelegate.getCommandArray(command, config)));
 
                String[] ret = new String[opts.size()];
                return opts.toArray(ret);
        }
 
-       protected String getTool(ILaunchConfiguration config) throws CoreException {
+       protected String getTool(ILaunchConfiguration config) throws CoreException
+       {
                return config.getAttribute(LaunchConfigurationConstants.ATTR_TOOL,
                                ValgrindLaunchPlugin.TOOL_EXT_DEFAULT);
        }
 
-       protected String getPluginID() {
+       protected String getPluginID()
+       {
                return ValgrindLaunchPlugin.PLUGIN_ID;
        }
 
-       public String[] getProgramArgumentsArray(ILaunchConfiguration config)
-                       throws CoreException {
+       public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException
+       {
                return LaunchUtils.getProgramArgumentsArray(config);
        }
 
-       protected String createLaunchStr(ILaunchConfiguration config)
-                       throws CoreException {
-               return config.getName() + " ["
-                               + ValgrindLaunchPlugin.getDefault().getToolName(toolID) + "] ";
+       protected String createLaunchStr(ILaunchConfiguration config) throws CoreException
+       {
+               return config.getName() + " [" + ValgrindLaunchPlugin.getDefault().getToolName(toolID) + "] ";
+       }
+       
+       
+       class ValgrindCanceledException extends Exception
+       {
+               private static final long serialVersionUID = 1L;
+               
+               public ValgrindCanceledException() {
+                       super();
+               }
        }
 }
index 7b9477d..bb4c59c 100644 (file)
@@ -26,11 +26,54 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
 import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.IEditorPart;
 
 
 public class ValgrindLaunchShortcut extends ProfileLaunchShortcut {
        private boolean canInitialize; //bery 20090715
+       
+       public void launch(IEditorPart editor, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul"), null);
+               }
+               else if(targetResult == 1)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul") + "\n" +
+                                       Messages.getString("ValgrindOptionsTab.inemul"), null);
+               }
+               else
+               {
+                       super.launch(editor, mode);
+               }
+       }
+
+       public void launch(ISelection selection, String mode) {
+               int targetResult = ProfileLaunchPlugin.checkTarget();
+               if(targetResult == 0)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul"), null);
+               }
+               else if(targetResult == 1)
+               {
+                       ProfileLaunchShortcut.showErrorDialog(Messages.getString("ValgrindOptionsTab.cannotrun"),
+                                       Messages.getString("ValgrindOptionsTab.noemul") + "\n" +
+                                       Messages.getString("ValgrindOptionsTab.inemul"), null);
+               }
+               else
+               {
+                       super.launch(selection, mode);
+               }
+       }
+
        @Override
        protected ILaunchConfigurationType getLaunchConfigType() {
                
index 52642c7..2965a09 100644 (file)
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.debug.ui;bundle-version="3.4.2",
  org.eclipse.ui.ide;bundle-version="3.4.2",
  org.eclipse.cdt.launch;bundle-version="5.0.2",
- org.eclipse.linuxtools.valgrind.core;bundle-version="0.1.0"
+ org.eclipse.linuxtools.profiling.launch,
+ org.eclipse.linuxtools.valgrind.core
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.linuxtools.valgrind.launch
index 9dda778..6a97f08 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
 import org.eclipse.debug.ui.ILaunchConfigurationTab;
 import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchPlugin;
 import org.eclipse.linuxtools.valgrind.core.utils.LaunchConfigurationConstants;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -57,6 +58,7 @@ import org.eclipse.ui.model.WorkbenchContentProvider;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
 import org.eclipse.ui.views.navigator.ResourceComparator;
 
+
 public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
        protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
        // Start controls
@@ -110,6 +112,39 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
        };
 
        public void createControl(Composite parent) {
+               // added by Jaewon Lim at 20120904
+               int targettype = ProfileLaunchPlugin.checkTarget();
+               
+               if(targettype != 2) {
+                       Composite top = new Composite(parent, SWT.NONE);
+                       setControl(top);
+                       top.setLayout(new GridLayout());
+                       
+                       // TODO : have to change help context id (temporarily empty string)
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "");
+                                               
+                       Label impossibleLabel = new Label(top, SWT.LEFT);
+                       if(targettype == 0)
+                       {
+                               String message = Messages.getString("ValgrindOptionsTab.noemul") 
+                                               + "\n" + Messages.getString("ValgrindOptionsTab.inemul");
+                               impossibleLabel.setText(message);
+                       }
+                       else if(targettype == 1)
+                       {
+                               impossibleLabel.setText(Messages.getString("ValgrindOptionsTab.inemul"));
+                       }
+                       else
+                       {
+                               // impossible
+                       }
+                               
+                       canInitialize = false;
+                       return;
+               }
+               
+               canInitialize = true;
+               
                /**
                 * Scrollable Options tab is implemented .
                 */
@@ -130,17 +165,7 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
                // changed by greatim at 2011.06.01 for fresh ide
                // TODO : change help context id (temporarily empty string)
                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ""); //$NON-NLS-1$
-
-               // if(TargetConnectionControl.isSimulator()){
-               canInitialize = true;
-               /*
-                * }else{ String error =
-                * "The Valgrind does not support the ARM target "; String reason =
-                * "An error occurred when the real target is selected. Please check whether your target is Simulator(i686)"
-                * ; showErrorDialog(error, reason , null); //$NON-NLS-1$ canInitialize
-                * = false; // return; }
-                */
-
+               
                createVerticalSpacer(top, 1);
                createVerticalSpacer(top, 1);
 
@@ -515,7 +540,11 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
        }
 
        public void initializeFrom(ILaunchConfiguration configuration) {
-
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize) {
+                       return;
+               }
+               
                isInitializing = true;
                getControl().setRedraw(false);
                launchConfiguration = configuration;
@@ -581,9 +610,13 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
 
        @Override
        public boolean isValid(ILaunchConfiguration launchConfig) {
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       setErrorMessage(Messages.getString("ValgrindOptionsTab.noemul"));
+                       return false;
+               }
 
                setErrorMessage(null);
-
                boolean result = false;
                if (result = isGeneralValid() && dynamicTab != null) {
                        result = dynamicTab.isValid(launchConfig);
@@ -617,8 +650,12 @@ public class ValgrindOptionsTab extends AbstractLaunchConfigurationTab {
        }
 
        public void performApply(ILaunchConfigurationWorkingCopy configuration) {
-               configuration
-                               .setAttribute(LaunchConfigurationConstants.ATTR_TOOL, tool);
+               // added by Jaewon Lim at 20120904
+               if(!canInitialize || ProfileLaunchPlugin.checkTarget() == 0){
+                       return;
+               }
+
+               configuration.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, tool);
                // commented by greatim at 2011.06.01 for fresh ide
                // configuration.setAttribute(ISMLCDTLaunchConstants.ATTR_LAUNCH_MODE,
                // "valgrind" );
index 93a7952..02ca739 100644 (file)
@@ -4,6 +4,7 @@ ValgrindLaunchConfigurationDelegate.Saving_Valgrind_output=Saving Valgrind outpu
 ValgrindLaunchConfigurationDelegate.Please_ensure_Valgrind=Please ensure Valgrind is installed and in your path.
 ValgrindLaunchPlugin.Cannot_retrieve_delegate=Cannot retrieve delegate from extension
 ValgrindLaunchPlugin.Cannot_retrieve_page=Cannot retrieve page from extension
+ValgrindLaunchPlugin.Confirm_cancel=Operation canceled.\nPlease note that the profiling with valgrind usually takes long time to launch the application.
 ValgrindOptionsTab.Basic_Options=Basic Options
 ValgrindOptionsTab.Collect_Options=Collect Options:
 ValgrindOptionsTab.child_silent=child silent after fork:
@@ -31,3 +32,7 @@ ValgrindOptionsTab.Workspace=&Workspace...
 ValgrindOptionsTab.collect_data1=Memory Error and Memory Leak data
 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.cannotrun=Cannot run valgrind profiling.
+