Generate CodeCoverage and ASAN report on press of Stop button from TizenStudio.
authorK Puneetha <k.puneetha@samsung.com>
Tue, 28 Mar 2017 09:00:40 +0000 (14:30 +0530)
committerK Puneetha <k.puneetha@samsung.com>
Tue, 28 Mar 2017 10:37:39 +0000 (16:07 +0530)
Change-Id: Ia7ff3cc81a12a6d068f19680f44d314b59779e37
Signed-off-by: K Puneetha <k.puneetha@samsung.com>
org.eclipse.linuxtools.asan/src/org/eclipse/linuxtools/asan/AsanUtil.java
org.eclipse.linuxtools.asan/src/org/eclipse/linuxtools/asan/LaunchDelegate.java
org.eclipse.linuxtools.asan/src/org/eclipse/linuxtools/asan/ProcessMonitor.java [deleted file]
org.tizen.profiler.codecoverage/src/org/tizen/profiler/codecoverage/CoverageUtil.java
org.tizen.profiler.codecoverage/src/org/tizen/profiler/codecoverage/LaunchDelegate.java

index a86dd18..87e4650 100644 (file)
@@ -30,14 +30,6 @@ import org.tizen.sdblib.exception.TimeoutException;
 
 public class AsanUtil {
 
-    public static boolean isExecuting(String execName) {
-        String cmd = "ps -ef | grep -e \"bin/" + execName + " \" | grep -v grep";
-        String[] res = AsanUtil.runCommandReturningResult(cmd);
-        if (res != null)
-            return true;
-        return false;
-    }
-
     public static String[] runCommandReturningResult(String command) {
         IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
         CommonReceiver commonReceiver = new CommonReceiver();
index d3158df..c9fe363 100644 (file)
@@ -418,39 +418,12 @@ public class LaunchDelegate extends TizenLaunchDelegate {
             CoreException {
 
         Process Proc = CommandManager.runApplication(command);
-        Thread thread = null;
-        ProcessMonitor runnable = null;
+
         if (Proc == null) {
             newCoreException("The profiling failed because the application was terminated abnormally",
                              null);
         }
-        try {
-            runnable = new ProcessMonitor(monitor, execName);
-            thread = new Thread(runnable);
-            thread.start();
-            Proc.waitFor();
-
-            boolean executing = false;
-            ProcessMonitor.resetHasExited();
-            while (!executing && !monitor.isCanceled() && !ProcessMonitor.hasExited()) {
-                executing = AsanUtil.isExecuting(execName);
-            }
-            while (executing && !ProcessMonitor.hasExited()) {
-                executing = AsanUtil.isExecuting(execName);
-            }
-
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-
-        if (thread != null && runnable != null) {
-            runnable.terminate();
-            try {
-                thread.join();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
+        while (!monitor.isCanceled() && !reportGenerated());
 
         String path = project.getLocation().toOSString();
         IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
@@ -464,7 +437,17 @@ public class LaunchDelegate extends TizenLaunchDelegate {
         viewInit.init(Report);
 
     }
-
+    
+    private boolean reportGenerated() {
+        String cmd = "ls -l /tmp/reportASAN.txt";
+        String[] res = AsanUtil.runCommandReturningResult(cmd);
+        if (res == null || res.length == 0)
+            return false;
+        if (res[0].contains("No such file or directory"))
+            return false;
+        return true;
+    }
+    
     public String expandEnvVariables(String inStr) {
         inStr = inStr.replaceAll("\\{", "\\(").replaceAll("\\}", "\\)");
         IConfiguration config = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
diff --git a/org.eclipse.linuxtools.asan/src/org/eclipse/linuxtools/asan/ProcessMonitor.java b/org.eclipse.linuxtools.asan/src/org/eclipse/linuxtools/asan/ProcessMonitor.java
deleted file mode 100644 (file)
index 056af6e..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *  Address Sanitizer LaunchDelegate Class
- *
- * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Karthik Bhat <kv.bhat@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:
- * - SRIB
- *
- */
-
-
-package org.eclipse.linuxtools.asan;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-public class ProcessMonitor implements Runnable {
-    private volatile boolean running = true;
-    private IProgressMonitor monitor;
-    private String execName;
-    private static boolean hasExited = false;
-
-    ProcessMonitor(IProgressMonitor monitor, String execName) {
-        this.monitor = monitor;
-        this.execName = execName;
-    }
-
-    public void terminate() {
-        running = false;
-    }
-
-    private boolean reportGenerated() {
-        String cmd = "ls -l /tmp/reportASAN.txt";
-        String[] res = AsanUtil.runCommandReturningResult(cmd);
-        if (res == null || res.length == 0)
-            return false;
-        if (res[0].contains("No such file or directory"))
-            return false;
-        return true;
-    }
-
-    public static void resetHasExited(){
-        hasExited = false;
-    }
-    
-    public static boolean hasExited() {
-        return hasExited;
-    }
-
-    @Override
-    public void run() {
-        while (running) {
-            if (monitor.isCanceled() || reportGenerated()) {
-                hasExited = true;
-                try {
-                    Thread.sleep(500);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-    }
-
-}
index 5f208da..2e42c82 100644 (file)
@@ -30,20 +30,11 @@ import org.tizen.sdblib.exception.TimeoutException;
 
 public class CoverageUtil {
 
-    public static boolean isExecuting(String execName) {
-        String cmd = "ps -ef | grep -e \"bin/" + execName + " \" | grep -v grep";
-        String[] res = CoverageUtil.runCommandReturningResult(cmd);
-        if (res != null)
-            return true;
-        return false;
-    }
-
     public static String[] runCommandReturningResult(String command) {
         IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
         CommonReceiver commonReceiver = new CommonReceiver();
         String[] result = null;
         try {
-            device.becomeSuperUser(true);
             device.executeShellCommand(command, commonReceiver);
             result = commonReceiver.getOutput();
         } catch (TimeoutException e) {
index 81061e9..2824b64 100644 (file)
@@ -485,6 +485,7 @@ public class LaunchDelegate extends TizenLaunchDelegate {
             String fullcommand = "";
             String appId = null;
             appId = ProjectUtil.getAppId(project);
+            String pkgID = ProjectUtil.getXmlStore(project).getPkgId();
             String exeName = ProjectUtil.getExecutableName(config);
             if (appId == null) {
                 newCoreException("The profiling failed because the application was terminated abnormally",
@@ -495,7 +496,7 @@ public class LaunchDelegate extends TizenLaunchDelegate {
                                 ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
             if (monitor.isCanceled())
                 throw new OperationCanceledException();
-            runApplication(config, launch, fullcommand, exeName, monitor, launchConsole);
+            runApplication(config, launch, fullcommand, exeName, monitor, launchConsole, pkgID);
             monitor.worked(2);
         } catch (CoverageCanceledException e) {
             e.printStackTrace();
@@ -524,23 +525,17 @@ public class LaunchDelegate extends TizenLaunchDelegate {
 
     private void runApplication(ILaunchConfiguration config, ILaunch launch, String command,
                                 final String exeName, final IProgressMonitor monitor,
-                                ConsoleManager launchConsole) throws CoverageCanceledException,
-            CoreException {
+                                ConsoleManager launchConsole, String pkgId)
+            throws CoverageCanceledException, CoreException {
         Process Proc = CommandManager.runApplication(command);
         if (Proc == null) {
             newCoreException("The profiling failed because the application was terminated abnormally",
                              null);
         }
 
-        boolean executing = false;
-        while (!executing && !monitor.isCanceled()) {
-            executing = CoverageUtil.isExecuting(exeName);
-        }
-        while (executing && !monitor.isCanceled()) {
-            executing = CoverageUtil.isExecuting(exeName);
-        }
-
-
+        while (!monitor.isCanceled());
+        String uninstallCommand = "pkgcmd -un "+ pkgId;
+        CoverageUtil.runCommandReturningResult(uninstallCommand);
     }
 
     public String expandEnvVariables(String inStr) {