Platform Support: support Windows, Mac OS 31/26631/1
authorwoojin <woojin2.jung@samsung.com>
Tue, 26 Aug 2014 21:23:08 +0000 (06:23 +0900)
committerwoojin <woojin2.jung@samsung.com>
Tue, 26 Aug 2014 21:23:08 +0000 (06:23 +0900)
1. platform project support (handling debug info/source rpm package) for Windows, Mac
2. md5sum utility for Windows, Mac
3. default location for FileExplorer of debuginfo file : user home directory of each OS
4. other code modification considering multi OS

Change-Id: I8fb01db558f3d58d0993fcb5b89ed22284ab3d4f
Signed-off-by: woojin <woojin2.jung@samsung.com>
28 files changed:
org.tizen.dynamicanalyzer.common/src/org/tizen/dynamicanalyzer/util/CommonUtil.java
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/MacOSWindowActivator [changed mode: 0644->0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/Shortcut.vbs [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/cpio.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/dd.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/debuginfo.bat [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/debuginfo.sh
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/gzip.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libiconv2.dll [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libintl3.dll [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/macoswindowactivator.sh [changed mode: 0644->0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/md5sum.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/od.exe [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.bat [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.sh [new file with mode: 0755]
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/InputRow.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/configuration/BinarySettingsPage.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/RpmUtil.java
package/build.linux

index f7dfc58..3897876 100644 (file)
@@ -13,6 +13,7 @@ public class CommonUtil {
        private static final String LINUX = "linux"; //$NON-NLS-1$
        private static final String MAC = "mac"; //$NON-NLS-1$
        private static final String WIN = "win"; //$NON-NLS-1$
+       private static final String USER_HOME = "user.home"; //$NON-NLS-1$
        
        private static String pid = null;
 
@@ -80,6 +81,10 @@ public class CommonUtil {
        private static String getOS() {
                return System.getProperty(OS_KEY).toLowerCase();
        }
+       
+       public static String getHomeDirectory() {
+               return System.getProperty(USER_HOME);
+       }
 
        public static String getCurrentPid() {
                if (pid == null) {
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/Shortcut.vbs b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/Shortcut.vbs
new file mode 100755 (executable)
index 0000000..ba0afaa
--- /dev/null
@@ -0,0 +1,4 @@
+set WshShell=WScript.CreateObject("WScript.Shell")\r
+set lnk = WshShell.CreateShortcut(WScript.Arguments.item(0))\r
+'WScript.Echo lnk.TargetPath\r
+WScript.Echo lnk.Description
\ No newline at end of file
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/cpio.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/cpio.exe
new file mode 100755 (executable)
index 0000000..8b9b30d
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/cpio.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/dd.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/dd.exe
new file mode 100755 (executable)
index 0000000..a998333
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/dd.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/debuginfo.bat b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/debuginfo.bat
new file mode 100755 (executable)
index 0000000..c46ee35
--- /dev/null
@@ -0,0 +1,43 @@
+@echo off\r
+set base_dir=%~dp0\r
+\r
+if "%1"=="-f" (\r
+shift\r
+goto :find_file\r
+) else (\r
+if "%1"=="-d" (\r
+shift\r
+goto :extract_pkg\r
+) else (\r
+if "%1"=="-r" (\r
+shift\r
+goto :extract_2pkgs\r
+) else (\r
+echo "unknown option!"\r
+exit /b 1\r
+)\r
+)\r
+)\r
+goto :eof\r
+\r
+\r
+:find_file\r
+cd %1\r
+%base_dir%\find . -name %2\r
+exit /b\r
+\r
+:extract_pkg\r
+echo %1\r
+echo %2\r
+cd %1\r
+%base_dir%\rpm2cpio %2\r
+exit /b\r
+\r
+:extract_2pkgs\r
+echo %1\r
+echo %2\r
+echo %3\r
+cd %1\r
+call %base_dir%\rpm2cpio %2\r
+call %base_dir%\rpm2cpio %3\r
+exit /b\r
index 8a76a80..f0e8dd2 100755 (executable)
@@ -1,10 +1,14 @@
 #!/bin/bash
+BASE_DIR=$(dirname $0)
 FIND=/usr/bin/find
-RPM_COMMAND=/usr/bin/rpm2cpio
+RPM_COMMAND_UBUNTU=/usr/bin/rpm2cpio
+RPM_COMMAND_MAC=$BASE_DIR/rpm2cpio.sh
 
 print_usage()
 {
-       echo "Usage: debuginfo [options] [arguments]"
+       echo "Usage: debuginfo -u|-m [options] [arguments]"
+       echo "-u                        ubuntu command"
+       echo "-m                        macos command"
        echo "Options:"
        echo "-r                        extract two rpm package"
        echo "-d                        extract one rpm package"
@@ -17,26 +21,73 @@ find_file()
        find . -name $2
 }
 
-extract()
+extract_2pkgs()
 {
        echo $1
        echo $2
        echo $3
        cd $1
-       rpm2cpio $2 | cpio -imd
-       rpm2cpio $3 | cpio -imd
+
+       case "$OS" in
+               ubuntu)
+                       $RPM_COMMAND_UBUNTU $2 | cpio -imd
+                       $RPM_COMMAND_UBUNTU $3 | cpio -imd
+                       ;;
+               mac)
+                       $RPM_COMMAND_MAC $2 | cpio -imd
+                       $RPM_COMMAND_MAC $3 | cpio -imd                 
+                       ;;
+               *)
+                       echo "unknown OS"
+                       print_usage
+                       exit 1
+                       ;;
+       esac
 }
 
-extract2()
+extract_pkg()
 {
        echo $1
        echo $2
        cd $1
-       rpm2cpio $2 | cpio -imd
+
+       case "$OS" in
+               ubuntu)
+                       $RPM_COMMAND_UBUNTU $2 | cpio -imd
+                       ;;
+               mac)
+                       $RPM_COMMAND_MAC $2 | cpio -imd
+                       ;;
+               *)
+                       echo "unknown OS"
+                       print_usage
+                       exit 1
+                       ;;
+       esac
 }
 
 if [[ -n $1 ]]; then
        case "$1" in
+               -u)
+                       OS=ubuntu
+                       shift
+                       ;;
+               -m)
+                       OS=mac
+                       shift
+                       ;;
+               *)
+                       echo "must specify host OS"
+                       print_usage
+                       exit 1
+                       ;;
+       esac
+else
+       print_usage
+fi
+
+if [[ -n $1 ]]; then
+       case "$1" in
                -f)
                        if [[ "$#" -ne 3 ]]; then
                                echo "find needs two arguments!"
@@ -51,7 +102,7 @@ if [[ -n $1 ]]; then
                                exit 1
                        fi
                        shift
-                       extract $@
+                       extract_2pkgs $@
                        ;;
                -d)
                        if [[ "$#" -ne 3 ]]; then
@@ -59,7 +110,7 @@ if [[ -n $1 ]]; then
                                exit 1
                        fi
                        shift
-                       extract2 $@
+                       extract_pkg $@
                        ;;
                *)
                        echo "unknown option!"
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.exe
new file mode 100755 (executable)
index 0000000..85192fb
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/gzip.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/gzip.exe
new file mode 100755 (executable)
index 0000000..f189a73
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/gzip.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libiconv2.dll b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libiconv2.dll
new file mode 100755 (executable)
index 0000000..747073f
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libiconv2.dll differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libintl3.dll b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libintl3.dll
new file mode 100755 (executable)
index 0000000..4f309be
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/libintl3.dll differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/md5sum.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/md5sum.exe
new file mode 100755 (executable)
index 0000000..4ae9f74
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/md5sum.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/od.exe b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/od.exe
new file mode 100755 (executable)
index 0000000..65395d8
Binary files /dev/null and b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/od.exe differ
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.bat b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.bat
new file mode 100755 (executable)
index 0000000..2bfce0e
--- /dev/null
@@ -0,0 +1,62 @@
+@echo off\r
+set base_dir=%~dp0\r
+\r
+if not '%1'=='' (\r
+if exist %1 goto args_ok\r
+)\r
+echo "no package supplied"\r
+exit /b 1\r
+\r
+:args_ok\r
+set pkg=%1\r
+\r
+setlocal enabledelayedexpansion\r
+set count=1\r
+set leadsize=96\r
+set /a o=%leadsize%+8\r
+for /f "tokens=2-9" %%a in ('%base_dir%\od -j %o% -N 8 -t u1 %pkg%') do (\r
+if !count!==2 goto endod\r
+set var1=%%a\r
+set var2=%%b\r
+set var3=%%c\r
+set var4=%%d\r
+set var5=%%e\r
+set var6=%%f\r
+set var7=%%g\r
+set var8=%%h\r
+set /a count=!count!+1\r
+)\r
+:endod\r
+\r
+set /a il=256 * ( 256 * ( 256 * %var1% + %var2% ) + %var3% ) + %var4%\r
+set /a dl=256 * ( 256 * ( 256 * %var5% + %var6% ) + %var7% ) + %var8%\r
+\r
+endlocal & set o=%o% & set il=%il% & set dl=%dl%\r
+\r
+set /a sigsize=8 + 16 * %il% + %dl%\r
+set /a o=%o% + %sigsize% + ( 8 - ( %sigsize% %% 8 ) ) %% 8 + 8\r
+setlocal enabledelayedexpansion\r
+set count=1\r
+for /f "tokens=2-9" %%a in ('%base_dir%\od -j %o% -N 8 -t u1 %pkg%') do (\r
+if !count!==2 goto end2od\r
+set var1=%%a\r
+set var2=%%b\r
+set var3=%%c\r
+set var4=%%d\r
+set var5=%%e\r
+set var6=%%f\r
+set var7=%%g\r
+set var8=%%h\r
+set /a count=!count!+1\r
+)\r
+:end2od\r
+\r
+set /a il=256 * ( 256 * ( 256 * %var1% + %var2% ) + %var3% ) + %var4%\r
+set /a dl=256 * ( 256 * ( 256 * %var5% + %var6% ) + %var7% ) + %var8%\r
+\r
+endlocal & set il=%il% & set dl=%dl%\r
+\r
+set /a hdrsize=8 + 16 * %il% + %dl%\r
+set /a o=%o% + %hdrsize%\r
+\r
+%base_dir%\dd if=%pkg% ibs=%o% skip=1 2>nul  | %base_dir%\gzip -d | %base_dir%\cpio -i --make-directories --preserve-modification-time 2>nul\r
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.sh b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm2cpio.sh
new file mode 100755 (executable)
index 0000000..6248b7b
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+pkg=$1
+if [ "$pkg" = "" -o ! -e "$pkg" ]; then
+echo "no package supplied" 1>&2
+exit 1
+fi
+
+leadsize=96
+o=`expr $leadsize + 8`
+set `od -j $o -N 8 -t u1 $pkg`
+il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
+dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
+
+sigsize=`expr 8 + 16 \* $il + $dl`
+o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
+set `od -j $o -N 8 -t u1 $pkg`
+il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
+dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
+
+hdrsize=`expr 8 + 16 \* $il + $dl`
+o=`expr $o + $hdrsize`
+
+dd if=$pkg ibs=$o skip=1 2>/dev/null | gunzip
index 222639a..a1954aa 100644 (file)
@@ -41,6 +41,10 @@ public class PathConstants {
        public static final String WINDOW_ACTIVATOR_WINDOWS = "windowactivator.bat";//$NON-NLS-1$
        public static final String WINDOW_ACTIVATOR_MACOS = "macoswindowactivator.sh";//$NON-NLS-1$
 
+       // debug info script
+       public static final String DEBUGINFO_LINUX_MAC = "debuginfo.sh";//$NON-NLS-1$
+       public static final String DEBUGINFO_WINDOWS = "debuginfo.bat";//$NON-NLS-1$    
+       
        // paths
        // DA_REMOTE_PROBE_PATH : to drop sample log from probe library [function profiling]
        public static final String DA_REMOTE_PROBE_PATH = "/usr/lib/da_probe"; //$NON-NLS-1$
index 2518416..387e87d 100755 (executable)
@@ -31,6 +31,7 @@ import java.io.File;
 import java.io.FilenameFilter;
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
+import org.tizen.dynamicanalyzer.util.Logger;
 
 // All paths of PathManager should not be ended with File.separater
 public class PathManager {
@@ -263,4 +264,20 @@ public class PathManager {
                return returnstr + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME  
                                + File.separator + PathConstants.TEST_FOLDER_NAME;  
        }
+       
+       public static String getDebugInfoScript() {
+               String path = null;
+               
+               if (CommonUtil.isLinux() || CommonUtil.isMac()) {
+                       path = DA_TOOL_FOLDER_PATH + File.separator
+                       + PathConstants.DEBUGINFO_LINUX_MAC;
+               } else if (CommonUtil.isWin()) {
+                       path = DA_TOOL_FOLDER_PATH + File.separator
+                       + PathConstants.DEBUGINFO_WINDOWS;
+               } else { // should never be here
+                       Logger.error("Unknown host OS!\n");                     
+               }
+               
+               return path;
+       }
 }
index 156e653..9f6a0bc 100755 (executable)
@@ -52,5 +52,6 @@ public class AnalyzerShellCommands {
        public static final String CMD_CAT_PORT_FILE = "cat /tmp/port.da"; //$NON-NLS-1$
 
        public static final String CMD_DA_MD_5_SUM = "da md5sum "; //$NON-NLS-1$
-       public static final String CMD_MD_5_SUM = "/usr/bin/md5sum"; //$NON-NLS-1$
+       public static final String CMD_LINUX_MD_5_SUM = "/usr/bin/md5sum"; //$NON-NLS-1$
+       public static final String CMD_MAC_MD_5_SUM = "/sbin/md5"; //$NON-NLS-1$
 }
index fb4fe98..3372720 100644 (file)
@@ -479,7 +479,8 @@ public class TableTooltipListener implements Listener {
        }
 
        private String getSourceFilePath(String sourcePath) {
-               int index = sourcePath.lastIndexOf("src/");
+               String separator = "src" + File.separator;
+               int index = sourcePath.lastIndexOf(separator);
                String filePath = sourcePath.substring(index + 4, sourcePath.length());
                return filePath;
        }
index faf3f65..fa26a64 100644 (file)
@@ -46,6 +46,7 @@ import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.model.AddrSymbolPair;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+import org.tizen.dynamicanalyzer.utils.RpmUtil;
 import org.tizen.sdblib.receiver.MultiLineReceiver;
 
 public class AppInfo {
@@ -242,10 +243,9 @@ public class AppInfo {
 
                // extract rpm file
                if (null != copiedRpmPath) {
-                       String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh";
+                       String toolPath = PathManager.getDebugInfoScript();
                        String[] command = null;
-                       command = new String[] { toolPath, "-d", rpmPath, debugRpmPath };
+                       command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-d", rpmPath, debugRpmPath };
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(command);
@@ -280,9 +280,9 @@ public class AppInfo {
 
                // check debuginfo file path
                if (debugInfoRpmFile.getName().contains(DEBUGPKGTYPE_DEBUGINFO)) {
-                       String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
-                                       + getExecFileName() + ".debug";
+                       String debugCmd = PathManager.getDebugInfoScript()      + " "
+                                       + RpmUtil.getDebugInfoOption() + " -f " + rpmPath 
+                                       + CommonConstants.SPACE + getExecFileName() + ".debug";
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(debugCmd);
@@ -309,9 +309,9 @@ public class AppInfo {
 
                        // future extension for applications with normal debug package
                } else if (debugInfoRpmFile.getName().contains(DEBUGPKGTYPE_DEBUG)) {
-                       String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
-                                       + getExecFileName();
+                       String debugCmd = PathManager.getDebugInfoScript() + " "
+                                       + RpmUtil.getDebugInfoOption() + " -f " 
+                                       + rpmPath + CommonConstants.SPACE + getExecFileName();
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(debugCmd);
@@ -385,10 +385,9 @@ public class AppInfo {
 
                // extract rpm file
                if (null != copiedRpmPath) {
-                       String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh";
+                       String toolPath = PathManager.getDebugInfoScript();
                        String[] command = null;
-                       command = new String[] { toolPath, "-d", rpmPath, sourceRpmPath };
+                       command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-d", rpmPath, sourceRpmPath };
 
                        try {
                                Runtime rt = Runtime.getRuntime();
@@ -423,9 +422,9 @@ public class AppInfo {
                }
 
                // check debugsource file path
-               String sourceCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                               + "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE + projectName
-                               + CommonConstants.ASTERISK;
+               String sourceCmd = PathManager.getDebugInfoScript() + " "
+                               + RpmUtil.getDebugInfoOption() + " -f " 
+                               + rpmPath + CommonConstants.SPACE + projectName + CommonConstants.ASTERISK;
                try {
                        Runtime rt = Runtime.getRuntime();
                        Process process = rt.exec(sourceCmd);
index 4d996f2..dac4001 100755 (executable)
@@ -52,6 +52,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
@@ -1116,69 +1118,97 @@ public class Communicator30 extends BaseCommunicator {
                                return;
                        }
 
-                       String[] splitLocalBinaryPath = localBinaryPath.split(CommonConstants.SLASH);
+                       String[] splitLocalBinaryPath = localBinaryPath.split(Pattern.quote(File.separator));
 
-                       if (CommonUtil.isLinux()) {
-                               // check local binary path validation
-                               // host has no binary file - pull binary file from target
-                               if (splitLocalBinaryPath.length < 3
-                                               || !(new File(localBinaryPath)).exists()) {
-                                       localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator
-                                                       + getFileName(targetPath);
-                                       result = pullTheFile(targetPath, localBinaryPath);
-                                       if (result.isSuccess()) {
-                                               binInfo.setTempBinaryPath(localBinaryPath);
-                                       }
-                               } else {
-                                       // if local binary exist already, then check for md5sum
-                                       String localHashCode = null;
-                                       try {
-                                               Runtime rt = Runtime.getRuntime();
-                                               Process process = rt.exec(new String[] {
-                                                               AnalyzerShellCommands.CMD_MD_5_SUM, localBinaryPath });
-                                               process.waitFor();
-                                               BufferedReader reader = new BufferedReader(new InputStreamReader(
-                                                               process.getInputStream()));
-                                               BufferedReader error = new BufferedReader(new InputStreamReader(
-                                                               process.getErrorStream()));
-                                               String line = reader.readLine();
-                                               String errorStr = error.readLine();
-                                               if (null == line) {
-                                                       Logger.debug("host md5sum get failed : " + errorStr);
-                                                       result = HostResult.ERR_BIN_INFO_GET_FAIL;
-                                               } else {
-                                                       String[] splitResult = line.trim().split(
-                                                                       CommonConstants.SPACE);
-                                                       localHashCode = new String(splitResult[0]);
-                                               }
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                               result = HostResult.ERR_BIN_INFO_GET_FAIL;
-                                       } catch (InterruptedException e) {
-                                               e.printStackTrace();
+                       // check local binary path validation
+                       // host has no binary file - pull binary file from target
+                       if (splitLocalBinaryPath.length < 3
+                                       || !(new File(localBinaryPath)).exists()) {
+                               localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator
+                                               + getFileName(targetPath);
+                               result = pullTheFile(targetPath, localBinaryPath);
+                               if (result.isSuccess()) {
+                                       binInfo.setTempBinaryPath(localBinaryPath);
+                               }
+                       } else {
+                               // if local binary exist already, then check for md5sum
+                               String localHashCode = null;
+                               try {
+                                       Runtime rt = Runtime.getRuntime();
+                                       Process process = rt.exec(new String[] {
+                                                       getMd5Command(), localBinaryPath });
+                                       process.waitFor();
+                                       BufferedReader reader = new BufferedReader(new InputStreamReader(
+                                                       process.getInputStream()));
+                                       BufferedReader error = new BufferedReader(new InputStreamReader(
+                                                       process.getErrorStream()));
+                                       String line = reader.readLine();
+                                       String errorStr = error.readLine();
+                                       if (null == line) {
+                                               Logger.debug("host md5sum get failed : " + errorStr);
                                                result = HostResult.ERR_BIN_INFO_GET_FAIL;
+                                       } else {
+                                               // md5sum.exe prepend "\" when target binary is not in current directory
+                                               if (CommonUtil.isWin()) {
+                                                       line = line.replace("\\", "");
+                                               }
+                                               localHashCode = parseMd5Result(line);
                                        }
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                                       result = HostResult.ERR_BIN_INFO_GET_FAIL;
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                                       result = HostResult.ERR_BIN_INFO_GET_FAIL;
+                               }
 
-                                       if (localHashCode == null
-                                                       || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) {
-                                               localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH
-                                                               + File.separator + getFileName(targetPath);
-                                               result = pullTheFile(targetPath, localBinaryPath);
-                                               if (result.isSuccess()) {
-                                                       binInfo.setTempBinaryPath(localBinaryPath);
-                                               }
-                                       } else {
+                               if (localHashCode == null
+                                               || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) {
+                                       localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH
+                                                       + File.separator + getFileName(targetPath);
+                                       result = pullTheFile(targetPath, localBinaryPath);
+                                       if (result.isSuccess()) {
                                                binInfo.setTempBinaryPath(localBinaryPath);
                                        }
-                               }
-                       } else { // if not linux
-                               localBinaryPath = PathManager.DA_TEMP_FOLDER_PATH + File.separator
-                                               + getFileName(targetPath);
-                               result = pullTheFile(targetPath, localBinaryPath);
-                               if (result.isSuccess()) {
+                               } else {
                                        binInfo.setTempBinaryPath(localBinaryPath);
                                }
                        }
                }
        }
+       
+       private String getMd5Command() {
+               String cmd = null;
+
+               if (CommonUtil.isLinux()) {
+                       cmd = AnalyzerShellCommands.CMD_LINUX_MD_5_SUM; 
+               } else if (CommonUtil.isMac()) {
+                       cmd = AnalyzerShellCommands.CMD_MAC_MD_5_SUM;                   
+               } else if (CommonUtil.isWin()) {
+                       cmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+                                       + "md5sum.exe";                 
+               } else { // should never be here
+                       Logger.error("Unknown host OS!\n");
+               }
+               
+               return cmd;
+       }
+       
+       private String parseMd5Result(String line) {
+               String md5value = null;
+               String[] splitResult = line.trim().split(
+                               CommonConstants.SPACE);         
+               
+               if (CommonUtil.isLinux()) {
+                       md5value = new String(splitResult[0]);
+               } else if (CommonUtil.isMac()) { // In md5's output, hash value comes last  
+                       md5value = new String(splitResult[splitResult.length - 1]);
+               } else if (CommonUtil.isWin()) {
+                       md5value = new String(splitResult[0]);                  
+               } else { // should never be here
+                       Logger.error("Unknown host OS!\n");                     
+               }
+               
+               return md5value;
+       }
 }
\ No newline at end of file
index 7bfda0c..4ff85c7 100644 (file)
@@ -34,6 +34,7 @@ import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
@@ -45,6 +46,7 @@ import org.tizen.dynamicanalyzer.ui.toolbar.ConfigureManager;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+import org.tizen.dynamicanalyzer.utils.RpmUtil;
 
 public class BinarySettingManager {
        private static BinarySettingManager instance = null;
@@ -151,14 +153,13 @@ public class BinarySettingManager {
 
                                // extract rpm file exists
                                if (null != debugRpmPath) {
-                                       String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                                       + "debuginfo.sh";
+                                       String toolPath = PathManager.getDebugInfoScript();
                                        String[] command = null;
                                        if (null != debugRpmSourcePath) {
-                                               command = new String[] { toolPath, "-r", rpmPath, debugRpmPath,
+                                               command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-r", rpmPath, debugRpmPath,
                                                                debugRpmSourcePath };
                                        } else {
-                                               command = new String[] { toolPath, "-d", rpmPath, debugRpmPath };
+                                               command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-d", rpmPath, debugRpmPath };
                                        }
                                        try {
                                                Runtime rt = Runtime.getRuntime();
@@ -173,7 +174,7 @@ public class BinarySettingManager {
                                                        if (lineCount == 1) {
                                                                Logger.debug("CHANGE DIR : " + line);
                                                        } else {
-                                                               Logger.debug("EXTRACE RPM : " + line);
+                                                               Logger.debug("EXTRACT RPM : " + line);
                                                        }
                                                }
                                                if (lineCount == 0) {
@@ -194,15 +195,15 @@ public class BinarySettingManager {
                                }
 
                                // check real debug file path
-                               String[] splitDebugPath = debugPath.split(CommonConstants.SLASH);
+                               String[] splitDebugPath = debugPath.split(Pattern.quote(File.separator));
                                String debugFileName = splitDebugPath[splitDebugPath.length - 1];
                                if (debugFileName.contains("debuginfo")) {
                                        String libPostFix = libFullName
                                                        .substring(index, libFullName.length());
                                        String libVersion = libPostFix.substring(4, libPostFix.length());
-                                       String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                                       + "debuginfo.sh -f " + rpmPath + " " + "*" + libPostFix
-                                                       + ".debug";
+                                       String debugCmd = PathManager.getDebugInfoScript() + " " 
+                                                       + RpmUtil.getDebugInfoOption() + " -f " + rpmPath 
+                                                       + " " + "*" + libPostFix + ".debug";
                                        String debugFilePath = null;
                                        try {
                                                Runtime rt = Runtime.getRuntime();
@@ -233,9 +234,9 @@ public class BinarySettingManager {
                                        // check real source file path
                                        if (null != debugRpmSourcePath && !debugRpmSourcePath.isEmpty()) {
                                                String sourceFilePath = null;
-                                               String sourceCmd = PathManager.DA_TOOL_FOLDER_PATH
-                                                               + File.separator + "debuginfo.sh -f " + rpmPath + " "
-                                                               + "*" + libVersion;
+                                               String sourceCmd = PathManager.getDebugInfoScript() + " " 
+                                                               + RpmUtil.getDebugInfoOption() + " -f " 
+                                                               + rpmPath + " " + "*" + libVersion;
                                                try {
                                                        Runtime rt = Runtime.getRuntime();
                                                        Process process = rt.exec(sourceCmd);
@@ -265,9 +266,9 @@ public class BinarySettingManager {
                                                binData.setDebugSourcePath(CommonConstants.EMPTY);
                                        }
                                } else if (debugFileName.contains("debug-")) {
-                                       String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                                       + "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
-                                                       + libFullName;
+                                       String debugCmd = PathManager.getDebugInfoScript() + " "
+                                                       + RpmUtil.getDebugInfoOption() + " -f " 
+                                                       + rpmPath + CommonConstants.SPACE + libFullName;
                                        String debugFilePath = null;
                                        try {
                                                Runtime rt = Runtime.getRuntime();
@@ -425,9 +426,8 @@ public class BinarySettingManager {
                String debugInfoToken = "*" + libFullName.substring(3, index) + "-debuginfo*.rpm";
                // String rootstrapPath = PathManager.getRootStrapsPath();
                List<String> lines = new ArrayList<String>();
-               String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                               + "debuginfo.sh";
-               String[] command = new String[] { toolPath, "-f", rootPath, debugInfoToken };
+               String toolPath = PathManager.getDebugInfoScript();
+               String[] command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-f", rootPath, debugInfoToken };
                try {
                        Runtime rt = Runtime.getRuntime();
                        Process process = rt.exec(command);
@@ -467,7 +467,7 @@ public class BinarySettingManager {
                        debugInfoToken = "*" + libFullName.substring(3, index) + "-debug-"
                                        + libVersion + "*.rpm";
 
-                       command = new String[] { toolPath, "-f", rootPath, debugInfoToken };
+                       command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-f", rootPath, debugInfoToken };
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(command);
index f8eadae..cf355c5 100644 (file)
@@ -133,14 +133,14 @@ public class DAFileExplorer extends Composite {
                                inputText.setText(current.getAbsolutePath());
                                return;
                        }
-
-                       if (!path.contains(root.getAbsolutePath())) {
-                               Logger.debug("Out of root range");
+// TODO: Are users allowed to select files outside user home directory?
+//                     if (!path.contains(root.getAbsolutePath())) {
+//                             Logger.debug("Out of root range");
                                // inputText.setBackground(ColorResources.RED);
                                // info.setText("Out of root range");
-                               inputText.setText(current.getAbsolutePath());
-                               return;
-                       }
+//                             inputText.setText(current.getAbsolutePath());
+//                             return;
+//                     }
 
                        int ret = setCurrent(path);
                        if (ret != FAIL) {
index 6f8fcd2..d9c14e9 100644 (file)
@@ -47,6 +47,7 @@ import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
 import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.swap.platform.ui.FileExplorer.FileExplorerDialog;
 import org.tizen.dynamicanalyzer.ui.toolbar.configuration.BinarySettingsPage;
+import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
 import org.tizen.dynamicanalyzer.widgets.da.base.DAText;
@@ -93,7 +94,7 @@ public class InputRow extends Composite {
                        dialog.setFilter("debug");
                        dialog.getExplorer().setRoot(
 //                                     BinarySettingManager.getInstance().getDebugRoot());
-                                       "/home/");
+                                       CommonUtil.getHomeDirectory());
                        Object result = dialog.open();
                        List<BinarySettingData> bins = new ArrayList<BinarySettingData>();
                        if (result != null) {
@@ -119,7 +120,7 @@ public class InputRow extends Composite {
                @Override
                public void handleClickEvent(DACustomButton button) {
                        FileExplorerDialog dialog = new FileExplorerDialog(getShell());
-                       dialog.getExplorer().setRoot("/home/");
+                       dialog.getExplorer().setRoot(CommonUtil.getHomeDirectory());
                        Object result = dialog.open();
                        if (result != null) {
                                @SuppressWarnings("unchecked")
index 95f3cad..36a621f 100644 (file)
@@ -164,7 +164,7 @@ public class BinarySettingsPage extends DAPageComposite {
                @Override
                public void handleClickEvent(DACustomButton button) {
                        FileExplorerDialog dialog = new FileExplorerDialog(getShell());
-                       dialog.getExplorer().setRoot("/home/");
+                       dialog.getExplorer().setRoot(CommonUtil.getHomeDirectory());
                        Object result = dialog.open();
                        if (result != null) {
                                @SuppressWarnings("unchecked")
index 3f4f6c8..d0e3e0d 100644 (file)
@@ -1,13 +1,13 @@
 package org.tizen.dynamicanalyzer.utils;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.dynamicanalyzer.common.path.PathManager;
+import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
 
 public class RpmUtil {
@@ -18,9 +18,8 @@ public class RpmUtil {
        // extract rpm file exists
        public static void extractRpm(String targetpath, String rpmpath) {
                if (null != rpmpath) {
-                       String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh";
-                       String[] command = new String[] { toolPath, "-d", targetpath, rpmpath };
+                       String toolPath = PathManager.getDebugInfoScript();
+                       String[] command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-d", targetpath, rpmpath };
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(command);
@@ -57,9 +56,8 @@ public class RpmUtil {
                List<String> ret = null;
 
                if (null != rpmpath) {
-                       String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
-                                       + "debuginfo.sh";
-                       String[] command = new String[] { toolPath, "-l", rpmpath };
+                       String toolPath = PathManager.getDebugInfoScript();
+                       String[] command = new String[] { toolPath, RpmUtil.getDebugInfoOption(), "-l", rpmpath };
                        try {
                                Runtime rt = Runtime.getRuntime();
                                Process process = rt.exec(command);
@@ -84,4 +82,20 @@ public class RpmUtil {
 
                return ret;
        }
+       
+       public static String getDebugInfoOption() {
+               String option = null;
+               
+               if (CommonUtil.isLinux()) {
+                       option = "-u";
+               } else if (CommonUtil.isMac()) {
+                       option = "-m";                  
+               } else if (CommonUtil.isWin()) {
+                       option = "";                    
+               } else { // should never be here
+                       Logger.error("Unknown host OS!\n");                     
+               }
+               
+               return option;
+       }
 }
index f1dbd5e..993cd20 100755 (executable)
@@ -310,11 +310,24 @@ packaging_bfiles()
        install_ide_path=${INSTALL_DIR}/${ide_root_path_name} bfile_dir=org.tizen.dynamicanalyzer.workbench/dynamic-analyzer
        ##install_lib_path=${INSTALL_DIR}/${ide_lib_path_name} blib_dir=org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/library
        tool_dir=tool
-       debugbinary=debuginfo.sh
 
        cp -rf ${SRCDIR}/${bfile_dir}/config ${install_ide_path}/
        mkdir -p ${install_ide_path}/${tool_dir}
-       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/${debugbinary} ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/debuginfo.sh ${install_ide_path}/${tool_dir}/
+# for macos
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/rpm2cpio.sh ${install_ide_path}/${tool_dir}/
+# for windows
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/Shortcut.vbs ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/debuginfo.bat ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/rpm2cpio.bat ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/cpio.exe ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/dd.exe ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/find.exe ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/gzip.exe ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/libiconv2.dll ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/libintl3.dll ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/md5sum.exe ${install_ide_path}/${tool_dir}/
+       cp -rf ${SRCDIR}/${bfile_dir}/${tool_dir}/od.exe ${install_ide_path}/${tool_dir}/
 ##     cp -rf ${SRCDIR}/${bfile_dir}/xml ${install_ide_path}/
 ##     cp -rf ${SRCDIR}/${blib_dir}/* ${install_lib_path}/
 }