[Title] sdblib change and bug fix
authorLee <jy.exe.lee@samsung.com>
Sun, 19 Aug 2012 09:59:16 +0000 (18:59 +0900)
committerLee <jy.exe.lee@samsung.com>
Sun, 19 Aug 2012 09:59:16 +0000 (18:59 +0900)
[Type] bug fix
[Module] Dynamic Analyzer
[Priority] major
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer/lib/sdblib.jar
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/DACommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/filePage/fileChart/FileChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/LeakDetector.java

index f4d92bd..5ab9901 100644 (file)
Binary files a/org.tizen.dynamicanalyzer/lib/sdblib.jar and b/org.tizen.dynamicanalyzer/lib/sdblib.jar differ
index 910f398..9bab9ea 100644 (file)
@@ -17,7 +17,6 @@
  * 
  */
 
-
 package org.tizen.dynamicanalyzer;
 
 import java.io.BufferedReader;
@@ -40,7 +39,6 @@ import org.tizen.dynamicanalyzer.model.AppDesktopInfo;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.threads.ReceiveCommunicator;
 import org.tizen.dynamicanalyzer.ui.views.CoolbarArea;
-
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.IShellOutputReceiver;
 import org.tizen.sdblib.MultiLineReceiver;
@@ -55,722 +53,747 @@ import org.tizen.sdblib.SyncService.ISyncProgressMonitor;
 import org.tizen.sdblib.SyncService.SyncResult;
 import org.tizen.sdblib.TimeoutException;
 
-
 public class DACommunicator {
-    private static Socket sock = null;
-    private static SmartDevelopmentBridge sdbBridge = null;
-    private static AppDesktopInfo selectedApp = null;
-    private static IDevice currentDevice = null;
-    private static BufferedWriter writer = null;
-    private static BufferedReader reader = null;
-    private static boolean isRunning = false;
-    private static List<IDevice> devs = null;
-    private static List<AppDesktopInfo> appDesktopList = null;
-
-    // for Application list
-    private static String reservedApplicationList = null;
-
-    public static List<IDevice> getDevs() {
-        if (null == devs) {
-            devs = new ArrayList<IDevice>();
-        }
-        return devs;
-    }
-
-    public static void setDevs(List<IDevice> devs) {
-        DACommunicator.devs = devs;
-    }
-
-    public static IDevice getSelectedDevice() {
-        return currentDevice;
-    }
-
-    public static void init() {
-        SmartDevelopmentBridge.init();
-        setNewBridge();
-        sock = null;
-        selectedApp = null;
-        currentDevice = null;
-        writer = null;
-        reader = null;
-        isRunning = false;
-        devs = null;
-        isArch = false;
-        appDesktopList = null;
-        pidOfDaemon = null;
-        existVersion = false;
-        correctVersion = false;
-    }
-
-    public static void setSelectedDevice(IDevice device) {
-        currentDevice = device;
-    }
-
-    public static AppDesktopInfo getSelectedApp() {
-        return selectedApp;
-    }
-
-    public static void setSelectedApp(AppDesktopInfo app) {
-        selectedApp = app;
-    }
-
-    public static Socket getSocket() {
-        return sock;
-    }
-
-    public static void setSocket(Socket socket) {
-        sock = socket;
-    }
-
-    public static SmartDevelopmentBridge getBridge() {
-        return sdbBridge;
-    }
-
-    public static void setBridge(SmartDevelopmentBridge bridge) {
-        sdbBridge = bridge;
-    }
-
-    public static void setNewBridge() {
-        String sdbPath = AnalyzerConstants.SDB_PATH;
-        if (null != AnalyzerConstants.SDB_PATH) {
-            try {
-                sdbBridge = SmartDevelopmentBridge.createBridge(sdbPath, false);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static boolean isRunning() {
-        return isRunning;
-    }
-
-    public static void setRunning(boolean run) {
-        isRunning = run;
-    }
-
-    protected static void reloadDevices() {
-        IDevice[] devices = null;
-        getDevs().clear();
-        if (null != sdbBridge) {
-            devices = sdbBridge.getDevices();
-            for (IDevice device : devices) {
-                devs.add(device);
-            }
-        }
-    }
-
-    private static boolean isArch = false;
-
-    private static MultiLineReceiver archReceiver = new MultiLineReceiver() {
-        @Override
-        public void processNewLines(String[] lines) {
-            if (lines[0].contains(AnalyzerConstants.ARM_ARCH)) {
-                isArch = true;
-            }
-        }
-    };
-
-    public static boolean isCurrentDeviceArmArch() {
-        execShellCommand(AnalyzerConstants.CMD_IS_ARM_ARCH, archReceiver);
-
-        return isArch;
-    }
-
-    protected static List<String> getDevicesNameList() {
-        List<String> deviceList = null;
-        SmartDevelopmentBridge sdbBridge = getBridge();
-        if (null != sdbBridge) {
-            List<IDevice> devicesList = getDevs();
-            deviceList = new ArrayList<String>();
-            for (IDevice device : devicesList) {
-                deviceList.add(device.getSerialNumber());
-            }
-        }
-
-        return deviceList;
-    }
-
-    private static MultiLineReceiver appListReceiver = new MultiLineReceiver() {
-        @Override
-        public void processNewLines(String[] appLines) {
-            List<String> appList = new ArrayList<String>();
-
-            if (reservedApplicationList != null) {
-                appList.add(reservedApplicationList);
-                reservedApplicationList = null;
-            }
-            for (int i = 0; i < appLines.length; i++) {
-                appList.add(appLines[i]);
-            }
-
-            appDesktopList = getAppDesktopList();
-            
-            /** do not delete!! for debug ***/
-//            for (int i = 0; i < appList.size(); i++) {
-//                System.out.println(i + "  " + appList.get(i));
-//            }
-//            System.out.println();
-            
-            int size = appList.size();
-            for (int i = 0; i < size;) {
-                if (i % 2 == 0 && i + 1 >= size) {
-                    System.out.println(" Multi line app list!!" + appList.get(i)); //$NON-NLS-1$
-                    reservedApplicationList = appList.get(i);
-                    break;
-                }
-                AppDesktopInfo desktopInfo = new AppDesktopInfo();
-                String desktopName = AnalyzerLabels.EMPTY_STRING;
-                for (int ii = 0; ii < 2; ii++) {
-                    String line = appList.get(i++);
-                    String[] splitLine = line.split(":"); //$NON-NLS-1$
-                    desktopName = splitLine[0];
-                    String[] splitName = splitLine[1].split("="); //$NON-NLS-1$
-                    String str = splitName[0];
-                    if (str.toLowerCase().equals("name")) { //$NON-NLS-1$
-                        desktopInfo.setName(new String(splitName[1]));
-                    } else if (str.toLowerCase().equals("exec")) { //$NON-NLS-1$
-                        desktopInfo.setExecPath(new String(splitName[1]));
-                    }
-                }
-                if ((null != desktopInfo.getExecPath() && !desktopInfo.getExecPath().isEmpty())
-                        && (null != desktopInfo.getName() && !desktopInfo.getName().isEmpty())) {
-                    desktopInfo.setDesktopName(new String(desktopName));
-                    if (appDesktopList.indexOf(desktopInfo) < 0) {
-                        appDesktopList.add(desktopInfo);
-                    }
-
-                }
-                // if (i == size) {
-                // break;
-                // }
-            }
-
-            /*** dont delete for debug ***/
-            // for (int i = 0; i < appDesktopList.size(); i++) {
-            // AppDesktopInfo info = appDesktopList.get(i);
-            // System.out.println("name " + info.getName() + "  path : " +
-            // info.getExecPath());
-            // }
-
-        }
-    };
-
-    public static List<AppDesktopInfo> getAppListFromTarget() {
-        getAppDesktopList().clear();
-        execShellCommand(AnalyzerConstants.CMD_APPLICATION_LIST, appListReceiver);
-
-        return appDesktopList;
-    }
-
-    private static List<AppDesktopInfo> getAppDesktopList() {
-        if (null == appDesktopList) {
-            appDesktopList = new ArrayList<AppDesktopInfo>();
-        }
-        return appDesktopList;
-    }
-
-    public static AppDesktopInfo getAppDesktopInfoByName(String name) {
-        List<AppDesktopInfo> appInfoList = getAppDesktopList();
-        int size = appInfoList.size();
-        for (int i = 0; i < size; i++) {
-            AppDesktopInfo ai = appInfoList.get(i);
-            if (ai.getName().equals(name)) {
-                return ai;
-            }
-        }
-        return null;
-    }
-
-    public static Socket createSocket(int port) {
-        try {
-            sock = new Socket(AnalyzerConstants.LOCAL_HOST, port);
-            if (null == sock) {
-                System.out.println("failed to create a socket"); //$NON-NLS-1$
-                return null;
-            }
-
-            sock.setSoTimeout(AnalyzerConstants.SOCKET_TIMEOUT);
-            sock.setReuseAddress(true);
-            sock.setTcpNoDelay(true);
-
-            reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
-            writer = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
-
-            new Thread(null, new ReceiveCommunicator(),
-                       AnalyzerConstants.COMMUNICATOR_RECEIVE_THREAD).start();
-
-        } catch (SocketTimeoutException e) {
-            System.out.println("socket timeout."); //$NON-NLS-1$
-            e.printStackTrace();
-        } catch (UnknownHostException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        return sock;
-    }
-
-    public static void closeSocket() {
-        try {
-            if (null != reader) {
-                reader.close();
-                reader = null;
-            }
-            if (null != writer) {
-                writer.close();
-                writer = null;
-            }
-            if (null != sock) {
-                sock.close();
-                sock = null;
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static BufferedReader getSockBufferedReader() {
-        return reader;
-    }
-
-    public static BufferedWriter getSockBufferedWriter() {
-        return writer;
-    }
-
-    public static void foward(int local, int remote) {
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                currentDevice.createForward(local, remote);
-                Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL);
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static void unfoward(int local, int remote) {
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                currentDevice.removeForward(local, remote);
-                Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL);
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private static String pidOfDaemon = null;
-
-    private static MultiLineReceiver pidofDaemon = new MultiLineReceiver() {
-        @Override
-        public void processNewLines(String[] lines) {
-            if (0 != lines.length && !lines[0].isEmpty()) {
-                pidOfDaemon = lines[0];
-            }
-        }
-    };
-
-    public static boolean isDaemonAlive() {
-        execShellCommand(AnalyzerConstants.CMD_PIDOF_DAEMON, pidofDaemon);
-        if (null != pidOfDaemon) {
-            return true;
-        }
-        return false;
-    }
-
-    public static void killDaemon() {
-        if (null != pidOfDaemon) {
-            System.out.println("kill daemon : " + pidOfDaemon); //$NON-NLS-1$
-            execShellCommand(AnalyzerConstants.CMD_KILL_DAEMON + AnalyzerConstants.SPACE
-                    + pidOfDaemon);
-        }
-    }
-
-    public static void execShellCommand(String command) {
-        execShellCommand(command, new NullOutputReceiver());
-    }
-
-    public static void execShellCommand(String command, IShellOutputReceiver receiver) {
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                currentDevice.executeShellCommand(command, receiver);
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (ShellCommandUnresponsiveException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static SdbShellProcess execCommand(String command) {
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                return currentDevice.executeShellCommand(command);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-        return null;
-    }
-
-    public static void sendMessage(String message) {
-        try {
-            if (null != sock) {
-                writer.write(message);
-                // writer.newLine();
-                writer.flush();
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static SyncResult push(String local, String remote) {
-        return push(local, remote, SyncService.getNullProgressMonitor());
-    }
-
-    public static SyncResult push(String local, String remote, ISyncProgressMonitor monitor) {
-        SyncResult result = null;
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                SyncService service = currentDevice.getSyncService();
-                if (null != service) {
-                    result = service.pushFile(local, remote, monitor);
-                }
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-        return result;
-    }
-
-    public static SyncResult pull(String remote, String local) {
-        return pull(remote, local, SyncService.getNullProgressMonitor());
-    }
-
-    public static SyncResult pull(String remote, String local, ISyncProgressMonitor monitor) {
-        SyncResult result = null;
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                SyncService service = currentDevice.getSyncService();
-                if (null != service) {
-                    result = service.pullFile(remote, local, monitor);
-                }
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-        return result;
-    }
-
-    public static void remove(String path) {
-        if (null != currentDevice && currentDevice.isOnline()) {
-            try {
-                currentDevice.executeShellCommand(AnalyzerConstants.CMD_REMOVE
-                        + AnalyzerConstants.SPACE + path, new NullOutputReceiver());
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (ShellCommandUnresponsiveException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static boolean isTargetEmulator() {
-        IDevice device = getSelectedDevice();
-        if (device != null) {
-            if (device.getSerialNumber().contains(AnalyzerConstants.EMULATOR)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean uploadSo() {
-        String target = AnalyzerConstants.TARGET_PATH;
-
-        if (isCurrentDeviceArmArch()) {
-            target += AnalyzerConstants.ARM_ARCH;
-        } else {
-            target += AnalyzerConstants.X86_ARCH;
-        }
-        String target_osp = target + File.separator + AnalyzerConstants.PROBE_SO_OSP_NAME;
-        target += File.separator + AnalyzerConstants.PROBE_SO_TIZEN_NAME;
-
-        SyncResult result =
-                push(target, AnalyzerConstants.DA_REMOTE_PROBE_PATH
-                        + AnalyzerConstants.PROBE_SO_TIZEN_NAME);
-        if (null == result || SyncService.RESULT_OK != result.getCode()) {
-            System.out.println("upload is failed : " + target); //$NON-NLS-1$
-            return false;
-        }
-
-        result =
-                push(target_osp, AnalyzerConstants.DA_REMOTE_PROBE_PATH
-                        + AnalyzerConstants.PROBE_SO_OSP_NAME);
-        if (null == result || SyncService.RESULT_OK != result.getCode()) {
-            System.out.println("upload is failed : " + target_osp); //$NON-NLS-1$
-            return false;
-        }
-        return true;
-    }
-
-    public static boolean uploadVersion() {
-        SyncResult result =
-                push(AnalyzerConstants.DYNAMIC_ANALYZER_INSTALL_PATH + File.separator
-                             + File.separator + AnalyzerConstants.VERSION_NAME,
-                     AnalyzerConstants.DA_REMOTE_PATH + AnalyzerConstants.VERSION_NAME);
-        if (null != result && SyncService.RESULT_OK == result.getCode()) {
-            return true;
-        }
-        System.out.println("version file upload is failed : "); //$NON-NLS-1$
-        return false;
-    }
-
-    public static boolean uploadDaemon() {
-        String target = AnalyzerConstants.TARGET_PATH;
-
-        if (DACommunicator.isCurrentDeviceArmArch()) {
-            target += AnalyzerConstants.ARM_ARCH;
-        } else {
-            target += AnalyzerConstants.X86_ARCH;
-        }
-        target += File.separator + AnalyzerConstants.DA_DAEMON_NAME;
-
-        SyncResult result = push(target, AnalyzerConstants.DA_REMOTE_DAEMON);
-        if (null != result && SyncService.RESULT_OK == result.getCode()) {
-            DACommunicator.execShellCommand(AnalyzerConstants.CMD_DAEMON_EXE_PERMISSION);
-            return true;
-        }
-        System.out.println("upload is failed : " + target); //$NON-NLS-1$
-        return false;
-    }
-
-    public static boolean uploadReadelf() {
-        String target = AnalyzerConstants.TARGET_PATH;
-
-        if (DACommunicator.isCurrentDeviceArmArch()) {
-            target += AnalyzerConstants.ARM_ARCH;
-        } else {
-            target += AnalyzerConstants.X86_ARCH;
-        }
-        target += File.separator + AnalyzerConstants.READELF_BIN;
-
-        SyncResult result =
-                push(target, AnalyzerConstants.DA_REMOTE_PATH + AnalyzerConstants.READELF_BIN);
-        if (null != result && SyncService.RESULT_OK == result.getCode()) {
-            DACommunicator.execShellCommand(AnalyzerConstants.CMD_READELF_PERMISSION);
-            return true;
-        }
-        System.out.println("upload is failed : " + target); //$NON-NLS-1$
-        return false;
-    }
-
-    public static boolean upload() {
-        if (uploadReadelf() && uploadSo() && uploadDaemon() && uploadVersion()) {
-            return true;
-        }
-        return false;
-    }
-
-    private static boolean existVersion = false;
-
-    private static MultiLineReceiver lsVersion = new MultiLineReceiver() {
-        @Override
-        public void processNewLines(String[] lines) {
-            if (0 != lines.length && !lines[0].isEmpty()
-                    && !lines[0].startsWith(AnalyzerConstants.CMD_NO_LIST)) {
-                existVersion = true;
-            }
-        }
-    };
-
-    private static boolean isVersionExist() {
-        execShellCommand(AnalyzerConstants.CMD_LS_VERSION, lsVersion);
-        return existVersion;
-    }
-
-    private static String getDAVersion() {
-        File version =
-                new File(AnalyzerConstants.DYNAMIC_ANALYZER_INSTALL_PATH + File.separator
-                        + AnalyzerConstants.VERSION_NAME);
-        if (version.exists()) {
-            BufferedReader br;
-            try {
-                br = new BufferedReader(new FileReader(version));
-                return br.readLine();
-            } catch (FileNotFoundException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-
-    private static boolean correctVersion = false;
-
-    private static MultiLineReceiver catVersion = new MultiLineReceiver() {
-        @Override
-        public void processNewLines(String[] lines) {
-            if (0 != lines.length && !lines[0].isEmpty()
-                    && !lines[0].startsWith(AnalyzerConstants.CMD_NO_LIST)) {
-
-                String daVersion = getDAVersion();
-                if (null != daVersion && daVersion.equals(lines[0])) {
-                    correctVersion = true;
-                    return;
-                }
-            }
-        }
-    };
-
-    private static boolean isCorrectVersion() {
-        execShellCommand(AnalyzerConstants.CMD_CAT_VERSION, catVersion);
-        return correctVersion;
-    }
-
-    public static boolean needUpdateVersion() {
-        if (!isVersionExist() || !isCorrectVersion()) {
-            return true;
-        }
-        return false;
-    }
-
-    public static void addDeviceListener() {
-        SmartDevelopmentBridge.addDeviceChangeListener(deviceChanged);
-    }
-
-    public static void removeDeviceListener() {
-        SmartDevelopmentBridge.removeDeviceChangeListener(deviceChanged);
-    }
-
-    private static IDeviceChangeListener deviceChanged = new IDeviceChangeListener() {
-        @Override
-        public void deviceDisconnected(IDevice device) {
-            checkDevices();
-            setSelectedDevice(null);
-            if (isRunning()) {
-                System.out.println("Disconnected while DA is running."); //$NON-NLS-1$
-                UIRecorderTool.getInstance().stop();
-
-                Display.getDefault().syncExec(new Runnable() {
-                    @Override
-                    public void run() {
-                        CoolbarArea.getInstance().setStartToolbarEnablement(false);
-                        CoolbarArea.getInstance().setToolbarEnablement(false);
-                        CoolbarArea.getInstance().stopTrace();
-                    }
-                });
-
-                Display.getDefault().syncExec(new Runnable() {
-                    @Override
-                    public void run() {
-                        StateManager.getInstance().stopProcessStart(AnalyzerLabels.STOP_PROCESS_DLG_DEVICE_DISCONNECTED);
-                    }
-                });
-                System.out.println("stop log process thread call by device disconnected");//$NON-NLS-1$
-                AnalyzerManager.runStopLogProcessThread();
-                // new Thread(null, new StopLogProcessThread(),
-                // AnalyzerConstants.STOP_LOG_THREAD).start();
-            } else {
-                Display.getDefault().syncExec(new Runnable() {
-                    @Override
-                    public void run() {
-                        CoolbarArea.getInstance().setStartToolbarEnablement(false);
-                    }
-                });
-            }
-        }
-
-        @Override
-        public void deviceConnected(IDevice device) {
-
-        }
-
-        @Override
-        public void deviceChanged(IDevice device, int changeMask) {
-            if (1 == changeMask) {
-                checkDevices();
-                if (null != getSelectedDevice() && null != getSelectedApp()) {
-                    Display.getDefault().syncExec(new Runnable() {
-                        @Override
-                        public void run() {
-                            CoolbarArea.getInstance().setStartToolbarEnablement(true);
-                        }
-                    });
-                }
-            }
-        }
-    };
-
-    public static void checkDevices() {
-        reloadDevices();
-        Display.getDefault().syncExec(new Runnable() {
-            @Override
-            public void run() {
-                List<String> deviceSerials = new ArrayList<String>();
-                String selDev = CoolbarArea.getInstance().getSelectedDevice();
-                int size = getDevs().size();
-                int selIndex = 0;
-                for (int i = 0; i < size; i++) {
-                    String serial = devs.get(i).getSerialNumber();
-                    deviceSerials.add(serial);
-                    if (null != selDev && selDev.equals(serial)) {
-                        selIndex = i;
-                    }
-                }
-                if (!devs.isEmpty()) {
-                    setSelectedDevice(devs.get(selIndex));
-                }
-                CoolbarArea.getInstance().setDeviceComboItems(deviceSerials);
-            }
-        });
-    }
-
-    public static void setSelectedDeviceBySerial(String serial) {
-        if (null == serial || serial.isEmpty()) {
-            setSelectedDevice(null);
-        }
-        int size = getDevs().size();
-        for (int i = 0; i < size; i++) {
-            if (serial.equals(devs.get(i).getSerialNumber())) {
-                setSelectedDevice(devs.get(i));
-            }
-        }
-    }
+       private static Socket sock = null;
+       private static SmartDevelopmentBridge sdbBridge = null;
+       private static AppDesktopInfo selectedApp = null;
+       private static IDevice currentDevice = null;
+       private static BufferedWriter writer = null;
+       private static BufferedReader reader = null;
+       private static boolean isRunning = false;
+       private static List<IDevice> devs = null;
+       private static List<AppDesktopInfo> appDesktopList = null;
+       private static List<String> appDesktopString = null;
+
+       public static List<IDevice> getDevs() {
+               if (null == devs) {
+                       devs = new ArrayList<IDevice>();
+               }
+               return devs;
+       }
+
+       public static void setDevs(List<IDevice> devs) {
+               DACommunicator.devs = devs;
+       }
+
+       public static IDevice getSelectedDevice() {
+               return currentDevice;
+       }
+
+       public static void init() {
+               SmartDevelopmentBridge.init();
+               setNewBridge();
+               sock = null;
+               selectedApp = null;
+               currentDevice = null;
+               writer = null;
+               reader = null;
+               isRunning = false;
+               devs = null;
+               isArch = false;
+               appDesktopList = null;
+               pidOfDaemon = null;
+               existVersion = false;
+               correctVersion = false;
+       }
+
+       public static void setSelectedDevice(IDevice device) {
+               currentDevice = device;
+       }
+
+       public static AppDesktopInfo getSelectedApp() {
+               return selectedApp;
+       }
+
+       public static void setSelectedApp(AppDesktopInfo app) {
+               selectedApp = app;
+       }
+
+       public static Socket getSocket() {
+               return sock;
+       }
+
+       public static void setSocket(Socket socket) {
+               sock = socket;
+       }
+
+       public static SmartDevelopmentBridge getBridge() {
+               return sdbBridge;
+       }
+
+       public static void setBridge(SmartDevelopmentBridge bridge) {
+               sdbBridge = bridge;
+       }
+
+       public static void setNewBridge() {
+               String sdbPath = AnalyzerConstants.SDB_PATH;
+               if (null != AnalyzerConstants.SDB_PATH) {
+                       try {
+                               sdbBridge = SmartDevelopmentBridge.createBridge(sdbPath, false);
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public static boolean isRunning() {
+               return isRunning;
+       }
+
+       public static void setRunning(boolean run) {
+               isRunning = run;
+       }
+
+       protected static void reloadDevices() {
+               IDevice[] devices = null;
+               getDevs().clear();
+               if (null != sdbBridge) {
+                       devices = sdbBridge.getDevices();
+                       for (IDevice device : devices) {
+                               devs.add(device);
+                       }
+               }
+       }
+
+       private static boolean isArch = false;
+
+       private static MultiLineReceiver archReceiver = new MultiLineReceiver() {
+               @Override
+               public void processNewLines(String[] lines) {
+                       if (lines[0].contains(AnalyzerConstants.ARM_ARCH)) {
+                               isArch = true;
+                       }
+               }
+       };
+
+       public static boolean isCurrentDeviceArmArch() {
+               execShellCommand(AnalyzerConstants.CMD_IS_ARM_ARCH, archReceiver);
+
+               return isArch;
+       }
+
+       protected static List<String> getDevicesNameList() {
+               List<String> deviceList = null;
+               SmartDevelopmentBridge sdbBridge = getBridge();
+               if (null != sdbBridge) {
+                       List<IDevice> devicesList = getDevs();
+                       deviceList = new ArrayList<String>();
+                       for (IDevice device : devicesList) {
+                               deviceList.add(device.getSerialNumber());
+                       }
+               }
+
+               return deviceList;
+       }
+
+       private static MultiLineReceiver appListReceiver = new MultiLineReceiver() {
+               @Override
+               public void processNewLines(String[] appLines) {
+                       for (int i = 0; i < appLines.length; i++) {
+                               appDesktopString.add(appLines[i]);
+                       }
+               }
+       };
+
+       private static AppDesktopInfo findDesktopInfoByDesktopName(
+                       String desktopName) {
+               appDesktopList = getAppDesktopList();
+               int size = appDesktopList.size();
+               for (int i = 0; i < size; i++) {
+                       if (appDesktopList.get(i).getDesktopName().equals(desktopName)) {
+                               return appDesktopList.get(i);
+                       }
+               }
+               return null;
+       }
+
+       public static List<AppDesktopInfo> getAppListFromTarget() {
+               getAppDesktopList().clear();
+               getAppDesktopString().clear();
+
+               execShellCommand(AnalyzerConstants.CMD_APPLICATION_LIST,
+                               appListReceiver);
+
+               int size = appDesktopString.size();
+               for (int i = 0; i < size; i++) {
+                       String line = appDesktopString.get(i);
+                       String[] splitLine = line.split(":"); //$NON-NLS-1$
+                       String desktopName = splitLine[0];
+
+                       AppDesktopInfo desktopInfo = findDesktopInfoByDesktopName(desktopName);
+                       if (null == desktopInfo) {
+                               desktopInfo = new AppDesktopInfo();
+                               desktopInfo.setDesktopName(desktopName);
+                               appDesktopList.add(desktopInfo);
+                       }
+
+                       String[] splitData = splitLine[1].split("="); //$NON-NLS-1$
+                       String strData = splitData[0];
+
+                       if (strData.toLowerCase().equals("name")) { //$NON-NLS-1$
+                               desktopInfo.setName(new String(splitData[1]));
+                       } else if (strData.toLowerCase().equals("exec")) { //$NON-NLS-1$
+                               desktopInfo.setExecPath(new String(splitData[1]));
+                       }
+               }
+
+               // verification
+               size = appDesktopList.size();
+               for (int i = 0; i < size; i++) {
+                       AppDesktopInfo appInfo = appDesktopList.get(i);
+                       if (null == appInfo.getExecPath()
+                                       || appInfo.getExecPath().isEmpty()) {
+                               appDesktopList.remove(i);
+                       }
+
+                       else if (null == appInfo.getName() || appInfo.getName().isEmpty()) {
+                               String execPath = appInfo.getExecPath();
+                               String[] splitPath = execPath.split("\\/");
+                               String name = new String(splitPath[splitPath.length - 1]);
+                               appInfo.setName(name);
+                       }
+               }
+
+               // /*** dont delete for debug ***/
+               for (int i = 0; i < appDesktopList.size(); i++) {
+                       AppDesktopInfo info = appDesktopList.get(i);
+                       System.out.println("name " + info.getName() + "  path : "
+                                       + info.getExecPath());
+               }
+
+               return appDesktopList;
+       }
+
+       private static List<AppDesktopInfo> getAppDesktopList() {
+               if (null == appDesktopList) {
+                       appDesktopList = new ArrayList<AppDesktopInfo>();
+               }
+               return appDesktopList;
+       }
+
+       private static List<String> getAppDesktopString() {
+               if (null == appDesktopString) {
+                       appDesktopString = new ArrayList<String>();
+               }
+               return appDesktopString;
+       }
+
+       public static AppDesktopInfo getAppDesktopInfoByName(String name) {
+               List<AppDesktopInfo> appInfoList = getAppDesktopList();
+               int size = appInfoList.size();
+               for (int i = 0; i < size; i++) {
+                       AppDesktopInfo ai = appInfoList.get(i);
+                       if (ai.getName().equals(name)) {
+                               return ai;
+                       }
+               }
+               return null;
+       }
+
+       public static Socket createSocket(int port) {
+               try {
+                       sock = new Socket(AnalyzerConstants.LOCAL_HOST, port);
+                       if (null == sock) {
+                               System.out.println("failed to create a socket"); //$NON-NLS-1$
+                               return null;
+                       }
+
+                       sock.setSoTimeout(AnalyzerConstants.SOCKET_TIMEOUT);
+                       sock.setReuseAddress(true);
+                       sock.setTcpNoDelay(true);
+
+                       reader = new BufferedReader(new InputStreamReader(
+                                       sock.getInputStream()));
+                       writer = new BufferedWriter(new OutputStreamWriter(
+                                       sock.getOutputStream()));
+
+                       new Thread(null, new ReceiveCommunicator(),
+                                       AnalyzerConstants.COMMUNICATOR_RECEIVE_THREAD).start();
+
+               } catch (SocketTimeoutException e) {
+                       System.out.println("socket timeout."); //$NON-NLS-1$
+                       e.printStackTrace();
+               } catch (UnknownHostException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+
+               return sock;
+       }
+
+       public static void closeSocket() {
+               try {
+                       if (null != reader) {
+                               reader.close();
+                               reader = null;
+                       }
+                       if (null != writer) {
+                               writer.close();
+                               writer = null;
+                       }
+                       if (null != sock) {
+                               sock.close();
+                               sock = null;
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static BufferedReader getSockBufferedReader() {
+               return reader;
+       }
+
+       public static BufferedWriter getSockBufferedWriter() {
+               return writer;
+       }
+
+       public static void foward(int local, int remote) {
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               currentDevice.createForward(local, remote);
+                               Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL);
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public static void unfoward(int local, int remote) {
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               currentDevice.removeForward(local, remote);
+                               Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL);
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       private static String pidOfDaemon = null;
+
+       private static MultiLineReceiver pidofDaemon = new MultiLineReceiver() {
+               @Override
+               public void processNewLines(String[] lines) {
+                       if (0 != lines.length && !lines[0].isEmpty()) {
+                               pidOfDaemon = lines[0];
+                       }
+               }
+       };
+
+       public static boolean isDaemonAlive() {
+               execShellCommand(AnalyzerConstants.CMD_PIDOF_DAEMON, pidofDaemon);
+               if (null != pidOfDaemon) {
+                       return true;
+               }
+               return false;
+       }
+
+       public static void killDaemon() {
+               if (null != pidOfDaemon) {
+                       System.out.println("kill daemon : " + pidOfDaemon); //$NON-NLS-1$
+                       execShellCommand(AnalyzerConstants.CMD_KILL_DAEMON
+                                       + AnalyzerConstants.SPACE + pidOfDaemon);
+               }
+       }
+
+       public static void execShellCommand(String command) {
+               execShellCommand(command, new NullOutputReceiver());
+       }
+
+       public static void execShellCommand(String command,
+                       IShellOutputReceiver receiver) {
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               currentDevice.executeShellCommand(command, receiver);
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (ShellCommandUnresponsiveException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public static SdbShellProcess execCommand(String command) {
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               return currentDevice.executeShellCommand(command);
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+
+               return null;
+       }
+
+       public static void sendMessage(String message) {
+               try {
+                       if (null != sock) {
+                               writer.write(message);
+                               // writer.newLine();
+                               writer.flush();
+                       }
+
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static SyncResult push(String local, String remote) {
+               return push(local, remote, SyncService.getNullProgressMonitor());
+       }
+
+       public static SyncResult push(String local, String remote,
+                       ISyncProgressMonitor monitor) {
+               SyncResult result = null;
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               SyncService service = currentDevice.getSyncService();
+                               if (null != service) {
+                                       result = service.pushFile(local, remote, monitor);
+                               }
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+
+               return result;
+       }
+
+       public static SyncResult pull(String remote, String local) {
+               return pull(remote, local, SyncService.getNullProgressMonitor());
+       }
+
+       public static SyncResult pull(String remote, String local,
+                       ISyncProgressMonitor monitor) {
+               SyncResult result = null;
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               SyncService service = currentDevice.getSyncService();
+                               if (null != service) {
+                                       result = service.pullFile(remote, local, monitor);
+                               }
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+
+               return result;
+       }
+
+       public static void remove(String path) {
+               if (null != currentDevice && currentDevice.isOnline()) {
+                       try {
+                               currentDevice.executeShellCommand(AnalyzerConstants.CMD_REMOVE
+                                               + AnalyzerConstants.SPACE + path,
+                                               new NullOutputReceiver());
+                       } catch (TimeoutException e) {
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (ShellCommandUnresponsiveException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public static boolean isTargetEmulator() {
+               IDevice device = getSelectedDevice();
+               if (device != null) {
+                       if (device.getSerialNumber().contains(AnalyzerConstants.EMULATOR)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public static boolean uploadSo() {
+               String target = AnalyzerConstants.TARGET_PATH;
+
+               if (isCurrentDeviceArmArch()) {
+                       target += AnalyzerConstants.ARM_ARCH;
+               } else {
+                       target += AnalyzerConstants.X86_ARCH;
+               }
+               String target_osp = target + File.separator
+                               + AnalyzerConstants.PROBE_SO_OSP_NAME;
+               target += File.separator + AnalyzerConstants.PROBE_SO_TIZEN_NAME;
+
+               SyncResult result = push(target, AnalyzerConstants.DA_REMOTE_PROBE_PATH
+                               + AnalyzerConstants.PROBE_SO_TIZEN_NAME);
+               if (null == result || SyncService.RESULT_OK != result.getCode()) {
+                       System.out.println("upload is failed : " + target); //$NON-NLS-1$
+                       return false;
+               }
+
+               result = push(target_osp, AnalyzerConstants.DA_REMOTE_PROBE_PATH
+                               + AnalyzerConstants.PROBE_SO_OSP_NAME);
+               if (null == result || SyncService.RESULT_OK != result.getCode()) {
+                       System.out.println("upload is failed : " + target_osp); //$NON-NLS-1$
+                       return false;
+               }
+               return true;
+       }
+
+       public static boolean uploadVersion() {
+               SyncResult result = push(
+                               AnalyzerConstants.DYNAMIC_ANALYZER_INSTALL_PATH
+                                               + File.separator + File.separator
+                                               + AnalyzerConstants.VERSION_NAME,
+                               AnalyzerConstants.DA_REMOTE_PATH
+                                               + AnalyzerConstants.VERSION_NAME);
+               if (null != result && SyncService.RESULT_OK == result.getCode()) {
+                       return true;
+               }
+               System.out.println("version file upload is failed : "); //$NON-NLS-1$
+               return false;
+       }
+
+       public static boolean uploadDaemon() {
+               String target = AnalyzerConstants.TARGET_PATH;
+
+               if (DACommunicator.isCurrentDeviceArmArch()) {
+                       target += AnalyzerConstants.ARM_ARCH;
+               } else {
+                       target += AnalyzerConstants.X86_ARCH;
+               }
+               target += File.separator + AnalyzerConstants.DA_DAEMON_NAME;
+
+               SyncResult result = push(target, AnalyzerConstants.DA_REMOTE_DAEMON);
+               if (null != result && SyncService.RESULT_OK == result.getCode()) {
+                       DACommunicator
+                                       .execShellCommand(AnalyzerConstants.CMD_DAEMON_EXE_PERMISSION);
+                       return true;
+               }
+               System.out.println("upload is failed : " + target); //$NON-NLS-1$
+               return false;
+       }
+
+       public static boolean uploadReadelf() {
+               String target = AnalyzerConstants.TARGET_PATH;
+
+               if (DACommunicator.isCurrentDeviceArmArch()) {
+                       target += AnalyzerConstants.ARM_ARCH;
+               } else {
+                       target += AnalyzerConstants.X86_ARCH;
+               }
+               target += File.separator + AnalyzerConstants.READELF_BIN;
+
+               SyncResult result = push(target, AnalyzerConstants.DA_REMOTE_PATH
+                               + AnalyzerConstants.READELF_BIN);
+               if (null != result && SyncService.RESULT_OK == result.getCode()) {
+                       DACommunicator
+                                       .execShellCommand(AnalyzerConstants.CMD_READELF_PERMISSION);
+                       return true;
+               }
+               System.out.println("upload is failed : " + target); //$NON-NLS-1$
+               return false;
+       }
+
+       public static boolean upload() {
+               if (uploadReadelf() && uploadSo() && uploadDaemon() && uploadVersion()) {
+                       return true;
+               }
+               return false;
+       }
+
+       private static boolean existVersion = false;
+
+       private static MultiLineReceiver lsVersion = new MultiLineReceiver() {
+               @Override
+               public void processNewLines(String[] lines) {
+                       if (0 != lines.length && !lines[0].isEmpty()
+                                       && !lines[0].startsWith(AnalyzerConstants.CMD_NO_LIST)) {
+                               existVersion = true;
+                       }
+               }
+       };
+
+       private static boolean isVersionExist() {
+               execShellCommand(AnalyzerConstants.CMD_LS_VERSION, lsVersion);
+               return existVersion;
+       }
+
+       private static String getDAVersion() {
+               File version = new File(AnalyzerConstants.DYNAMIC_ANALYZER_INSTALL_PATH
+                               + File.separator + AnalyzerConstants.VERSION_NAME);
+               if (version.exists()) {
+                       BufferedReader br;
+                       try {
+                               br = new BufferedReader(new FileReader(version));
+                               return br.readLine();
+                       } catch (FileNotFoundException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+               return null;
+       }
+
+       private static boolean correctVersion = false;
+
+       private static MultiLineReceiver catVersion = new MultiLineReceiver() {
+               @Override
+               public void processNewLines(String[] lines) {
+                       if (0 != lines.length && !lines[0].isEmpty()
+                                       && !lines[0].startsWith(AnalyzerConstants.CMD_NO_LIST)) {
+
+                               String daVersion = getDAVersion();
+                               if (null != daVersion && daVersion.equals(lines[0])) {
+                                       correctVersion = true;
+                                       return;
+                               }
+                       }
+               }
+       };
+
+       private static boolean isCorrectVersion() {
+               execShellCommand(AnalyzerConstants.CMD_CAT_VERSION, catVersion);
+               return correctVersion;
+       }
+
+       public static boolean needUpdateVersion() {
+               if (!isVersionExist() || !isCorrectVersion()) {
+                       return true;
+               }
+               return false;
+       }
+
+       public static void addDeviceListener() {
+               SmartDevelopmentBridge.addDeviceChangeListener(deviceChanged);
+       }
+
+       public static void removeDeviceListener() {
+               SmartDevelopmentBridge.removeDeviceChangeListener(deviceChanged);
+       }
+
+       private static IDeviceChangeListener deviceChanged = new IDeviceChangeListener() {
+               @Override
+               public void deviceDisconnected(IDevice device) {
+                       checkDevices();
+                       setSelectedDevice(null);
+                       if (isRunning()) {
+                               System.out.println("Disconnected while DA is running."); //$NON-NLS-1$
+                               UIRecorderTool.getInstance().stop();
+
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               CoolbarArea.getInstance().setStartToolbarEnablement(
+                                                               false);
+                                               CoolbarArea.getInstance().setToolbarEnablement(false);
+                                               CoolbarArea.getInstance().stopTrace();
+                                       }
+                               });
+
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               StateManager
+                                                               .getInstance()
+                                                               .stopProcessStart(
+                                                                               AnalyzerLabels.STOP_PROCESS_DLG_DEVICE_DISCONNECTED);
+                                       }
+                               });
+                               System.out
+                                               .println("stop log process thread call by device disconnected");//$NON-NLS-1$
+                               AnalyzerManager.runStopLogProcessThread();
+                               // new Thread(null, new StopLogProcessThread(),
+                               // AnalyzerConstants.STOP_LOG_THREAD).start();
+                       } else {
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               CoolbarArea.getInstance().setStartToolbarEnablement(
+                                                               false);
+                                       }
+                               });
+                       }
+               }
+
+               @Override
+               public void deviceConnected(IDevice device) {
+
+               }
+
+               @Override
+               public void deviceChanged(IDevice device, int changeMask) {
+                       if (1 == changeMask) {
+                               checkDevices();
+                               if (null != getSelectedDevice() && null != getSelectedApp()) {
+                                       Display.getDefault().syncExec(new Runnable() {
+                                               @Override
+                                               public void run() {
+                                                       CoolbarArea.getInstance()
+                                                                       .setStartToolbarEnablement(true);
+                                               }
+                                       });
+                               }
+                       }
+               }
+       };
+
+       public static void checkDevices() {
+               reloadDevices();
+               Display.getDefault().syncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               List<String> deviceSerials = new ArrayList<String>();
+                               String selDev = CoolbarArea.getInstance().getSelectedDevice();
+                               int size = getDevs().size();
+                               int selIndex = 0;
+                               for (int i = 0; i < size; i++) {
+                                       String serial = devs.get(i).getSerialNumber();
+                                       deviceSerials.add(serial);
+                                       if (null != selDev && selDev.equals(serial)) {
+                                               selIndex = i;
+                                       }
+                               }
+                               if (!devs.isEmpty()) {
+                                       setSelectedDevice(devs.get(selIndex));
+                               }
+                               CoolbarArea.getInstance().setDeviceComboItems(deviceSerials);
+                       }
+               });
+       }
+
+       public static void setSelectedDeviceBySerial(String serial) {
+               if (null == serial || serial.isEmpty()) {
+                       setSelectedDevice(null);
+               }
+               int size = getDevs().size();
+               for (int i = 0; i < size; i++) {
+                       if (serial.equals(devs.get(i).getSerialNumber())) {
+                               setSelectedDevice(devs.get(i));
+                       }
+               }
+       }
 }
index c9d6732..6d2b782 100644 (file)
@@ -350,7 +350,7 @@ public class FileChartManager {
                        } 
                        else  /// Other
                        {
-                               System.out.print(" Other "+input+"\n");
+//                             System.out.print(" Other "+input+"\n");
                                if ( PrintCalledFunctionChart( input  ) == false ){
                                        continue;
                                }
index 0b343e4..73ad89c 100644 (file)
@@ -35,14 +35,15 @@ public class LeakDetector {
        public final static int API_TYPE_OPEN = 0;
        public final static int API_TYPE_CLOSE = 1;
        public final static int API_TYPE_REALLOC = 2;
-//     private final String[] columnNames = { SummaryLabels.LEAK_DETECTOR_ADDRESS,
-//                     SummaryLabels.LEAK_DETECTOR_SEQUENCE,
-//                     SummaryLabels.LEAK_DETECTOR_ID, SummaryLabels.LEAK_DETECTOR_TIME,
-//                     SummaryLabels.LEAK_DETECTOR_API_NAME,
-//                     SummaryLabels.LEAK_DETECTOR_INPUT_PARAM,
-//                     SummaryLabels.LEAK_DETECTOR_RETURN,
-//                     SummaryLabels.LEAK_DETECTOR_LEAK_SEQ,
-//                     SummaryLabels.LEAK_DETECTOR_PARENT };
+       // private final String[] columnNames = {
+       // SummaryLabels.LEAK_DETECTOR_ADDRESS,
+       // SummaryLabels.LEAK_DETECTOR_SEQUENCE,
+       // SummaryLabels.LEAK_DETECTOR_ID, SummaryLabels.LEAK_DETECTOR_TIME,
+       // SummaryLabels.LEAK_DETECTOR_API_NAME,
+       // SummaryLabels.LEAK_DETECTOR_INPUT_PARAM,
+       // SummaryLabels.LEAK_DETECTOR_RETURN,
+       // SummaryLabels.LEAK_DETECTOR_LEAK_SEQ,
+       // SummaryLabels.LEAK_DETECTOR_PARENT };
 
        HashMap<String, Check> leakCheckHash;
        HashMap<String, LeakData> leakHash;
@@ -160,7 +161,16 @@ public class LeakDetector {
                int seqNum = Integer
                                .parseInt(input[LogCenterConstants.SEQUENCE_NUMBER_INDEX]);
                CallStackData csd = cdMap.get(seqNum);
-               List<Long> addrs = csd.getAddrs();
+               List<Long> addrs = null;
+               try {
+                       addrs = csd.getAddrs();
+               } catch (Exception e) {
+//                     for (int i = 0; i < input.length; i++)
+//                             System.out.print(input[i] + "  ");
+//                     System.out.println();
+//                     e.printStackTrace();
+                       return;
+               }
                if (addrs.isEmpty() || addrs.size() < 3) {
                        return;
                }
@@ -184,7 +194,8 @@ public class LeakDetector {
                                        return;
                                }
                                // if (funcName.contains(AnalyzerConstants.USER_BIN_POS)) {
-                               if (CallStackManager.getInstance().checkUserCall(funcName.getPath())) {
+                               if (CallStackManager.getInstance().checkUserCall(
+                                               funcName.getPath())) {
                                        LeakData childData = new LeakData(input[chk.getKeyIndex()],
                                                        input);
                                        String addr = Long.toString(addrs.get(i - 1));
@@ -217,7 +228,7 @@ public class LeakDetector {
                leakSeq = 0;
        }
 
-//     public String[] getColumnNames() {
-//             return columnNames;
-//     }
+       // public String[] getColumnNames() {
+       // return columnNames;
+       // }
 }