[SRADA-177] Add one DB file and modify some files
authordongkyu6 lee <dongkyu6.lee@samsung.com>
Tue, 15 Mar 2016 06:41:14 +0000 (15:41 +0900)
committerdongkyu6 lee <dongkyu6.lee@samsung.com>
Wed, 16 Mar 2016 07:05:56 +0000 (16:05 +0900)
They ard not fixed files.

Change-Id: Id9c10dc3bd80f31dc6dae7314d89a3a1b5fb0d2a
Signed-off-by: dongkyu6 lee <dongkyu6.lee@samsung.com>
[SRADA-177] Add one DB file and modify some files

 -Modified MemoryDataManager.java

Change-Id: I7082fabab88937db8650f61335c26e8ba232cf06

[SRADA-177] Add one DB file and modify some files

They ard not fixed files.

Change-Id: Id9c10dc3bd80f31dc6dae7314d89a3a1b5fb0d2a
Signed-off-by: dongkyu6 lee <dongkyu6.lee@samsung.com>
[SRADA-177] Add one DB file and modify some files

 -Modified MemoryDataManager.java

Change-Id: I7082fabab88937db8650f61335c26e8ba232cf06

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryDetailsTableView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/AllocateCallStackDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/AllocateDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/FreeDBTable.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/ProcessMemoryDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/SystemMemoryDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/table/MemoryDetailsTable.java

index 8b3f4ce..999d0e5 100755 (executable)
@@ -5,24 +5,29 @@ import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.ScrollBar;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.DASelectionData;
 import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.swap.model.data.LogData;
 import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener;
 import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
 import org.tizen.dynamicanalyzer.ui.memory.chart.MemoryChartBoard;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;
 import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
 import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
 import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
+import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
 import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
 import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardSelectionListener;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
+import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
 
 public class MemoryChartView extends DAViewComposite {
@@ -89,4 +94,97 @@ public class MemoryChartView extends DAViewComposite {
                timeline.addMouseMoveListener(new SetRangeMarkerMouseMoveListener(rangeDataManager,
                                memoryChartBoard, timeline));
        }
+       
+       @Override
+       public void updateView() {
+               memoryChartBoard.updateChart();
+
+               /*
+                * In case of Latest status, update visibleStartTime of chartBoard.
+                * Because Chart should be refreshed automatically even Page change.
+                */
+               if (AnalyzerUtil.isLatestTraceMode(MemoryPage.pageID)) {
+                       memoryChartBoard.updateVisibleStartTime();
+                       memoryChartBoard.setTotalEndTime(Toolbar.INSTANCE.getTime(), true);
+               } else {
+                       memoryChartBoard.setTotalEndTime(Toolbar.INSTANCE.getTime(), false);
+               }
+
+               memoryChartBoard.setTimelineMarkerStartTime(rangeDataManager.getMarkerStartTime()
+                               / TimelineConstants.MEGA_DOUBLE);
+               memoryChartBoard.setTimelineMarkerEndTime(rangeDataManager.getMarkerEndTime()
+                               / TimelineConstants.MEGA_DOUBLE);
+
+               if (RangeDataManager.getInstance().isBeingAnalyzed()) {
+                       ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
+                                       UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(
+                                       rangeDataManager.getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
+                                       rangeDataManager.getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE);
+               } else {
+                       ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
+                                       UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1, -1);
+               }
+
+               ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
+                               UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
+                               rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE,
+                               rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
+
+       }
+
+       @Override
+       public void updateView(DAViewData data) {
+               memoryChartBoard.updateChart();
+               if (data instanceof DASelectionData == false) {
+                       return;
+               }
+               DASelectionData selData = (DASelectionData) data;
+               String id = data.getViewID();
+               if (id.equals(NetworkPage.chartViewID) || id.equals(NetworkPage.detailViewID)) {
+                       return;
+               }
+               if (id.equals(NetworkPage.listViewID)) {
+                       moveChartPosition(selData.getStartTime(), -1);
+               } else {
+                       updateFromOtherView(selData.getData());
+               }
+       }
+       
+       @Override
+       public void clear() {
+               memoryChartBoard.clear();
+       }
+
+       @Override
+       public Control getControl() {
+               return memoryChartBoard;
+       }
+       
+       private void updateFromOtherView(Object obData) {
+               if (null == obData || (obData instanceof LogData == false)) { // summary
+                       return;
+               }
+               LogData ldata = (LogData) obData;
+               long dataTime = ldata.getTime();
+               if (null != lastSelectedItemForSummary) {
+                       AnalyzerManager.getCurrentPage().updateView(
+                                       new DASelectionData(NetworkPage.chartViewID, dataTime, dataTime,
+                                                       lastSelectedItemForSummary.getData(), null));
+               }
+               moveChartPosition(dataTime, ldata.getSeq());
+       }
+
+       private void moveChartPosition(long dataTime, long seq) {
+               double selectionTime = dataTime / TimelineConstants.MEGA_DOUBLE;
+               memoryChartBoard.setVisibleMiddleTime(selectionTime);
+               DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) memoryChartBoard
+                               .getMarkers().get(UICommonConstants.SELECTION_MARKER_INDEX);
+               intervalMarker.setInterval(selectionTime, selectionTime);
+               if (seq > 0) {
+                       int parentChartIndex = MemoryDataManager.getInstance().getParentIndexOfSeq(seq);
+                       int childChartIndex = MemoryDataManager.getInstance().getChildIndexOfSeq(seq);
+
+                       memoryChartBoard.selectItem(parentChartIndex, childChartIndex);
+               }
+       }
 }
index 0b6f28e..eb1b880 100755 (executable)
@@ -16,6 +16,9 @@ import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 
 public class MemoryDetailsTableView extends DAViewComposite {
+       
+       public static final String ID = MemoryDetailsTableView.class.getName();
+       
        public static final int ITEM_TABLE_IDEX = 0;
        public static final int CURRENT_TABLE_INDEX = 1;
        public static final int START_TABLE_INDEX = 2;
index 785d483..3e09a0b 100755 (executable)
@@ -34,4 +34,8 @@ public class MemoryChartBoard extends DAChartBoard {
                rangeMarker.setAlpha((int) (255 * 0.25));\r
                addIntervalMarker(rangeMarker);\r
        }\r
+       \r
+       public void updateChart() {\r
+               \r
+       }\r
 }\r
index d068d4d..2cbcfdb 100644 (file)
@@ -6,7 +6,8 @@ import java.util.List;
 import org.tizen.dynamicanalyzer.database.DBTable;
 
 public class AllocateCallStackDBTable extends DBTable {
-
+       private static final String TABLENAME = "MEMORY_CALLSTACK_DATA";
+       
        @Override
        public boolean prepare(PreparedStatement prep, List<Object> rowData) {
                // TODO Auto-generated method stub
@@ -15,8 +16,7 @@ public class AllocateCallStackDBTable extends DBTable {
 
        @Override
        public String getTableName() {
-               // TODO Auto-generated method stub
-               return null;
+               return TABLENAME;
        }
 
 }
index f58c657..c6364b8 100644 (file)
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
+import java.sql.SQLException;
 import java.util.List;
 
+import org.tizen.dynamicanalyzer.common.DALimit;
+import org.tizen.dynamicanalyzer.database.DBColumn;
+import org.tizen.dynamicanalyzer.database.DBConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
 
 public class AllocateDBTable extends DBTable {
+       private static final String TABLENAME = "MEMORY_ALLOCATED_DATA";
 
+       public enum COLUMN {
+               SEQUENCE_NUMBER(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
+               PID(1, DBConstants.DBCOLUMN_PID),
+               API_ID(2, DBConstants.DBCOLUMN_API_ID),
+               API_TYPE(3, DBConstants.DBCOLUMN_API_TYPE),
+               ALLOCATED_ADDRESS(4, "ALLOCATED_ADDRESS"),
+               ALLOCATED_TIME(5, "ALLOCATED_TIME"),
+               CALLER_PC_ADDRESS(6, DBConstants.DBCOLUMN_CALLER_PC_ADDRESS),
+               ARGUMENT(7, DBConstants.DBCOLUMN_ARGUMENT),
+               RETURN_VALUE(8, DBConstants.DBCOLUMN_RETURN_VALUE),
+               CALLER_LIBRARY_NAME(9, DBConstants.DBCOLUMN_CALLER_LIBRARY_NAME),
+               MESSAGE_ID(10, "MESSAGE_ID"),
+               TID(11, DBConstants.DBCOLUMN_TID),
+               ALLOCATED_MEMORY_SIZE(12, "ALLOCATED_MEMORY_SIZE");
+               // MEMORY_ALLOCATION_KEY(13, "MEMORY_ALLOCATION_KEY"),
+               // MEMORY_ALLOCATION_PARENT_KEY(14, "MEMORY_ALLOCATION_PARENT_KEY");
+
+               public final int index;
+               public final String name;
+
+               COLUMN(int index, String name) {
+                       this.index = index;
+                       this.name = name;
+               }
+       }
+       
        @Override
-       public boolean prepare(PreparedStatement prep, List<Object> rowData) {
-               // TODO Auto-generated method stub
-               return false;
+       public String getTableName() {
+               return TABLENAME;
+       }
+       
+       public AllocateDBTable() {
+               addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY,
+                               DBConstants.DBTYPE_INT8));
+               addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.API_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.ALLOCATED_ADDRESS.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_LONG)); // default:-1
+               addColumn(new DBColumn(COLUMN.ALLOCATED_TIME.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(COLUMN.CALLER_PC_ADDRESS.name, DBConstants.EMPTY,
+                               DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(COLUMN.ARGUMENT.name, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR,
+                               DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH));
+               addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY,
+                               DBConstants.DBTYPE_VARCHAR, DALimit.FUNCTION_ARGUMENTS_FORMAT_LENGTH));
+               addColumn(new DBColumn(COLUMN.CALLER_LIBRARY_NAME.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_VARCHAR, DALimit.FUNCTION_NAME_LENGTH));
+               addColumn(new DBColumn(COLUMN.MESSAGE_ID.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.ALLOCATED_MEMORY_SIZE.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_LONG));
+               // addColumn(new DBColumn(COLUMN.MEMORY_ALLOCATION_KEY.name,
+               // DBConstants.NOT_NULL, DBConstants.INTEGER));
+               // addColumn(new DBColumn(COLUMN.MEMORY_ALLOCATION_PARENT_KEY.name,
+               // DBConstants.NOT_NULL, DBConstants.INTEGER));
+               setIndexColumn(COLUMN.PID.index);
+               setIndexColumn(COLUMN.ALLOCATED_ADDRESS.index);
        }
 
        @Override
-       public String getTableName() {
-               // TODO Auto-generated method stub
-               return null;
+       public boolean prepare(PreparedStatement prep, List<Object> rowData) {
+               boolean isPrepared = true;
+               
+               int columnsize = getColumnSize();
+               if (columnsize != rowData.size()) {
+                       isPrepared = false;
+               } else {
+                       try {
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.SEQUENCE_NUMBER.index)));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.PID.index)));
+                               prep.setInt(3, (Integer) (rowData.get(COLUMN.API_ID.index)));
+                               prep.setInt(4, (Integer) (rowData.get(COLUMN.API_TYPE.index)));
+                               prep.setLong(5, (Long) (rowData.get(COLUMN.ALLOCATED_ADDRESS.index)));
+                               prep.setLong(6, (Long) (rowData.get(COLUMN.ALLOCATED_TIME.index)));
+                               prep.setLong(7, (Long) (rowData.get(COLUMN.CALLER_PC_ADDRESS.index)));
+                               prep.setString(8, (String) (rowData.get(COLUMN.ARGUMENT.index)));
+                               prep.setString(9, (String) (rowData.get(COLUMN.RETURN_VALUE.index)));
+                               prep.setString(10, (String) (rowData.get(COLUMN.CALLER_LIBRARY_NAME.index)));
+                               prep.setInt(11, (Integer) (rowData.get(COLUMN.MESSAGE_ID.index)));
+                               prep.setInt(12, (Integer) (rowData.get(COLUMN.TID.index)));
+                               prep.setLong(13, (Long) (rowData.get(COLUMN.ALLOCATED_MEMORY_SIZE.index)));
+//                             prep.setInt(13, (Integer) (rowData.get(COLUMN.MEMORY_ALLOCATION_KEY.index)));
+//                             prep.setInt(14, (Integer) (rowData.get(COLUMN.MEMORY_ALLOCATION_PARENT_KEY.index)));
+                       } catch (SQLException e) {
+                               Logger.exception(e);
+                               isPrepared = false;
+                       }
+               }
+               
+               return isPrepared;
        }
 
 }
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/FreeDBTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/FreeDBTable.java
new file mode 100644 (file)
index 0000000..7b0cc66
--- /dev/null
@@ -0,0 +1,73 @@
+package org.tizen.dynamicanalyzer.ui.memory.data;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.database.DBColumn;
+import org.tizen.dynamicanalyzer.database.DBConstants;
+import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+public class FreeDBTable extends DBTable {
+       private static final String TABLENAME = "MEMORY_FREE_DATA";
+       
+       public enum COLUMN {
+               SEQUENCE_NUMBER(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
+               PID(1, DBConstants.DBCOLUMN_PID),
+               MESSAGE_ID(2, "MESSAGE_ID"),
+               FREE_TIME(3, "FREE_TIME"),
+               ALLOCATED_ADDRESS(4, "ALLOCATED_ADDRESS");
+               
+               public final int index;
+               public final String name;
+               
+               COLUMN(int index, String name) {
+                       this.index = index;
+                       this.name = name;
+               }
+       }
+       
+       @Override
+       public String getTableName() {
+               return TABLENAME;
+       }
+       
+       public FreeDBTable() {
+               addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY,
+                               DBConstants.DBTYPE_INT8));
+               addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.MESSAGE_ID.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(COLUMN.FREE_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG)); // default:0
+               addColumn(new DBColumn(COLUMN.ALLOCATED_ADDRESS.name, DBConstants.NOT_NULL,
+                               DBConstants.DBTYPE_LONG));
+               setIndexColumn(COLUMN.PID.index);
+               setIndexColumn(COLUMN.FREE_TIME.index);
+       }
+
+       @Override
+       public boolean prepare(PreparedStatement prep, List<Object> rowData) {
+               boolean isPrepared = true;
+               
+               int columnsize = getColumnSize();
+               if (columnsize != rowData.size()) {
+                       isPrepared = false;
+               } else {
+                       try {
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.SEQUENCE_NUMBER.index)));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.PID.index)));
+                               prep.setInt(3, (Integer) (rowData.get(COLUMN.MESSAGE_ID.index)));
+                               prep.setLong(4, (Long) (rowData.get(COLUMN.FREE_TIME.index)));
+                               prep.setLong(5, (Long) (rowData.get(COLUMN.ALLOCATED_ADDRESS.index)));
+                       } catch (SQLException e) {
+                               Logger.exception(e);
+                               isPrepared = false;
+                       }
+               }
+               
+               return isPrepared;
+       }
+
+}
index 6f07790..c14889a 100755 (executable)
@@ -1,27 +1,91 @@
+/*\r
+ *  Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Dongkye Lee <dongkyu6.lee@samsung.com>\r
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>\r
+ * Gihun Chang <gihun.chang@@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ */\r
+\r
 package org.tizen.dynamicanalyzer.ui.memory.data;\r
 \r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.LinkedHashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
+import org.tizen.dynamicanalyzer.common.Global;\r
+import org.tizen.dynamicanalyzer.constant.CommonConstants;\r
 import org.tizen.dynamicanalyzer.database.DBInserter;\r
+import org.tizen.dynamicanalyzer.database.SqlConnectionManager;\r
+import org.tizen.dynamicanalyzer.project.BinaryInfo;\r
+import org.tizen.dynamicanalyzer.project.LibraryObject;\r
+import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;\r
+import org.tizen.dynamicanalyzer.project.Project;\r
 import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;\r
 import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;\r
 import org.tizen.dynamicanalyzer.swap.logparser.Logs;\r
 import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;\r
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;\r
+import org.tizen.dynamicanalyzer.swap.model.data.MemoryData;\r
+import org.tizen.dynamicanalyzer.swap.model.data.ProcessProfileData;\r
+import org.tizen.dynamicanalyzer.swap.model.data.SystemData;\r
+import org.tizen.dynamicanalyzer.util.Logger;\r
+import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;\r
 \r
 public class MemoryDataManager extends PageDataManager {\r
        private static MemoryDataManager instance = new MemoryDataManager();\r
        \r
+       private DAChartBoard chartBoard = null;\r
+       \r
+       private static final int MEM_API_TYPE_ALLOC = 0;\r
+       private static final int MEM_API_TYPE_FREE = 1;\r
+       private static final int MEM_USER = 2;\r
+       private static final int appAllocSeriesID = -10;\r
+       \r
+       // Map<PID, target Allocation Byte>\r
+       private Map<Integer, Long> allocByteMap = new HashMap<Integer, Long>(); \r
+       // Map<PID, Map<binaryID, Allocation Byte>>\r
+       private Map<Integer, Map<Integer, Long>> libraryAllocByteMap = new HashMap<Integer, Map<Integer, Long>>();\r
+       // Map<Address, Allocation Byte>\r
+       private HashMap<Long, Long> allocationSeriesDataSetMap = new HashMap<Long, Long>();\r
+       \r
+       private ArrayList<List<Object>> memoryAllocDataList = new ArrayList<List<Object>> ();\r
+       private ArrayList<List<Object>> memoryfreeDataList = new ArrayList<List<Object>> ();\r
+       \r
        private SystemMemoryDBTable systemMemoryDBTable = null;\r
        private ProcessMemoryDBTable processMemoryDBTable = null;\r
        private AllocateDBTable allocateDBTable = null;\r
+       private FreeDBTable freeDBTable = null;\r
        private AllocateCallStackDBTable allocateCallStackDBTable = null;\r
        \r
        private DBInserter systemMemoryDBInserter = null;\r
        private DBInserter processMemoryDBInserter = null;\r
        private DBInserter allocateDBInserter = null;\r
+       private DBInserter freeDBInserter = null;\r
        private DBInserter allocateCallStackDBInserter = null;\r
+       \r
+       private LinkedHashMap<Long, Integer> parentChartIndexOfSeq = new LinkedHashMap<Long, Integer>();\r
+       private LinkedHashMap<Long, Integer> childChartIndexOfSeq = new LinkedHashMap<Long, Integer>();\r
 \r
        public static MemoryDataManager getInstance() {\r
                return instance;\r
@@ -31,39 +95,47 @@ public class MemoryDataManager extends PageDataManager {
                systemMemoryDBTable = new SystemMemoryDBTable();\r
                processMemoryDBTable = new ProcessMemoryDBTable();\r
                allocateDBTable = new AllocateDBTable();\r
+               freeDBTable = new FreeDBTable();\r
                allocateCallStackDBTable = new AllocateCallStackDBTable();\r
                \r
                systemMemoryDBInserter = makeInserter(systemMemoryDBTable);\r
                processMemoryDBInserter = makeInserter(processMemoryDBTable);\r
                allocateDBInserter = makeInserter(allocateDBTable);\r
-               allocateCallStackDBInserter = makeInserter(allocateCallStackDBTable);\r
+               freeDBInserter = makeInserter(freeDBTable);\r
+               allocateCallStackDBInserter = makeInserter(allocateCallStackDBTable); \r
+       }\r
+\r
+       public void setChartMemoryChartBoard(DAChartBoard board) {\r
+               chartBoard = board;\r
        }\r
        \r
        public void clear() {\r
-               \r
+               allocByteMap = new HashMap<Integer, Long>();\r
+               libraryAllocByteMap = new HashMap<Integer, Map<Integer, Long>>();\r
+               allocationSeriesDataSetMap = new HashMap<Long, Long>();\r
+               parentChartIndexOfSeq = new LinkedHashMap<Long, Integer>();\r
+               childChartIndexOfSeq = new LinkedHashMap<Long, Integer>();\r
+\r
+               memoryAllocDataList.clear();\r
+               memoryfreeDataList.clear();\r
        }\r
-       \r
+\r
        public void saveData(Map<String, String> dataMap) {\r
-               \r
+\r
        }\r
        \r
        public void openData(Map<String, String> dataMap) {\r
-               \r
+\r
        }\r
-       \r
+\r
        @Override\r
        protected void makeData(LogPackage pack) {\r
                Logs systemmemorylogs = getLogsFromLogPackage(pack, ProtocolConstants.MSG_DATA_SYSTEM);\r
-               if (null != systemmemorylogs) {\r
-                       makeSystemMemoryData(systemmemorylogs);\r
-               }\r
-               \r
                Logs allocatedlogs = getLogsFromLogPackage(pack, ProtocolConstants.MSG_PROBE_MEMORY);\r
-               if (null != allocatedlogs) {\r
-                       makeAllocateMemoryData(allocatedlogs);\r
-               }\r
+\r
+               makeSystemMemoryData(systemmemorylogs, allocatedlogs);\r
        }\r
-       \r
+\r
        private Logs getLogsFromLogPackage(LogPackage logPack, int logCenterConstants) {\r
                Logs logs = logPack.getLogs(logCenterConstants);\r
                if (null == logs || logs.getRawLogs().size() == 0) {\r
@@ -72,12 +144,458 @@ public class MemoryDataManager extends PageDataManager {
                \r
                return logs;\r
        }\r
+\r
+       private void makeSystemMemoryData(Logs syslogs, Logs alloclogs) {\r
+               List<LogData> memoryLogList = alloclogs == null ? null : alloclogs.getRawLogs();\r
+               List<LogData> systemLogList = syslogs == null ? null : syslogs.getRawLogs();\r
+               \r
+               if (memoryLogList != null) {\r
+                       GetAllocationData(memoryLogList);\r
+\r
+                       if (memoryAllocDataList.size() > 0) {\r
+                               @SuppressWarnings("unchecked")\r
+                               List<List<Object>> mList = (List<List<Object>>) memoryAllocDataList.clone();\r
+                               memoryAllocDataList.clear();\r
+\r
+                               allocateDBInserter.pushData(mList);\r
+                       }\r
+\r
+                       if (memoryfreeDataList.size() > 0) {\r
+                               @SuppressWarnings("unchecked")\r
+                               List<List<Object>> fList = (List<List<Object>>) memoryfreeDataList.clone();\r
+                               memoryfreeDataList.clear();\r
+\r
+                               freeDBInserter.pushData(fList);\r
+                       }       \r
+               }\r
+               \r
+               if (systemLogList != null) {\r
+                       GetSystemMemoryData(systemLogList);\r
+               }\r
+       }\r
+\r
+       private void addNewSeriesUserAllocData(int fdApiType, MemoryData log, BinaryInfo libraryInfo) {\r
+               long size = 0;\r
+               Long allocByte = allocByteMap.get(log.getPid());\r
+\r
+               long address = log.getAddress();\r
+               if (address == 0) {\r
+                       return;\r
+               }\r
+\r
+               if (MEM_API_TYPE_ALLOC == fdApiType) {\r
+                       try {\r
+                               size = log.getSize();\r
+                               if (libraryInfo == null) {\r
+                                       allocByteMap.put(log.getPid(), allocByte + size);\r
+                               } else {\r
+                                       Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(\r
+                                                       libraryInfo.getID());\r
+                                       if (libraryAllocByte == null) {\r
+                                               libraryAllocByte = new Long(0);\r
+                                       }\r
+                                       libraryAllocByteMap.get(log.getPid()).put(libraryInfo.getID(),\r
+                                                       libraryAllocByte + size);\r
+                               }\r
+                               allocationSeriesDataSetMap.put(address, size);\r
+                       } catch (NumberFormatException ne) {\r
+                               Logger.exception(ne);\r
+                       }\r
+               } else if (MEM_API_TYPE_FREE == fdApiType) {\r
+                       if (!allocationSeriesDataSetMap.containsKey(address)) {\r
+                               return;\r
+                       }\r
+                       size = allocationSeriesDataSetMap.get(address);\r
+\r
+                       if (libraryInfo == null) {\r
+                               allocByteMap.put(log.getPid(), allocByte - size);\r
+                       } else {\r
+                               Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(\r
+                                               libraryInfo.getID());\r
+                               libraryAllocByteMap.get(log.getPid()).put(libraryInfo.getID(),\r
+                                               libraryAllocByte - size);\r
+                       }\r
+               }\r
+       }\r
+\r
+       public void makeAllocData(MemoryData log) {\r
+               ArrayList<Object> dbAllocData = new ArrayList<Object>();\r
+\r
+               MemoryData mData = log;\r
+\r
+               dbAllocData.add(Long.valueOf(mData.getSeq()));\r
+               dbAllocData.add(Integer.valueOf(mData.getPid()));\r
+               dbAllocData.add(Integer.valueOf(mData.getApiId()));\r
+               dbAllocData.add(Integer.valueOf(mData.getMemoryApiType()));\r
+               dbAllocData.add(Long.valueOf(mData.getAddress()));\r
+               dbAllocData.add(Long.valueOf(mData.getTime()));\r
+               dbAllocData.add(Long.valueOf(mData.getCallerPcAddr()));\r
+               dbAllocData.add(String.valueOf(mData.getArgs()));\r
+               dbAllocData.add(String.valueOf(mData.getReturn()));\r
+               dbAllocData.add(String.valueOf(mData.getLibName()));\r
+               dbAllocData.add(Integer.valueOf(mData.getMsgID()));\r
+               dbAllocData.add(Integer.valueOf(mData.getTid()));\r
+               dbAllocData.add(Long.valueOf(mData.getSize()));\r
+\r
+               memoryAllocDataList.add(dbAllocData);\r
+       }\r
+\r
+       public void makeFreeData(MemoryData log) {\r
+               ArrayList<Object> dbFreeData = new ArrayList<Object>();\r
+\r
+               MemoryData mData = log;\r
+\r
+               dbFreeData.add(Long.valueOf(mData.getSeq()));\r
+               dbFreeData.add(Integer.valueOf(mData.getPid()));\r
+               dbFreeData.add(Integer.valueOf(mData.getMsgID()));\r
+               dbFreeData.add(Long.valueOf(mData.getTime()));\r
+               dbFreeData.add(Long.valueOf(mData.getAddress()));\r
+\r
+               memoryfreeDataList.add(dbFreeData);\r
+       }\r
+\r
+       public List<List<Object>> getSystemDataFromDB(long start, long end) {\r
+               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end\r
+                               + " ORDER BY SAMPLING_TIME";\r
+               List<List<Object>> result = systemMemoryDBTable.selectAllColumnData(where);\r
+\r
+               if (result != null) {\r
+                       return result;\r
+               } else {\r
+                       return new ArrayList<List<Object>>();\r
+               }\r
+       }\r
+\r
+       public Map<Integer, List<List<Object>>> getTargetProcessDataFromDB(long start, long end,\r
+                       int targetPID) {\r
+               Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();\r
+               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end;\r
+               if (targetPID > 0) {\r
+                       where += " AND PID = " + targetPID;\r
+               } else {\r
+                       // Do nothing. Get information from all processes.\r
+               }\r
+               where += " ORDER BY SAMPLING_TIME";\r
+\r
+               List<List<Object>> queryResult = processMemoryDBTable.selectAllColumnData(where);\r
+               if (queryResult == null) {\r
+                       return processedResult;\r
+               }\r
+\r
+               for (int i = 0; i < queryResult.size(); i++) {\r
+                       List<Object> row = queryResult.get(i);\r
+                       Integer pid = (Integer) row.get(ProcessMemoryDBTable.COLUMN.PID.ordinal());\r
+                       List<List<Object>> processData = processedResult.get(pid);\r
+                       if (processData == null) {\r
+                               processData = new ArrayList<List<Object>>();\r
+                               processedResult.put(pid, processData);\r
+                       }\r
+                       processData.add(row);\r
+               }\r
+               return processedResult;\r
+       }\r
+\r
+       public long getProcessMemoriesFromDB(long time) {\r
+               long processMemories = 0;\r
+               String query = "SELECT MEMORY_RESIDENT FROM MEMORY_PROCESS_DATA WHERE SAMPLING_TIME = "\r
+                               + "(SELECT MAX(SAMPLING_TIME) FROM MEMORY_PROCESS_DATA WHERE SAMPLING_TIME <= "\r
+                               + time + ")";\r
+               ResultSet rs = SqlConnectionManager.executeQueryRS(query);\r
+               if (rs != null) {\r
+                       try {\r
+                               while (rs.next()) {\r
+                                       processMemories += rs.getLong(1);\r
+                               }\r
+                       } catch (SQLException e) {\r
+                               Logger.exception(e);\r
+                       } finally {\r
+                               SqlConnectionManager.releaseResultSet(rs);\r
+                       }\r
+               }\r
+               return processMemories;\r
+       }\r
+       \r
+       public List<List<Object>> getAllocationDataFromDB(long start, long end, int targetPID) {\r
+               List<List<Object>> allocatedResult = new ArrayList<List<Object>> ();\r
+               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end;\r
+               if (targetPID > 0) {\r
+                       where += " AND PID = " + targetPID;\r
+               } else {\r
+                       // Do nothing. Get information from all processes.\r
+               }\r
+               where += " ORDER BY SAMPLING_TIME";\r
+\r
+               List<List<Object>> queryResult = allocateDBTable.selectAllColumnData(where);\r
+               if (queryResult == null) {\r
+                       return allocatedResult;\r
+               }\r
+               allocatedResult = queryResult;\r
+\r
+               return allocatedResult;\r
+       }\r
+\r
+       public List<List<Object>> getFreeDataFromDB(long start, long end, int targetPID) {\r
+               List<List<Object>> freeResult = new ArrayList<List<Object>> ();\r
+               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end;\r
+               if (targetPID > 0) {\r
+                       where += " AND PID = " + targetPID;\r
+               } else {\r
+                       // Do nothing. Get information from all processes.\r
+               }\r
+               where += " ORDER BY SAMPLING_TIME";\r
+\r
+               List<List<Object>> queryResult = freeDBTable.selectAllColumnData(where);\r
+               if (queryResult == null) {\r
+                       return freeResult;\r
+               }\r
+               freeResult = queryResult;\r
+\r
+               return freeResult;\r
+       }\r
        \r
-       private void makeSystemMemoryData(Logs syslogs) {\r
+       public List<List<Object>> makeLeakDataForRange(long startTime, long endTime, int targetPID) {\r
+               List<List<Object>> rangeDataList = new ArrayList<List<Object>> ();\r
+               \r
+               if (targetPID != 0) {\r
+                               List<List<Object>> allocDataList = getAllocationDataFromDB(startTime, endTime, targetPID);\r
+                               List<List<Object>> freeDataList = getFreeDataFromDB(startTime, endTime, targetPID);\r
+                               \r
+                               if (allocDataList != null) {\r
+                                       if (freeDataList == null) {\r
+                                               rangeDataList.addAll(allocDataList);\r
+                                       } else {\r
+                                               List<List<Object>> result = makeSubLeakDataForRange(allocDataList, freeDataList);\r
+                                               if (result != null && !result.isEmpty())\r
+                                                       rangeDataList.addAll(result);\r
+                                       }\r
+                               }\r
+               } else {\r
+                       int[] pids = Global.getProject().getProcessIDs();\r
+                       for (int i = 0; i < pids.length; i++) {\r
+                               List<List<Object>> allocDataList = getAllocationDataFromDB(startTime,\r
+                                               endTime, pids[i]);\r
+                               List<List<Object>> freeDataList = getFreeDataFromDB(startTime, endTime,\r
+                                               pids[i]);\r
+\r
+                               if (allocDataList == null)\r
+                                       continue;\r
+\r
+                               if (freeDataList == null) {\r
+                                       rangeDataList.addAll(allocDataList);\r
+                                       continue;\r
+                               }\r
+\r
+                               List<List<Object>> result = makeSubLeakDataForRange(allocDataList, freeDataList);\r
+                               if (result != null && !result.isEmpty())\r
+                                       rangeDataList.addAll(result);\r
+                       }\r
+               }\r
                \r
+               return rangeDataList;\r
        }\r
        \r
-       private void makeAllocateMemoryData(Logs alloclogs) {\r
+       private List<List<Object>> makeSubLeakDataForRange(List<List<Object>> allocData, List<List<Object>> freeData) {\r
+               for (int i = 0; i < freeData.size(); i++) {\r
+                       List<Object> iFreeData = freeData.get(i);\r
+                       long address = (Long) iFreeData.get(4);\r
+                       long freeTime = (Long) iFreeData.get(3);\r
+\r
+                       int allocDataSize = allocData.size();\r
+                       for (int j = 0; j < allocDataSize; j++) {\r
+                               List<Object> iAllocData = allocData.get(j);\r
+                               long allocatedTime = (Long) iAllocData.get(AllocateDBTable.COLUMN.ALLOCATED_TIME.index);\r
+                               if (allocatedTime <= freeTime) {\r
+                                       if (address == (Long) iAllocData.get(AllocateDBTable.COLUMN.ALLOCATED_ADDRESS.index)) {\r
+                                               allocData.remove(j);\r
+                                               break;\r
+                                       }\r
+                               } else {\r
+                                       break;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               return allocData;\r
+       }\r
+\r
+       public int getParentIndexOfSeq(long seq) {\r
+               Integer chartIndex = this.parentChartIndexOfSeq.get(seq);\r
+               if (null != chartIndex) {\r
+                       return chartIndex;\r
+               } else {\r
+                       return 0;\r
+               }\r
+       }\r
+\r
+       public void setParentIndexOfSeq(long seq, int paretnChartIndex) {\r
+               Integer chartIndex = this.parentChartIndexOfSeq.get(seq);\r
+               if (null == chartIndex) {\r
+                       this.parentChartIndexOfSeq.put(seq, paretnChartIndex);\r
+               }\r
+\r
+       }\r
+\r
+       public int getChildIndexOfSeq(long seq) {\r
+               Integer chartIndex = this.childChartIndexOfSeq.get(seq);\r
+               if (null != chartIndex) {\r
+                       return chartIndex;\r
+               } else {\r
+                       return 0;\r
+               }\r
+       }\r
+\r
+       public void setChildIndexOfSeq(long seq, int childChartIndex) {\r
+               Integer chartIndex = this.childChartIndexOfSeq.get(seq);\r
+               if (null == chartIndex) {\r
+                       this.childChartIndexOfSeq.put(seq, childChartIndex);\r
+               }\r
+       }\r
+\r
+       private void GetAllocationData(List<LogData> memoryLogList) {\r
+               int size = memoryLogList.size();\r
+               for (int i = 0; i < size; i++) {\r
+                       MemoryData logData = (MemoryData) memoryLogList.get(i);\r
+                       if (allocByteMap.get(logData.getPid()) == null) {\r
+                               allocByteMap.put(Integer.valueOf(logData.getPid()), new Long(0));\r
+                               libraryAllocByteMap.put(Integer.valueOf(logData.getPid()), new HashMap<Integer, Long>());\r
+                       }\r
+\r
+                       int memApiType = logData.getMemoryApiType();\r
+                       int internalFlag = logData.getInternalCall();\r
+                       long errorNo = logData.getErrno();\r
+               \r
+                       /*\r
+                        * Check library allocation\r
+                        */\r
+                       BinaryInfo binaryInfo = null;\r
+                       Project project = Global.getProject();\r
+                       ProcessMemoryMap pmap = project.getProcessInformation(logData.getPid()).getProcessMemoryMap(logData.getTime());\r
+\r
+                       if (pmap != null) {\r
+                               LibraryObject lib = pmap.getLibraryByAddress(logData.getCallerPcAddr());\r
+                               if (lib != null && lib != pmap.getMainbinary()) {\r
+                                       binaryInfo = project.getDeviceStatusInfo().getBinaryInfo(lib.getBinaryID());\r
+                               }\r
+                       }\r
+\r
+                       if (errorNo == 0 && MEM_USER == internalFlag) {\r
+                               if (MEM_API_TYPE_ALLOC == memApiType || MEM_API_TYPE_FREE == memApiType) {\r
+                                       addNewSeriesUserAllocData(memApiType, logData, binaryInfo);\r
+                               }\r
+                       }\r
+\r
+                       if(MEM_API_TYPE_ALLOC == memApiType) {\r
+                               makeAllocData(logData);\r
+                       }\r
+                       else if(MEM_API_TYPE_FREE == memApiType) {\r
+                               makeFreeData(logData);\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+       private void GetSystemMemoryData(List<LogData> systemLogList) {\r
+               ArrayList<List<Object>> systemDataList = new ArrayList<List<Object>>();\r
+               ArrayList<List<Object>> targetProcessDataList = new ArrayList<List<Object>>();\r
+\r
+               int size = systemLogList.size();\r
+               for (int i = 0; i < size; i++) {\r
+                       SystemData log = (SystemData) systemLogList.get(i);\r
+                       \r
+                       /*\r
+                        * Make information for other process\r
+                        */\r
+                       List<Object> pIDList = new ArrayList<Object>();\r
+                       List<Object> processLoadList = new ArrayList<Object>();\r
+                       String[] processLoadDatas = log.getOtherProcessLoad().split(CommonConstants.COMMA);\r
+                       for (int ii = 0; ii < processLoadDatas.length; ii++) {\r
+                               String processLoad = processLoadDatas[ii];\r
+                               if (processLoad == null || processLoad.isEmpty()) {\r
+                                       continue;\r
+                               }\r
+                               pIDList.add(new Integer(processLoad));\r
+                               processLoadList.add(processLoadDatas[++ii]);\r
+                       }\r
+\r
+                       /*\r
+                        * Make SystemData Table data\r
+                        */\r
+                       ArrayList<Object> dbSystemData = new ArrayList<Object>();\r
+                       dbSystemData.add(new Long(log.getTime()));\r
+                       dbSystemData.add(new Long(log.getSystemMemoryUsed()));\r
+                       dbSystemData.add(pIDList);\r
+                       dbSystemData.add(processLoadList);\r
+                       systemDataList.add(dbSystemData);\r
+\r
+                       /*\r
+                        * Make target Process Table data\r
+                        */\r
+                       ProcessProfileData[] targetProcessList = log.getProcessProfileDataList();\r
+                       if (targetProcessList != null) {\r
+                               for (int j = 0; j < targetProcessList.length; j++) {\r
+                                       ProcessProfileData process = targetProcessList[j];\r
+\r
+                                       ArrayList<Object> dbTargetProcessData = new ArrayList<Object>();\r
+                                       dbTargetProcessData.add(new Long(log.getTime()));\r
+                                       dbTargetProcessData.add(new Integer(process.getPid()));\r
+                                       dbTargetProcessData.add(new Float(process.getProcessLoad()));\r
+                                       dbTargetProcessData.add(new Long(process.getVirtualMemory()));\r
+                                       dbTargetProcessData.add(new Long(process.getResidentMemory()));\r
+                                       dbTargetProcessData.add(new Long(process.getSharedMemory()));\r
+                                       dbTargetProcessData.add(new Long(process.getPssMemory()));\r
+                                       dbTargetProcessData.add(new Integer(process.getThreadCount()));\r
+                                       dbTargetProcessData.add(new Long(process.getTotalAllocSize()));\r
+\r
+                                       /*\r
+                                        * Set inform for Heap allocation\r
+                                        */\r
+                                       List<Object> binaryIDList = new ArrayList<Object>();\r
+                                       List<Object> allocByteList = new ArrayList<Object>();\r
+                                       binaryIDList.add(appAllocSeriesID);\r
+                                       if (allocByteMap.get(process.getPid()) == null) {\r
+                                               allocByteList.add(new Long(0));\r
+                                       } else {\r
+                                               allocByteList.add(allocByteMap.get(process.getPid()));\r
+                                       }\r
+\r
+                                       Map<Integer, Long> libraryList = libraryAllocByteMap.get(process.getPid());\r
+                                       if (libraryList == null) {\r
+                                               libraryList = new HashMap<Integer, Long>();\r
+                                       }\r
+\r
+                                       Iterator<Integer> iter = libraryList.keySet().iterator();\r
+                                       while (iter.hasNext()) {\r
+                                               Integer binaryID = iter.next();\r
+                                               binaryIDList.add(binaryID);\r
+                                               allocByteList.add(libraryList.get(binaryID));\r
+                                       }\r
+                                       dbTargetProcessData.add(binaryIDList);\r
+                                       dbTargetProcessData.add(allocByteList);\r
+\r
+                                       /*\r
+                                        * Set inform for Thread\r
+                                        */\r
+                                       List<Object> threadIdList = new ArrayList<Object>();\r
+                                       List<Object> threadLoadList = new ArrayList<Object>();\r
+                                       // TODO Remove unnecessary String parsing. first Fix in SystemData.java\r
+                                       String[] threadLoads = process.getThreadLoad().split(CommonConstants.COMMA);\r
+                                       for (int iii = 0; iii < threadLoads.length; iii++) {\r
+                                               String threadLoad = threadLoads[iii];\r
+                                               if (threadLoad == null || threadLoad.isEmpty()) {\r
+                                                       continue;\r
+                                               }\r
+                                               threadIdList.add(new Integer(threadLoad));\r
+                                               threadLoadList.add(threadLoads[++iii]);\r
+                                       }\r
+                                       dbTargetProcessData.add(threadIdList);\r
+                                       dbTargetProcessData.add(threadLoadList);\r
+\r
+                                       targetProcessDataList.add(dbTargetProcessData);\r
+                               }\r
+                       }\r
+               }\r
                \r
+               systemMemoryDBInserter.pushData(systemDataList);\r
+               processMemoryDBInserter.pushData(targetProcessDataList);\r
        }\r
 }\r
index 821899e..7aed34c 100644 (file)
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.List;
 
+import org.tizen.dynamicanalyzer.database.DBColumn;
+import org.tizen.dynamicanalyzer.database.DBConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
 
 public class ProcessMemoryDBTable extends DBTable {
+       private static final String TABLENAME = "MEMORY_PROCESS_DATA";
+       
+       public static enum COLUMN {
+               SAMPLING_TIME,
+               PID,
+               CPU_LOAD,
+               MEMORY_VIRTUAL,
+               MEMORY_RESIDENT,
+               MEMORY_SHARED,
+               MEMORY_PSS,
+               THREAD_COUNT,
+               HEAP_ALLOCATION_TOTAL_BYTE,
+               HEAP_ALLOCATION_BINARY_ID,
+               HEAP_ALLOCATION_BYTE,
+               TID,
+               THREAD_LOAD
+       }
+
+       public static final String SAMPLING_TIME = "SAMPLING_TIME";
+       public static final String PID = "PID";
+       public static final String CPU_LOAD = "CPU_LOAD";
+       public static final String MEMORY_VIRTUAL = "MEMORY_VIRTUAL";
+       public static final String MEMORY_RESIDENT = "MEMORY_RESIDENT";
+       public static final String MEMORY_SHARED = "MEMORY_SHARED";
+       public static final String MEMORY_PSS = "MEMORY_PSS";
+       public static final String THREAD_COUNT = "THREAD_COUNT";
+       public static final String HEAP_ALLOCATION_TOTAL_BYTE = "HEAP_ALLOCATION_TOTAL_BYTE";
+       public static final String HEAP_ALLOCATION_BINARY_ID = "HEAP_ALLOCATION_BINARY_ID";
+       public static final String HEAP_ALLOCATION_BYTE = "HEAP_ALLOCATION_BYTE";
+       public static final String TID = "TID";
+       public static final String THREAD_LOAD = "THREAD_LOAD";
 
        @Override
-       public boolean prepare(PreparedStatement prep, List<Object> rowData) {
-               // TODO Auto-generated method stub
-               return false;
+       public String getTableName() {
+               return TABLENAME;
+       }
+
+       public ProcessMemoryDBTable() {
+               addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(PID, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(CPU_LOAD, DBConstants.EMPTY, DBConstants.DBTYPE_FLOAT));
+               addColumn(new DBColumn(MEMORY_VIRTUAL, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(MEMORY_RESIDENT, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(MEMORY_SHARED, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(MEMORY_PSS, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(THREAD_COUNT, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
+               addColumn(new DBColumn(HEAP_ALLOCATION_TOTAL_BYTE, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(HEAP_ALLOCATION_BINARY_ID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
+               addColumn(new DBColumn(HEAP_ALLOCATION_BYTE, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
+               addColumn(new DBColumn(TID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
+               addColumn(new DBColumn(THREAD_LOAD, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
+               setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
        }
 
        @Override
-       public String getTableName() {
-               // TODO Auto-generated method stub
-               return null;
+       public boolean prepare(PreparedStatement prep, List<Object> rowData) {
+               boolean isPrepared = true;
+
+               int columnsize = getColumnSize();
+               if (columnsize != rowData.size()) {
+                       isPrepared = false;
+               } else {
+                       try {
+                               int index = 0;
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.SAMPLING_TIME.ordinal())));
+                               prep.setInt(++index, (Integer) (rowData.get(COLUMN.PID.ordinal())));
+                               prep.setFloat(++index, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_RESIDENT.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_SHARED.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_PSS.ordinal())));
+                               prep.setInt(++index, (Integer) (rowData.get(COLUMN.THREAD_COUNT.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal())));
+                               setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BINARY_ID.ordinal(), 
+                                               DBConstants.DBTYPE_INT4, prep, rowData);
+                               setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BYTE.ordinal(),
+                                               DBConstants.DBTYPE_LONG, prep, rowData);
+                               setArrayToPreparedStatement(COLUMN.TID.ordinal(), DBConstants.DBTYPE_INT4, prep,
+                                               rowData);
+                               setArrayToPreparedStatement(COLUMN.THREAD_LOAD.ordinal(), DBConstants.DBTYPE_FLOAT, prep,
+                                               rowData);
+                       } catch (SQLException e) {
+                               Logger.exception(e);
+                               isPrepared = false;
+                       }
+               }
+
+               return isPrepared;
        }
 
+       @Override
+       public List<Object> extractDataFromResultSet(ResultSet rs) {
+               List<Object> row = new ArrayList<Object>();
+               try {
+                       row.add(Long.valueOf(rs.getLong(1)));
+                       row.add(Integer.valueOf(rs.getInt(2)));
+                       row.add(Float.valueOf(rs.getFloat(3)));
+                       row.add(Long.valueOf(rs.getLong(4)));
+                       row.add(Long.valueOf(rs.getLong(5)));
+                       row.add(Long.valueOf(rs.getLong(6)));
+                       row.add(Long.valueOf(rs.getLong(7)));
+                       row.add(Integer.valueOf(rs.getInt(8)));
+                       row.add(Long.valueOf(rs.getLong(9)));
+                       row.add(getArrayFromResultSet(rs, 10, Integer.valueOf(0)));
+                       row.add(getArrayFromResultSet(rs, 11, Long.valueOf(0)));
+                       row.add(getArrayFromResultSet(rs, 12, Integer.valueOf(0)));
+                       row.add(getArrayFromResultSet(rs, 13, Float.valueOf(0)));
+               } catch (SQLException e) {
+                       Logger.exception(e);
+                       return null;
+               }
+               
+               return row;
+       }
 }
index da88855..8673f46 100644 (file)
@@ -1,22 +1,82 @@
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.List;
 
+import org.tizen.dynamicanalyzer.database.DBColumn;
+import org.tizen.dynamicanalyzer.database.DBConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
 
 public class SystemMemoryDBTable extends DBTable {
+       private static final String TABLENAME = "MEMORY_SYSTEM_DATA";
+       
+       public static enum COLUMN {
+               SAMPLING_TIME,
+               MEMORY_USAGE_SYSTEM,
+               PROCESS_PID_OTHER,
+               PROCESS_LOAD_OTHER,
+       }
 
+       public static final String SAMPLING_TIME = "SAMPLING_TIME";
+       public static final String MEMORY_USAGE_SYSTEM = "MEMORY_USAGE_SYSTEM";
+       public static final String PROCESS_PID_OTHER = "PROCESS_PID_OTHER";
+       public static final String PROCESS_LOAD_OTHER = "PROCESS_LOAD_OTHER";
+       
+       public SystemMemoryDBTable() {
+               addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(MEMORY_USAGE_SYSTEM, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+               addColumn(new DBColumn(PROCESS_PID_OTHER, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
+               addColumn(new DBColumn(PROCESS_LOAD_OTHER, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
+               setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
+       }
+       
        @Override
        public boolean prepare(PreparedStatement prep, List<Object> rowData) {
-               // TODO Auto-generated method stub
-               return false;
+               boolean isPrepared = true;
+
+               int columnsize = getColumnSize();
+               if (columnsize != rowData.size()) {
+                       isPrepared = false;
+               } else {
+                       try {
+                               int index = 1;
+                               prep.setLong(index++, (Long) (rowData.get(COLUMN.SAMPLING_TIME.ordinal())));
+                               prep.setLong(index++, (Long) (rowData.get(COLUMN.MEMORY_USAGE_SYSTEM.ordinal())));
+                               setArrayToPreparedStatement(COLUMN.PROCESS_PID_OTHER.ordinal(),
+                                               DBConstants.DBTYPE_INT4, prep, rowData);
+                               setArrayToPreparedStatement(COLUMN.PROCESS_LOAD_OTHER.ordinal(), DBConstants.DBTYPE_FLOAT,
+                                               prep, rowData);
+                       } catch (SQLException e) {
+                               Logger.exception(e);
+                               isPrepared = false;
+                       }
+               }
+               return isPrepared;
        }
 
        @Override
        public String getTableName() {
-               // TODO Auto-generated method stub
-               return null;
+               return TABLENAME;
+       }
+       
+       @Override
+       public List<Object> extractDataFromResultSet(ResultSet rs) {
+               List<Object> row = new ArrayList<Object>();
+               try {
+                       row.add(Long.valueOf(rs.getLong(1)));
+                       row.add(Long.valueOf(rs.getLong(2)));
+                       row.add(getArrayFromResultSet(rs, 3, Integer.valueOf(0)));
+                       row.add(getArrayFromResultSet(rs, 4, Float.valueOf(0)));
+               } catch (SQLException e) {
+                       Logger.exception(e);
+                       return null;
+               }
+
+               return row;
        }
 
 }
index 0cfb2b2..3f4b4f4 100755 (executable)
@@ -2,15 +2,68 @@ package org.tizen.dynamicanalyzer.ui.memory.table;
 \r
 import java.util.List;\r
 \r
+import org.eclipse.nebula.widgets.grid.GridItem;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
 import org.eclipse.swt.widgets.Composite;\r
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;\r
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;\r
+import org.tizen.dynamicanalyzer.common.DASelectionData;\r
 import org.tizen.dynamicanalyzer.model.TableInput;\r
+import org.tizen.dynamicanalyzer.ui.memory.MemoryDetailsTableView;\r
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;\r
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;\r
+import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;\r
 \r
 public class MemoryDetailsTable extends DATableComposite {\r
 \r
        public MemoryDetailsTable(Composite parent, int style, int tableStyle) {\r
                super(parent, style, tableStyle);\r
-               // TODO Auto-generated method stub\r
+\r
+               setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE);\r
+\r
+               setComparator(new DefaultTableComparator());\r
+               comparator.setType(AnalyzerConstants.SORT_TYPE_NUM);\r
+               comparator.setColumn(0);\r
+               \r
+               table.addSelectionListener(new SelectionListener() {\r
+\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+\r
+                               GridItem[] items = table.getSelection();\r
+                               if (null == items) {\r
+                                       return;\r
+                               }\r
+                               long startTime = 0;\r
+                               long endTime = 0;\r
+\r
+                               DATableDataFormat dataFormat = null;\r
+                               long itemTime;\r
+                               for (int i = 0; i < items.length; i++) {\r
+                                       dataFormat = (DATableDataFormat) items[i].getData();\r
+                                       itemTime = dataFormat.getLogData().getTime();\r
+                                       if (0 == startTime) {\r
+                                               startTime = itemTime;\r
+                                       }\r
+                                       if (startTime > itemTime) {\r
+                                               startTime = itemTime;\r
+                                       }\r
+                                       if (endTime < itemTime) {\r
+                                               endTime = itemTime;\r
+                                       }\r
+                               }\r
+                               DASelectionData selData = new DASelectionData(MemoryDetailsTableView.ID, startTime,\r
+                                               endTime, items, table);\r
+\r
+                               AnalyzerManager.getCurrentPage().updateView(selData);\r
+                       }\r
+\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+                               // TODO Auto-generated method stub\r
+                       }\r
+               });\r
        }\r
 \r
        @Override\r