From e91130520ec1e89b8b0b69ec36715b33ee54fd44 Mon Sep 17 00:00:00 2001 From: jooyoul_lee Date: Tue, 22 Oct 2013 14:15:48 +0900 Subject: [PATCH] [Title] device connection and init fixed [Desc.] [Issue] - --- .../dynamicanalyzer/common/AnalyzerManager.java | 7 + .../communicator/BaseCommunicator.java | 5 +- .../communicator/Communicator22.java | 17 +- .../communicator/DACommunicator.java | 513 +++------------------ .../listeners/AnalyzerPerspectiveListener.java | 13 +- .../tizen/dynamicanalyzer/model/DeviceInfo.java | 23 + .../swap/communicator/Communicator30.java | 130 ++---- .../swap/logparser/MessageParser.java | 49 +- .../swap/logparser/SWAPLogParser.java | 60 ++- .../swap/model/RecordEventObject.java | 1 + .../swap/model/data/DataChannelConstants.java | 3 +- .../swap/model/data/ProcessInfo.java | 6 + .../swap/platform/ui/LoadSettingDialog.java | 2 +- .../swap/platform/ui/SaveSettingDialog.java | 1 + .../ui/info/callstack/CallStackUnit.java | 7 +- .../ui/toolbar/ConfigureManager.java | 5 +- .../dynamicanalyzer/ui/toolbar/ToolbarArea.java | 84 ++-- .../tizen/dynamicanalyzer/utils/AnalyzerUtil.java | 102 ++++ 18 files changed, 391 insertions(+), 637 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java index 749c852..09777d0 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java @@ -75,6 +75,8 @@ public class AnalyzerManager { private static List imageList = null; private static int imageListSize = 0; + private static HashMap funcNameMap = new HashMap(); + private static LeakDetector leakDetector = new LeakDetector(); private static FailedChecker failedChecker = new FailedChecker(); private static FailedChecker calledChecker = new FailedChecker(); @@ -198,6 +200,7 @@ public class AnalyzerManager { startBinaryAddr = -1; endBinaryAddr = -1; appInfoArrived = false; + funcNameMap.clear(); } public static List getImageList() { @@ -470,4 +473,8 @@ public class AnalyzerManager { isLogParsingComplete = complete; } + public static HashMap getFuncNameMap() { + return funcNameMap; + } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java index 3f6761f..111d93e 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java @@ -11,11 +11,12 @@ public abstract class BaseCommunicator { protected boolean blocked = false; - public abstract HostResult init(); + public abstract HostResult init(DeviceInfo deviceInfo); public abstract HostResult startTrace(); - public abstract HostResult sendRuntimeMessage(int type, String message); + public abstract HostResult sendRuntimeMessage(DeviceInfo devInfo, int type, + String message); public abstract HostResult stopTrace(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java index fbadbbc..096927e 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/Communicator22.java @@ -69,7 +69,7 @@ public class Communicator22 extends BaseCommunicator { private BufferedReader dataReader = null; @Override - public HostResult init() { + public HostResult init(DeviceInfo deviceInfo) { controlSock = null; dataSock = null; controlWriter = null; @@ -124,8 +124,9 @@ public class Communicator22 extends BaseCommunicator { } @Override - public HostResult sendRuntimeMessage(int type, String msg) { - long state = ConfigureManager.getInstance().getConfiguration(); + public HostResult sendRuntimeMessage(DeviceInfo devInfo, int type, + String msg) { + long state = ConfigureManager.getInstance().getConfiguration(devInfo); String statestr = Long.toString(state); String message = AnalyzerConstants.MSG_OPTION + CommonConstants.CMD_SPLIT + statestr.length() @@ -179,11 +180,15 @@ public class Communicator22 extends BaseCommunicator { if (null == DACommunicator.getSelectedApp()) { 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() + + ConfigureManager.getInstance().getConfiguration(device) + CommonConstants.CMD_SPLIT - + DACommunicator.getSelectedApp().getInfo(PackageInfo.EXEC_INDEX); + + DACommunicator.getSelectedApp().getInfo( + PackageInfo.EXEC_INDEX); String message = AnalyzerConstants.MSG_START + CommonConstants.CMD_SPLIT + rearMessage.length() diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java index 7b988e4..8c32978 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java @@ -62,11 +62,6 @@ public class DACommunicator { public static int MSG_TYPE_SWAP_INST = 1; public static int READ_BUFFER_SIZE = 1024; - private static BaseCommunicator communicator = null; - - private static Communicator22 communicator_211 = new Communicator22(); - private static Communicator30 communicator_30 = new Communicator30(); - private static SmartDevelopmentBridge sdbBridge = null; private static List packageInfoMultiLines = new ArrayList(); @@ -84,46 +79,30 @@ public class DACommunicator { private static boolean isRunning = false; - public static HostResult checkVersion() { - HostResult result = HostResult.SUCCESS; - DeviceInfo currentDevice = getSelectedDevice(); - if (null == currentDevice) { - return HostResult.ERR_DEVICE_IS_NULL; - } - String version = currentDevice.getTargetVersion(); - - if (version.contains(DA_VERSION_SWAP)) { - communicator = communicator_30; - } else if (version.contains(DA_VERSION_OLD)) { - communicator = communicator_211; - } else { - result = HostResult.ERR_INVALID_VERSION; - - // TODO : delete this temporary codes - communicator = communicator_211; - result = HostResult.SUCCESS; + public static void init(List devices) { + for (DeviceInfo device : devices) { + HostResult result = device.initCommunicator(); + if (!result.isSuccess()) { + System.out.println("init failed : " + + device.getIDevice().getSerialNumber()); + } } - return result; - } - - public static void init() { - communicator.init(); } public static HostResult startTrace() { - return communicator.startTrace(); + return currentDevice.getCommunicator().startTrace(); } public static HostResult sendRuntimeMessage(int type, String message) { - return communicator.sendRuntimeMessage(type, message); + return currentDevice.sendRuntimeMessage(type, message); } public static HostResult stopTrace() { - return communicator.stopTrace(); + return currentDevice.getCommunicator().stopTrace(); } public static void exit() { - communicator.exit(); + currentDevice.getCommunicator().exit(); } public static void reload() { @@ -162,17 +141,6 @@ public class DACommunicator { public static void setSelectedDevice(DeviceInfo device) { currentDevice = device; - // if (null != currentDevice) { - // String version = currentDevice.getTargetVersion(); - // if (version.equals(DA_VERSION_OLD)) { - // communicator = communicator_211; - // } else if (version.equals(DA_VERSION_SWAP)) { - // communicator = communicator_30; - // } else { - // // error - // System.out.println("not supported version"); - // } - // } } public static PackageInfo getSelectedApp() { @@ -181,8 +149,8 @@ public class DACommunicator { public static void setSelectedApp(PackageInfo app) { selectedApp = app; - if (null != app && null != communicator) { - communicator.setSelectedApp(app); + if (null != app && null != currentDevice) { + currentDevice.getCommunicator().setSelectedApp(app); } } @@ -204,29 +172,38 @@ public class DACommunicator { public static void loadDevices() { IDevice[] devices = null; - getDevices().clear(); + List devs = new ArrayList(); if (null != sdbBridge) { devices = sdbBridge.getDevices(); int size = devices.length; if (size > 0) { for (int i = 0; i < size; i++) { if (isOnline(devices[i])) { - addDevice(devices[i]); + DeviceInfo devInfo = new DeviceInfo(devices[i]); + HostResult result = readVersion(devInfo); + if (result.isSuccess()) { + devInfo.setTargetVersion(result.getMessage()); + devs.add(devInfo); + } } } } + if (!devs.isEmpty()) { + init(devs); + if (!getDevices().isEmpty()) { + setSelectedDevice(devs.get(0)); + } + } } else { System.out.println("sdbbridge is null!"); } } - private static void addDevice(IDevice device) { - DeviceInfo devInfo = new DeviceInfo(device); - HostResult result = readVersion(devInfo); - if (result.isSuccess()) { - System.out.println(result.toString()); - devices.add(devInfo); + public static IDevice[] getIDevices() { + if (null != sdbBridge) { + return sdbBridge.getDevices(); } + return null; } private static HostResult readVersion(DeviceInfo info) { @@ -246,7 +223,6 @@ public class DACommunicator { if (checkVersionResult.isEmpty()) { info.setTargetVersion(DA_VERSION_OLD); return HostResult.ERR_INVALID_VERSION; - // info.setTargetVersion(DA_VERSION_SWAP); } else { version = checkVersionResult.get(0); System.out.println("version :" + version); @@ -256,7 +232,6 @@ public class DACommunicator { } else { info.setTargetVersion(DA_VERSION_OLD); result = HostResult.SUCCESS; - // result = HostResult.ERR_INVALID_VERSION; } } @@ -266,24 +241,6 @@ public class DACommunicator { return result; } - // private static boolean isArch = false; - - // public static boolean isCurrentDeviceArmArch() { - // execShellCommand(AnalyzerShellCommands.CMD_IS_ARM_ARCH, - // new MultiLineReceiver() { - // @Override - // public void processNewLines(String[] lines) { - // if (lines[0].contains(CommonConstants.ARM_ARCH)) { - // isArch = true; - // } else { - // isArch = false; - // } - // } - // }); - // - // return isArch; - // } - protected static List getDevicesNameList() { List devNameList = null; if (null != sdbBridge) { @@ -493,273 +450,9 @@ public class DACommunicator { return null; } - // public static Socket createSocket(int port) { - // try { - // sock = new Socket(CommonConstants.LOCAL_HOST, port); - // if (null == sock) { - // System.out.println("failed to create a socket"); //$NON-NLS-1$ - // return null; - // } else { - // System.out.println("data socket create success!!"); - // } - // - // sock.setSoTimeout(AnalyzerConstants.SOCKET_TIMEOUT); - // sock.setReuseAddress(true); - // sock.setTcpNoDelay(true); - // - // reader = new BufferedReader(new InputStreamReader( - // sock.getInputStream())); - // writer = new BufferedWriter(new OutputStreamWriter( - // sock.getOutputStream())); - // - // new Thread(null, new ReceiveCommunicator(), - // AnalyzerConstants.COMMUNICATOR_RECEIVE_THREAD).start(); - // - // System.out.println("Receive Thread start"); - // } catch (SocketTimeoutException e) { - // System.out.println("socket timeout."); //$NON-NLS-1$ - // e.printStackTrace(); - // } catch (UnknownHostException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // - // return sock; - // } - - // public static Socket createControlSocket(int port) { - // try { - // - // controlSock = new Socket(CommonConstants.LOCAL_HOST, port); - // if (null == controlSock) { - // System.out.println("failed to create a control socket"); //$NON-NLS-1$ - // return null; - // } - // - // controlSock.setSoTimeout(AnalyzerConstants.SOCKET_TIMEOUT); - // controlSock.setReuseAddress(true); - // controlSock.setTcpNoDelay(true); - // - // controlReader = new BufferedReader(new InputStreamReader( - // controlSock.getInputStream())); - // controlWriter = new BufferedWriter(new OutputStreamWriter( - // controlSock.getOutputStream())); - // } catch (SocketTimeoutException e) { - // System.out.println("socket timeout."); //$NON-NLS-1$ - // e.printStackTrace(); - // } catch (UnknownHostException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // - // return controlSock; - // } - - // public static void closeSocket() { - // AnalyzerUtil.tryClose(reader, writer, sock, controlReader, - // controlWriter, controlSock); - // } - - // public static BufferedReader getSockBufferedReader() { - // return reader; - // } - - // public static BufferedWriter getSockBufferedWriter() { - // return writer; - // } - - // public static void foward(int local, int remote) { - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // currentDevice.getIDevice().createForward(local, remote); - // Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL); - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - // } - // } - - // public static void unfoward(int local, int remote) { - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // System.out.println("unfoward!!"); - // currentDevice.getIDevice().removeForward(local, remote); - // Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL); - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - // } - // } - - // public static void execShellCommand(String command) { - // execShellCommand(command, NullOutputReceiver.getInstance()); - // } - - // public static void execShellCommand(String command, - // IShellOutputReceiver receiver) { - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // currentDevice.getIDevice().executeShellCommand(command, - // receiver); - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (ShellCommandUnresponsiveException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // } - // } - - // public static Process execCommand(String command) { - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // return currentDevice.getIDevice().executeShellCommand(command, - // false); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // } - // - // return null; - // } - - // public static void sendMessage(String message) { - // try { - // if (null != sock) { - // writer.write(message); - // writer.flush(); - // } - // - // } catch (IOException e) { - // System.out.println(e.getMessage()); - // } - // } - - // public static String handleControlMessage(String message) { - // String result = null; - // try { - // if (null != controlSock && !controlSock.isClosed()) { - // controlWriter.write(message); - // controlWriter.flush(); - // } - // - // System.out.println("wait for ack... [send message : " + message - // + " ]"); - // while (isRunning) { - // char cbuf[] = new char[64]; - // blocked = true; - // int readsize = controlReader.read(cbuf); - // blocked = false; - // if (readsize > 0) { - // result = String.copyValueOf(cbuf, 0, readsize); - // if (null != result && !result.isEmpty()) { - // break; - // } - // } - // } - // } catch (SocketException e) { - // e.printStackTrace(); - // return null; - // } catch (SocketTimeoutException e) { - // e.printStackTrace(); - // return null; - // } catch (IOException e) { - // e.printStackTrace(); - // return null; - // } finally { - // blocked = false; - // } - // return result; - // } - - // public static SyncResult push(String local, String remote) { - // return push(local, remote, SyncService.getNullProgressMonitor()); - // } - - // public static SyncResult pull(String local, String remote) { - // return pull(local, remote, SyncService.getNullProgressMonitor()); - // } - - // public static SyncResult push(String local, String remote, - // ISyncProgressMonitor monitor) { - // SyncResult result = null; - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // SyncService service = currentDevice.getIDevice() - // .getSyncService(); - // if (null != service) { - // result = service.pushFile(local, remote, monitor); - // } - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // } - // - // return result; - // } - - // public static SyncResult pull(String remote, String local, - // ISyncProgressMonitor monitor) { - // SyncResult result = null; - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // SyncService service = currentDevice.getIDevice() - // .getSyncService(); - // if (null != service) { - // result = service.pullFile(remote, local, monitor); - // } - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // } - // - // return result; - // } - public static void removeCommand(String path) { CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_REMOVE + CommonConstants.SPACE + path); - // if (null != currentDevice && currentDevice.getIDevice().isOnline()) { - // try { - // currentDevice.getIDevice().executeShellCommand( - // AnalyzerShellCommands.CMD_REMOVE - // + CommonConstants.SPACE + path, - // NullOutputReceiver.getInstance()); - // } catch (TimeoutException e) { - // e.printStackTrace(); - // } catch (SdbCommandRejectedException e) { - // e.printStackTrace(); - // } catch (ShellCommandUnresponsiveException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // e.printStackTrace(); - // } - // } } public static boolean isTargetEmulator() { @@ -773,91 +466,6 @@ public class DACommunicator { return false; } - // private static boolean uploadFile(String source, String targetPath) { - // - // SyncResult result = push(source, targetPath); - // if (null == result || SyncService.RESULT_OK != result.getCode()) { - // System.out.println("upload to" + targetPath + " is failed! "); //$NON-NLS-1$ //$NON-NLS-2$ - // if (null != result) { - // System.out.println("Error : " + result.getMessage()); //$NON-NLS-1$ - // } else { - // System.out.println("push result is null!"); - // } - // return false; - // } - // return true; - // } - - // public static boolean uploadReadElf() { - // long readelfSize = -1; - // String readelf = AnalyzerPaths.READELF_PATH; - // - // if (isCurrentDeviceArmArch()) { - // readelf += CommonConstants.ARM_ARCH; - // } else { - // readelf += CommonConstants.X86_ARCH; - // } - // String source = readelf + File.separator - // + AnalyzerConstants.READELF_BIN; - // File file = new File(source); - // if (file.exists()) { - // readelfSize = file.length(); - // } else { - // System.out.println("upload error! file is not exist : " + source); //$NON-NLS-1$ - // return false; - // } - // if (!uploadFile(source, AnalyzerPaths.DA_REMOTE_PATH - // + AnalyzerConstants.READELF_BIN)) { - // return false; - // } - // - // // readelf - // long uploadSize = getReadelfSize(); - // if (uploadSize < 0) { - // return false; - // } - // if (readelfSize != uploadSize) { - // System.out.println("readelf file size is different!! "); //$NON-NLS-1$ - // return false; - // } - // return true; - // } - - // private static long getReadelfSize() { - // long ret = -1; - // getUploadDataResult().clear(); - // execShellCommand(AnalyzerShellCommands.CMD_UPLOAD_FILE_LIST, - // uploadDataReceiver); - // if (getUploadDataResult().isEmpty()) { - // return ret; - // } - // - // String duResult = getUploadDataResult().get(0); - // if (!duResult.contains("cannot access")) { - // String[] splitResult = duResult.split("\\/"); //$NON-NLS-1$ - // duResult = new String(splitResult[0].trim()); - // ret = Long.parseLong(duResult); - // } - // return ret; - // } - - // private static MultiLineReceiver uploadDataReceiver = new - // MultiLineReceiver() { - // @Override - // public void processNewLines(String[] appLines) { - // for (int i = 0; i < appLines.length; i++) { - // getUploadDataResult().add(appLines[i]); - // } - // } - // }; - - // private static List getUploadDataResult() { - // if (null == uploadDataResult) { - // uploadDataResult = new ArrayList(); - // } - // return uploadDataResult; - // } - public static void addDeviceListener() { SmartDevelopmentBridge.addDeviceChangeListener(deviceChanged); } @@ -884,7 +492,7 @@ public class DACommunicator { if (null != devices && !devices.isEmpty()) { devices.remove(deviceInfo); if (!AnalyzerManager.isRunning()) { - checkDevices(); + updateToolbarDevice(); } if (isRunning()) { if (selectedDevice.getIDevice().getSerialNumber() @@ -902,9 +510,14 @@ public class DACommunicator { // It called when dynamic-analyzer start, only one time System.out .println("device connected : " + device.getSerialNumber()); - addDevice(device); + // addDevice(device); if (!AnalyzerManager.isRunning()) { - checkDevices(); + DeviceInfo devInfo = new DeviceInfo(device); + HostResult result = readVersion(devInfo); + if (result.isSuccess()) { + devInfo.initCommunicator(); + updateToolbarDevice(); + } } if (null != getSelectedDevice() && null != getSelectedApp()) { Display.getDefault().syncExec(new Runnable() { @@ -924,9 +537,13 @@ public class DACommunicator { System.out.println("device changed : " + device.getSerialNumber() + " " + changeMask); if (1 == changeMask) { - addDevice(device); if (!AnalyzerManager.isRunning()) { - checkDevices(); + DeviceInfo devInfo = new DeviceInfo(device); + HostResult result = readVersion(devInfo); + if (result.isSuccess()) { + devInfo.initCommunicator(); + updateToolbarDevice(); + } } if (null != getSelectedDevice() && null != getSelectedApp()) { Display.getDefault().syncExec(new Runnable() { @@ -937,11 +554,13 @@ public class DACommunicator { } }); } + } else { + System.out.println("device changed type :" + changeMask); } } }; - public static void checkDevices() { + public static void updateToolbarDevice() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { @@ -963,7 +582,7 @@ public class DACommunicator { } else { clearDeviceAppInfo(); } - ToolbarArea.getInstance().setDeviceComboItems(deviceSerials); + ToolbarArea.getInstance().setDeviceComboItems(selectedDevice, deviceSerials); } }); } @@ -1033,53 +652,63 @@ public class DACommunicator { // } public static boolean isWaitControlMessage() { - return communicator.isBlocked(); + return currentDevice.getCommunicator().isBlocked(); } public static BufferedReader getSockBufferedReader() { - return communicator.getDataBufferedReader(); + return currentDevice.getCommunicator().getDataBufferedReader(); } public static void closeAll() { - communicator.clear(); + currentDevice.getCommunicator().clear(); } public static void closeSock() { - communicator.closeSock(); + currentDevice.getCommunicator().closeSock(); } public static HostResult handleControlMessage(String msg) { - return communicator.handleControlMessage(msg); + return currentDevice.getCommunicator().handleControlMessage(msg); } public static HostResult sendBinaryInfoMessageForLib() { if (isSWAPVersion()) { - return communicator_30.sendBinaryInfoMessageForLib(); + return ((Communicator30) currentDevice.getCommunicator()) + .sendBinaryInfoMessageForLib(); } return null; } public static HostResult sendSWAPMessage(int messageId) { if (isSWAPVersion()) { - return communicator_30.sendSWAPMessage(messageId); + return ((Communicator30) currentDevice.getCommunicator()) + .sendSWAPMessage(messageId); } return null; } - + public static HostResult sendKeepAliveMessage(DeviceInfo device) { - return communicator.sendKeepAliveMessage(device); + return device.getCommunicator().sendKeepAliveMessage(device); } public static Socket getDataSocket() { - return communicator.getDataSocket(); + return currentDevice.getCommunicator().getDataSocket(); } - public static String getTargetVersion() { - return currentDevice.getTargetVersion(); + public static String getTargetVersion(DeviceInfo device) { + return device.getTargetVersion(); } public static boolean isSWAPVersion() { - if (getTargetVersion().contains("3.0")) { + if (currentDevice.getTargetVersion().contains("3.0")) { + return true; + } else { + return false; + } + } + + public static boolean isSWAPVersion(DeviceInfo device) { + if (device.getTargetVersion().contains("3.0")) { return true; } else { return false; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/AnalyzerPerspectiveListener.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/AnalyzerPerspectiveListener.java index 50aa771..671cba2 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/AnalyzerPerspectiveListener.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/AnalyzerPerspectiveListener.java @@ -42,18 +42,11 @@ public class AnalyzerPerspectiveListener extends PerspectiveAdapter { if (!init) { ToolbarArea.getInstance().initToolbarEnablement(); DACommunicator.reload(); - DACommunicator.addDeviceListener(); DACommunicator.loadDevices(); - DACommunicator.checkDevices(); - if (DACommunicator.checkVersion().isSuccess()) { - DACommunicator.init(); - init = true; - System.out.println("DA device init complete!!"); - } else { - System.out.println("invalid version"); - // TODO: error popup and exit - } + DACommunicator.updateToolbarDevice(); + DACommunicator.setSelectedApp(DACommunicator.getSelectedApp()); + init = true; } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java index fdfeeee..de22adc 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceInfo.java @@ -30,8 +30,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.HostResult; +import org.tizen.dynamicanalyzer.communicator.BaseCommunicator; +import org.tizen.dynamicanalyzer.communicator.Communicator22; import org.tizen.dynamicanalyzer.communicator.CommunicatorUtils; import org.tizen.dynamicanalyzer.project.PackageInfo; +import org.tizen.dynamicanalyzer.swap.communicator.Communicator30; import org.tizen.dynamicanalyzer.swap.model.control.TargetInfo; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.sdblib.IDevice; @@ -40,6 +45,7 @@ public class DeviceInfo { private IDevice device; private String selectedApplication; private String targetVersion = null; + private BaseCommunicator communicator = null; private List appInfoList = null; private HashMap appInfoHash = null; @@ -82,6 +88,11 @@ public class DeviceInfo { public void setTargetVersion(String version) { targetVersion = version; + if (version.contains(AnalyzerConstants.DA_VERSION_SWAP)) { + communicator = new Communicator30(); + } else { + communicator = new Communicator22(); + } } public String getTargetVersion() { @@ -148,4 +159,16 @@ public class DeviceInfo { public void setApiList(List apiList) { this.apiList = apiList; } + + public HostResult initCommunicator() { + return communicator.init(this); + } + + public BaseCommunicator getCommunicator() { + return communicator; + } + + public HostResult sendRuntimeMessage(int type, String message) { + return communicator.sendRuntimeMessage(this, type, message); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java index 7188f69..1383f12 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java @@ -90,110 +90,69 @@ import org.tizen.sdblib.exception.TimeoutException; import org.tizen.sdblib.service.SyncResult; public class Communicator30 extends BaseCommunicator { - private boolean isInit = false; @Override - public HostResult init() { - if (isInit) { - return null; - } else { - isInit = true; - } + public HostResult init(DeviceInfo devInfo) { // daemon start - List devices = DACommunicator.getDevices(); - for (DeviceInfo devInfo : devices) { - Process ps = CommunicatorUtils.execCommand(devInfo.getIDevice(), - AnalyzerShellCommands.DACOMMAND_RUN_MANAGER); - System.out.println(ps.toString()); - } + // List devices = DACommunicator.getDevices(); + // for (DeviceInfo devInfo : devices) { + Process ps = CommunicatorUtils.execCommand(devInfo.getIDevice(), + AnalyzerShellCommands.DACOMMAND_RUN_MANAGER); + System.out.println(ps.toString()); + // } // get port - List removeList = new ArrayList(); - for (DeviceInfo devInfo : devices) { - int remotePort = CommunicatorUtils.getRemotePort(devInfo - .getIDevice()); - if (remotePort < 0) { + int remotePort = CommunicatorUtils.getRemotePort(devInfo.getIDevice()); + if (remotePort < 0) { + System.out.println(devInfo.getIDevice().getSerialNumber() + + " remote port get failed and remove this device : " + + devInfo.getIDevice().getSerialNumber()); + return HostResult.ERR_REMOTE_PORT_GET_FAILED; + } else { + devInfo.setRemotePort(remotePort); + // step 4. port foward + HostResult result = CommunicatorUtils.foward(devInfo.getIDevice(), + CommunicatorUtils.LOCAL_PORT, remotePort); + System.out.println(result.toString()); + if (!HostResult.SUCCESS.equals(result)) { System.out.println(devInfo.getIDevice().getSerialNumber() - + " remote port get failed and remove this device : " - + devInfo.getIDevice().getSerialNumber()); - removeList.add(devInfo); - } else { - devInfo.setRemotePort(remotePort); - // step 4. port foward - HostResult result = CommunicatorUtils.foward( - devInfo.getIDevice(), CommunicatorUtils.LOCAL_PORT, - remotePort); - System.out.println(result.toString()); - if (!HostResult.SUCCESS.equals(result)) { - System.out.println(devInfo.getIDevice().getSerialNumber() - + " port fowarding failed and remove this device"); - removeList.add(devInfo); - } + + " port fowarding failed and remove this device"); + return HostResult.ERR_REMOTE_PORT_GET_FAILED; } } - if (!removeList.isEmpty()) { - devices.removeAll(removeList); - removeList.clear(); - } - // port get failed popup - // create control socket - for (DeviceInfo devInfo : devices) { - HostResult result = createControlSocket(devInfo); + HostResult result = createControlSocket(devInfo); + if (!result.isSuccess()) { + System.out.println(result.toString()); + return HostResult.ERR_CONTROL_SOCKET_CREATION_FAIL; + } else { + result = createDataSocket(devInfo); if (!result.isSuccess()) { System.out.println(result.toString()); - removeList.add(devInfo); - } else { - result = createDataSocket(devInfo); - if (!result.isSuccess()) { - System.out.println(result.toString()); - // add control socket close - removeList.add(devInfo); - } + return HostResult.ERR_DATA_SOCKET_CREATION_FAIL; } } - // create data socket - not create data receive thread - - if (!removeList.isEmpty()) { - devices.removeAll(removeList); - removeList.clear(); - } - // target info get - for (DeviceInfo devInfo : devices) { - HostResult result = getTargetInfo(devInfo); - if (!result.isSuccess()) { - System.out.println(result.toString()); - removeList.add(devInfo); - } + result = getTargetInfo(devInfo); + if (!result.isSuccess()) { + System.out.println(result.toString()); + return HostResult.ERR_TARGET_INFO_GET_FAIL; } - if (!removeList.isEmpty()) { - devices.removeAll(removeList); - removeList.clear(); - } - - for (DeviceInfo devInfo : devices) { - HostResult result = sendRuntimeMessage(0, null); - if (!result.isSuccess()) { - System.out.println(result.toString()); - removeList.add(devInfo); - } + result = sendRuntimeMessage(devInfo, 0, null); + if (!result.isSuccess()) { + System.out.println(result.toString()); + return result; } - if (devices.isEmpty()) { - System.out.println("device init faiiled..."); - // TODO: close da - } + DACommunicator.getDevices().add(devInfo); - // heart beat thread start + /** heart beat thread start */ // Thread heartBeat = new Thread(null, new HeartBeatThread(), // AnalyzerConstants.HEART_BEAT_THREAD); // heartBeat.start(); // - - setSelectedApp(DACommunicator.getSelectedApp()); return HostResult.SUCCESS; } @@ -313,6 +272,7 @@ public class Communicator30 extends BaseCommunicator { System.out.println(); } appInst.setFunctionCount(size - exSize); + // appInst.setFunctionCount(0); output.getAppInstList().add(appInst); return output; } @@ -466,16 +426,16 @@ public class Communicator30 extends BaseCommunicator { } @Override - public HostResult sendRuntimeMessage(int type, String message) { + public HostResult sendRuntimeMessage(DeviceInfo devInfo, int type, + String message) { // send config message byte[] config = ByteUtils.toBytes(AnalyzerConstants.MSG_CONFIG); RunTimeConfiguration rt = new RunTimeConfiguration(); - rt.setFeatures(ConfigureManager.getInstance().getConfiguration()); + rt.setFeatures(ConfigureManager.getInstance().getConfiguration(devInfo)); byte[] rtByte = rt.getByteValue(); int length = rtByte.length; byte[] msg = ByteUtils.getByte(config, length, rtByte); - HostResult result = handleControlMessage( - DACommunicator.getSelectedDevice(), msg); + HostResult result = handleControlMessage(devInfo, msg); if (result.isSuccess()) { if (isCorrectAck(MSG_CONFIG_ACK, result)) { @@ -883,7 +843,7 @@ public class Communicator30 extends BaseCommunicator { functionInstList.add(functionInst); // for debug - System.out.print("DEBUG : addr "); + System.out.print("LIB : addr "); AnalyzerUtil.printHexdecimal(addrSymbol.getAddr()); System.out.print(" symbol " + addrSymbol.getSymbol() + " args "); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java index f9e5c2b..98ad8e2 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java @@ -28,7 +28,6 @@ package org.tizen.dynamicanalyzer.swap.logparser; import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.Socket; @@ -41,10 +40,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.eclipse.swt.widgets.Display; -import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; -import org.tizen.dynamicanalyzer.common.CommonConstants; -import org.tizen.dynamicanalyzer.communicator.CommunicatorUtils; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler; import org.tizen.dynamicanalyzer.handlers.StopHandler; @@ -60,7 +56,6 @@ 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.utils.AnalyzerUtil; -import org.tizen.sdblib.service.SyncResult; public class MessageParser { @@ -134,7 +129,6 @@ public class MessageParser { private void processProcessInfo(byte[] data) { HashMap processMap = AnalyzerManager.getProject() .getProcessInfoHash(); - int pid = 0; int ppid = 0; DATime processStartTime = new DATime(); @@ -170,18 +164,23 @@ public class MessageParser { } List libObjs = pInfo.getLibObjs(); + HashMap libHash = pInfo.getLibObjHash(); for (int i = 0; i < dependantLibCount; i++) { LibraryObject libObj = new LibraryObject(); + libObj.setPid(pid); long lowestAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; long highestAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; String libPath = ByteUtils.getString(data, index); + // remove \0 char + libPath = libPath.substring(0, libPath.length() -1); index += ByteUtils.getStringLength(data, index); libObj.setLowestAddress(lowestAddr); libObj.setHighestAddress(highestAddr); libObj.setLibPath(libPath); libObjs.add(libObj); + libHash.put(libPath, libObj); } DATime startTime = AnalyzerManager.getProject().getStartTime(); @@ -211,33 +210,6 @@ public class MessageParser { AnalyzerManager.setProcessInfoArrived(true); } - private String getImageName(String fullPath) { - String name = null; - name = fullPath - .substring(fullPath.lastIndexOf(CommonConstants.SLASH) + 1); - return name; - } - - private void processImage(final String from) { - final String fileName = getImageName(from); - final String to = AnalyzerManager.getProject().getSavePath() - + File.separator + AnalyzerConstants.IMAGE_FOLDER_NAME - + File.separator + fileName; - - new Thread(null, new Runnable() { - @Override - public void run() { - SyncResult res = CommunicatorUtils.pull(from, to); - if (null != res && res.isOk()) { - DACommunicator.removeCommand(from); - } else { - System.out.println("Failed to get '" + from + "' file"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - }, AnalyzerConstants.MESSAGE_INTERNAL_IMAGE_THREAD).start(); - - } - private void processTerminate() { if (!AnalyzerManager.isExit()) { Display.getDefault().syncExec(new Runnable() { @@ -287,12 +259,13 @@ public class MessageParser { // ByteUtils.printByteArray(header); int id = ByteUtils.toInt(header, 0); - int seq = ByteUtils.toInt(header, INT_SIZE); - // for debug - System.out.print("sequence : " + seq + " id :"); - AnalyzerUtil.printHexdecimal(id); - System.out.println(); + /** for debug */ +// int seq = ByteUtils.toInt(header, INT_SIZE); +// System.out.print("sequence : " + seq + " id :"); +// AnalyzerUtil.printHexdecimal(id); +// System.out.println(); + int payloadSize = ByteUtils.toInt(header, MSG_PAYLOAD_SIZE_INDEX); byte[] payload = null; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java index b135363..9278252 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java @@ -319,18 +319,35 @@ public class SWAPLogParser implements Runnable { } private void setFuncName(ProfileData input) { + + String functionName = ""; + + /** for debug */ +// System.out.println("set func name - profile data id : " + input.getId() +// + " pid : " + input.getPid()); +// if (input.getId() == DataChannelConstants.MSG_FUNCTION_ENTRY) { +// System.out.println("Function entry - type : " +// + input.getProbeType() + " subtype : " +// + input.getProbeSubType()); +// } + +// if (input.getId() == 0x0008 || input.getId() == 0x0009) { + functionName = AnalyzerUtil.getFuncName(input.getPid(), + input.getPcAddr()); +// } // boolean isPieBuild = AnalyzerManager.getProject().isPieBuild(); - boolean isPieBuild = (DACommunicator.getSelectedApp().getBinInfo() - .getType() == 1) ? true : false; - String baseAddr = Long.toString(AnalyzerManager.getProject() - .getBaseAddress(input.getPid())); - String highAddr = Long.toString(AnalyzerManager.getProject() - .getHighestAddress(input.getPid())); - String path = DACommunicator.getSelectedApp().getBinInfo() - .getLocalBinaryPath(); - String pcAddr = Long.toString(input.getPcAddr()); - String functionName = SymbolManager.addr2func(path, pcAddr, isPieBuild, - baseAddr); + // boolean isPieBuild = (DACommunicator.getSelectedApp().getBinInfo() + // .getType() == 1) ? true : false; + // String baseAddr = Long.toString(AnalyzerManager.getProject() + // .getBaseAddress(input.getPid())); + // String highAddr = Long.toString(AnalyzerManager.getProject() + // .getHighestAddress(input.getPid())); + // String path = DACommunicator.getSelectedApp().getBinInfo() + // .getLocalBinaryPath(); + // String pcAddr = Long.toString(input.getPcAddr()); + // String functionName = SymbolManager.addr2func(path, pcAddr, + // isPieBuild, + // baseAddr); /** debug code */ // if (input.getId() != 0x2006 && input.getProbeType() == 1) { @@ -358,16 +375,17 @@ public class SWAPLogParser implements Runnable { // System.out.println(" ]"); // } - if (null == functionName || functionName.isEmpty() - || functionName.equals("_end")) { //$NON-NLS-1$ - functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; - ApiNameManager.getApiId(functionName); - } else { - String prevFunctionName = functionName; - functionName = SymbolManager - .demanglingFunctionName(prevFunctionName); - ApiNameManager.getApiId(functionName); - } + // if (null == functionName || functionName.isEmpty() + // || functionName.equals("_end")) { //$NON-NLS-1$ + // functionName = + // InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; + // ApiNameManager.getApiId(functionName); + // } else { + // String prevFunctionName = functionName; + // functionName = SymbolManager + // .demanglingFunctionName(prevFunctionName); + // ApiNameManager.getApiId(functionName); + // } input.setApiName(functionName); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java index baa1041..f30cf29 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java @@ -113,4 +113,5 @@ public class RecordEventObject extends LogData { // TODO Auto-generated method stub return 0; } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/DataChannelConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/DataChannelConstants.java index f2b0cc4..b7ef1fa 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/DataChannelConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/DataChannelConstants.java @@ -33,7 +33,8 @@ public class DataChannelConstants { public final static int MSG_DATA_ERROR = 0x0003; public final static int MSG_DATA_SAMPLE = 0x0004; public final static int MSG_DATA_SYSTEM = 0x0005; - public final static int MSG_DATA_RECORD = 0x0006; + public final static int MSG_DATA_IMAGE = 0x0006; + public final static int MSG_DATA_RECORD = 0x0007; public final static int MSG_FUNCTION_ENTRY = 0x0008; public final static int MSG_FUNCTION_EXIT = 0x0009; public final static int MSG_CONTEXT_SWITCH_ENTRY = 0x0010; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProcessInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProcessInfo.java index 12b2c9c..ac043a9 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProcessInfo.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProcessInfo.java @@ -26,6 +26,7 @@ package org.tizen.dynamicanalyzer.swap.model.data; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.tizen.dynamicanalyzer.swap.model.DATime; @@ -39,6 +40,7 @@ public class ProcessInfo { private String binaryPath = null; private int depLibCount = 0; private List libObjs = new ArrayList(); + private HashMap libObjHash = new HashMap(); public int getPid() { return pid; @@ -100,4 +102,8 @@ public class ProcessInfo { return libObjs; } + public HashMap getLibObjHash() { + return libObjHash; + } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/LoadSettingDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/LoadSettingDialog.java index 9b92444..fa877d1 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/LoadSettingDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/LoadSettingDialog.java @@ -95,7 +95,7 @@ public class LoadSettingDialog extends DAMessageBox { protected boolean run() { shell.setLayout(new FormLayout()); shell.setSize(400, 204); - shell.setText(AnalyzerLabels.OPEN_TRACE_TITLE); + shell.setText("Load Binary Settings"); Composite tableComp = new Composite(shell, SWT.NONE); tableComp.setLayout(new FormLayout()); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/SaveSettingDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/SaveSettingDialog.java index 21667e9..5cc6c57 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/SaveSettingDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/SaveSettingDialog.java @@ -79,6 +79,7 @@ public class SaveSettingDialog extends DAMessageBox { shell.setLayout(new FormLayout()); shell.setSize(446, 127 + 22); shell.setBackground(ColorResources.DIALOG_BG_UPPER); + shell.setText("Save Binary Settings"); Label label = new Label(shell, SWT.TRANSPARENT); FormData data = new FormData(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackUnit.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackUnit.java index 8c60ab2..592da5e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackUnit.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackUnit.java @@ -86,9 +86,10 @@ public class CallStackUnit { .demanglingFunctionName(prevFunctionName); } } else { - if (DACommunicator.isDeviceConnected() - && path.equals(DACommunicator.getSelectedApp().getInfo( - PackageInfo.EXEC_INDEX)) && AnalyzerManager.isOsp()) { + PackageInfo selectedApp = DACommunicator.getSelectedApp(); + if (DACommunicator.isDeviceConnected() && null != selectedApp + && path.equals(selectedApp.getInfo(PackageInfo.EXEC_INDEX)) + && AnalyzerManager.isOsp()) { path += ".exe"; //$NON-NLS-1$ } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ConfigureManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ConfigureManager.java index 7078a42..7add40e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ConfigureManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ConfigureManager.java @@ -43,6 +43,7 @@ import org.tizen.dynamicanalyzer.common.AnalyzerPaths; import org.tizen.dynamicanalyzer.common.CommonConstants; import org.tizen.dynamicanalyzer.common.PathManager; import org.tizen.dynamicanalyzer.communicator.DACommunicator; +import org.tizen.dynamicanalyzer.model.DeviceInfo; import org.tizen.dynamicanalyzer.nl.ConfigureLabels; import org.tizen.dynamicanalyzer.nl.TimelineChartLabels; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; @@ -371,7 +372,7 @@ public class ConfigureManager { } } - public long getConfiguration() { + public long getConfiguration(DeviceInfo devInfo) { long state = 0; state |= getValueInt(ConfigureLabels.FEATURE_FUNCTION_PROFILING); @@ -383,7 +384,7 @@ public class ConfigureManager { state |= getValueInt(ConfigureLabels.FEATURE_USER_EVENT); state |= getValueInt(ConfigureLabels.FEATURE_RECORDING); - if (DACommunicator.isSWAPVersion()) { + if (DACommunicator.isSWAPVersion(devInfo)) { state |= getValueInt(ConfigureLabels.FEATURE_SYSCALL_FILE); state |= getValueInt(ConfigureLabels.FEATURE_SYSCALL_IPC); state |= getValueInt(ConfigureLabels.FEATURE_SYSCALL_PROCESS); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java index 1cfdd98..337db58 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java @@ -28,6 +28,7 @@ package org.tizen.dynamicanalyzer.ui.toolbar; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -74,6 +75,7 @@ import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton; import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo; import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboSelectionListener; import org.tizen.dynamicanalyzer.widgets.timer.TimerClock; +import org.tizen.sdblib.IDevice; public class ToolbarArea { @@ -265,20 +267,42 @@ public class ToolbarArea { @Override public void selectionEvent(DACustomCombo combo) { + String oldDevice = getSelectedDevice(); String serial = combo.getText(); - DACommunicator.setSelectedDeviceBySerial(serial); - setSelectedDevice(serial); - if (null != serial && !serial.isEmpty()) { - initAppCombo(); + if (!serial.equals(oldDevice)) { + DACommunicator.setSelectedDeviceBySerial(serial); + setSelectedDevice(serial); + if (null != serial && !serial.isEmpty()) { + initAppCombo(); + } + setRepalyButtonEnable(true); } - setRepalyButtonEnable(true); } }); deviceCombo.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { - DACommunicator.checkDevices(); + IDevice[] idevices = DACommunicator.getIDevices(); + List diffList = new ArrayList(); + List currentDevList = DACommunicator.getDevices(); + List serials = new ArrayList(); + for (DeviceInfo dev : currentDevList) { + serials.add(dev.getIDevice().getSerialNumber()); + } + + if (null != idevices) { + for (int i = 0; i < idevices.length; i++) { + int index = serials.indexOf(idevices[i] + .getSerialNumber()); + if (index < 0) { + diffList.add(idevices[i]); + } + } + } + if (!diffList.isEmpty()) { + DACommunicator.updateToolbarDevice(); + } } }); @@ -578,16 +602,18 @@ public class ToolbarArea { buttons.put(REPLAY_BUTTON, replayButton); // create binarySettingButton - binarySettingsButton = new DACustomButton(parent, ImageResources.SCREEN_SHOT_TOGGLE, - ImageResources.SCREEN_SHOT_TOGGLE_PUSH, ImageResources.SCREEN_SHOT_TOGGLE_HOVER, + binarySettingsButton = new DACustomButton(parent, + ImageResources.SCREEN_SHOT_TOGGLE, + ImageResources.SCREEN_SHOT_TOGGLE_PUSH, + ImageResources.SCREEN_SHOT_TOGGLE_HOVER, ImageResources.SCREEN_SHOT_DISABLE); binarySettingsButton.setToolTipText("Binary Settings"); buttons.put(SETTING_BUTTON, binarySettingsButton); - + // 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); buttons.put(CONFIG_BUTTON, configButton); @@ -612,16 +638,16 @@ public class ToolbarArea { buttons.put(SOURCE_BUTTON, viewSourceButton); // Creates snapshot on/off button. -// snapshotButton = new DACustomToggleButton(parent, -// ImageResources.SCREEN_SHOT_NORMAL, -// ImageResources.SCREEN_SHOT_PUSH, -// ImageResources.SCREEN_SHOT_HOVER, -// ImageResources.SCREEN_SHOT_DISABLE, -// ImageResources.SCREEN_SHOT_TOGGLE, -// ImageResources.SCREEN_SHOT_TOGGLE_HOVER, -// ImageResources.SCREEN_SHOT_TOGGLE_PUSH); -// snapshotButton.setToolTipText(AnalyzerLabels.SNAPSHOT_ENABLE); -// setSnapshotButtonEnablement(true); + // snapshotButton = new DACustomToggleButton(parent, + // ImageResources.SCREEN_SHOT_NORMAL, + // ImageResources.SCREEN_SHOT_PUSH, + // ImageResources.SCREEN_SHOT_HOVER, + // ImageResources.SCREEN_SHOT_DISABLE, + // ImageResources.SCREEN_SHOT_TOGGLE, + // ImageResources.SCREEN_SHOT_TOGGLE_HOVER, + // ImageResources.SCREEN_SHOT_TOGGLE_PUSH); + // snapshotButton.setToolTipText(AnalyzerLabels.SNAPSHOT_ENABLE); + // setSnapshotButtonEnablement(true); FormData data = new FormData(); data.top = new FormAttachment(0, 4); @@ -678,7 +704,7 @@ public class ToolbarArea { data.width = 34; // 31 data.height = 30; binarySettingsButton.setLayoutData(data); - + data = new FormData(); data.top = new FormAttachment(0, 4); data.right = new FormAttachment(binarySettingsButton, -5); @@ -842,7 +868,7 @@ public class ToolbarArea { saveTraceButton.setButtonEnabled(false); } - public void setDeviceComboItems(List items) { + public void setDeviceComboItems(String oldDevice, List items) { deviceCombo.initCombo(); if (null == items || items.isEmpty()) { deviceCombo.add(CommonConstants.EMPTY); @@ -855,21 +881,27 @@ public class ToolbarArea { } else { int size = items.size(); int selIndex = 0; - String selDevice = getSelectedDevice(); + String selDevice = DACommunicator.getSelectedDevice().getIDevice() + .getSerialNumber(); for (int i = 0; i < size; i++) { deviceCombo.add(items.get(i)); if (items.get(i).equals(selDevice)) { selIndex = i; } } + deviceCombo.select(selIndex); setSelectedDevice(items.get(selIndex)); deviceCombo.setToolTipText(items.get(selIndex)); - initAppCombo(); + + if (null == oldDevice || !oldDevice.equals(selDevice)) { + initAppCombo(); + } appCombo.setEnabled(true); setRepalyButtonEnable(true); setStartButtonEnablement(true); setSettingsButtonEnablement(true); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java index 7fae24b..194a028 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java @@ -68,17 +68,21 @@ import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.AnalyzerPaths; import org.tizen.dynamicanalyzer.common.CommonConstants; +import org.tizen.dynamicanalyzer.common.SymbolManager; import org.tizen.dynamicanalyzer.communicator.CommunicatorUtils; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.handlers.RealtimePerspectiveHandler; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.nl.InformationViewLabels; import org.tizen.dynamicanalyzer.swap.model.ByteUtils; import org.tizen.dynamicanalyzer.swap.model.control.BinaryInfo; import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager; import org.tizen.dynamicanalyzer.swap.model.data.DataChannelConstants; +import org.tizen.dynamicanalyzer.swap.model.data.LibraryObject; import org.tizen.dynamicanalyzer.swap.model.data.ProcessInfo; import org.tizen.dynamicanalyzer.swap.model.probe2.LogDataFactory; import org.tizen.dynamicanalyzer.swap.model.probe2.ProbeCommonData; +import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager; import org.tizen.dynamicanalyzer.ui.page.BaseView; import org.tizen.dynamicanalyzer.ui.page.DAPageComposite; import org.tizen.dynamicanalyzer.ui.page.ViewAction; @@ -1133,4 +1137,102 @@ public class AnalyzerUtil { } return false; } + + public static String getFuncName(int pid, long pcAddr) { + HashMap funcNameMap = AnalyzerManager.getFuncNameMap(); + String functionName = funcNameMap.get(pcAddr); + // if (null != functionName) { + // return functionName; + // } + + ProcessInfo processInfo = AnalyzerManager.getProject().getProcessInfo( + pid); + + + /** for debug */ +// String binPath1 = processInfo.getBinaryPath().substring(0, +// processInfo.getBinaryPath().length() - 1); +// System.out.print("binary : " + binPath1 + " ==> "); +// AnalyzerUtil.printHexdecimal(processInfo.getLowestAddress()); +// System.out.print(" < "); +// AnalyzerUtil.printHexdecimal(pcAddr); +// System.out.print(" < "); +// AnalyzerUtil.printHexdecimal(processInfo.getHighestAddress()); +// System.out.println(); + + if (pcAddr >= processInfo.getLowestAddress() + && pcAddr <= processInfo.getHighestAddress()) { + String baseAddr = Long.toString(processInfo.getLowestAddress()); + String pcStr = Long.toString(pcAddr); + BinaryInfo binInfo = DACommunicator.getSelectedApp().getBinInfo(); + String path = binInfo.getLocalBinaryPath(); + boolean isPieBuild = true; + if (binInfo.getType() != 1) { + isPieBuild = false; + } + functionName = SymbolManager.addr2func(path, pcStr, isPieBuild, + baseAddr); + } else { + HashMap binInfoMap = BinarySettingManager + .getInstance().getTargetBinInfoMap(); + List binPaths = new ArrayList(); + binPaths.addAll(binInfoMap.keySet()); + + HashMap libHash = processInfo + .getLibObjHash(); + LibraryObject libraryObject = null; + int size = binPaths.size(); + for (int i = 0; i < size; i++) { + String binPath = binPaths.get(i); + LibraryObject libObj = libHash.get(binPath); + if (null == libObj) { + continue; + } + long lowAddr = libObj.getLowestAddress(); + long highAddr = libObj.getHighestAddress(); + + /** for debug */ +// System.out.print("lib : " + binPath + " ==> "); +// AnalyzerUtil.printHexdecimal(lowAddr); +// System.out.print(" < "); +// AnalyzerUtil.printHexdecimal(pcAddr); +// System.out.print(" < "); +// AnalyzerUtil.printHexdecimal(highAddr); +// System.out.println(); + + if (pcAddr >= lowAddr && pcAddr <= highAddr) { + libraryObject = libObj; + break; + } + } + if (null != libraryObject) { + String path = libraryObject.getLibPath(); + BinaryInfo binInfo = binInfoMap.get(path); + if (null != binInfo) { + String baseAddr = Long.toString(libraryObject + .getLowestAddress()); + String pcStr = Long.toString(pcAddr); + boolean isPieBuild = true; + if (binInfo.getType() != 1) { + isPieBuild = false; + } + functionName = SymbolManager.addr2func(path, pcStr, + isPieBuild, baseAddr); + } + } + } + + if (null == functionName || functionName.isEmpty() + || functionName.equals("_end")) { //$NON-NLS-1$ + functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION; + ApiNameManager.getApiId(functionName); + } else { + String prevFunctionName = functionName; + functionName = SymbolManager + .demanglingFunctionName(prevFunctionName); + ApiNameManager.getApiId(functionName); + } + AnalyzerManager.getFuncNameMap().put(pcAddr, functionName); + return functionName; + } } -- 2.7.4