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();
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();
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();
+++ /dev/null
-/*
- * 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();
- }
- }
- }
-
- }
-
-}
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) {
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",
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();
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) {