INTERNAL: fix potentially critical bug 66/26466/2
authorgreatim <jaewon81.lim@samsung.com>
Sat, 23 Aug 2014 06:52:59 +0000 (15:52 +0900)
committergreatim <jaewon81.lim@samsung.com>
Wed, 27 Aug 2014 06:07:00 +0000 (15:07 +0900)
fix potentially critical bug
null pointer dereference, lock not released on all path, resource leaks

Change-Id: I0773f7068399a87d1d3ea131298e886e437a86c8
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/CommunicatorUtils.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/MessageProcess.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DeviceExplorer/DeviceExplorer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/data/KernelDataManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java

index 6ceaedc..702d565 100755 (executable)
@@ -160,24 +160,24 @@ public class Communicator22 extends BaseCommunicator {
                }
 
                DeviceInfo device = GlobalInformation.getCurrentDeviceInfo();
-               if (null != device
-                               && device.getIDevice().getSerialNumber()
-                                               .startsWith(CommonConstants.EMULATOR)) {
+               if (device == null) {
+                       return HostResult.ERR_DEVICE_IS_NULL;
+               }
+
+               if (device.getIDevice().getSerialNumber()
+                               .startsWith(CommonConstants.EMULATOR)) {
                        isEmul = 1;
                }
 
-               if (null == GlobalInformation.getCurrentApplication()) {
+               AppInfo app = GlobalInformation.getCurrentApplication();
+               if (null == app) {
                        return HostResult.ERR_SELECTED_APP_IS_NULL;
                }
-               String rearMessage = CommonConstants.EMPTY
-                               + res
-                               + isEmul
-                               + isArm
+               String rearMessage = CommonConstants.EMPTY + res + isEmul + isArm
                                + CommonConstants.CMD_SPLIT
                                + ConfigureManager.getInstance().getConfiguration(device)
                                + CommonConstants.CMD_SPLIT
-                               + GlobalInformation.getCurrentApplication().getInfo(
-                                               AppInfo.PROPERTY.EXEC.index);
+                               + app.getInfo(AppInfo.PROPERTY.EXEC.index);
 
                String message = AnalyzerConstants.MSG_START
                                + CommonConstants.CMD_SPLIT + rearMessage.length()
index d19bba9..4ee3591 100755 (executable)
@@ -47,6 +47,7 @@ import org.tizen.dynamicanalyzer.common.path.PathConstants;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.model.DeviceInfo;
+import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.IShellOutputReceiver;
@@ -519,10 +520,14 @@ public class CommunicatorUtils {
                        Logger.debug("file open failed...");
                        return null;
                }
+               
+               FileInputStream fis = null;
+               InputStreamReader isr = null;
+               BufferedReader reader = null;
                try {
-                       FileInputStream fis = new FileInputStream(file);
-                       InputStreamReader isr = new InputStreamReader(fis);
-                       BufferedReader reader = new BufferedReader(isr);
+                       fis = new FileInputStream(file);
+                       isr = new InputStreamReader(fis);
+                       reader = new BufferedReader(isr);
 
                        String input = null;
                        while (null != (input = reader.readLine())) {
@@ -539,6 +544,8 @@ public class CommunicatorUtils {
                        return null;
                } catch (ArrayIndexOutOfBoundsException e) {
                        e.printStackTrace();
+               } finally {
+                       CommonUtil.tryClose(reader, isr, fis);
                }
                return apiMap;
        }
index 89280e8..b87784a 100644 (file)
@@ -783,7 +783,7 @@ public class DACommunicator {
        // return null;
        // }
 
-       public static boolean isWaitControlMessage() {
+       public static boolean isWaitToReceive() {
                return GlobalInformation.getCurrentDeviceInfo().getCommunicator().isBlocked();
        }
 
index 4145247..a38e2cd 100644 (file)
@@ -103,13 +103,14 @@ public class MessageProcess {
 
        private void addBufferToList() {
                lock.lock();
-               if (null == buffer || 0 == buffer.size()) {
+               try {
+                       if (null != buffer && 0 != buffer.size()) {
+                               LogParser.getLogQueue().putLog(buffer);
+                               buffer = new ArrayList<String>();
+                       }
+               } finally {
                        lock.unlock();
-                       return;
                }
-               LogParser.getLogQueue().putLog(buffer);
-               buffer = new ArrayList<String>();
-               lock.unlock();
        }
 
        public void processMessage(String message) {
@@ -161,53 +162,54 @@ public class MessageProcess {
        }
 
        private void processAppInfo(String message) {
-//             String[] data = message.split(AnalyzerConstants.DATA_PARSING_TOKEN);
-//
-//             Project project = AnalyzerManager.getProject();
-//             TargetInfo tInfo = project.getTargetInfo();
-//             ProcessInfo pInfo = project.getProcessInfo();
-//
-//             tInfo.setSystemMemorySize(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_SYSTEM_MEMORY_SIZE]));
-//             tInfo.setStorageSize(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_STORAGE_SIZE]));
-//             tInfo.setBluetoothSupport(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_BLUETOOTH_SUPPORT]));
-//             tInfo.setGpsSupport(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_GPS_SUPPORT]));
-//             tInfo.setWifiSupport(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_WIFI_SUPPORT]));
-//             tInfo.setCameraCount(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_CAMERA_COUNT]));
-//             tInfo.setNetworkType(data[AnalyzerConstants.APP_INFO_NETWORK_TYPE]);
-//             tInfo.setMaxBrightness(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_MAX_BRIGHTNESS]));
-//
-//             pInfo.setPid(Integer.parseInt(data[AnalyzerConstants.APP_INFO_PID]));
-//             // pInfo.setTime(Integer
-//             // .parseInt(data[AnalyzerConstants.APP_INFO_START_TIME]) * 100);
-//             pInfo.setBinaryType(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_PIE_BUILD]));
-//             pInfo.setLowestAddress(Long
-//                             .parseLong(data[AnalyzerConstants.APP_INFO_BASE_ADDRESS]));
-//             pInfo.setAppType(Integer
-//                             .parseInt(data[AnalyzerConstants.APP_INFO_APP_TYPE]));
-//             pInfo.setBinaryPath(data[AnalyzerConstants.APP_INFO_BINARY_PATH]);
-//
-//             if (null == pInfo.getBinaryPath() || pInfo.getBinaryPath().isEmpty()) {
-//                     ToolbarArea.getInstance().setSourceViewEnable(false);
-//                     ToolbarArea.getInstance().setSourceViewTooltip(
-//                                     AnalyzerLabels.MESSAGE_PROCESS_PG_WARNING);
-//             } else {
-//                     ToolbarArea.getInstance().setSourceViewEnable(true);
-//                     ToolbarArea.getInstance().setSourceViewTooltip(
-//                                     AnalyzerLabels.MESSAGE_PROCESS_VIEW_SOURCE);
-//             }
-//
-//             // User Call Trace : App is Tizen C++ or Tizen native
-//             if (pInfo.getAppType() == AnalyzerConstants.APP_TYPE_OSP) {
-//                     LogParser.setDropCallTraceLog(true);
-//             }
+               // String[] data = message.split(AnalyzerConstants.DATA_PARSING_TOKEN);
+               //
+               // Project project = AnalyzerManager.getProject();
+               // TargetInfo tInfo = project.getTargetInfo();
+               // ProcessInfo pInfo = project.getProcessInfo();
+               //
+               // tInfo.setSystemMemorySize(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_SYSTEM_MEMORY_SIZE]));
+               // tInfo.setStorageSize(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_STORAGE_SIZE]));
+               // tInfo.setBluetoothSupport(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_BLUETOOTH_SUPPORT]));
+               // tInfo.setGpsSupport(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_GPS_SUPPORT]));
+               // tInfo.setWifiSupport(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_WIFI_SUPPORT]));
+               // tInfo.setCameraCount(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_CAMERA_COUNT]));
+               // tInfo.setNetworkType(data[AnalyzerConstants.APP_INFO_NETWORK_TYPE]);
+               // tInfo.setMaxBrightness(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_MAX_BRIGHTNESS]));
+               //
+               // pInfo.setPid(Integer.parseInt(data[AnalyzerConstants.APP_INFO_PID]));
+               // // pInfo.setTime(Integer
+               // // .parseInt(data[AnalyzerConstants.APP_INFO_START_TIME]) * 100);
+               // pInfo.setBinaryType(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_PIE_BUILD]));
+               // pInfo.setLowestAddress(Long
+               // .parseLong(data[AnalyzerConstants.APP_INFO_BASE_ADDRESS]));
+               // pInfo.setAppType(Integer
+               // .parseInt(data[AnalyzerConstants.APP_INFO_APP_TYPE]));
+               // pInfo.setBinaryPath(data[AnalyzerConstants.APP_INFO_BINARY_PATH]);
+               //
+               // if (null == pInfo.getBinaryPath() || pInfo.getBinaryPath().isEmpty())
+               // {
+               // ToolbarArea.getInstance().setSourceViewEnable(false);
+               // ToolbarArea.getInstance().setSourceViewTooltip(
+               // AnalyzerLabels.MESSAGE_PROCESS_PG_WARNING);
+               // } else {
+               // ToolbarArea.getInstance().setSourceViewEnable(true);
+               // ToolbarArea.getInstance().setSourceViewTooltip(
+               // AnalyzerLabels.MESSAGE_PROCESS_VIEW_SOURCE);
+               // }
+               //
+               // // User Call Trace : App is Tizen C++ or Tizen native
+               // if (pInfo.getAppType() == AnalyzerConstants.APP_TYPE_OSP) {
+               // LogParser.setDropCallTraceLog(true);
+               // }
        }
 
        // private String getImageName(String fullPath) {
@@ -217,7 +219,6 @@ public class MessageProcess {
        // return name;
        // }
 
-
        // private void processImage(final String from) {
        // final String fileName = getImageName(from);
        // final String to = AnalyzerManager.getProject().getSavePath()
@@ -348,7 +349,7 @@ public class MessageProcess {
                Logger.debug("Ending steps!");
                message = null;
                DACommunicator.setRunning(false);
-//             AnalyzerUtil.setRecordState(RecordStateSourceProvider.RECORD_READY);
+               // AnalyzerUtil.setRecordState(RecordStateSourceProvider.RECORD_READY);
                AnalyzerManager.setRunningState(false);
                Display.getDefault().syncExec(new Runnable() {
                        @Override
index dac4001..b39b9f0 100755 (executable)
@@ -105,6 +105,9 @@ import org.tizen.sdblib.service.SyncResult;
 
 public class Communicator30 extends BaseCommunicator {
        static final boolean PRINT_CONTROL_LOG_TOFILE = true;
+       
+       private static final int CONTROL_HEADER_SIZE = 8;
+       
        private PrintWriter printWriter = null;
 
        @Override
@@ -190,23 +193,26 @@ public class Communicator30 extends BaseCommunicator {
                        replayData = ByteUtil.getByte(ReplayTraceHandler.REPLAY_OFF);
                }
 
-               byte[] rear = ByteUtil.getByte(userSpaceInst.toByteStream(), replayData);
+               byte[] rear = ByteUtil
+                               .getByte(userSpaceInst.toByteStream(), replayData);
                int length = rear.length;
 
-               byte[] ret = ByteUtil.getByte(AnalyzerConstants.MSG_START_SWAP, length, rear);
+               byte[] ret = ByteUtil.getByte(AnalyzerConstants.MSG_START_SWAP, length,
+                               rear);
 
                Logger.debug("print start message");
                // ByteUtils.printByteArrayForStart(ret);
 
                if (PRINT_CONTROL_LOG_TOFILE) {
-                       File logPath = new File(PathManager.DA_DEBUG_CONTROL_CHANNEL_LOG_FILE);
+                       File logPath = new File(
+                                       PathManager.DA_DEBUG_CONTROL_CHANNEL_LOG_FILE);
                        if (logPath.exists()) {
                                logPath.delete();
                        }
 
                        try {
-                               printWriter = new PrintWriter(
-                                               new BufferedWriter(new FileWriter(logPath)), true);
+                               printWriter = new PrintWriter(new BufferedWriter(
+                                               new FileWriter(logPath)), true);
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
@@ -229,8 +235,8 @@ public class Communicator30 extends BaseCommunicator {
                if (result.isSuccess()) {
                        if (!isCorrectAck(MSG_START_ACK, result)) {
                                HostResult failResult = HostResult.ERR_MSG_START_FAIL;
-                               failResult.setMessage(ErrorCode.getError(getReturnId(result.getRet()))
-                                               .toString());
+                               failResult.setMessage(ErrorCode.getError(
+                                               getReturnId(result.getRet())).toString());
                                DACommunicator.setRunning(false);
                                dataThread = null;
                                return failResult;
@@ -244,7 +250,8 @@ public class Communicator30 extends BaseCommunicator {
                                index += INT_SIZE;
                                int nano = ByteUtil.toInt(data, index);
 
-                               AnalyzerManager.getProject().setProfilingStartTime(new DATime(sec, nano));
+                               AnalyzerManager.getProject().setProfilingStartTime(
+                                               new DATime(sec, nano));
                        }
                } else {
                        DACommunicator.setRunning(false);
@@ -269,7 +276,8 @@ public class Communicator30 extends BaseCommunicator {
                ToolbarArea.getInstance().startTimer();
                Logger.performance("TEST", "Start Trace", "Start Timer");
                SWAPLogParser.startLogParser();
-               Logger.performance("TEST", "Start Trace", "Start SWAP log parser thread");
+               Logger.performance("TEST", "Start Trace",
+                               "Start SWAP log parser thread");
                // start registered data manager thread
                DataManagerRegistry.startThreads();
                Logger.performance("TEST", "Start Trace", "Start DataManager threads");
@@ -289,11 +297,14 @@ public class Communicator30 extends BaseCommunicator {
 
                if (pkgInfo.getPackageId().equals(AnalyzerConstants.RUNNING_PROCESS)) {
                        // if running process is selected for tracing
-                       Map<Integer, String> selectedProcess = apps.get(0).getRunningProcesses();
+                       Map<Integer, String> selectedProcess = apps.get(0)
+                                       .getRunningProcesses();
                        if (selectedProcess != null && selectedProcess.size() > 0) {
-                               for (Map.Entry<Integer, String> entry : selectedProcess.entrySet()) {
+                               for (Map.Entry<Integer, String> entry : selectedProcess
+                                               .entrySet()) {
                                        BinaryInfo binInfo = AnalyzerManager.getProject()
-                                                       .getDeviceStatusInfo().getBinaryInfo(entry.getValue());
+                                                       .getDeviceStatusInfo()
+                                                       .getBinaryInfo(entry.getValue());
                                        String temppath = binInfo.getTempBinaryPath();
                                        if (temppath == null) {
                                                // this means the app binary does not exist in device
@@ -312,7 +323,8 @@ public class Communicator30 extends BaseCommunicator {
                                        output.getAppInstList().add(appInst);
                                }
                        }
-               } else if (pkgInfo.getPackageId().equals(AnalyzerConstants.WITHOUT_EXECUTABLE)) {
+               } else if (pkgInfo.getPackageId().equals(
+                               AnalyzerConstants.WITHOUT_EXECUTABLE)) {
                        // TODO : if no executable is selected for tracing (system wide
                        // tracing)
                        return null;
@@ -330,8 +342,8 @@ public class Communicator30 extends BaseCommunicator {
                                        continue;
                                }
 
-                               BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo()
-                                               .getBinaryInfo(app.getExecPath());
+                               BinaryInfo binInfo = AnalyzerManager.getProject()
+                                               .getDeviceStatusInfo().getBinaryInfo(app.getExecPath());
                                String temppath = binInfo.getTempBinaryPath();
                                if (temppath == null) {
                                        // this means the app binary does not exist in device
@@ -359,7 +371,8 @@ public class Communicator30 extends BaseCommunicator {
                                appInst.setExecutablePath(app.getExecPath());
                                Logger.debug("Set execute path : " + app.getExecPath());
 
-                               List<FunctionInst> functionInstList = getFunctionInstList(app, temppath);
+                               List<FunctionInst> functionInstList = getFunctionInstList(app,
+                                               temppath);
                                appInst.getFunctionInstList().addAll(functionInstList);
                                appInst.setFunctionCount(functionInstList.size());
                                output.getAppInstList().add(appInst);
@@ -408,7 +421,8 @@ public class Communicator30 extends BaseCommunicator {
                                paths.add(entry.getValue());
                                preMsg = ByteUtil.getByte(preMsg, entry.getValue());
                        }
-               } else if (AnalyzerConstants.WITHOUT_EXECUTABLE.equals(selectedApp.getAppId())) {
+               } else if (AnalyzerConstants.WITHOUT_EXECUTABLE.equals(selectedApp
+                               .getAppId())) {
                        // do not send message for system wide trace
                        return HostResult.SUCCESS;
                } else {
@@ -458,7 +472,8 @@ public class Communicator30 extends BaseCommunicator {
        private HostResult pullTheFile(String from, String to) {
 
                try {
-                       GlobalInformation.getCurrentDeviceInfo().getIDevice().becomeSuperUser(true);
+                       GlobalInformation.getCurrentDeviceInfo().getIDevice()
+                                       .becomeSuperUser(true);
                } catch (TimeoutException e) {
                        e.printStackTrace();
                } catch (SdbCommandRejectedException e) {
@@ -484,9 +499,11 @@ public class Communicator30 extends BaseCommunicator {
                // send config message
                byte[] config = ByteUtil.toBytes(AnalyzerConstants.MSG_CONFIG);
                RunTimeConfiguration rt = new RunTimeConfiguration();
-               rt.setFeatures(ConfigureManager.getInstance().getConfiguration(devInfo),
+               rt.setFeatures(
+                               ConfigureManager.getInstance().getConfiguration(devInfo),
                                ConfigureManager.getInstance().getPreConfiguration(devInfo));
-               rt.setSystemTracePeriod(ConfigureManager.getInstance().getSystemPeriod());
+               rt.setSystemTracePeriod(ConfigureManager.getInstance()
+                               .getSystemPeriod());
                rt.setSamplingPeriod(ConfigureManager.getInstance().getSamplingPeriod());
                byte[] rtByte = rt.toByteStream();
                int length = rtByte.length;
@@ -512,7 +529,8 @@ public class Communicator30 extends BaseCommunicator {
                Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
-                               final Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+                               final Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                               .getShell();
                                DADialog dialog = new DADialog(shell, SWT.NONE, 550, 153);
                                dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
                                dialog.setMessage("Configuration failed..");
@@ -579,48 +597,60 @@ public class Communicator30 extends BaseCommunicator {
                                        printWriter.printf("\n");
                                }
                                controlSock.getOutputStream().write(message);
-                       }
-
-                       int msgId = ByteUtil.toInt(message);
-                       Logger.debug("wait for ack... [send message : " + msgId + " ]");
-
-                       int readsize = -1;
-                       // read buffer size is sufficient??
-                       byte[] cbuf = new byte[DACommunicator.READ_BUFFER_SIZE * 2];
-                       blocked = true;
-                       Logger.debug("blocked");
-                       ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                       do {
-                               readsize = controlSock.getInputStream().read(cbuf);
-                               baos.write(cbuf, 0, readsize);
-                       } while (readsize == DACommunicator.READ_BUFFER_SIZE * 2);
-                       blocked = false;
-
-                       readsize = baos.size();
-                       cbuf = baos.toByteArray();
-                       if (PRINT_CONTROL_LOG_TOFILE && printWriter != null) {
-                               printWriter.printf("recv :");
-                               for (int k = 0; k < readsize; k++)
-                                       printWriter.printf("%02x ", cbuf[k]);
-                               printWriter.printf("\n");
-                       }
+                               Logger.debug("wait for ack... [send message : "
+                                               + ByteUtil.toInt(message) + " ]");
+
+                               int readsize = -1;
+                               byte[] cbuf = new byte[DACommunicator.READ_BUFFER_SIZE];
+                               
+                               Logger.debug("blocked");
+                               blocked = true;
+                               
+                               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                               readsize = controlSock.getInputStream().read(cbuf, 0, CONTROL_HEADER_SIZE);
+                               if (readsize == CONTROL_HEADER_SIZE) {
+                                       baos.write(cbuf, 0, readsize);
+                                       int payloadsize = ByteUtil.toInt(cbuf, INT_SIZE);
+                                       
+                                       do {
+                                               readsize = controlSock.getInputStream().read(cbuf);
+                                               baos.write(cbuf, 0, readsize);
+                                               
+                                               payloadsize -= readsize;
+                                       } while (payloadsize > 0);
+                                       blocked = false;
+
+                                       readsize = baos.size();
+                                       cbuf = baos.toByteArray();
+                                       if (PRINT_CONTROL_LOG_TOFILE && printWriter != null) {
+                                               printWriter.printf("recv :");
+                                               for (int k = 0; k < readsize; k++)
+                                                       printWriter.printf("%02x ", cbuf[k]);
+                                               printWriter.printf("\n");
+                                       }
+                                       Logger.debug("unblocked");
 
-                       Logger.debug("unblocked");
-                       if (readsize > 0) {
-                               byte[] buf = new byte[readsize];
-                               System.arraycopy(cbuf, 0, buf, 0, readsize);
-                               result = HostResult.SUCCESS;
-                               int ackId = ByteUtil.toInt(buf);
+                                       if (readsize > 0) {
+                                               byte[] buf = new byte[readsize];
+                                               System.arraycopy(cbuf, 0, buf, 0, readsize);
+                                               result = HostResult.SUCCESS;
+                                               int ackId = ByteUtil.toInt(buf);
 
-                               // for debug
-                               System.out.print("ack id : ");
-                               AnalyzerUtil.printHexdecimal(ackId);
-                               Logger.debug();
+                                               // for debug
+                                               System.out.print("ack id : ");
+                                               AnalyzerUtil.printHexdecimal(ackId);
+                                               Logger.debug();
 
-                               result.setRet(buf);
-                       } else {
-                               result = HostResult.ERR_CONTROL_SOCKET_CONNECTION_CLOSED;
-                               result.setMessage(result.getMessage());
+                                               result.setRet(buf);
+                                       } else {
+                                               result = HostResult.ERR_CONTROL_SOCKET_CONNECTION_CLOSED;
+                                               result.setMessage(result.getMessage());
+                                       }
+                               } else {
+                                       blocked = false;
+                                       result = HostResult.ERR_EXCEPTION_OCCURRED;
+                                       result.setMessage("Failed to read Ack Header");
+                               }
                        }
                } catch (SocketException e) {
                        result = HostResult.ERR_EXCEPTION_OCCURRED;
@@ -748,7 +778,8 @@ public class Communicator30 extends BaseCommunicator {
                index += INT_SIZE;
 
                if (ackType == msgId) {
-                       if (paylen != INT_SIZE || retId == ErrorCode.SUCCESS.getErrorNumber()) {
+                       if (paylen != INT_SIZE
+                                       || retId == ErrorCode.SUCCESS.getErrorNumber()) {
                                return true;
                        }
                }
@@ -760,7 +791,8 @@ public class Communicator30 extends BaseCommunicator {
                return GlobalInformation.getCurrentDeviceInfo().getDataSock();
        }
 
-       private void processTargetInfo(byte[] payload, int index, DeviceStatusInfo tInfo) {
+       private void processTargetInfo(byte[] payload, int index,
+                       DeviceStatusInfo tInfo) {
                long systemMemorySize = 0;
                long storageSize = 0;
                int bluetoothSupport = 0;
@@ -900,7 +932,8 @@ public class Communicator30 extends BaseCommunicator {
        public HostResult sendScreenShotRequest() {
                byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_GET_SCREENSHOT, 0);
                HostResult result = HostResult.SUCCESS;
-               Socket controlSock = GlobalInformation.getCurrentDeviceInfo().getControlSock();
+               Socket controlSock = GlobalInformation.getCurrentDeviceInfo()
+                               .getControlSock();
 
                try {
                        if (null != controlSock && !controlSock.isClosed()) {
@@ -930,9 +963,10 @@ public class Communicator30 extends BaseCommunicator {
                return result;
        }
 
-       public HostResult sendSWAPMessage(int messageId, List<BinarySettingData> settings) {
-               HashMap<String, BinaryInfo> targetBinInfoMap = BinarySettingManager.getInstance()
-                               .getTargetBinInfoMap();
+       public HostResult sendSWAPMessage(int messageId,
+                       List<BinarySettingData> settings) {
+               HashMap<String, BinaryInfo> targetBinInfoMap = BinarySettingManager
+                               .getInstance().getTargetBinInfoMap();
                byte[] msg = new byte[0];
                int count = settings.size();
                int failedCount = 0;
@@ -1018,13 +1052,15 @@ public class Communicator30 extends BaseCommunicator {
                        }
 
                        int length = sendbin.length;
-                       byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO,
-                                       length, sendbin);
+                       byte[] msg = ByteUtil
+                                       .getByte(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO,
+                                                       length, sendbin);
                        HostResult result = handleControlMessage(
                                        GlobalInformation.getCurrentDeviceInfo(), msg);
 
                        if (result.isSuccess()
-                                       && isCorrectAck(AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO_ACK,
+                                       && isCorrectAck(
+                                                       AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO_ACK,
                                                        result)) {
                                // parse binary info
                                byte[] payload = getMessagePayload(result.getRet());
@@ -1035,13 +1071,13 @@ public class Communicator30 extends BaseCommunicator {
 
                                if (count > 0) {
                                        infoMap = new HashMap<Integer, String>();
-                                       
+
                                        for (int i = 0; i < count; i++) {
                                                int pid = ByteUtil.toInt(payload, index);
                                                index += INT_SIZE;
                                                String cmdname = ByteUtil.getString(payload, index);
                                                index += ByteUtil.getStringLength(payload, index);
-                                               
+
                                                infoMap.put(Integer.valueOf(pid), cmdname);
                                        }
                                }
@@ -1051,7 +1087,8 @@ public class Communicator30 extends BaseCommunicator {
                return infoMap;
        }
 
-       public HostResult sendBinaryInfoMessageForLib(List<BinarySettingData> binaryData) {
+       public HostResult sendBinaryInfoMessageForLib(
+                       List<BinarySettingData> binaryData) {
                List<String> binPaths = new ArrayList<String>();
 
                for (BinarySettingData data : binaryData) {
@@ -1068,7 +1105,8 @@ public class Communicator30 extends BaseCommunicator {
                }
 
                int length = sendBin.length;
-               byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_BINARY_INFO, length, sendBin);
+               byte[] msg = ByteUtil.getByte(AnalyzerConstants.MSG_BINARY_INFO,
+                               length, sendBin);
                HostResult result = handleControlMessage(
                                GlobalInformation.getCurrentDeviceInfo(), msg);
 
@@ -1098,8 +1136,8 @@ public class Communicator30 extends BaseCommunicator {
 
                for (int i = 0; i < count; i++) {
                        String targetPath = targetPaths.get(i);
-                       BinaryInfo binInfo = curDevice.getDeviceStatusInfo()
-                                       .getBinaryInfo(targetPath);
+                       BinaryInfo binInfo = curDevice.getDeviceStatusInfo().getBinaryInfo(
+                                       targetPath);
 
                        int binaryType = ByteUtil.toInt(payload, index);
                        index += INT_SIZE;
@@ -1211,4 +1249,4 @@ public class Communicator30 extends BaseCommunicator {
                
                return md5value;
        }
-}
\ No newline at end of file
+}
index 6efda0f..c17007b 100755 (executable)
@@ -69,6 +69,7 @@ import org.tizen.dynamicanalyzer.ui.toolbar.StopLogProcessor;
 import org.tizen.dynamicanalyzer.ui.toolbar.StopProcessManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
 import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
@@ -122,8 +123,8 @@ public class MessageParser {
 
        public void startTimer() {
                timer = new Timer();
-               timer.scheduleAtFixedRate(new AddBufferTimerTask(), MSG_BUFFER_TIMER_DELAY,
-                               MSG_BUFFER_TIMER_PERIOD);
+               timer.scheduleAtFixedRate(new AddBufferTimerTask(),
+                               MSG_BUFFER_TIMER_DELAY, MSG_BUFFER_TIMER_PERIOD);
        }
 
        public void stopTimer() {
@@ -135,12 +136,10 @@ public class MessageParser {
 
        private void addBufferToList() {
                lock.lock();
-               if (null == buffer || 0 == buffer.size()) {
-                       lock.unlock();
-                       return;
-               }
                try {
-                       SWAPLogParser.getLogQueue().putLog(buffer);
+                       if (null != buffer && 0 != buffer.size()) {
+                               SWAPLogParser.getLogQueue().putLog(buffer);
+                       }
                } catch (UnsupportedOperationException e) {
                        e.printStackTrace();
                } catch (ClassCastException e) {
@@ -215,23 +214,25 @@ public class MessageParser {
                        index += LONG_SIZE;
                        String libPath = ByteUtil.getString(data, index);
 
-                       LibraryObject libObj = new LibraryObject(project.getDeviceStatusInfo()
-                                       .getBinaryInfo(libPath).getID(), lowestAddr, highestAddr);
+                       LibraryObject libObj = new LibraryObject(project
+                                       .getDeviceStatusInfo().getBinaryInfo(libPath).getID(),
+                                       lowestAddr, highestAddr);
 
                        index += ByteUtil.getStringLength(data, index);
 
                        pMap.addLibraryMap(libObj);
                }
 
-               Logger.debug("process info start time : " + capturedTime.getSec() + "  "
-                               + capturedTime.getNano());
+               Logger.debug("process info start time : " + capturedTime.getSec()
+                               + "  " + capturedTime.getNano());
 
                pMap.setMainBinary(new LibraryObject(project.getDeviceStatusInfo()
                                .getBinaryInfo(targetBinaryPath).getID(), lowAddr, highAddr));
 
                AnalyzerManager.setProcessInfoArrived(true);
 
-               ThreadChartManager.getInstance().getThreadDataManager().createMainThreadItem(pid);
+               ThreadChartManager.getInstance().getThreadDataManager()
+                               .createMainThreadItem(pid);
        }
 
        private void memoryMapChanged(byte[] data) {
@@ -278,8 +279,10 @@ public class MessageParser {
                        String libPath = LogDataUtils.getString(index, data);
                        index += LogDataUtils.getStringLength(index, data);
 
-                       BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(libPath);
-                       LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr, highAddr);
+                       BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(
+                                       libPath);
+                       LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr,
+                                       highAddr);
                        newMap.addLibraryMap(libObj);
                } else {
                        newMap.removeLibrary(lowAddr, highAddr);
@@ -297,12 +300,6 @@ public class MessageParser {
                InputStream inputStream = null;
                PrintWriter printWriter = null;
 
-               try {
-                       inputStream = dataSocket.getInputStream();
-               } catch (IOException e1) {
-                       e1.printStackTrace();
-               }
-
                if (PRINT_DATA_LOG_TOFILE) {
                        File logPath = new File(PathManager.DA_DEBUG_DATA_CHANNEL_LOG_FILE);
                        if (logPath.exists()) {
@@ -310,8 +307,8 @@ public class MessageParser {
                        }
 
                        try {
-                               printWriter = new PrintWriter(
-                                               new BufferedWriter(new FileWriter(logPath)), true);
+                               printWriter = new PrintWriter(new BufferedWriter(
+                                               new FileWriter(logPath)), true);
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
@@ -322,11 +319,14 @@ public class MessageParser {
                try {
                        byte[] header = new byte[MSG_HEADER_SIZE];
 
+                       inputStream = dataSocket.getInputStream();
+
                        while (true) {
                                int readSize = 0;
                                int toRead = MSG_HEADER_SIZE;
                                while (toRead > 0) {
-                                       readSize = inputStream.read(header, MSG_HEADER_SIZE - toRead, toRead);
+                                       readSize = inputStream.read(header, MSG_HEADER_SIZE
+                                                       - toRead, toRead);
                                        toRead -= readSize;
                                        if (!DACommunicator.isRunning() && readSize == -1) {
                                                // manager socket closed!!
@@ -351,7 +351,8 @@ public class MessageParser {
                                // AnalyzerUtil.printHexdecimal(id);
                                // System.out.println();
 
-                               int payloadSize = ByteUtil.toInt(header, MSG_PAYLOAD_SIZE_INDEX);
+                               int payloadSize = ByteUtil
+                                               .toInt(header, MSG_PAYLOAD_SIZE_INDEX);
                                byte[] payload = null;
 
                                try {
@@ -362,7 +363,8 @@ public class MessageParser {
 
                                toRead = payloadSize;
                                while (toRead > 0) {
-                                       readSize = inputStream.read(payload, payloadSize - toRead, toRead);
+                                       readSize = inputStream.read(payload, payloadSize - toRead,
+                                                       toRead);
                                        toRead -= readSize;
                                        if (!DACommunicator.isRunning() && readSize == -1) {
                                                // manager socket closed!!
@@ -377,12 +379,14 @@ public class MessageParser {
 
                                byte[] buffer = new byte[MSG_HEADER_SIZE + payloadSize];
                                System.arraycopy(header, 0, buffer, 0, MSG_HEADER_SIZE);
-                               System.arraycopy(payload, 0, buffer, MSG_HEADER_SIZE, payloadSize);
+                               System.arraycopy(payload, 0, buffer, MSG_HEADER_SIZE,
+                                               payloadSize);
 
                                if (PRINT_DATA_LOG_TOFILE && printWriter != null) {
-                                       printWriter.printf("%d %d %d %d %d :", id, ByteUtil.toInt(header, 4),
-                                                       ByteUtil.toInt(header, 8), ByteUtil.toInt(header, 12),
-                                                       payloadSize);
+                                       printWriter.printf("%d %d %d %d %d :", id,
+                                                       ByteUtil.toInt(header, 4),
+                                                       ByteUtil.toInt(header, 8),
+                                                       ByteUtil.toInt(header, 12), payloadSize);
                                        for (int k = 0; k < payloadSize; k++)
                                                printWriter.printf("%02x ", payload[k]);
                                        printWriter.printf("\n");
@@ -391,20 +395,24 @@ public class MessageParser {
                                processMessage(buffer);
                                if (id == DataChannelConstants.MSG_DATA_TERMINATE) {
                                        Logger.debug("message data terminate arrived!!!");
-                                       Logger.performance("TEST", "While tracing", "Terminate Application");
+                                       Logger.performance("TEST", "While tracing",
+                                                       "Terminate Application");
                                        if (AnalyzerManager.getProcessCount() == 0) {
                                                break;
                                        }
                                }
                        } // end while()
+
                        Logger.debug("Receive thread end!!");
                        Logger.performance("TEST", "DA end", "End receive thread");
                        if (!StartProcessManager.getInstance().isCancelled()) {
                                Display.getDefault().asyncExec(new Runnable() {
                                        @Override
                                        public void run() {
-                                               StopProcessManager.getInstance().stopProcessStart(
-                                                               AnalyzerLabels.STOP_PROCESS_DLG_SUMMARIZING_DATA); // socket
+                                               StopProcessManager
+                                                               .getInstance()
+                                                               .stopProcessStart(
+                                                                               AnalyzerLabels.STOP_PROCESS_DLG_SUMMARIZING_DATA); // socket
                                                // timeout
                                        }
                                });
@@ -416,12 +424,18 @@ public class MessageParser {
                        Display.getDefault().asyncExec(new Runnable() {
                                @Override
                                public void run() {
-                                       StopProcessManager.getInstance().stopProcessStart(
-                                                       AnalyzerLabels.STOP_PROCESS_DLG_DEVICE_DISCONNECTED); // socket
+                                       StopProcessManager
+                                                       .getInstance()
+                                                       .stopProcessStart(
+                                                                       AnalyzerLabels.STOP_PROCESS_DLG_DEVICE_DISCONNECTED); // socket
                                        // timeout
                                }
                        });
                        endingSteps();
+               } finally {
+                       if (printWriter != null) {
+                               CommonUtil.tryClose(printWriter);
+                       }
                }
        }
 
@@ -432,8 +446,8 @@ public class MessageParser {
                Display.getDefault().syncExec(new Runnable() {
                        @Override
                        public void run() {
-                               ToolbarArea.getInstance()
-                                               .setToolbarState(ToolbarArea.TOOLBAR_STATE_READY);
+                               ToolbarArea.getInstance().setToolbarState(
+                                               ToolbarArea.TOOLBAR_STATE_READY);
                        }
                });
                stopTimer();
@@ -474,13 +488,16 @@ public class MessageParser {
 
                case DataChannelConstants.MSG_DATA_SYSTEM:
                        Runtime runtime = Runtime.getRuntime();
-                       if ((runtime.totalMemory() - runtime.freeMemory()) >= runtime.maxMemory() * 0.8) {
+                       if ((runtime.totalMemory() - runtime.freeMemory()) >= runtime
+                                       .maxMemory() * 0.8) {
                                ToolbarArea.getInstance().stopTrace();
                                Display.getDefault().asyncExec(new Runnable() {
                                        @Override
                                        public void run() {
-                                               final Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-                                               DADialog dialog = new DADialog(shell, SWT.NONE, 550, 153);
+                                               final Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                                               .getShell();
+                                               DADialog dialog = new DADialog(shell, SWT.NONE, 550,
+                                                               153);
                                                dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
                                                dialog.setMessage(AnalyzerLabels.HEAP_MEMORY_WARNING_PRE
                                                                + PathManager.DA_INSTALL_PATH
@@ -522,7 +539,8 @@ public class MessageParser {
                }
                        break;
                default: // MSG_PROBE
-                       if (AnalyzerManager.isProcessInfoArrived() && id > 0x0100 && id < 0x0200) {
+                       if (AnalyzerManager.isProcessInfoArrived() && id > 0x0100
+                                       && id < 0x0200) {
                                log = LogDataFactory.createInstance(data);
                                if (null != log) {
                                        buffer.add(log);
index 7f57b54..b619a34 100644 (file)
@@ -129,31 +129,7 @@ public class DeviceExplorer extends Composite {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
-                       String path = inputText.getText();
-                       if (null == path || path.isEmpty()) {
-                               Logger.debug("path must not empty");
-                               // inputText.setBackground(ColorResources.RED);
-                               // info.setText("Empty path");
-                               inputText.setText(current.getFullPath());
-                               return;
-                       }
-
-                       if (!path.contains(root.getFullPath())) {
-                               Logger.debug("Out of root range");
-                               // inputText.setBackground(ColorResources.RED);
-                               // info.setText("Out of root range");
-                               inputText.setText(current.getFullPath());
-                               return;
-                       }
-
-                       int ret = setCurrent(path);
-                       if (ret != FAIL) {
-                               inputText.setBackground(ColorResources.WHITE);
-                       } else {
-                               // inputText.setBackground(ColorResources.RED);
-                               // info.setText("Invalid path");
-                               inputText.setText(current.getFullPath());
-                       }
+                       adjustInput();
                }
        };
 
@@ -162,13 +138,11 @@ public class DeviceExplorer extends Composite {
                @Override
                public void keyReleased(KeyEvent e) {
                        if (e.keyCode == 13) {
-                               goButtonClickListener.handleClickEvent(null);
+                               adjustInput();
                                inputText.getControl().setSelection(
                                                inputText.getText().length());
-                       }
-                       else
-                       {
-                                
+                       } else {
+
                        }
                }
 
@@ -365,7 +339,7 @@ public class DeviceExplorer extends Composite {
                this.device = dev;
        }
 
-       public int setCurrent(String path) {
+       private int setCurrent(String path) {
                int result = FAIL;
                if (null != path && !path.isEmpty()) {
                        FileEntry file = device.getFileEntry(path);
@@ -387,6 +361,34 @@ public class DeviceExplorer extends Composite {
                return result;
        }
 
+       private void adjustInput() {
+               String path = inputText.getText();
+               if (null == path || path.isEmpty()) {
+                       Logger.debug("path must not empty");
+                       // inputText.setBackground(ColorResources.RED);
+                       // info.setText("Empty path");
+                       inputText.setText(current.getFullPath());
+                       return;
+               }
+
+               if (!path.contains(root.getFullPath())) {
+                       Logger.debug("Out of root range");
+                       // inputText.setBackground(ColorResources.RED);
+                       // info.setText("Out of root range");
+                       inputText.setText(current.getFullPath());
+                       return;
+               }
+
+               int ret = setCurrent(path);
+               if (ret != FAIL) {
+                       inputText.setBackground(ColorResources.WHITE);
+               } else {
+                       // inputText.setBackground(ColorResources.RED);
+                       // info.setText("Invalid path");
+                       inputText.setText(current.getFullPath());
+               }
+       }
+
        public void setFilterString(String filter) {
                this.filter = filter;
        }
index cf355c5..70d2710 100644 (file)
@@ -125,31 +125,7 @@ public class DAFileExplorer extends Composite {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
-                       String path = inputText.getText();
-                       if (null == path || path.isEmpty()) {
-                               Logger.debug("path must not empty");
-                               // inputText.setBackground(ColorResources.RED);
-                               // info.setText("Empty path");
-                               inputText.setText(current.getAbsolutePath());
-                               return;
-                       }
-// 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;
-//                     }
-
-                       int ret = setCurrent(path);
-                       if (ret != FAIL) {
-                               inputText.setBackground(ColorResources.WHITE);
-                       } else {
-                               // inputText.setBackground(ColorResources.RED);
-                               inputText.setText(current.getAbsolutePath());
-                               // info.setText("Invalid path");
-                       }
+                       adjustInput();
                }
        };
 
@@ -158,7 +134,7 @@ public class DAFileExplorer extends Composite {
                @Override
                public void keyReleased(KeyEvent e) {
                        if (e.keyCode == 13) {
-                               goButtonClickListener.handleClickEvent(null);
+                               adjustInput();
                                inputText.getControl().setSelection(
                                                inputText.getText().length());
                        }
@@ -350,7 +326,7 @@ public class DAFileExplorer extends Composite {
                return files;
        }
 
-       public int setCurrent(String path) {
+       private int setCurrent(String path) {
                int result = FAIL;
                if (null != path && !path.isEmpty()) {
                        File file = new File(path);
@@ -372,6 +348,35 @@ public class DAFileExplorer extends Composite {
                return result;
        }
 
+       private void adjustInput() {
+               String path = inputText.getText();
+               if (null == path || path.isEmpty()) {
+                       Logger.debug("path must not empty");
+                       // inputText.setBackground(ColorResources.RED);
+                       // info.setText("Empty path");
+                       inputText.setText(current.getAbsolutePath());
+                       return;
+               }
+
+               // 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;
+//             }
+
+               int ret = setCurrent(path);
+               if (ret != FAIL) {
+                       inputText.setBackground(ColorResources.WHITE);
+               } else {
+                       // inputText.setBackground(ColorResources.RED);
+                       inputText.setText(current.getAbsolutePath());
+                       // info.setText("Invalid path");
+               }
+       }
+
        public void setFilterString(String filter) {
                this.filter = filter;
        }
index 4565ae2..902e763 100644 (file)
@@ -134,19 +134,19 @@ public class KernelDataManager extends PageDataManager {
 
                        switch (top.getId()) {
                        case DataChannelConstants.MSG_CONTEXT_SWITCH_ENTRY:
-                               if (centryiter.hasNext())
+                               if (centryiter != null && centryiter.hasNext())
                                        pqueue.offer(centryiter.next());
                                break;
                        case DataChannelConstants.MSG_CONTEXT_SWITCH_EXIT:
-                               if (cexititer.hasNext())
+                               if (cexititer != null && cexititer.hasNext())
                                        pqueue.offer(cexititer.next());
                                break;
                        case DataChannelConstants.MSG_FUNCTION_ENTRY:
-                               if (fentryiter.hasNext())
+                               if (fentryiter != null && fentryiter.hasNext())
                                        pqueue.offer(fentryiter.next());
                                break;
                        case DataChannelConstants.MSG_FUNCTION_EXIT:
-                               if (fexititer.hasNext())
+                               if (fexititer != null && fexititer.hasNext())
                                        pqueue.offer(fexititer.next());
                                break;
                        default:
index 69bad32..68f1dc8 100644 (file)
@@ -71,7 +71,7 @@ public class StopLogProcessor implements Runnable {
                int percent = 0;
 
                int exitCount = 0;
-               while (DACommunicator.isWaitControlMessage() && exitCount < 1000) {
+               while (DACommunicator.isWaitToReceive() && exitCount < 1000) {
                        // System.out.println("wait for STOP ACK message...");
                        try {
                                Thread.sleep(10);
index de9d48d..ee31bf2 100755 (executable)
@@ -89,8 +89,8 @@ public class ToolbarArea {
        public static final int REPLAY_EDIT_BUTTON = 9;
 
        public static final String ALL_PROCESS = "All Processes";
-       public static final String PROCESS_SPLITER = CommonConstants.SPACE + CommonConstants.COLON
-                       + CommonConstants.SPACE;
+       public static final String PROCESS_SPLITER = CommonConstants.SPACE
+                       + CommonConstants.COLON + CommonConstants.SPACE;
 
        private static ToolbarArea coolbarArea;
 
@@ -177,7 +177,8 @@ public class ToolbarArea {
                                String text = appCombo.getText();
                                if ((null != pDeviceName && !pDeviceName.isEmpty() && pDeviceName
                                                .equals(sDeviceName))
-                                               && (null != appName && !appName.isEmpty() && appName.equals(text))) {
+                                               && (null != appName && !appName.isEmpty() && appName
+                                                               .equals(text))) {
                                        replayButton.setButtonEnabled(true);
                                        replayEditButton.setButtonEnabled(false);
                                        // disable button until complete TV SDK
@@ -195,11 +196,13 @@ public class ToolbarArea {
                        @Override
                        public void selectionEvent(DACustomCombo combo) {
                                String oldDeviceName = null;
-                               DeviceInfo oldDevInfo = GlobalInformation.getCurrentDeviceInfo();
+                               DeviceInfo oldDevInfo = GlobalInformation
+                                               .getCurrentDeviceInfo();
                                if (oldDevInfo != null)
                                        oldDeviceName = oldDevInfo.getIDevice().getSerialNumber();
                                String serial = combo.getText();
-                               if (!serial.equals(oldDeviceName)) {
+
+                               if (serial != null && !serial.equals(oldDeviceName)) {
                                        GlobalInformation.setCurrentDeviceInfo(DACommunicator
                                                        .setSelectedDeviceBySerial(serial));
                                        if (null != serial && !serial.isEmpty()) {
@@ -223,7 +226,8 @@ public class ToolbarArea {
 
                                if (null != idevices) {
                                        for (int i = 0; i < idevices.length; i++) {
-                                               int index = serials.indexOf(idevices[i].getSerialNumber());
+                                               int index = serials.indexOf(idevices[i]
+                                                               .getSerialNumber());
                                                if (index < 0) {
                                                        diffList.add(idevices[i]);
                                                }
@@ -243,12 +247,16 @@ public class ToolbarArea {
                                if (null != appName && !appName.isEmpty()) {
                                        boolean enablestart = true;
 
-                                       AppInfo selectedApp = DACommunicator.getPkgInfoByName(appName);
+                                       AppInfo selectedApp = DACommunicator
+                                                       .getPkgInfoByName(appName);
                                        if (null != selectedApp) {
                                                if (appName.equals(AnalyzerConstants.RUNNING_PROCESS)) {
-                                                       Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-                                                       ProcessExplorerDialog pdialog = new ProcessExplorerDialog(shell);
-                                                       pdialog.setProcessList(selectedApp.getRunningProcesses());
+                                                       Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                                                       .getShell();
+                                                       ProcessExplorerDialog pdialog = new ProcessExplorerDialog(
+                                                                       shell);
+                                                       pdialog.setProcessList(selectedApp
+                                                                       .getRunningProcesses());
                                                        Object result = pdialog.open();
                                                        if (result != null) {
                                                                @SuppressWarnings("unchecked")
@@ -262,15 +270,19 @@ public class ToolbarArea {
                                                }
 
                                                GlobalInformation.setCurrentApplication(selectedApp);
-                                               GlobalInformation.getCurrentDeviceInfo().getCommunicator()
-                                                               .onAppSelected(selectedApp);
-                                               GlobalInformation.getCurrentDeviceInfo().setSelectedAppName(
-                                                               selectedApp.getInfo(AppInfo.PROPERTY.LABEL.index));
+                                               GlobalInformation.getCurrentDeviceInfo()
+                                                               .getCommunicator().onAppSelected(selectedApp);
+                                               GlobalInformation
+                                                               .getCurrentDeviceInfo()
+                                                               .setSelectedAppName(
+                                                                               selectedApp
+                                                                                               .getInfo(AppInfo.PROPERTY.LABEL.index));
                                        } else {
                                                enablestart = false;
                                        }
 
-                                       if (enablestart && null != GlobalInformation.getCurrentDeviceInfo()) {
+                                       if (enablestart
+                                                       && null != GlobalInformation.getCurrentDeviceInfo()) {
                                                // AnalyzerUtil
                                                // .setRecordState(RecordStateSourceProvider.RECORD_READY);
                                                AnalyzerManager.setRunningState(false);
@@ -298,7 +310,8 @@ public class ToolbarArea {
 
                        @Override
                        public void selectionEvent(DACustomCombo combo) {
-                               BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
+                               BaseView baseView = (BaseView) WorkbenchUtil
+                                               .getViewPart(BaseView.ID);
                                baseView.getTopComposite().updateView();
                        }
                });
@@ -319,15 +332,19 @@ public class ToolbarArea {
                                int pcount = pids.length;
 
                                for (int i = 0; i < pcount; i++) {
-                                       ProcessInformation process = project.getProcessInformation(pids[i]);
+                                       ProcessInformation process = project
+                                                       .getProcessInformation(pids[i]);
                                        String binName = process.getProcessName();
                                        if (binName == null || binName.isEmpty()) {
-                                               int bid = process.getLastProcessMemoryMap().getMainbinary().getBinaryID();
-                                               String binPath = project.getDeviceStatusInfo().getBinaryInfo(bid)
-                                                               .getTargetBinaryPath();
+                                               int bid = process.getLastProcessMemoryMap()
+                                                               .getMainbinary().getBinaryID();
+                                               String binPath = project.getDeviceStatusInfo()
+                                                               .getBinaryInfo(bid).getTargetBinaryPath();
                                                if (null != binPath && !binPath.isEmpty()) {
-                                                       int index = binPath.lastIndexOf(CommonConstants.SLASH);
-                                                       binName = binPath.substring(index + 1, binPath.length());
+                                                       int index = binPath
+                                                                       .lastIndexOf(CommonConstants.SLASH);
+                                                       binName = binPath.substring(index + 1,
+                                                                       binPath.length());
                                                }
                                        }
 
@@ -351,28 +368,32 @@ public class ToolbarArea {
                        }
                });
 
-               saveTraceButton.addClickListener(new DACustomButtonClickEventListener() {
-
-                       @Override
-                       public void handleClickEvent(DACustomButton button) {
-                               Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-                               SaveAsDialog dialog = new SaveAsDialog(shell);
-                               Object result = dialog.open();
-                               if (null != result) {
-                                       button.setButtonEnabled(false);
-                               }
-                       }
-               });
+               saveTraceButton
+                               .addClickListener(new DACustomButtonClickEventListener() {
+
+                                       @Override
+                                       public void handleClickEvent(DACustomButton button) {
+                                               Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                                               .getShell();
+                                               SaveAsDialog dialog = new SaveAsDialog(shell);
+                                               Object result = dialog.open();
+                                               if (null != result) {
+                                                       button.setButtonEnabled(false);
+                                               }
+                                       }
+                               });
 
-               openTraceButton.addClickListener(new DACustomButtonClickEventListener() {
+               openTraceButton
+                               .addClickListener(new DACustomButtonClickEventListener() {
 
-                       @Override
-                       public void handleClickEvent(DACustomButton button) {
-                               Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-                               OpenTraceDialog dialog = new OpenTraceDialog(shell);
-                               dialog.open();
-                       }
-               });
+                                       @Override
+                                       public void handleClickEvent(DACustomButton button) {
+                                               Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                                               .getShell();
+                                               OpenTraceDialog dialog = new OpenTraceDialog(shell);
+                                               dialog.open();
+                                       }
+                               });
 
                replayButton.addClickListener(new DACustomButtonClickEventListener() {
 
@@ -386,15 +407,17 @@ public class ToolbarArea {
                        }
                });
 
-               replayEditButton.addClickListener(new DACustomButtonClickEventListener() {
+               replayEditButton
+                               .addClickListener(new DACustomButtonClickEventListener() {
 
-                       @Override
-                       public void handleClickEvent(DACustomButton button) {
-                               Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-                               ReplayEditDialog dialog = new ReplayEditDialog(shell);
-                               dialog.open();
-                       }
-               });
+                                       @Override
+                                       public void handleClickEvent(DACustomButton button) {
+                                               Shell shell = WorkbenchUtil.getWorkbenchWindow()
+                                                               .getShell();
+                                               ReplayEditDialog dialog = new ReplayEditDialog(shell);
+                                               dialog.open();
+                                       }
+                               });
 
                configButton.addClickListener(new DACustomButtonClickEventListener() {
 
@@ -406,13 +429,14 @@ public class ToolbarArea {
                        }
                });
 
-               screenshotButton.addClickListener(new DACustomButtonClickEventListener() {
+               screenshotButton
+                               .addClickListener(new DACustomButtonClickEventListener() {
 
-                       @Override
-                       public void handleClickEvent(DACustomButton button) {
-                               DACommunicator.sendScreenShotMessage();
-                       }
-               });
+                                       @Override
+                                       public void handleClickEvent(DACustomButton button) {
+                                               DACommunicator.sendScreenShotMessage();
+                                       }
+                               });
 
                aboutButton.addClickListener(new DACustomButtonClickEventListener() {
 
@@ -424,14 +448,15 @@ public class ToolbarArea {
                        }
                });
 
-               viewSourceButton.addClickListener(new DACustomButtonClickEventListener() {
-                       @Override
-                       public void handleClickEvent(DACustomButton button) {
+               viewSourceButton
+                               .addClickListener(new DACustomButtonClickEventListener() {
+                                       @Override
+                                       public void handleClickEvent(DACustomButton button) {
 
-                               // TODO : use for test code...
+                                               // TODO : use for test code...
 
-                       }
-               });
+                                       }
+                               });
        }
 
        public void setStartButtonToolTipText(final String text) {
@@ -456,15 +481,18 @@ public class ToolbarArea {
 
                        setToolbarStartStopState(true);
 
-                       if (null == DACommunicator.getDevices() || DACommunicator.getDevices().isEmpty()) {
+                       if (null == DACommunicator.getDevices()
+                                       || DACommunicator.getDevices().isEmpty()) {
                                deviceCombo.setEnabled(false);
                        }
 
-                       if (!deviceCombo.isEnabled() || null == GlobalInformation.getCurrentDeviceInfo()) {
+                       if (!deviceCombo.isEnabled()
+                                       || null == GlobalInformation.getCurrentDeviceInfo()) {
                                appCombo.setEnabled(false);
                        }
 
-                       if (!appCombo.isEnabled() || null == GlobalInformation.getCurrentApplication()) {
+                       if (!appCombo.isEnabled()
+                                       || null == GlobalInformation.getCurrentApplication()) {
                                setStartButtonEnablement(false);
                        }
 
@@ -479,7 +507,8 @@ public class ToolbarArea {
 
                        @Override
                        public void run() {
-                               StartProcessManager.getInstance().startProcessStart("prepare for tracing");
+                               StartProcessManager.getInstance().startProcessStart(
+                                               "prepare for tracing");
                        }
                });
 
@@ -506,8 +535,9 @@ public class ToolbarArea {
                /** which contains start, TimerClock, save, open and replay buttons. */
 
                // Creates start button.
-               startButton = new DACustomButton(parent, ImageResources.START, ImageResources.START_PUSH,
-                               ImageResources.START_HOVER, ImageResources.START_DISABLE);
+               startButton = new DACustomButton(parent, ImageResources.START,
+                               ImageResources.START_PUSH, ImageResources.START_HOVER,
+                               ImageResources.START_DISABLE);
                // startButton.setButtonEnabled(false);
                setStartButtonState(false);
                startButton.setToolTipText(ShortCutManager.START_TRACE);
@@ -519,16 +549,18 @@ public class ToolbarArea {
                timerClock.setClockFont(FontResources.TIMER);
 
                // // Creates save trace button.
-               saveTraceButton = new DACustomButton(parent, ImageResources.SAVE, ImageResources.SAVE_PUSH,
-                               ImageResources.SAVE_HOVER, ImageResources.SAVE_DISABLE);
+               saveTraceButton = new DACustomButton(parent, ImageResources.SAVE,
+                               ImageResources.SAVE_PUSH, ImageResources.SAVE_HOVER,
+                               ImageResources.SAVE_DISABLE);
                saveTraceButton.setButtonEnabled(false);
                saveTraceButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                saveTraceButton.setToolTipText(ShortCutManager.SAVE_TRACE);
                buttons.put(SAVE_BUTTON, saveTraceButton);
 
                // // Creates open trace button.
-               openTraceButton = new DACustomButton(parent, ImageResources.OPEN, ImageResources.OPEN_PUSH,
-                               ImageResources.OPEN_HOVER, ImageResources.OPEN_DISABLE);
+               openTraceButton = new DACustomButton(parent, ImageResources.OPEN,
+                               ImageResources.OPEN_PUSH, ImageResources.OPEN_HOVER,
+                               ImageResources.OPEN_DISABLE);
                openTraceButton.setToolTipText(ShortCutManager.OPEN_TRACE);
                openTraceButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(OPEN_BUTTON, openTraceButton);
@@ -542,42 +574,51 @@ public class ToolbarArea {
                buttons.put(REPLAY_BUTTON, replayButton);
 
                // Creates replayEdit button.
-               replayEditButton = new DACustomButton(parent, ImageResources.REPLAY_EDIT,
-                               ImageResources.REPLAY_EDIT_PUSH, ImageResources.REPLAY_EDIT_HOVER,
+               replayEditButton = new DACustomButton(parent,
+                               ImageResources.REPLAY_EDIT, ImageResources.REPLAY_EDIT_PUSH,
+                               ImageResources.REPLAY_EDIT_HOVER,
                                ImageResources.REPLAY_EDIT_DISABLE);
                replayEditButton.setToolTipText(ShortCutManager.REPLAY_EDIT);
                replayEditButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(REPLAY_EDIT_BUTTON, replayEditButton);
 
                // Creates config button
-               configButton = new DACustomButton(parent, ImageResources.SETTINGS_NORMAL,
-                               ImageResources.SETTINGS_PUSH, ImageResources.SETTINGS_HOVER,
-                               ImageResources.SETTINGS_DISABLE);
+               configButton = new DACustomButton(parent,
+                               ImageResources.SETTINGS_NORMAL, ImageResources.SETTINGS_PUSH,
+                               ImageResources.SETTINGS_HOVER, ImageResources.SETTINGS_DISABLE);
                configButton.setToolTipText(ShortCutManager.COOLBAR_AREA_SETTING);
                configButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(CONFIG_BUTTON, configButton);
 
                // Creates screenshot button
-               screenshotButton = new DACustomButton(parent, ImageResources.SCREEN_SHOT_NORMAL,
-                               ImageResources.SCREEN_SHOT_PUSH, ImageResources.SCREEN_SHOT_HOVER,
+               screenshotButton = new DACustomButton(parent,
+                               ImageResources.SCREEN_SHOT_NORMAL,
+                               ImageResources.SCREEN_SHOT_PUSH,
+                               ImageResources.SCREEN_SHOT_HOVER,
                                ImageResources.SCREEN_SHOT_DISABLE);
                screenshotButton.setToolTipText("Capture screen");
                screenshotButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(SCREENSHOT_BUTTON, screenshotButton);
 
                // Creates about button.
-               aboutButton = new DACustomButton(parent, ImageResources.ABOUT, ImageResources.ABOUT_PUSH,
-                               ImageResources.ABOUT_HOVER, ImageResources.ABOUT_DISABLE);
+               aboutButton = new DACustomButton(parent, ImageResources.ABOUT,
+                               ImageResources.ABOUT_PUSH, ImageResources.ABOUT_HOVER,
+                               ImageResources.ABOUT_DISABLE);
                aboutButton.setToolTipText(ShortCutManager.COOLBAR_AREA_ABOUT);
                aboutButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(ABOUT_BUTTON, aboutButton);
 
                // Creates view source button.
-               viewSourceButton = new DACustomToggleButton(parent, ImageResources.VIEW_SOURCE_NORMAL,
-                               ImageResources.VIEW_SOURCE_PUSH, ImageResources.VIEW_SOURCE_HOVER,
-                               ImageResources.VIEW_SOURCE_DISABLE, ImageResources.VIEW_SOURCE_TOGGLE,
-                               ImageResources.VIEW_SOURCE_TOGGLE_HOVER, ImageResources.VIEW_SOURCE_TOGGLE_PUSH);
-               viewSourceButton.setToolTipText(ShortCutManager.COOLBAR_AREA_VIEW_SOURCE);
+               viewSourceButton = new DACustomToggleButton(parent,
+                               ImageResources.VIEW_SOURCE_NORMAL,
+                               ImageResources.VIEW_SOURCE_PUSH,
+                               ImageResources.VIEW_SOURCE_HOVER,
+                               ImageResources.VIEW_SOURCE_DISABLE,
+                               ImageResources.VIEW_SOURCE_TOGGLE,
+                               ImageResources.VIEW_SOURCE_TOGGLE_HOVER,
+                               ImageResources.VIEW_SOURCE_TOGGLE_PUSH);
+               viewSourceButton
+                               .setToolTipText(ShortCutManager.COOLBAR_AREA_VIEW_SOURCE);
                viewSourceButton.setBackground(ColorResources.COOLBAR_BG_COLOR);
                buttons.put(SOURCE_BUTTON, viewSourceButton);
 
@@ -712,12 +753,17 @@ public class ToolbarArea {
 
        private DACustomCombo makeDACustomCombo(Composite parent) {
                DACustomCombo returnCombo = new DACustomCombo(parent, SWT.NONE);
-               returnCombo.setComboGradation(ColorResources.TOOLBAR_COMBO_NORMAL_START,
-                               ColorResources.TOOLBAR_COMBO_NORMAL_END, ColorResources.TOOLBAR_COMBO_PUSH_START,
-                               ColorResources.TOOLBAR_COMBO_PUSH_END, ColorResources.TOOLBAR_COMBO_HOVER_START,
-                               ColorResources.TOOLBAR_COMBO_HOVER_END, ColorResources.TOOLBAR_COMBO_DISABLE_START,
+               returnCombo.setComboGradation(
+                               ColorResources.TOOLBAR_COMBO_NORMAL_START,
+                               ColorResources.TOOLBAR_COMBO_NORMAL_END,
+                               ColorResources.TOOLBAR_COMBO_PUSH_START,
+                               ColorResources.TOOLBAR_COMBO_PUSH_END,
+                               ColorResources.TOOLBAR_COMBO_HOVER_START,
+                               ColorResources.TOOLBAR_COMBO_HOVER_END,
+                               ColorResources.TOOLBAR_COMBO_DISABLE_START,
                                ColorResources.TOOLBAR_COMBO_DISABLE_END);
-               returnCombo.setOutlineColors(ColorResources.TOOLBAR_COMBO_OUTLINE_NORMAL_IN_COLOR,
+               returnCombo.setOutlineColors(
+                               ColorResources.TOOLBAR_COMBO_OUTLINE_NORMAL_IN_COLOR,
                                ColorResources.TOOLBAR_COMBO_OUTLINE_PUSH_IN_COLOR,
                                ColorResources.TOOLBAR_COMBO_OUTLINE_HOVER_IN_COLOR,
                                ColorResources.TOOLBAR_COMBO_OUTLINE_DISABLE_IN_COLOR);
@@ -726,11 +772,13 @@ public class ToolbarArea {
                                ImageResources.TOOLBAR_COMBO_BUTTON_NORMAL,
                                ImageResources.TOOLBAR_COMBO_BUTTON_DISABLE);
                returnCombo.setComboImagePoint(new Point(130, 9));
-               returnCombo.setComboButtonColor(ColorResources.TOOLBAR_COMBO_BUTTON_NORMAL_COLOR,
+               returnCombo.setComboButtonColor(
+                               ColorResources.TOOLBAR_COMBO_BUTTON_NORMAL_COLOR,
                                ColorResources.TOOLBAR_COMBO_BUTTON_PUSH_COLOR,
                                ColorResources.TOOLBAR_COMBO_BUTTON_HOVER_COLOR,
                                ColorResources.TOOLBAR_COMBO_BUTTON_DISABLE_COLOR);
-               returnCombo.setArrowOutlineColors(ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR,
+               returnCombo.setArrowOutlineColors(
+                               ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR,
                                ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR,
                                ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR,
                                ColorResources.TOOLBAR_COMBO_ARROW_OUTLINE_COLOR);
@@ -740,7 +788,8 @@ public class ToolbarArea {
                returnCombo.setEnabled(true);
                returnCombo.setComboFont(FontResources.COMBO);
                returnCombo.setItemFont(FontResources.DROPDOWN);
-               returnCombo.setFontColors(ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR,
+               returnCombo.setFontColors(
+                               ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR,
                                ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR,
                                ColorResources.TOOLBAR_COMBO_FONT_NORMAL_COLOR,
                                ColorResources.TOOLBAR_COMBO_FONT_DISABLE_COLOR);
@@ -777,7 +826,8 @@ public class ToolbarArea {
                List<AppInfo> apps = addToAppComboFromTarget();
 
                if (apps != null && apps.size() > 0) {
-                       String appName = GlobalInformation.getCurrentDeviceInfo().getSelectedAppName();
+                       String appName = GlobalInformation.getCurrentDeviceInfo()
+                                       .getSelectedAppName();
                        if (null == appName) {
                                appCombo.select(0);
                                GlobalInformation.setCurrentApplication(apps.get(0));
@@ -792,8 +842,10 @@ public class ToolbarArea {
                                        GlobalInformation.setCurrentApplication(appInfo);
                                        GlobalInformation.getCurrentDeviceInfo().getCommunicator()
                                                        .onAppSelected(appInfo);
-                                       GlobalInformation.getCurrentDeviceInfo().setSelectedAppName(
-                                                       appInfo.getInfo(AppInfo.PROPERTY.LABEL.index));
+                                       GlobalInformation
+                                                       .getCurrentDeviceInfo()
+                                                       .setSelectedAppName(
+                                                                       appInfo.getInfo(AppInfo.PROPERTY.LABEL.index));
                                        // startButton.setButtonEnabled(true);
                                        setStartButtonState(true);
                                } else {
@@ -831,8 +883,8 @@ public class ToolbarArea {
                } else {
                        int size = items.size();
                        int selIndex = 0;
-                       String selDevice = GlobalInformation.getCurrentDeviceInfo().getIDevice()
-                                       .getSerialNumber();
+                       String selDevice = GlobalInformation.getCurrentDeviceInfo()
+                                       .getIDevice().getSerialNumber();
                        for (int i = 0; i < size; i++) {
                                deviceCombo.add(items.get(i));
                                if (items.get(i).equals(selDevice)) {
@@ -841,8 +893,8 @@ public class ToolbarArea {
                        }
 
                        deviceCombo.select(selIndex);
-                       GlobalInformation.setCurrentDeviceInfo(DACommunicator.getDeviceByName(items
-                                       .get(selIndex)));
+                       GlobalInformation.setCurrentDeviceInfo(DACommunicator
+                                       .getDeviceByName(items.get(selIndex)));
                        deviceCombo.setToolTipText(items.get(selIndex));
 
                        if (null == oldDevice || !oldDevice.equals(selDevice)) {
@@ -879,7 +931,8 @@ public class ToolbarArea {
                        for (AppInfo app : apps) {
                                String appid = app.getInfo(AppInfo.PROPERTY.APPID.index);
                                String pkgid = app.getInfo(AppInfo.PROPERTY.PACKAGE.index);
-                               if (appid.startsWith(pkgid) && !appid.contains(AnalyzerConstants.APPCONTROL)) {
+                               if (appid.startsWith(pkgid)
+                                               && !appid.contains(AnalyzerConstants.APPCONTROL)) {
                                        appcomboList.add(app);
                                }
                        }
@@ -894,7 +947,8 @@ public class ToolbarArea {
                AppInfo appInfo = DACommunicator.getPkgInfoByName(text);
                if (null != appInfo) {
                        GlobalInformation.setCurrentApplication(appInfo);
-                       GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(appInfo);
+                       GlobalInformation.getCurrentDeviceInfo().getCommunicator()
+                                       .onAppSelected(appInfo);
                        GlobalInformation.getCurrentDeviceInfo().setSelectedAppName(
                                        appInfo.getInfo(AppInfo.PROPERTY.LABEL.index));
                        Display.getDefault().syncExec(new Runnable() {
@@ -910,7 +964,8 @@ public class ToolbarArea {
                AppInfo appInfo = DACommunicator.getPkgInfoByAppPkgId(id);
                if (null != appInfo) {
                        GlobalInformation.setCurrentApplication(appInfo);
-                       GlobalInformation.getCurrentDeviceInfo().getCommunicator().onAppSelected(appInfo);
+                       GlobalInformation.getCurrentDeviceInfo().getCommunicator()
+                                       .onAppSelected(appInfo);
                        GlobalInformation.getCurrentDeviceInfo().setSelectedAppName(
                                        appInfo.getInfo(AppInfo.PROPERTY.LABEL.index));
                        appCombo.setText(appInfo.getInfo(AppInfo.PROPERTY.LABEL.index));
@@ -945,8 +1000,8 @@ public class ToolbarArea {
                                }
 
                                String text = deviceCombo.getText();
-                               String device = GlobalInformation.getCurrentDeviceInfo().getIDevice()
-                                               .getSerialNumber();
+                               String device = GlobalInformation.getCurrentDeviceInfo()
+                                               .getIDevice().getSerialNumber();
                                if (!device.equals(text)) {
                                        // startButton.setButtonEnabled(false);
                                        setStartButtonState(false);
@@ -988,12 +1043,14 @@ public class ToolbarArea {
 
        private void setStartButtonImagesToStop(boolean isStarted) {
                if (isStarted) {
-                       startButton.setImages(ImageResources.STOP, ImageResources.STOP_PUSH,
-                                       ImageResources.STOP_HOVER, ImageResources.START_DISABLE);
+                       startButton.setImages(ImageResources.STOP,
+                                       ImageResources.STOP_PUSH, ImageResources.STOP_HOVER,
+                                       ImageResources.START_DISABLE);
                        startButton.setToolTipText(ShortCutManager.STOP_TRACE);
                } else {
-                       startButton.setImages(ImageResources.START, ImageResources.START_PUSH,
-                                       ImageResources.START_HOVER, ImageResources.START_DISABLE);
+                       startButton.setImages(ImageResources.START,
+                                       ImageResources.START_PUSH, ImageResources.START_HOVER,
+                                       ImageResources.START_DISABLE);
                        startButton.setToolTipText(ShortCutManager.START_TRACE);
                }
        }