From c6dec20edc4db75fdf3ffd1fabb99211d619ab3f Mon Sep 17 00:00:00 2001 From: woojin Date: Mon, 7 Jul 2014 20:58:45 +0900 Subject: [PATCH] INTERNAL : drop LogData when it has corruped or wrong data During parsing LogData from target, if wrong data was found, then print error msg and drop the LogData. Fix typo. Change-Id: Iac5121378cccc44aee5182d175bc6951d26b1791 Signed-off-by: woojin --- .../org/tizen/dynamicanalyzer/common/AnalyzerManager.java | 2 +- .../tizen/dynamicanalyzer/swap/logparser/MessageParser.java | 2 +- .../dynamicanalyzer/swap/model/data/ContextSwitchData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/ControlData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/CustomData.java | 4 +++- .../org/tizen/dynamicanalyzer/swap/model/data/FileData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/GLES20LogData.java | 4 +++- .../org/tizen/dynamicanalyzer/swap/model/data/LogData.java | 4 +++- .../dynamicanalyzer/swap/model/data/LogDataFactory.java | 9 +++++++-- .../tizen/dynamicanalyzer/swap/model/data/MemoryData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/NetworkData.java | 4 +++- .../dynamicanalyzer/swap/model/data/ProbeCommonData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/ProfileData.java | 12 ++++++++++-- .../tizen/dynamicanalyzer/swap/model/data/ReplayData.java | 4 +++- .../org/tizen/dynamicanalyzer/swap/model/data/SceneData.java | 4 +++- .../dynamicanalyzer/swap/model/data/ScreenShotData.java | 4 +++- .../org/tizen/dynamicanalyzer/swap/model/data/SyncData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/SystemData.java | 5 +++-- .../tizen/dynamicanalyzer/swap/model/data/ThreadData.java | 4 +++- .../tizen/dynamicanalyzer/swap/model/data/UIEventData.java | 4 +++- .../dynamicanalyzer/swap/model/data/UserFunctionData.java | 4 +++- package/changelog | 4 ++++ package/pkginfo.manifest | 2 +- 23 files changed, 75 insertions(+), 25 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 0db2f1d..75b3385 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java @@ -375,7 +375,7 @@ public class AnalyzerManager { return processCount; } - public static synchronized void increseProcessCount() { + public static synchronized void increaseProcessCount() { processCount++; } 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 7950072..627573c 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 @@ -518,7 +518,7 @@ public class MessageParser { switch (id) { case DataChannelConstants.MSG_DATA_PROCESS_INFO: // setting process info - AnalyzerManager.increseProcessCount(); + AnalyzerManager.increaseProcessCount(); processProcessInfo(data); break; case DataChannelConstants.MSG_PROCESS_MAP: diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ContextSwitchData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ContextSwitchData.java index c9e2cb3..67ffb7a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ContextSwitchData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ContextSwitchData.java @@ -61,7 +61,7 @@ public class ContextSwitchData extends LogData { return log; } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); index = MessageParser.MSG_HEADER_SIZE; @@ -73,6 +73,8 @@ public class ContextSwitchData extends LogData { index += INT_SIZE; cpuNum = ByteUtil.toInt(data, index); index += INT_SIZE; + + return true; } public long getPcAddr() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ControlData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ControlData.java index a5c30a7..4bf9d9a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ControlData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ControlData.java @@ -44,7 +44,7 @@ public class ControlData extends ProbeCommonData { public ControlData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); int length = LogDataUtils.getStringLength(index, data); @@ -75,6 +75,8 @@ public class ControlData extends ProbeCommonData { index += length; childPointer = ByteUtil.toLong(data, index); + + return true; } public String getParentName() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/CustomData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/CustomData.java index 773110b..b34a223 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/CustomData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/CustomData.java @@ -43,7 +43,7 @@ public class CustomData extends ProbeCommonData { public CustomData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); handle = ByteUtil.toInt(data, index); @@ -62,6 +62,8 @@ public class CustomData extends ProbeCommonData { index += INT_SIZE; value = ByteUtil.toDouble(data, index); + + return true; } public int getHandle() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/FileData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/FileData.java index fe489e3..d52da40 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/FileData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/FileData.java @@ -85,7 +85,7 @@ public class FileData extends ProbeCommonData { public FileData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); size = ByteUtil.toLong(data, index); @@ -101,6 +101,8 @@ public class FileData extends ProbeCommonData { index += LONG_SIZE; filePath = LogDataUtils.getString(index, data); + + return true; } @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/GLES20LogData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/GLES20LogData.java index 1144507..e014e57 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/GLES20LogData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/GLES20LogData.java @@ -14,7 +14,7 @@ public class GLES20LogData extends ProbeCommonData { String contextValue = ""; @Override - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); glCurrentContextName = ByteUtil.toLong(data, index); index += CommonConstants.LONG_SIZE; @@ -29,6 +29,8 @@ public class GLES20LogData extends ProbeCommonData { byte[] temp = new byte[length]; System.arraycopy(data, index, temp, 0, length); contextValue = new String(temp); + + return true; } public long getCurrentContextName() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogData.java index 34a5fe9..0781901 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogData.java @@ -66,7 +66,7 @@ public abstract class LogData implements Cloneable { return log; } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { isSWAP = DACommunicator.isSWAPVersion(); id = ByteUtil.toInt(data, index); @@ -96,6 +96,8 @@ public abstract class LogData implements Cloneable { } index += INT_SIZE; // payload length field offset + + return true; } public int getKey() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataFactory.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataFactory.java index 536f803..a71659d 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataFactory.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataFactory.java @@ -127,6 +127,7 @@ public class LogDataFactory { } public static LogData createInstance(byte[] data) { + boolean result; int id = ByteUtil.toInt(data, 0); LogData output = null; @@ -201,8 +202,12 @@ public class LogDataFactory { default: return null; } - output.makeData(data); - return output; + result = output.makeData(data); + if (result == true) { + return output; + } else { // error occurred during parse LogData + return null; + } } public static LogData createInstance(ResultSet rs) throws SQLException { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/MemoryData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/MemoryData.java index f081079..2b4e737 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/MemoryData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/MemoryData.java @@ -42,7 +42,7 @@ public class MemoryData extends ProbeCommonData { public MemoryData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); size = ByteUtil.toInt(data, index); @@ -51,6 +51,8 @@ public class MemoryData extends ProbeCommonData { index += INT_SIZE; address = ByteUtil.toLong(data, index); + + return true; } public long getSize() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/NetworkData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/NetworkData.java index a808b38..94d0b6c 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/NetworkData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/NetworkData.java @@ -64,7 +64,7 @@ public class NetworkData extends ProbeCommonData { public NetworkData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); objectAddress = ByteUtil.toLong(data, index); @@ -87,6 +87,8 @@ public class NetworkData extends ProbeCommonData { if (messageSize > 0) { packetMessage = LogDataUtils.getString(index, data); } + + return true; } public static String intToIp(int integerIP) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProbeCommonData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProbeCommonData.java index df03317..6677323 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProbeCommonData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProbeCommonData.java @@ -78,7 +78,7 @@ public class ProbeCommonData extends LogData { } @Override - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); index = MessageParser.MSG_HEADER_SIZE; @@ -129,6 +129,8 @@ public class ProbeCommonData extends LogData { } // System.out.println("lib name : " + libName); } + + return true; } public int getApiId() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProfileData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProfileData.java index 51074ae..1fdc5ed 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProfileData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ProfileData.java @@ -43,9 +43,10 @@ import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo; import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfo; import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfoPackage; import org.tizen.dynamicanalyzer.util.ByteUtil; +import org.tizen.dynamicanalyzer.util.DALogger; public class ProfileData extends LogData { - + private static final DALogger DA_LOG = DALogger.getInstance(); public static int logCount = 0; long pcAddr = 0; // profiling common long callerPcAddr = 0; // function entry specific @@ -109,7 +110,7 @@ public class ProfileData extends LogData { return log; } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); switch (id) { case MSG_FUNCTION_ENTRY: @@ -182,6 +183,11 @@ public class ProfileData extends LogData { ProcessInfoPackage processInfoPkg = AnalyzerManager.getProject() .getProcessInfoPackage(pid); + if (null == processInfoPkg) { + DA_LOG.error("ProfileData of type: " + id + " is from wrong process: " + pid + "\n"); + return false; + } + //TODO: handling negative time value in LogData.makeData if (time > 0) { ProcessInfo processInfo = processInfoPkg.getProcessInfo(time); BinaryInfo binInfo = processInfo.getTargetBinary(pcAddr); @@ -192,6 +198,8 @@ public class ProfileData extends LogData { } // System.out.println("plib name : " + libName); } + + return true; } public long getPcAddr() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ReplayData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ReplayData.java index edf67a6..0ff3e0e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ReplayData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ReplayData.java @@ -45,7 +45,7 @@ public class ReplayData extends LogData { public ReplayData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { // super.makeData(data); isSWAP = DACommunicator.isSWAPVersion(); @@ -115,6 +115,8 @@ public class ReplayData extends LogData { getRecordEvent().add(recordObj); } + + return true; } public int getObjectCount() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SceneData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SceneData.java index e58fd0b..7e8d59e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SceneData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SceneData.java @@ -45,7 +45,7 @@ public class SceneData extends ProbeCommonData { public SceneData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); int length = LogDataUtils.getStringLength(index, data); @@ -76,6 +76,8 @@ public class SceneData extends ProbeCommonData { index += INT_SIZE; userTransitionTime = ByteUtil.toInt(data, index); + + return true; } public String getSceneName() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ScreenShotData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ScreenShotData.java index 3afbd7e..ef9271e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ScreenShotData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ScreenShotData.java @@ -36,13 +36,15 @@ public class ScreenShotData extends ProbeCommonData { int orientation = 0; public ScreenShotData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); imageFilePath = ByteUtil.getString(data, index); index += ByteUtil.getStringLength(data, index); orientation = ByteUtil.toInt(data, index); + + return true; } public String getImageFilePath() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SyncData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SyncData.java index a204c71..27c2566 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SyncData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SyncData.java @@ -41,7 +41,7 @@ public class SyncData extends ProbeCommonData { public SyncData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); syncValue = ByteUtil.toLong(data, index); @@ -51,6 +51,8 @@ public class SyncData extends ProbeCommonData { index += INT_SIZE; apiType = ByteUtil.toInt(data, index); + + return true; } public long getSyncValue() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SystemData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SystemData.java index fac1653..a8024b0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SystemData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/SystemData.java @@ -77,7 +77,7 @@ public class SystemData extends LogData { public SystemData() { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); // index = MessageParser.MSG_HEADER_SIZE; int coreCount = AnalyzerManager.getProject().getDeviceStatusInfo() @@ -179,7 +179,8 @@ public class SystemData extends LogData { applicationEnergyUsage = parseUsage(index, data); index += (INT_SIZE * deviceCount); - + + return true; } private static String parseLoad(int start, byte[] payload) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ThreadData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ThreadData.java index 51a965d..3bc9bdd 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ThreadData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/ThreadData.java @@ -43,7 +43,7 @@ public class ThreadData extends ProbeCommonData { public ThreadData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); pThreadId = ByteUtil.toLong(data, index); @@ -59,6 +59,8 @@ public class ThreadData extends ProbeCommonData { index += INT_SIZE; className = ByteUtil.getString(data, index); + + return true; } public long getPThreadId() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UIEventData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UIEventData.java index 7d53a89..0737554 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UIEventData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UIEventData.java @@ -44,7 +44,7 @@ public class UIEventData extends ProbeCommonData { public UIEventData(){} - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); eventType = ByteUtil.toInt(data, index); @@ -63,6 +63,8 @@ public class UIEventData extends ProbeCommonData { index += ByteUtil.getStringLength(data, index); info2 = ByteUtil.toInt(data, index); + + return true; } public int getEventType() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UserFunctionData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UserFunctionData.java index 4fff976..4ad3afb 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UserFunctionData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/UserFunctionData.java @@ -46,7 +46,7 @@ public class UserFunctionData extends ProbeCommonData { } - public void makeData(byte[] data) { + public boolean makeData(byte[] data) { super.makeData(data); lowPc = ByteUtil.toLong(data, index); index += LONG_SIZE; @@ -61,6 +61,8 @@ public class UserFunctionData extends ProbeCommonData { index += LONG_SIZE; pcAddr = ByteUtil.toLong(data, index); + + return true; } public long getLowPc() { diff --git a/package/changelog b/package/changelog index 97d17e7..7c339fc 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,7 @@ +* 2.1.41 +- bug fix in communicator for windows, macos +- drop LogData when it has corrupted data +== woojin jung 2014-07-07 * 2.1.40 - Source link support for CoreApp - Remove apps within one package diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 5dc498f..e7c93f7 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Source:dynamic-analyzer -Version:2.1.40 +Version:2.1.41 Maintainer:Jaewon Lim , Juyoung Kim Package:dynamic-analyzer-product -- 2.7.4