[Title] function profiling bug fix
authorwoojin <woojin2.jung@samsung.com>
Thu, 7 Nov 2013 01:12:45 +0000 (10:12 +0900)
committerwoojin <woojin2.jung@samsung.com>
Thu, 7 Nov 2013 01:12:45 +0000 (10:12 +0900)
[Desc.] fix 1. same function appears twice 2. minus value in elapsed time
[Issue]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackUnit.java

index f168d21..aa43828 100644 (file)
@@ -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<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,
@@ -149,33 +149,30 @@ 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));
+                                               CallStackItem topCallstackItem = userCallstack.get(
+                                                               size - 1);
+                                               callerCsa.setFunctionStartAddr(topCallstackItem.getCallStackUnit().getAddr());
+                                               userCallstack.set(size - 1, new CallStackItem(callerCsa, topCallstackItem.getStartTime()));
                                        }
                                }
                                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);
@@ -183,8 +180,7 @@ 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
@@ -195,8 +191,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);
@@ -204,30 +200,28 @@ public class SWAPCallStackManager extends BaseCallstackManager {
                                }
                                size = userCallstack.size();
                                if (size > 0) {
-                                       CallStackUnit prevCallstackUnit = userCallstack.get(
-                                                       size - 1).getCallStackUnit();
-                                       long prevSelfAddr = prevCallstackUnit
+                                       CallStackItem prevCallstackItem = userCallstack
+                                                       .get(size - 1);
+                                       long prevSelfAddr = prevCallstackItem.getCallStackUnit()
                                                        .getFunctionStartAddr();
                                        CallStackUnit callerCsa = addrMap.get(prevSelfAddr);
                                        if (null == callerCsa) {
-                                               prevCallstackUnit.setAddr(prevSelfAddr);
+                                               prevCallstackItem.getCallStackUnit().setAddr(prevSelfAddr);
                                        } else {
-                                               userCallstack.set(size - 1,
-                                                               new CallStackItem(callerCsa));
+                                               userCallstack.set(size - 1, new CallStackItem(callerCsa, prevCallstackItem.getStartTime()));
                                        }
                                }
                                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);
@@ -333,12 +327,10 @@ 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$
@@ -347,8 +339,7 @@ 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);
 
@@ -393,8 +384,7 @@ 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) {
index 820f189..e08205a 100644 (file)
@@ -78,7 +78,7 @@ public class CallStackUnit {
 
        private void makeCallstackData() {
 
-               String[] splitPath = originSymbol.split("\\("); //$NON-NLS-1$
+               String[] splitPath = originSymbol.split("\\(", 2); //$NON-NLS-1$
                path = splitPath[0];
                if (!path.startsWith("/") && !path.contains(FunctionUsageProfiler.APPLICATION) //$NON-NLS-1$
                                && !path.contains(FunctionUsageProfiler.DEPENDENT_LIB)) {