[Desc.] 1. show functions usage profiling data for sample log, user function log 2. show callstack of calltrace
[Issue]
dropCallTraceLog = drop;
}
- public static boolean isDrapCallTraceLog() {
+ public static boolean isDropCallTraceLog() {
return dropCallTraceLog;
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.TreeMap;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
public abstract class BaseCallstackManager {
protected HashMap<Long, CallStackUnit> callstackApiByAddrMap = new HashMap<Long, CallStackUnit>();
protected HashMap<Integer, CallStackData> callstackDataBySeqMap = new HashMap<Integer, CallStackData>();
protected String userFunctionBin = null;
- protected HashMap<Integer, List<CallStackUnit>> userCallstackByTidMap = new HashMap<Integer, List<CallStackUnit>>();
+ protected HashMap<Integer, List<CallStackItem>> userCallstackByTidMap = new HashMap<Integer, List<CallStackItem>>();
protected HashMap<Integer, DuplicateUserCall> dupUserCallByTidMap = new HashMap<Integer, DuplicateUserCall>();
-
+ protected HashMap<Integer, TreeMap<Long, Integer>> seqTimeByTidMap = new HashMap<Integer, TreeMap<Long, Integer>>();
+
abstract public void makeUserCallstack(LogData log,
ProfileDataMaker profiler);
return dupUserCallByTidMap;
}
+ public TreeMap<Long, Integer> getSeqTimeByTidMap(int tid) {
+ if (null == seqTimeByTidMap) {
+ seqTimeByTidMap = new HashMap<Integer, TreeMap<Long, Integer>>();
+ }
+ TreeMap<Long, Integer> seqByTimeMap = seqTimeByTidMap.get(tid);
+ if(null == seqByTimeMap) {
+ seqByTimeMap = new TreeMap<Long, Integer>();
+ seqTimeByTidMap.put(tid, seqByTimeMap);
+ }
+ return seqByTimeMap;
+ }
+
public String getUserFunctionPosition() {
if (userFunctionBin == null || userFunctionBin.isEmpty()) {
if (AnalyzerManager.isOsp()) {
return userFunctionBin;
}
- public List<CallStackUnit> getUserCallstack(int tid) {
+ public List<CallStackItem> getUserCallstack(int tid) {
if (null == userCallstackByTidMap) {
- userCallstackByTidMap = new HashMap<Integer, List<CallStackUnit>>();
+ userCallstackByTidMap = new HashMap<Integer, List<CallStackItem>>();
}
- List<CallStackUnit> userCallstack = userCallstackByTidMap.get(tid);
+ List<CallStackItem> userCallstack = userCallstackByTidMap.get(tid);
if (null == userCallstack) {
- userCallstack = new ArrayList<CallStackUnit>();
+ userCallstack = new ArrayList<CallStackItem>();
userCallstackByTidMap.put(tid, userCallstack);
}
return userCallstack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.TreeMap;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.SymbolManager;
import org.tizen.dynamicanalyzer.communicator.DACommunicator;
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
+import org.tizen.dynamicanalyzer.swap.logparser.SWAPLogParser;
import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
int seq = log.getSeq();
int tid = log.getTid();
+ long time = log.getTime();
long selfAddr = log.getPcAddr();
long callerAddr = log.getCallerPcAddr();
// insert call count
profiler.makeFupDataForCallTrace(selfCallstackUnit, log);
- List<CallStackUnit> userCallstack = getUserCallstack(tid);
+ List<CallStackItem> userCallstack = getUserCallstack(tid);
int size = userCallstack.size();
-
+ TreeMap<Long, Integer> seqByTimeMap = getSeqTimeByTidMap(tid);
+
CallStackUnit callerCallstackUnit = addrMap.get(callerAddr);
if (null == callerCallstackUnit) {
String strCallerFuncName = SymbolManager.addr2func(sourceBinPath,
int eventType = log.getId();
if (eventType == MSG_FUNCTION_ENTRY) {
if (size == 0) {
- userCallstack.add(selfCallstackUnit);
+ userCallstack.add(new CallStackItem(selfCallstackUnit, time));
} else {
if (!AnalyzerManager.isInBinaryRange(callerAddr)) {
CallStackUnit callbackApi = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL,
log);
- userCallstack.add(callbackApi);
+ userCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL,
log);
- userCallstack.add(callbackApi);
+ userCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
defaultCallstackUnit);
}
- userCallstack.add(callerCallstackUnit);
+ userCallstack.add(new CallStackItem(callerCallstackUnit));
} else {
CallStackUnit callerCsa = addrMap.get(callerAddr);
if (null == callerCsa) {
- callerCsa = userCallstack.get(size - 1);
+ callerCsa = userCallstack.get(size - 1).getCallStackUnit();
callerCsa.setFunctionStartAddr(callerCsa.getAddr());
callerCsa.setAddr(callerAddr);
} else {
callerCsa.setFunctionStartAddr(userCallstack.get(
- size - 1).getAddr());
- userCallstack.set(size - 1, callerCsa);
+ size - 1).getCallStackUnit().getAddr());
+ userCallstack.set(size - 1, new CallStackItem(callerCsa));
}
}
- userCallstack.add(selfCallstackUnit);
+ userCallstack.add(new CallStackItem(selfCallstackUnit, time));
}
size = userCallstack.size();
for (int i = size - 1; i >= 0; i--) {
- callstackData.getAddrs().add(userCallstack.get(i).getAddr());
+ callstackData.getAddrs().add(userCallstack.get(i).getCallStackUnit().getAddr());
}
getCallStackDataBySeqMap().put(seq, callstackData);
+ 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);
+ CallStackUnit removeCallStackUnit = userCallstack.get(size - 1).getCallStackUnit();
if (selfCallstackUnit.getFunctionName().equals(
removeCallStackUnit.getFunctionName())) {
userCallstack.remove(size - 1);
if (callerCallstackUnit.getFunctionName().contains(
AnalyzerConstants.VIRTUAL_THUNK)) {
if (callerCallstackUnit.getFunctionName().equals(
- userCallstack.get(size - 2).getFunctionName())) {
+ userCallstack.get(size - 2).getCallStackUnit().getFunctionName())) {
userCallstack.remove(size - 2);
} else {
System.out
size = userCallstack.size();
if (size - 1 > 0) {
CallStackUnit checkCallStackUnit = userCallstack
- .get(size - 1);
+ .get(size - 1).getCallStackUnit();
if (checkCallStackUnit.getFunctionName().equals(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC)) {
userCallstack.remove(size - 1);
size = userCallstack.size();
if (size > 0) {
CallStackUnit prevCallstackUnit = userCallstack
- .get(size - 1);
+ .get(size - 1).getCallStackUnit();
long prevSelfAddr = prevCallstackUnit
.getFunctionStartAddr();
CallStackUnit callerCsa = addrMap.get(prevSelfAddr);
if (null == callerCsa) {
prevCallstackUnit.setAddr(prevSelfAddr);
} else {
- userCallstack.set(size - 1, callerCsa);
+ userCallstack.set(size - 1, new CallStackItem(callerCsa));
}
}
+ for (int i = size - 1; i >= 0; i--) {
+ callstackData.getAddrs().add(userCallstack.get(i).getCallStackUnit().getAddr());
+ }
+ getCallStackDataBySeqMap().put(seq, callstackData);
+ seqByTimeMap.put(time, seq);
} else {
System.out
.println("makeUserCallstack : EXIT self is not the same as top of user callstack");
}
- // if (AnalyzerManager.isOsp()) {
+ if (AnalyzerManager.isOsp()) {
// String apiName = input[LogCenterConstants.APINAME_INDEX];
- // String apiName = log.getApiName();
- // if (apiName.equals("OspMain")) { //$NON-NLS-1$
- // LogParser.setDropCallTraceLog(true);
- // }
- // }
+ String apiName = log.getApiName();
+ if (apiName.equals("OspMain")) { //$NON-NLS-1$
+ SWAPLogParser.setDropCallTraceLog(true);
+ }
+ }
}
}
String strCallerAddr = Long.toString(callerAddr);
// System.out.println("tid :" + tid);
- List<CallStackUnit> probeCallstack = new ArrayList<CallStackUnit>(
+ List<CallStackItem> probeCallstack = new ArrayList<CallStackItem>(
getUserCallstack(tid));
// List<CallStackUnit> probeCallstack =
// getUserCallstack(tid);
CallStackUnit callbackApi = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL, log);
- probeCallstack.add(callbackApi);
+ probeCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
addrMap.put(callerAddr, callerCallstackUnit);
}
- CallStackUnit topUserCallstack = probeCallstack.get(size - 1);
+ CallStackUnit topUserCallstack = probeCallstack.get(size - 1).getCallStackUnit();
if (callerCallstackUnit.getFunctionName().equals(
topUserCallstack.getFunctionName())) {
- probeCallstack.set(size - 1, 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$
size = probeCallstack.size();
for (int i = size - 1; i >= 0; i--) {
- callstackData.getAddrs().add(probeCallstack.get(i).getAddr());
+ callstackData.getAddrs().add(probeCallstack.get(i).getCallStackUnit().getAddr());
}
getCallStackDataBySeqMap().put(seq, callstackData);
addrMap.put(selfAddr, selfCallstackUnit);
}
- List<CallStackUnit> userCallstack = getUserCallstack(tid);
+ List<CallStackItem> userCallstack = getUserCallstack(tid);
int size = userCallstack.size();
int eventType = input.getId();
if (size > 0) {
if (eventType == MSG_FUNCTION_ENTRY) {
- CallStackUnit topCallstackUnit = userCallstack.get(size - 1);
+ CallStackUnit topCallstackUnit = userCallstack.get(size - 1).getCallStackUnit();
if (topCallstackUnit.equals(selfCallstackUnit)) {
DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
if (null == dupUserCall) {
selfCallstackUnit)) {
dupUserCall.increaseDupCallCount();
} else {
- // System.out
- // .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
+ System.out
+ .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
}
}
return true;
dupUserCallMap.remove(tid);
}
} else {
- // System.out
- // .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
+ System.out
+ .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
}
return true;
}
userFunctionBin = null;
userCallstackByTidMap.clear();
dupUserCallByTidMap.clear();
+ seqTimeByTidMap.clear();
}
}
import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler;
import org.tizen.dynamicanalyzer.handlers.StopHandler;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.project.PackageInfo;
import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
import org.tizen.dynamicanalyzer.swap.channel.data.LibraryObject;
import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfo;
List<LibraryObject> libObjs = pInfo.getLibObjs();
HashMap<String, LibraryObject> libHash = pInfo.getLibObjHash();
+ System.out.println("LIBCOUNT :: " + dependantLibCount);
for (int i = 0; i < dependantLibCount; i++) {
LibraryObject libObj = new LibraryObject();
libObj.setPid(pid);
libObj.setLibPath(libPath);
libObjs.add(libObj);
libHash.put(libPath, libObj);
+ System.out.println("LIBPATH :: (" + i + ") " + libPath +
+ "low : " + AnalyzerUtil.toHexdecimal(lowestAddr) + " high : " + AnalyzerUtil.toHexdecimal(highestAddr));
}
DATime startTime = AnalyzerManager.getProject().getProfileStartTime();
pInfo.setMainTargetBinaryPath(targetBinaryPath);
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)) {
+ SWAPLogParser.setDropCallTraceLog(true);
+ }
+
AnalyzerManager.setProcessInfoArrived(true);
}
import org.tizen.dynamicanalyzer.swap.model.data.ScreenShotData;
import org.tizen.dynamicanalyzer.swap.model.data.SystemData;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
import org.tizen.dynamicanalyzer.uirecorder.UIRecorderPlayThread;
import org.tizen.dynamicanalyzer.uirecorder.UIRecorderTool;
public class SWAPLogParser implements Runnable {
private final String OSP_MAIN = "OspMain"; //$NON-NLS-1$
private static Thread logParser = null;
- private static boolean dropCallTraceLog = true;
+// default false, turn on when Tizen C++ app
+// private static boolean dropCallTraceLog = true;
+ private static boolean dropCallTraceLog = false;
private static LogQueue logQueue = null;
private int SMALL_IMG_WIDTH = 40;
dropCallTraceLog = drop;
}
- public static boolean isDrapCallTraceLog() {
+ public static boolean isDropCallTraceLog() {
return dropCallTraceLog;
}
public static void startLogParser() {
getLogQueue().clear();
- dropCallTraceLog = true;
+// why here?
+// dropCallTraceLog = true;
if (null == logParser || !logParser.isAlive()) {
logParser = new Thread(null, new SWAPLogParser(),
AnalyzerConstants.LOG_QUEUE_OBSERVING_THREAD);
if (!AnalyzerManager.isProcessInfoArrived()) {
continue;
}
- ProfileData pData = (ProfileData) log;
- String apiName = pData.getApiName();
- if (null == apiName || apiName.isEmpty()
- || apiName.equals("_end")) { //$NON-NLS-1$
- // setFuncName(pData);
- apiName = AnalyzerUtil.getFuncName(pData);
- if (apiName.equals("<unknown function>")) {
- continue;
- } else {
- pData.setApiName(apiName);
+
+ if (id != DataChannelConstants.MSG_DATA_SAMPLE) {
+ ProfileData pData = (ProfileData) log;
+ String apiName = pData.getApiName();
+ if (null == apiName || apiName.isEmpty()
+ || apiName.equals("_end")) { //$NON-NLS-1$
+ // setFuncName(pData);
+ apiName = AnalyzerUtil.getFuncName(pData);
+ if (apiName.equals("<unknown function>")) {
+// necessary? pData.setApiName(apiName);
+ continue;
+ } else {
+ pData.setApiName(apiName);
+ }
}
- }
-
- if (isDrapCallTraceLog()) {
- apiName = pData.getApiName();
- if (apiName.contains(OSP_MAIN)) {
- setDropCallTraceLog(false);
- } else {
+
+ if (isDropCallTraceLog()) {
+ apiName = pData.getApiName();
+ if (apiName.contains(OSP_MAIN)) {
+ setDropCallTraceLog(false);
+ } else {
+ continue;
+ }
+ }
+ // irregular call check still necessary?
+ if (AnalyzerManager.getCallstackManager().isIrregularUserCall(
+ pData)) {
continue;
}
+
+ ProcessInfoPackage processInfoPkg = AnalyzerManager
+ .getProject().getProcessInfo(pData.getPid());
+ ProcessInfo processInfo = processInfoPkg.getProcessInfo(pData
+ .getTime());
+
+ System.out.println(" PROFILE LOG DEBUG = ID: "
+ + pData.getId()
+ + " PC : "
+ + AnalyzerUtil.toHexdecimal(pData.getPcAddr())
+ + " Api : "
+ + pData.getApiName()
+ + " caller : "
+ + AnalyzerUtil.toHexdecimal(pData.getCallerPcAddr())
+ + " base addr : "
+ + AnalyzerUtil.toHexdecimal(processInfo
+ .getLowestAddress()));
+ pushLog(log, logPack);
+ /* user callstack create by entry and exit */
+ AnalyzerManager.getCallstackManager().makeUserCallstack(
+ pData,
+ FunctionUsageProfiler.getInstance()
+ .getProfileDataMaker());
+ } else {
+ pushLog(log, logPack);
}
-
- // if
- // (AnalyzerManager.getCallstackManager().isIrregularUserCall(
- // pData)) {
- // continue;
- // }
-
- ProcessInfoPackage processInfoPkg = AnalyzerManager
- .getProject().getProcessInfo(pData.getPid());
- ProcessInfo processInfo = processInfoPkg.getProcessInfo(pData
- .getTime());
-
- System.out.println(" PROFILE LOG DEBUG = ID: "
- + pData.getId()
- + " PC : "
- + AnalyzerUtil.toHexdecimal(pData.getPcAddr())
- + " Api : "
- + pData.getApiName()
- + " caller : "
- + AnalyzerUtil.toHexdecimal(pData.getCallerPcAddr())
- + " base addr : "
- + AnalyzerUtil.toHexdecimal(processInfo
- .getLowestAddress()));
- pushLog(log, logPack);
- /* user callstack create by entry and exit */
- // AnalyzerManager.getCallstackManager().makeUserCallstack(
- // pData,
- // FunctionUsageProfiler.getInstance()
- // .getProfileDataMaker());
} else if (log instanceof ReplayData) {
pushLog(log, logPack);
} else if (log instanceof ContextSwitchData) {
.put(imgInfo.getSeq(), imgInfo);
}
pushLog(log, logPack);
- // AnalyzerManager.getCallstackManager()
- // .makeCallstackWithoutBacktrace(log);
+ AnalyzerManager.getCallstackManager()
+ .makeCallstackWithoutBacktrace(log);
if (id == DataChannelConstants.MSG_PROBE_FILE
|| id == DataChannelConstants.MSG_PROBE_MEMORY) {
AnalyzerManager.getLeakDetector().runLeakDectect(log);
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * WooJin Jung <woojin2.jung@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.info.callstack;
+
+public class CallStackItem {
+ protected long startTime;
+ protected CallStackUnit callstackUnit;
+
+ public CallStackItem(CallStackUnit CallstackUnit) {
+ callstackUnit = CallstackUnit;
+ startTime = -1;
+ }
+
+ public CallStackItem(CallStackUnit CallstackUnit, long time) {
+ callstackUnit = CallstackUnit;
+ startTime = time;
+ }
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ public CallStackUnit getCallStackUnit() {
+ return callstackUnit;
+ }
+
+}
\ No newline at end of file
// insert call count
profiler.makeFupDataForCallTrace(selfCallstackUnit, log);
- List<CallStackUnit> userCallstack = getUserCallstack(tid);
+ List<CallStackItem> userCallstack = getUserCallstack(tid);
int size = userCallstack.size();
CallStackUnit callerCallstackUnit = addrMap.get(callerAddr);
int eventType = log.getType();
if (eventType == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_ENTER) {
if (size == 0) {
- userCallstack.add(selfCallstackUnit);
+ userCallstack.add(new CallStackItem(selfCallstackUnit));
} else {
if (!AnalyzerManager.isInBinaryRange(callerAddr)) {
CallStackUnit callbackApi = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL,
log);
- userCallstack.add(callbackApi);
+ userCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL,
log);
- userCallstack.add(callbackApi);
+ userCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
defaultCallstackUnit);
}
- userCallstack.add(callerCallstackUnit);
+ userCallstack.add(new CallStackItem(callerCallstackUnit));
} else {
CallStackUnit callerCsa = addrMap.get(callerAddr);
if (null == callerCsa) {
- callerCsa = userCallstack.get(size - 1);
+ callerCsa = userCallstack.get(size - 1).getCallStackUnit();
callerCsa.setFunctionStartAddr(callerCsa.getAddr());
callerCsa.setAddr(callerAddr);
} else {
callerCsa.setFunctionStartAddr(userCallstack.get(
- size - 1).getAddr());
- userCallstack.set(size - 1, callerCsa);
+ size - 1).getCallStackUnit().getAddr());
+ userCallstack.set(size - 1, new CallStackItem(callerCsa));
}
}
- userCallstack.add(selfCallstackUnit);
+ userCallstack.add(new CallStackItem(selfCallstackUnit));
}
size = userCallstack.size();
for (int i = size - 1; i >= 0; i--) {
- callstackData.getAddrs().add(userCallstack.get(i).getAddr());
+ callstackData.getAddrs().add(userCallstack.get(i).getCallStackUnit().getAddr());
}
getCallStackDataBySeqMap().put(seq, callstackData);
} else if (eventType == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) {
// this case only range profiling, other time is bug
return;
}
- CallStackUnit removeCallStackUnit = userCallstack.get(size - 1);
+ CallStackUnit removeCallStackUnit = userCallstack.get(size - 1).getCallStackUnit();
if (selfCallstackUnit.getFunctionName().equals(
removeCallStackUnit.getFunctionName())) {
userCallstack.remove(size - 1);
if (callerCallstackUnit.getFunctionName().contains(
AnalyzerConstants.VIRTUAL_THUNK)) {
if (callerCallstackUnit.getFunctionName().equals(
- userCallstack.get(size - 2).getFunctionName())) {
+ userCallstack.get(size - 2).getCallStackUnit().getFunctionName())) {
userCallstack.remove(size - 2);
} else {
System.out
size = userCallstack.size();
if (size - 1 > 0) {
CallStackUnit checkCallStackUnit = userCallstack
- .get(size - 1);
+ .get(size - 1).getCallStackUnit();
if (checkCallStackUnit.getFunctionName().equals(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC)) {
userCallstack.remove(size - 1);
size = userCallstack.size();
if (size > 0) {
CallStackUnit prevCallstackUnit = userCallstack
- .get(size - 1);
+ .get(size - 1).getCallStackUnit();
long prevSelfAddr = prevCallstackUnit
.getFunctionStartAddr();
CallStackUnit callerCsa = addrMap.get(prevSelfAddr);
if (null == callerCsa) {
prevCallstackUnit.setAddr(prevSelfAddr);
} else {
- userCallstack.set(size - 1, callerCsa);
+ userCallstack.set(size - 1, new CallStackItem(callerCsa));
}
}
} else {
}
String strCallerAddr = Long.toString(callerAddr);
- List<CallStackUnit> probeCallstack = new ArrayList<CallStackUnit>(
+ List<CallStackItem> probeCallstack = new ArrayList<CallStackItem>(
getUserCallstack(tid));
int size = probeCallstack.size();
CallStackUnit callbackApi = new CallStackUnit(
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL, log);
- probeCallstack.add(callbackApi);
+ probeCallstack.add(new CallStackItem(callbackApi));
if (addrMap
.get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR) == null) {
CallStackUnit defaultCallstackUnit = new CallStackUnit(
addrMap.put(callerAddr, callerCallstackUnit);
}
- CallStackUnit topUserCallstack = probeCallstack.get(size - 1);
+ CallStackUnit topUserCallstack = probeCallstack.get(size - 1).getCallStackUnit();
if (callerCallstackUnit.getFunctionName().equals(
topUserCallstack.getFunctionName())) {
- probeCallstack.set(size - 1, 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$
size = probeCallstack.size();
for (int i = size - 1; i >= 0; i--) {
- callstackData.getAddrs().add(probeCallstack.get(i).getAddr());
+ callstackData.getAddrs().add(probeCallstack.get(i).getCallStackUnit().getAddr());
}
getCallStackDataBySeqMap().put(seq, callstackData);
addrMap.put(selfAddr, selfCallstackUnit);
}
- List<CallStackUnit> userCallstack = getUserCallstack(tid);
+ List<CallStackItem> userCallstack = getUserCallstack(tid);
int size = userCallstack.size();
int eventType = input.getType();
if (size > 0) {
if (eventType == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_ENTER) {
- CallStackUnit topCallstackUnit = userCallstack.get(size - 1);
+ CallStackUnit topCallstackUnit = userCallstack.get(size - 1).getCallStackUnit();
if (topCallstackUnit.equals(selfCallstackUnit)) {
DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
if (null == dupUserCall) {
selfCallstackUnit)) {
dupUserCall.increaseDupCallCount();
} else {
- // System.out
- // .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
+ System.out
+ .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
}
}
return true;
dupUserCallMap.remove(tid);
}
} else {
- // System.out
- // .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
+ System.out
+ .println("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
}
return true;
}
userFunctionBin = null;
userCallstackByTidMap.clear();
dupUserCallByTidMap.clear();
+ seqTimeByTidMap.clear();
}
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.TreeMap;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.SymbolManager;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
+import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
import org.tizen.dynamicanalyzer.swap.callstack.BaseCallstackManager;
+import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo;
+import org.tizen.dynamicanalyzer.swap.channel.data.LibraryObject;
+import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfo;
+import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfoPackage;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
import org.tizen.dynamicanalyzer.swap.model.data.UserFunctionData;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.utils.Formatter;
public class ProfileDataMaker {
double rate = 0.;
if (exclusive) {
count = data.getExCount();
+ if(totalSampleCount == 0) {
+ rate = 0;
+ }
rate = count / (double) totalSampleCount * 100;
} else {
count = data.getInCount();
+ if(totalSampleCount == 0) {
+ rate = 0;
+ }
rate = count / (double) totalSampleCount * 100;
}
}
}
+ public String getSamplePCSymbol(ProfileData sampleLog) {
+ String functionName = null;
+ String symbol = null;
+ long pcAddr = sampleLog.getPcAddr();
+ ProcessInfoPackage processInfoPkg = AnalyzerManager
+ .getProject().getProcessInfo(sampleLog.getPid());
+ ProcessInfo processInfo = processInfoPkg.getProcessInfo(sampleLog
+ .getTime());
+
+ if (pcAddr >= processInfo.getLowestAddress()
+ && pcAddr <= processInfo.getHighestAddress()) { // application binary
+ String baseAddr = Long.toString(processInfo.getLowestAddress());
+ String pcStr = Long.toString(pcAddr);
+ BinaryInfo binInfo = DACommunicator.getSelectedApp()
+ .getMainBinaryInfo();
+ String localPath = binInfo.getSourceBinaryPath();
+ boolean isPieBuild = true;
+ if (binInfo.getType() != 1) {
+ isPieBuild = false;
+ }
+ functionName = SymbolManager.addr2func(localPath, 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);
+ }
+ // need to be checked again - in case pid is not main application
+ symbol = callstackManager.getUserFunctionPosition()
+ + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING
+ + functionName;
+ } else {
+ HashMap<String, BinaryInfo> binInfoMap = BinarySettingManager
+ .getInstance().getTargetBinInfoMap();
+// List<String> binPaths = new ArrayList<String>();
+// binPaths.addAll(binInfoMap.keySet());
+
+ List<LibraryObject> libObjs = processInfo.getLibObjs();
+// HashMap<String, LibraryObject> libHash = processInfo
+// .getLibObjHash();
+ LibraryObject libraryObject = null;
+ int size = libObjs.size();
+ for (int i = 0; i < size; i++) {
+// String binPath = binPaths.get(i);
+ LibraryObject libObj = libObjs.get(i);
+// if (null == libObj) {
+// continue;
+// }
+ long lowAddr = libObj.getLowestAddress();
+ long highAddr = libObj.getHighestAddress();
+
+ /** for debug */
+/* if (lowAddr > pcAddr || highAddr < pcAddr) {
+ System.out.print(sampleLog.getId()
+ + "lib : " + libObj.getLibPath() + " ==> ");
+ 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;
+ }
+ else {
+// System.out.print(sampleLog.getId()
+// + "lib : " + libObj.getLibPath() + " ==> ");
+// AnalyzerUtil.printHexdecimal(lowAddr);
+// System.out.print(" < ");
+// AnalyzerUtil.printHexdecimal(pcAddr);
+// System.out.print(" < ");
+// AnalyzerUtil.printHexdecimal(highAddr);
+// System.out.println();
+ }
+ }
+ if (null != libraryObject) {
+ String path = libraryObject.getLibPath();
+ BinaryInfo binInfo = binInfoMap.get(path);
+ if (null != binInfo) {
+ String localPath = binInfo.getSourceBinaryPath();
+ String baseAddr = Long.toString(libraryObject
+ .getLowestAddress());
+ String pcStr = Long.toString(pcAddr);
+ boolean isPieBuild = true;
+ if (binInfo.getType() != 1) {
+ isPieBuild = false;
+ }
+ functionName = SymbolManager.addr2func(localPath, 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);
+ }
+ // need to be checked again - in case pid is not main application
+ } else {
+ functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
+ }
+ symbol = path + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING
+ + functionName;
+ } else {
+ System.out
+ .println("binary for the sample pc is not found :" + AnalyzerUtil.toHexdecimal(pcAddr)); //$NON-NLS-1$
+ symbol = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_LIBRARY
+ + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING
+ + AnalyzerUtil.toHexdecimal(pcAddr);
+// + InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
+ }
+ }
+
+ AnalyzerManager.getFuncNameMap().put(pcAddr, functionName);
+ return symbol;
+ }
+
public void makeFunctionUsageProfileData(ProfileData sampleLog) {
totalSampleCount++;
- String callstack = sampleLog.getCallstack();
- if (null == callstack) {
- return;
- }
- String[] splitCallstack = callstack
- .split(AnalyzerConstants.DATA_PARSING_TOKEN);
-
- List<String> sampleCallstack = new ArrayList<String>();
+ List<Long> addrs = null;
+ long selfAddr = sampleLog.getPcAddr();
+
+ if(DACommunicator.isSWAPVersion()) {
+ int seq;
+ int tid = sampleLog.getTid();
+ long sampleTime = sampleLog.getTime();
+ long callstackTime;
+ Long longTime = null;
+ CallStackData callstackData;
+ TreeMap<Long, Integer> seqByTimeMap = callstackManager.getSeqTimeByTidMap(tid);
+ HashMap<Long, CallStackUnit> addrMap = callstackManager
+ .getCallStackApiByAddrMap();
+
+ CallStackUnit callstackUnit = addrMap.get(selfAddr);
+ if (null == callstackUnit) {
+ CallStackUnit newCallstackUnit = new CallStackUnit(selfAddr,
+ getSamplePCSymbol(sampleLog), sampleLog);
+ addrMap.put(selfAddr, newCallstackUnit);
+ }
+
+ longTime = seqByTimeMap.floorKey(sampleTime);
+ if(null != longTime) {
+ callstackTime = longTime.longValue();
+ seq = seqByTimeMap.get(callstackTime);
+ callstackData = callstackManager.getCallStackDataBySeqMap().get(seq);
+ addrs = new ArrayList<Long>(callstackData.getAddrs());
+ for(int i = 0; i < addrs.size(); i++) {
+ if(addrs.get(i) == 0) {
+ addrs.remove(i);
+ }
+ }
+ addrs.add(0, selfAddr);
+ } else {
+ System.out
+ .println("makeFunctionUsageProfileData : cannot find seq by time");
+ addrs = new ArrayList<Long>();
+ addrs.add(selfAddr);
+ }
- for (int i = 0; i < splitCallstack.length; i++) {
- sampleCallstack.add(new String(splitCallstack[i]));
+ } else {
+ String callstack = sampleLog.getCallstack();
+ if (null == callstack) {
+ return;
+ }
+ String[] splitCallstack = callstack
+ .split(AnalyzerConstants.DATA_PARSING_TOKEN);
+
+ List<String> sampleCallstack = new ArrayList<String>();
+
+ for (int i = 0; i < splitCallstack.length; i++) {
+ sampleCallstack.add(new String(splitCallstack[i]));
+ }
+
+ addrs = makeCallstackHashAndList(sampleCallstack, sampleLog);
}
-
- List<Long> addrs = makeCallstackHashAndList(sampleCallstack, sampleLog);
+
HashMap<Long, CallStackUnit> addrMap = callstackManager
.getCallStackApiByAddrMap();
- long selfAddr = sampleLog.getPcAddr();
CallStackUnit inputData = addrMap.get(selfAddr);
if (null == inputData) {
return;
public void makeFupDataForCallTrace(CallStackUnit inputCallstackApiData,
UserFunctionData log) {
- totalSampleCount++;
long exeTime = 0;
int type = log.getType();
+ int tid = log.getTid();
+ List<CallStackItem> userCallstack = callstackManager.getUserCallstack(tid);
+ int size = userCallstack.size();
+
if (type == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) {
+ if(size == 0 ||
+ !userCallstack.get(size - 1).getCallStackUnit()
+ .getFunctionName().equals(inputCallstackApiData.getFunctionName())) {
+ System.out
+ .println("exit without entry or EXIT self is not the same as top of user callstack :"
+ + inputCallstackApiData.getFunctionName()); //$NON-NLS-1$
+ return;
+ }
exeTime += log.getElapsedTime();
}
ProfilingData child = makeNewProfilingData(inputCallstackApiData,
false);
parent.addChild(child);
- child.addExCount();
child.addElpasedTime(exeTime);
child.setParent(parent.getName());
parent.addChild(child);
child.setParent(parent.getName());
}
- child.addExCount();
child.addElpasedTime(exeTime);
if (type != LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) {
child.addCallCount();
public void makeFupDataForCallTrace(CallStackUnit inputCallstackApiData,
ProfileData log) {
- totalSampleCount++;
long exeTime = 0;
int type = log.getId();
- if (type == MSG_FUNCTION_EXIT) {
- // exeTime += log.getElapsedTime();
- }
+ int tid = log.getTid();
+ long time = log.getTime();
+ long startTime;
+
+ List<CallStackItem> userCallstack = callstackManager.getUserCallstack(tid);
+ int size = userCallstack.size();
+
+ if (type == MSG_FUNCTION_EXIT) {
+ if(size == 0 ||
+ !userCallstack.get(size - 1).getCallStackUnit()
+ .getFunctionName().equals(inputCallstackApiData.getFunctionName())) {
+ System.out
+ .println("exit without entry or EXIT self is not the same as top of user callstack :"
+ + inputCallstackApiData.getFunctionName()); //$NON-NLS-1$
+ return;
+ }
+ startTime = userCallstack.get(size - 1).getStartTime();
+ if(startTime != -1) {
+ exeTime += time - startTime;
+ // exeTime += log.getElapsedTime();
+ }
+ }
ProfilingData parent = getProfilingDataByKey(inputCallstackApiData
.getPath());
ProfilingData child = makeNewProfilingData(inputCallstackApiData,
false);
parent.addChild(child);
- child.addExCount();
child.addElpasedTime(exeTime);
child.setParent(parent.getName());
parent.addChild(child);
child.setParent(parent.getName());
}
- child.addExCount();
child.addElpasedTime(exeTime);
if (type != MSG_FUNCTION_EXIT) {
child.addCallCount();
public static String getBinarySourcePath(int pid, long time) {
String localBinPath = AnalyzerUtil.getProcessLocalBinaryPath(pid, time);
+ String key = getTargetPathKey(localBinPath);
BinaryInfo binInfo = DACommunicator.getSelectedApp().getBinaryInfo(
- localBinPath);
+ key);
String sourceBinPath = binInfo.getSourceBinaryPath();
return sourceBinPath;
}
if (null != libraryObject) {
String path = libraryObject.getLibPath();
BinaryInfo binInfo = binInfoMap.get(path);
- String localPath = binInfo.getSourceBinaryPath();
if (null != binInfo) {
+ String localPath = binInfo.getSourceBinaryPath();
String baseAddr = Long.toString(libraryObject
.getLowestAddress());
String pcStr = Long.toString(pcAddr);