From: jooyoul_lee Date: Tue, 5 Nov 2013 07:41:16 +0000 (+0900) Subject: [Title] process map message applied X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a402c07ec66fce7d32ef5eccc59521535f1c5e48;p=sdk%2Ftools%2Fdynamic-analyzer.git [Title] process map message applied [Desc.] process map chage snapshot applied [Issue] --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java index 96c69f5..f168d21 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java @@ -70,7 +70,7 @@ public class SWAPCallStackManager extends BaseCallstackManager { int seq = log.getSeq(); int tid = log.getTid(); - long time = log.getTime(); + long time = log.getTime(); long selfAddr = log.getPcAddr(); long callerAddr = log.getCallerPcAddr(); @@ -94,7 +94,7 @@ public class SWAPCallStackManager extends BaseCallstackManager { List userCallstack = getUserCallstack(tid); int size = userCallstack.size(); TreeMap seqByTimeMap = getSeqTimeByTidMap(tid); - + CallStackUnit callerCallstackUnit = addrMap.get(callerAddr); if (null == callerCallstackUnit) { String strCallerFuncName = SymbolManager.addr2func(sourceBinPath, @@ -149,29 +149,33 @@ public class SWAPCallStackManager extends BaseCallstackManager { } else { CallStackUnit callerCsa = addrMap.get(callerAddr); if (null == callerCsa) { - callerCsa = userCallstack.get(size - 1).getCallStackUnit(); + callerCsa = userCallstack.get(size - 1) + .getCallStackUnit(); callerCsa.setFunctionStartAddr(callerCsa.getAddr()); callerCsa.setAddr(callerAddr); } else { - callerCsa.setFunctionStartAddr(userCallstack.get( - size - 1).getCallStackUnit().getAddr()); - userCallstack.set(size - 1, new CallStackItem(callerCsa)); + callerCsa.setFunctionStartAddr(userCallstack + .get(size - 1).getCallStackUnit().getAddr()); + userCallstack.set(size - 1, + new CallStackItem(callerCsa)); } } userCallstack.add(new CallStackItem(selfCallstackUnit, time)); } size = userCallstack.size(); for (int i = size - 1; i >= 0; i--) { - callstackData.getAddrs().add(userCallstack.get(i).getCallStackUnit().getAddr()); + callstackData.getAddrs().add( + userCallstack.get(i).getCallStackUnit().getAddr()); } getCallStackDataBySeqMap().put(seq, callstackData); - seqByTimeMap.put(time, seq); + seqByTimeMap.put(time, seq); } else if (eventType == MSG_FUNCTION_EXIT) { if (size == 0) { // this case only range profiling, other time is bug return; } - CallStackUnit removeCallStackUnit = userCallstack.get(size - 1).getCallStackUnit(); + CallStackUnit removeCallStackUnit = userCallstack.get(size - 1) + .getCallStackUnit(); if (selfCallstackUnit.getFunctionName().equals( removeCallStackUnit.getFunctionName())) { userCallstack.remove(size - 1); @@ -179,7 +183,8 @@ public class SWAPCallStackManager extends BaseCallstackManager { if (callerCallstackUnit.getFunctionName().contains( AnalyzerConstants.VIRTUAL_THUNK)) { if (callerCallstackUnit.getFunctionName().equals( - userCallstack.get(size - 2).getCallStackUnit().getFunctionName())) { + userCallstack.get(size - 2).getCallStackUnit() + .getFunctionName())) { userCallstack.remove(size - 2); } else { System.out @@ -190,8 +195,8 @@ public class SWAPCallStackManager extends BaseCallstackManager { } size = userCallstack.size(); if (size - 1 > 0) { - CallStackUnit checkCallStackUnit = userCallstack - .get(size - 1).getCallStackUnit(); + CallStackUnit checkCallStackUnit = userCallstack.get( + size - 1).getCallStackUnit(); if (checkCallStackUnit.getFunctionName().equals( LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC)) { userCallstack.remove(size - 1); @@ -199,28 +204,30 @@ public class SWAPCallStackManager extends BaseCallstackManager { } size = userCallstack.size(); if (size > 0) { - CallStackUnit prevCallstackUnit = userCallstack - .get(size - 1).getCallStackUnit(); + CallStackUnit prevCallstackUnit = userCallstack.get( + size - 1).getCallStackUnit(); long prevSelfAddr = prevCallstackUnit .getFunctionStartAddr(); CallStackUnit callerCsa = addrMap.get(prevSelfAddr); if (null == callerCsa) { prevCallstackUnit.setAddr(prevSelfAddr); } else { - userCallstack.set(size - 1, new CallStackItem(callerCsa)); + userCallstack.set(size - 1, + new CallStackItem(callerCsa)); } } for (int i = size - 1; i >= 0; i--) { - callstackData.getAddrs().add(userCallstack.get(i).getCallStackUnit().getAddr()); + callstackData.getAddrs().add( + userCallstack.get(i).getCallStackUnit().getAddr()); } getCallStackDataBySeqMap().put(seq, callstackData); - seqByTimeMap.put(time, seq); + seqByTimeMap.put(time, seq); } else { System.out .println("makeUserCallstack : EXIT self is not the same as top of user callstack"); } if (AnalyzerManager.isOsp()) { - // String apiName = input[LogCenterConstants.APINAME_INDEX]; + // String apiName = input[LogCenterConstants.APINAME_INDEX]; String apiName = log.getApiName(); if (apiName.equals("OspMain")) { //$NON-NLS-1$ SWAPLogParser.setDropCallTraceLog(true); @@ -326,10 +333,12 @@ public class SWAPCallStackManager extends BaseCallstackManager { addrMap.put(callerAddr, callerCallstackUnit); } - CallStackUnit topUserCallstack = probeCallstack.get(size - 1).getCallStackUnit(); + CallStackUnit topUserCallstack = probeCallstack.get(size - 1) + .getCallStackUnit(); if (callerCallstackUnit.getFunctionName().equals( topUserCallstack.getFunctionName())) { - probeCallstack.set(size - 1, new CallStackItem(callerCallstackUnit)); + probeCallstack.set(size - 1, new CallStackItem( + callerCallstackUnit)); } else { System.out .println("bug : probe caller is not the same as top of user callstack"); //$NON-NLS-1$ @@ -338,7 +347,8 @@ public class SWAPCallStackManager extends BaseCallstackManager { size = probeCallstack.size(); for (int i = size - 1; i >= 0; i--) { - callstackData.getAddrs().add(probeCallstack.get(i).getCallStackUnit().getAddr()); + callstackData.getAddrs().add( + probeCallstack.get(i).getCallStackUnit().getAddr()); } getCallStackDataBySeqMap().put(seq, callstackData); @@ -383,7 +393,8 @@ public class SWAPCallStackManager extends BaseCallstackManager { int eventType = input.getId(); if (size > 0) { if (eventType == MSG_FUNCTION_ENTRY) { - CallStackUnit topCallstackUnit = userCallstack.get(size - 1).getCallStackUnit(); + CallStackUnit topCallstackUnit = userCallstack.get(size - 1) + .getCallStackUnit(); if (topCallstackUnit.equals(selfCallstackUnit)) { DuplicateUserCall dupUserCall = dupUserCallMap.get(tid); if (null == dupUserCall) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/DataChannelConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/DataChannelConstants.java index 5febf7e..b0914d0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/DataChannelConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/DataChannelConstants.java @@ -39,6 +39,8 @@ public class DataChannelConstants { public final static int MSG_FUNCTION_EXIT = 0x0009; public final static int MSG_CONTEXT_SWITCH_ENTRY = 0x0010; public final static int MSG_CONTEXT_SWITCH_EXIT = 0x0011; + public final static int MSG_PROCESS_MAP = 0x0012; + public final static int MSG_PROCESS_UNMAP = 0x0013; public final static int MSG_PROBE_MEMORY = 0x0101; public final static int MSG_PROBE_UICONTROL = 0x0102; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/ProcessInfoPackage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/ProcessInfoPackage.java index d1082a0..e53201a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/ProcessInfoPackage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/data/ProcessInfoPackage.java @@ -67,4 +67,9 @@ public class ProcessInfoPackage { return (sec * 1000000 + nano / 1000); } + + public ProcessInfo getBaseProcessInfo() + { + return processSnapshots.get(0); + } } 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 5cff06c..0e25f73 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 @@ -54,10 +54,12 @@ import org.tizen.dynamicanalyzer.swap.model.ByteUtils; import org.tizen.dynamicanalyzer.swap.model.DATime; import org.tizen.dynamicanalyzer.swap.model.data.LogData; import org.tizen.dynamicanalyzer.swap.model.data.LogDataFactory; +import org.tizen.dynamicanalyzer.swap.model.data.LogDataUtils; 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.dynamicanalyzer.widgets.chart.DAChart; public class MessageParser { @@ -175,7 +177,7 @@ public class MessageParser { List libObjs = pInfo.getLibObjs(); HashMap libHash = pInfo.getLibObjHash(); - System.out.println("LIBCOUNT :: " + dependantLibCount); + System.out.println("LIBCOUNT :: " + dependantLibCount); for (int i = 0; i < dependantLibCount; i++) { LibraryObject libObj = new LibraryObject(); libObj.setPid(pid); @@ -192,8 +194,9 @@ public class MessageParser { libObj.setLibPath(libPath); libObjs.add(libObj); libHash.put(libPath, libObj); - System.out.println("LIBPATH :: (" + i + ") " + libPath + - "low : " + AnalyzerUtil.toHexdecimal(lowestAddr) + " high : " + AnalyzerUtil.toHexdecimal(highestAddr)); + System.out.println("LIBPATH :: (" + i + ") " + libPath + "low : " + + AnalyzerUtil.toHexdecimal(lowestAddr) + " high : " + + AnalyzerUtil.toHexdecimal(highestAddr)); } DATime startTime = AnalyzerManager.getProject().getProfileStartTime(); @@ -225,14 +228,122 @@ public class MessageParser { pInfo.setDepLibCount(dependantLibCount); // User Call Trace : App is Tizen C++ or Tizen native - String applicationType = DACommunicator.getSelectedApp().getInfo(PackageInfo.APPTYPE_INDEX); - if(applicationType.contains(PackageInfo.APPTYPE_CPP)) { + String applicationType = DACommunicator.getSelectedApp().getInfo( + PackageInfo.APPTYPE_INDEX); + if (applicationType.contains(PackageInfo.APPTYPE_CPP)) { SWAPLogParser.setDropCallTraceLog(true); } - + AnalyzerManager.setProcessInfoArrived(true); } + private void memoryMapChanged(byte[] data) { + HashMap processPkgMap = AnalyzerManager + .getProject().getProcessInfoPackHash(); + + /** parsing */ + int index = 0; + int id = ByteUtils.toInt(data, index); + index += INT_SIZE; + int seq = ByteUtils.toInt(data, index); + index += INT_SIZE; + DATime changeTime = new DATime(); + int sec = ByteUtils.toInt(data, index); + index += INT_SIZE; + int nano = ByteUtils.toInt(data, index); + index += INT_SIZE; + changeTime.setSec(sec); + changeTime.setNano(nano); + + int length = ByteUtils.toInt(data, index); + index += INT_SIZE; + + int pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + + long lowAddr = 0; + long highAddr = 0; + + if (id == DataChannelConstants.MSG_PROCESS_MAP) { + lowAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + highAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + } + String libPath = LogDataUtils.getString(index, data); + index += LogDataUtils.getStringLength(index, data); + + if (id == DataChannelConstants.MSG_PROCESS_MAP) { + + } else { + + } + + ProcessInfoPackage pInfoPack = processPkgMap.get(pid); + if (null == pInfoPack) { + // bug!!! + System.out.println("bug occurred!!"); + } + ProcessInfo baseProcessInfo = pInfoPack.getBaseProcessInfo(); + ProcessInfo pInfo = new ProcessInfo(); + pInfo.setPid(pid); + pInfo.setPpid(baseProcessInfo.getPpid()); + pInfo.setStartTime(baseProcessInfo.getStartTime()); + pInfo.setMainTargetBinaryPath(baseProcessInfo.getMainTargetBinaryPath()); + pInfo.getLibObjs().addAll(baseProcessInfo.getLibObjs()); + pInfo.getLibObjHash().putAll(baseProcessInfo.getLibObjHash()); + pInfo.setLowestAddress(baseProcessInfo.getLowestAddress()); + pInfo.setHighestAddress(baseProcessInfo.getHighestAddress()); + + pInfoPack.getProcessSnapshots().add(pInfo); + + List libObjs = pInfo.getLibObjs(); + + if (id == DataChannelConstants.MSG_PROCESS_MAP) { + LibraryObject libObj = new LibraryObject(); + libObj.setHighestAddress(highAddr); + libObj.setLowestAddress(lowAddr); + libObj.setPid(pid); + libObj.setLibPath(libPath); + pInfo.getLibObjs().add(libObj); + pInfo.setDepLibCount(pInfo.getLibObjs().size()); + pInfo.getLibObjHash().put(libPath, libObj); + + // log + System.out.println("MAP CHANGED MAP " + + AnalyzerUtil.toHexdecimal(id) + " libPath : " + libPath + + " low : " + AnalyzerUtil.toHexdecimal(lowAddr) + + " high: " + AnalyzerUtil.toHexdecimal(highAddr)); + } else { + System.out.println("MAP CHANGED UNMAP " + + AnalyzerUtil.toHexdecimal(id) + " libPath : " + libPath + + " low : " + AnalyzerUtil.toHexdecimal(lowAddr) + + " high: " + AnalyzerUtil.toHexdecimal(highAddr)); + + int size = libObjs.size(); + for (int i = 0; i < size; i++) { + LibraryObject libObj = libObjs.get(i); + long low = libObj.getLowestAddress(); + long high = libObj.getHighestAddress(); + if (low <= lowAddr && high >= highAddr) { + libObjs.remove(libObj); + pInfo.getLibObjHash().remove(libObj.getLibPath()); + + System.out.println("LIB UNMAP : " + + libObj.getLibPath() + + " low : " + + AnalyzerUtil.toHexdecimal(libObj + .getLowestAddress()) + + " high: " + + AnalyzerUtil.toHexdecimal(libObj + .getHighestAddress())); + break; + } + } + pInfo.setDepLibCount(libObjs.size()); + } + } + private void processTerminate() { if (!AnalyzerManager.isExit()) { Display.getDefault().syncExec(new Runnable() { @@ -384,6 +495,10 @@ public class MessageParser { // setting process info processProcessInfo(data); break; + case DataChannelConstants.MSG_PROCESS_MAP: + case DataChannelConstants.MSG_PROCESS_UNMAP: + memoryMapChanged(data); + break; case DataChannelConstants.MSG_DATA_TERMINATE: processTerminate(); break; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataUtils.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataUtils.java index 97ee53d..346c292 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataUtils.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/LogDataUtils.java @@ -81,7 +81,6 @@ public class LogDataUtils { } else { buffer.append("true"); } - System.out.println("boolean type arg : " + b); break; case 's': // System.out.println("args payload size : " + payload.length); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakDetector.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakDetector.java index 3c7ec31..a256a72 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakDetector.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakDetector.java @@ -118,8 +118,6 @@ public class LeakDetector { // if (chk.isCheckUserCall()) { // checkUserFuncLeakData(logData, chk); // } else { - System.out.println("api : + " + log.getApiName() - + " internal check : " + log.getInternalCall()); LeakData newLeak = new LeakData(logData, this); leaks.put(logData.getKey(), newLeak); // }