LIFECYCLE: obtain lifecycle API ID when every trace is started 30/40430/2
authorgreatim <jaewon81.lim@samsung.com>
Wed, 3 Jun 2015 13:41:44 +0000 (22:41 +0900)
committerJaewon Lim <jaewon81.lim@samsung.com>
Mon, 8 Jun 2015 08:04:05 +0000 (01:04 -0700)
Obtail lifecycle API ID when every trace is started
Bug fix in IndexedHashMap
Add some error log for debugging

Change-Id: I140f09f8c07151e77061c43dd1e70bf3a5473955
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/collection/IndexedHashMap.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/DeviceStatusInfo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotTimer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/logparser/LifecycleLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java

index 0687f79..69dd4ac 100644 (file)
@@ -89,7 +89,7 @@ public class IndexedHashMap<K, V extends Indexable> {
 
        public boolean buildFrom(List<K> keylist, List<V> valuelist, int maxindex) {
                if (keylist == null || valuelist == null || keylist.size() != valuelist.size()
-                               || maxindex < keylist.size()) {
+                               || maxindex + 1 < keylist.size()) {
                        return false;
                }
 
index 7e1e825..d3a9c3f 100755 (executable)
@@ -36,6 +36,7 @@ import java.util.Map;
 import org.tizen.dynamicanalyzer.collection.IndexedHashMap;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
 
 public class DeviceStatusInfo {
        private static final String SYSMEM = "SystemMemory";
@@ -312,6 +313,8 @@ public class DeviceStatusInfo {
                        }
                }
 
-               binaryInfos.buildFrom(keylist, valuelist, maxindex);
+               if (!binaryInfos.buildFrom(keylist, valuelist, maxindex)) {
+                       Logger.error("failed to build binary info map");
+               }
        }
 }
index bf8be60..f7d91b5 100755 (executable)
@@ -319,7 +319,9 @@ public class Project {
                                }
 
                                synchronized (functionInfos) {
-                                       functionInfos.buildFrom(keylist, valuelist, maxindex);
+                                       if (!functionInfos.buildFrom(keylist, valuelist, maxindex)) {
+                                               Logger.error("failed to build function info map");
+                                       }
                                }
                        }
                }
@@ -830,7 +832,9 @@ public class Project {
                                }
                        }
 
-                       functionInfos.buildFrom(namelist, finfolist, maxindex);
+                       if (!functionInfos.buildFrom(namelist, finfolist, maxindex)) {
+                               Logger.error("failed to build function info map");
+                       }
                }
        }
 
index 79986fb..2fba42f 100644 (file)
@@ -54,7 +54,9 @@ public class ScreenshotTimer extends TimerTask {
        @Override
        public void run() {
                try {
-                       DACommunicator.captureScreenshot();
+                       if (!DACommunicator.captureScreenshot().isSuccess()) {
+                               Logger.error("Failed to capture screenshot");
+                       }
                } catch (InterruptedException e) {
                        Logger.warning("Interrupted during send screenshot message");
                } catch (UnsupportedProtocolException e) {
index 54f8d54..4f1a58f 100644 (file)
@@ -168,6 +168,17 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                loadSelectedChartList();
        }
 
+       @Override
+       protected void resetBeforeStart() {
+               super.resetBeforeStart();
+               lifecycleLogParser.initialize(Global.getProject());
+       }
+
+       @Override
+       protected void clearAfterStop() {
+               super.clearAfterStop();
+       }
+
        public void setChartTimelineChartBoard(DAChartBoard board) {
                chartBoard = board;
        }
@@ -828,6 +839,8 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                /*
                 * Set Lifecycle
                 */
+               lifecycleLogParser.initialize(Global.getProject());
+
                List<List<Object>> logDataList = getLifeCycleDataFromDB();
                for (int i = 0; i < logDataList.size(); i++) {
                        List<Object> row = logDataList.get(i);
index 1cb556e..31e389b 100644 (file)
@@ -36,6 +36,7 @@ import org.eclipse.swt.graphics.Color;
 import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
 import org.tizen.dynamicanalyzer.project.AppInfo;
+import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
@@ -50,37 +51,35 @@ import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
 
 public class LifecycleLogParser {
        private static LifecycleLogParser instance = null;
-       
-//     2 void _AppImpl::OnTerminate(void* user_data)
-//     3 void _AppInfo::SetAppState(AppState appState)
-//     4 void _UiAppImpl::OnBackground(void)
-//     5 void _UiAppImpl::OnForeground(void)
-//
-//     83 _dalc_app_create
-//     84 _dalc_app_terminate
-//     85 _dalc_app_pause
-//     86 _dalc_app_resume
-//     87 _dalc_app_service
-       
-       /*
-        * for OSP
-        */
-       private static final int API_ID_INITIALIZING_OSP = 3;
-       private static final int API_ID_RUNNING_OSP = 5;
-       private static final int API_ID_PAUSING_OSP = 4;
-       private static final int API_ID_TERMINATING_OSP = 2;
-       
-       /*
-        * for EFL
-        */
-       private static final int API_ID_INITIALIZING_EFL = 83;
-       private static final int API_ID_SERVICE_EFL = 87;
-       private static final int API_ID_RESUME_EFL = 86;
-       private static final int API_ID_PAUSING_EFL = 85;
-       private static final int API_ID_TERMINATING_EFL = 84;
-       
+
+       // life-cycle API names for OSP
+       private static final String API_NAME_INITIALIZING_OSP = "_AppInfo::SetAppState(AppState appState)";
+       private static final String API_NAME_RUNNING_OSP = "_UiAppImpl::OnForeground(void)";
+       private static final String API_NAME_PAUSING_OSP = "_UiAppImpl::OnBackground(void)";
+       private static final String API_NAME_TERMINATING_OSP = "_AppImpl::OnTerminate(void* user_data)";
+
+       // life-cycle API names for EFL
+       private static final String API_NAME_INITIALIZING_EFL = "_dalc_app_create";
+       private static final String API_NAME_SERVICE_EFL = "_dalc_app_service";
+       private static final String API_NAME_RESUME_EFL = "_dalc_app_resume";
+       private static final String API_NAME_PAUSING_EFL = "_dalc_app_pause";
+       private static final String API_NAME_TERMINATING_EFL = "_dalc_app_terminate";
+
+       // life-cycle API ID for OSP
+       private int API_ID_INITIALIZING_OSP = 0;
+       private int API_ID_RUNNING_OSP = 0;
+       private int API_ID_PAUSING_OSP = 0;
+       private int API_ID_TERMINATING_OSP = 0;
+
+       // life-cycle API ID for EFL
+       private int API_ID_INITIALIZING_EFL = 0;
+       private int API_ID_SERVICE_EFL = 0;
+       private int API_ID_RESUME_EFL = 0;
+       private int API_ID_PAUSING_EFL = 0;
+       private int API_ID_TERMINATING_EFL = 0;
+
        // Use HashSet because prevent duplicated insertion
-       private Set<LifecycleBar> lifecycleBarList = new HashSet<LifecycleBar>();       
+       private Set<LifecycleBar> lifecycleBarList = new HashSet<LifecycleBar>();
        private List<DATimeline> timelineList = new ArrayList<DATimeline>();
 
        public static LifecycleLogParser getInstance() {
@@ -93,32 +92,44 @@ public class LifecycleLogParser {
        private LifecycleLogParser() {
        }
 
+       public void initialize(Project project) {
+               API_ID_INITIALIZING_OSP = project.getFunctionID(API_NAME_INITIALIZING_OSP);
+               API_ID_RUNNING_OSP = project.getFunctionID(API_NAME_RUNNING_OSP);
+               API_ID_PAUSING_OSP = project.getFunctionID(API_NAME_PAUSING_OSP);
+               API_ID_TERMINATING_OSP = project.getFunctionID(API_NAME_TERMINATING_OSP);
+
+               API_ID_INITIALIZING_EFL = project.getFunctionID(API_NAME_INITIALIZING_EFL);
+               API_ID_SERVICE_EFL = project.getFunctionID(API_NAME_SERVICE_EFL);
+               API_ID_RESUME_EFL = project.getFunctionID(API_NAME_RESUME_EFL);
+               API_ID_PAUSING_EFL = project.getFunctionID(API_NAME_PAUSING_EFL);
+               API_ID_TERMINATING_EFL = project.getFunctionID(API_NAME_TERMINATING_EFL);
+       }
+
        public void parseLogPackage(LogPackage logPack) {
                Logs logs = logPack.getLogs(ProtocolConstants.MSG_PROBE_LIFECYCLE);
                if (null == logs) {
                        return;
                }
-               
+
                List<LogData> logDataList = logs.getRawLogs();
 
                for (LogData logData : logDataList) {
-                       parseLog(logData.getTime(), ((LifeCycleLogData)logData).getApiId());
+                       parseLog(logData.getTime(), ((LifeCycleLogData) logData).getApiId());
                }
        }
 
        public void parseLog(long lifeChangeTime, int lifeStatus) {
                Color color;
                String text;
-               
-               if(Global.getProject() == null) {
+
+               if (Global.getProject() == null) {
                        return;
                }
                /*
                 * TODO need to check detail application type
                 */
                // EFL
-               if (Global.getProject().getApplicationInfo().getAppType().
-                               contains(AppInfo.APPTYPE_CAPP)) {
+               if (Global.getProject().getApplicationInfo().getAppType().contains(AppInfo.APPTYPE_CAPP)) {
                        if (lifeStatus == API_ID_INITIALIZING_EFL) {
                                color = ColorResources.LIFECYCLE_INITIALIZING;
                                text = TimelineChartLabels.LIFECYCLE_INITIALIZING;
@@ -132,13 +143,13 @@ public class LifecycleLogParser {
                                color = ColorResources.LIFECYCLE_TERMINATING;
                                text = TimelineChartLabels.LIFECYCLE_TERMINATING;
                        } else {
-                               Logger.error("lifecycle log error"); //$NON-NLS-1$
+                               Logger.error("lifecycle log error (%d)", lifeStatus); //$NON-NLS-1$
                                return;
                        }
-               } 
+               }
                // OSP
-               else if (Global.getProject().getApplicationInfo().getAppType().
-                               contains(AppInfo.APPTYPE_CPP)) {
+               else if (Global.getProject().getApplicationInfo().getAppType()
+                               .contains(AppInfo.APPTYPE_CPP)) {
                        if (lifeStatus == API_ID_INITIALIZING_OSP) {
                                color = ColorResources.LIFECYCLE_INITIALIZING;
                                text = TimelineChartLabels.LIFECYCLE_INITIALIZING;
@@ -152,14 +163,14 @@ public class LifecycleLogParser {
                                color = ColorResources.LIFECYCLE_TERMINATING;
                                text = TimelineChartLabels.LIFECYCLE_TERMINATING;
                        } else {
-                               Logger.error("lifecycle log error"); //$NON-NLS-1$
+                               Logger.error("lifecycle log error (%d)", lifeStatus); //$NON-NLS-1$
                                return;
                        }
                } else {
                        Logger.error("It doesn't support lifecycle application type.");
                        return;
                }
-               
+
                double startTime = Double.parseDouble(Long.toString(lifeChangeTime))
                                / TimelineConstants.MEGA_DOUBLE;
 
index 7a65344..c752a76 100755 (executable)
@@ -408,7 +408,9 @@ public enum Toolbar {
                        @Override
                        public void handleClickEvent(DACustomButton button) {
                                try {
-                                       DACommunicator.captureScreenshot();
+                                       if (!DACommunicator.captureScreenshot().isSuccess()) {
+                                               Logger.error("Failed to capture screenshot");
+                                       }
                                } catch (InterruptedException e) {
                                        Logger.warning("Interrupted during send screenshot message");
                                } catch (UnsupportedProtocolException e) {
index 51dfebc..3e2b14b 100644 (file)
@@ -428,10 +428,10 @@ public abstract class DAWindowingTableComposite extends DATableComposite {
                        if (selectedCount != getRecordCount(itemCount)
                                        && selectedCount != itemCount - scrollSelection) {
                                // scroll is at bottom-most and the number of records is less than the size of table
-                               Logger.debug("requestedRecordCount : " + getRecordCount(itemCount)
-                                               + " selectedCount : " + selectedCount);
+//                             Logger.debug("requestedRecordCount : " + getRecordCount(itemCount)
+//                                             + " selectedCount : " + selectedCount);
                                selectSuccess = false;
-                               Logger.debug("selected record count mismatch with requested record count");
+//                             Logger.debug("selected record count mismatch with requested record count");
                        }
                }