Timeline : revision heap chart and System table DB 67/26267/2
authorjungwook.ryu <jungwook.ryu@samsung.com>
Wed, 20 Aug 2014 02:20:44 +0000 (11:20 +0900)
committerjungwook.ryu <jungwook.ryu@samsung.com>
Thu, 21 Aug 2014 04:06:22 +0000 (13:06 +0900)
1. Heap chart support checking memory allocation per library
2. Store Thread information to System Data Table.

Change-Id: I4d81eb2595b0f6e00d683f0cbf67b4e60fabc179
Signed-off-by: jungwook.ryu <jungwook.ryu@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBColumn.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/SqlConnectionManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/TargetProcessDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/HeapChart.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineChartManager.java

index c378552..f5f45eb 100644 (file)
@@ -40,14 +40,12 @@ public class DBColumn {
 
        public String getColumnString() {
                if (DBConstants.VARCHAR.equals(type)) {
-                       return name + CommonConstants.SPACE + type + "(" + string_size
-                                       + ")" + CommonConstants.SPACE + option;
+                       return name + CommonConstants.SPACE + type + "(" + string_size + ")" + CommonConstants.SPACE + option;
                } else if (DBConstants.VARCHAR_ARRAY.equals(type)) {
-                       return type.replaceFirst("\\?", String.valueOf(string_size)) + 
-                                       CommonConstants.SPACE + option;
+                       return name + CommonConstants.SPACE + "VARCHAR(" + string_size + ") ARRAY"
+                                       CommonConstants.SPACE + option;
                } else {
-                       return name + CommonConstants.SPACE + type + CommonConstants.SPACE
-                                       + option;
+                       return name + CommonConstants.SPACE + type + CommonConstants.SPACE + option;
                }
        }
 
index 5634492..11519d7 100644 (file)
@@ -43,7 +43,7 @@ public class DBConstants {
        public static final String INTEGER_ARRAY = "INTEGER ARRAY";//$NON-NLS-1$
        public static final String BIGINT_ARRAY = "BIGINT ARRAY";//$NON-NLS-1$
        public static final String FLOAT_ARRAY = "DOUBLE ARRAY";//$NON-NLS-1$
-       public static final String VARCHAR_ARRAY = "VARCHAR(?) ARRAY";
+       public static final String VARCHAR_ARRAY = "VARCHAR ARRAY";
 
        // types constant
        public static final String DBTYPE_INT1 = "TINYINT";//$NON-NLS-1$
index f97ec46..7a9f821 100644 (file)
@@ -478,6 +478,9 @@ public class SqlConnectionManager {
                                                        } else if (rsMetaData.getColumnTypeName(i).contains(
                                                                        DBConstants.FLOAT_ARRAY)) {
                                                                rowData.add(addArray(i, rs, new Float(0)));
+                                                       } else if (rsMetaData.getColumnTypeName(i).contains(
+                                                                       DBConstants.VARCHAR_ARRAY)) {
+                                                               rowData.add(addArray(i, rs, new String()));
                                                        } else if (rsMetaData.getColumnTypeName(i)
                                                                        .contains(DBConstants.INTEGER)) {
                                                                rowData.add(Integer.valueOf(rs.getInt(i)));
index 8794eec..ff7227d 100644 (file)
@@ -33,20 +33,25 @@ 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.database.SqlConnectionManager;
 
 public class TargetProcessDBTable extends DBTable {
        private static final String TABLENAME = "TIMELINE_TARGET_PROCESS";
 
        public static enum COLUMN {
-       TIME,
-       PID,
+               TIME,
+               PID,
                CPU_LOAD,
                MEMORY_VIRTUAL,
                MEMORY_RESIDENT,
                MEMORY_SHARED,
                MEMORY_PSS,
-               HEAP_ALLOCATION_TOTAL,
-               HEAP_ALLOCATION,
+               THREAD_COUNT,
+               HEAP_ALLOCATION_TOTAL_BYTE,
+               HEAP_ALLOCATION_NAME,
+               HEAP_ALLOCATION_BYTE,
+               THREAD_ID,
+               THREAD_LOAD
        }
 
        public static final String TIME = "TIME";
@@ -56,8 +61,13 @@ public class TargetProcessDBTable extends DBTable {
        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 HEAP_ALLOCATION_TOTAL = "HEAP_ALLOCATION_TOTAL";
-       public static final String HEAP_ALLOCATION_APP = "HEAP_ALLOCATION_APP";
+       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_NAME = "HEAP_ALLOCATION_NAME";
+       public static final String HEAP_ALLOCATION_BYTE = "HEAP_ALLOCATION_BYTE";
+       public static final String THREAD_ID = "THREAD_ID";
+       public static final String THREAD_LOAD = "THREAD_LOAD";
+       public static final int HEAP_ALLOCATION_NAME_LEN = 256;
 
        @Override
        public String getTableName() {
@@ -72,8 +82,13 @@ public class TargetProcessDBTable extends DBTable {
                addColumn(new DBColumn(MEMORY_RESIDENT, DBConstants.EMPTY, DBConstants.LONG));
                addColumn(new DBColumn(MEMORY_SHARED, DBConstants.EMPTY, DBConstants.LONG));
                addColumn(new DBColumn(MEMORY_PSS, DBConstants.EMPTY, DBConstants.LONG));
-               addColumn(new DBColumn(HEAP_ALLOCATION_TOTAL, DBConstants.EMPTY, DBConstants.LONG));
-               addColumn(new DBColumn(HEAP_ALLOCATION_APP, DBConstants.EMPTY, DBConstants.LONG));
+               addColumn(new DBColumn(THREAD_COUNT, DBConstants.EMPTY, DBConstants.INTEGER));
+               addColumn(new DBColumn(HEAP_ALLOCATION_TOTAL_BYTE, DBConstants.EMPTY, DBConstants.LONG));
+               addColumn(new DBColumn(HEAP_ALLOCATION_NAME, DBConstants.EMPTY, DBConstants.VARCHAR_ARRAY,
+                               HEAP_ALLOCATION_NAME_LEN));
+               addColumn(new DBColumn(HEAP_ALLOCATION_BYTE, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
+               addColumn(new DBColumn(THREAD_ID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
+               addColumn(new DBColumn(THREAD_LOAD, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
        }
 
        @Override
@@ -85,15 +100,24 @@ public class TargetProcessDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
-                               prep.setInt(2, (Integer) (rowData.get(COLUMN.PID.ordinal())));
-                               prep.setFloat(3, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
-                               prep.setLong(4, (Long) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
-                               prep.setLong(5, (Long) (rowData.get(COLUMN.MEMORY_RESIDENT.ordinal())));
-                               prep.setLong(6, (Long) (rowData.get(COLUMN.MEMORY_SHARED.ordinal())));
-                               prep.setLong(7, (Long) (rowData.get(COLUMN.MEMORY_PSS.ordinal())));
-                               prep.setLong(8, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL.ordinal())));
-                               prep.setLong(9, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION.ordinal())));
+                               int index = 0;
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.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.setLong(++index, (Integer) (rowData.get(COLUMN.THREAD_COUNT.ordinal())));
+                               prep.setLong(++index, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal())));
+                               SqlConnectionManager.setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_NAME.ordinal(),
+                                               DBConstants.VARCHAR, prep, rowData);
+                               SqlConnectionManager.setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BYTE.ordinal(),
+                                               DBConstants.LONG, prep, rowData);
+                               SqlConnectionManager.setArrayToPreparedStatement(COLUMN.THREAD_ID.ordinal(),
+                                               DBConstants.INTEGER, prep, rowData);
+                               SqlConnectionManager.setArrayToPreparedStatement(COLUMN.THREAD_LOAD.ordinal(),
+                                               DBConstants.FLOAT, prep, rowData);
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index 6f5ccfa..24e8f8d 100644 (file)
@@ -36,15 +36,21 @@ import java.util.Map;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
+import org.tizen.dynamicanalyzer.project.BinaryInfo;
+import org.tizen.dynamicanalyzer.project.LibraryObject;
+import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
 import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
+import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 import org.tizen.dynamicanalyzer.utils.Formatter;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
 import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
 import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
 import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
@@ -55,12 +61,11 @@ import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
 public class HeapChart extends TimelineChart {
        private static HeapChart instance = null;
 
-       private final int TOTAL_ALLOC = 0;
-       private final int USER_ALLOC = 1;
-
-       private Map<Integer, DAChartBoardItem> processChartboardMap = new HashMap<Integer, DAChartBoardItem>();
-       private Map<Integer, String> processNameMap = new HashMap<Integer, String>();
+       private List<String> librarySequenceList = new ArrayList<String>();
+       // Map<PID, Map<binaryPath, DAChartSeries>>
+       private Map<Integer, Map<String, DAChartSeries>> seriesPerProcessMap = new HashMap<Integer, Map<String, DAChartSeries>>();
        private DAChartBoardItem parentBoardItem;
+       private List<DAChartBoardItem> childBoardItemList = new ArrayList<DAChartBoardItem>();
 
        public static HeapChart getInstance() {
                if (instance == null) {
@@ -69,22 +74,39 @@ public class HeapChart extends TimelineChart {
                return instance;
        }
 
-       private List<DAChartSeries> createChartSeries() {
-               List<DAChartSeries> chartSeriesList = new ArrayList<DAChartSeries>();
-
+       private Map<String, DAChartSeries> createChartSeries(int pid) {
+               Map<String, DAChartSeries> chartSeriesMap = new HashMap<String, DAChartSeries>();
+               /*
+                * Add total allocation
+                */
                DAChartSeries totalAllocationSeries = new DAChartSeries(
-                               TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION,
-                               DAChartSeries.SERIES_STYLE_AREA, ColorResources.SERIES_COLOR_HEAP_SYSTEM);
-               DAChartSeries userAllocationSeries = new DAChartSeries(
-                               TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION,
-                               DAChartSeries.SERIES_STYLE_AREA, ColorResources.SERIES_COLOR_HEAP_USER);
+                               TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION, DAChartSeries.SERIES_STYLE_AREA,
+                               ColorResources.SERIES_COLOR_HEAP_SYSTEM);
+               chartSeriesMap.put(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION, totalAllocationSeries);
                /*
-                * Insert order is important.
+                * Add additional library allocation
                 */
-               chartSeriesList.add(totalAllocationSeries);
-               chartSeriesList.add(userAllocationSeries);
+               HashMap<String, BinaryInfo> binInfoMap = BinarySettingManager.getInstance().getTargetBinInfoMap();
+               ProcessMemoryMap pmap = AnalyzerManager.getProject().getProcessInformation(pid)
+                               .getProcessMemoryMap(ToolbarArea.getInstance().getTime());
+               Iterator<String> iter = binInfoMap.keySet().iterator();
+               while (iter.hasNext()) {
+                       String libraryPath = iter.next();
+                       LibraryObject libObj = pmap.getLibraryByBinaryID(binInfoMap.get(libraryPath).getID());
+                       if (null != libObj) {
+                               DAChartSeries libraryAllocSeries = new DAChartSeries(libraryPath, DAChartSeries.SERIES_STYLE_AREA);
+                               chartSeriesMap.put(libraryPath, libraryAllocSeries);
+                       }
+               }
+               /*
+                * Add target allocation
+                */
+               DAChartSeries targetAllocationSeries = new DAChartSeries(
+                               TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION, DAChartSeries.SERIES_STYLE_AREA,
+                               ColorResources.SERIES_COLOR_HEAP_USER);
+               chartSeriesMap.put(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION, targetAllocationSeries);
 
-               return chartSeriesList;
+               return chartSeriesMap;
        }
 
        private HeapChart() {
@@ -108,8 +130,7 @@ public class HeapChart extends TimelineChart {
        }
 
        public DAChartBoardItem createChildBoardItem(DAChartBoardItem parent) {
-               DAChartBoardItem item = new DAChartBoardItem(parent, chartName, chartIcon,
-                               chartStyle);
+               DAChartBoardItem item = new DAChartBoardItem(parent, chartName, chartIcon, chartStyle);
                chart = item.getChart();
                setChartStyle();
 
@@ -127,8 +148,7 @@ public class HeapChart extends TimelineChart {
                                popupMenu, parent.getChartBoard().getTimeline());
                chart.addMouseListener(timelineChartMouseEventListener);
                chart.addMouseMoveListener(timelineChartMouseEventListener);
-               chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(parent
-                               .getChartBoard().getTimeline()));
+               chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(parent.getChartBoard().getTimeline()));
 
                return item;
        }
@@ -138,96 +158,139 @@ public class HeapChart extends TimelineChart {
                /*
                 * Clear series items
                 */
-               for (Map.Entry<Integer, DAChartBoardItem> entry : processChartboardMap.entrySet()) {
-                       DAChartBoardItem board = entry.getValue();
-                       List<DAChartSeries> seriesList = board.getChart().getSeriesList();
-                       for (int i = 0; i < seriesList.size(); i++) {
-                               seriesList.get(i).clear();
+               Iterator<Map<String, DAChartSeries>> iterPerPID = seriesPerProcessMap.values().iterator();
+               while (iterPerPID.hasNext()) {
+                       Iterator<DAChartSeries> iterSeries = iterPerPID.next().values().iterator();
+                       while (iterSeries.hasNext()) {
+                               iterSeries.next().clear();
                        }
                }
 
                if (AnalyzerManager.getProject() == null) {
                        return;
                }
+
                @SuppressWarnings("unchecked")
                Map<Integer, List<List<Object>>> processDataMap = (Map<Integer, List<List<Object>>>) dataList
                                .get(TimelineConstants.TARGET_PROCESS_DB_DATA);
-
                Iterator<Integer> iterProcessData = processDataMap.keySet().iterator();
                while (iterProcessData.hasNext()) {
                        final Integer pid = iterProcessData.next();
-
+                       List<List<Object>> data = processDataMap.get(pid);
                        /*
                         * First process, use parentBoardItem.
                         */
-                       if (processChartboardMap.isEmpty()) {
-                               List<DAChartSeries> seriesList = createChartSeries();
-                               processChartboardMap.put(pid, parentBoardItem);
-                               for (int i = 0; i < seriesList.size(); i++) {
-                                       parentBoardItem.getChart().addSeries(seriesList.get(i));
-                               }
+                       if (seriesPerProcessMap.isEmpty()) {
+                               Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+                               seriesPerProcessMap.put(pid, seriesMap);
+                               setChartSeries(chart, seriesMap);
+                               final String processName = AnalyzerUtil.getProcessName(pid.intValue());
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               parentBoardItem.getItemCell().setAdditionalInfo(processName + "\nPID : " + pid.intValue(),
+                                                               ImageResources.CHART_HEAP_SMALL);
+                                       }
+                               });
                        }
                        /*
                         * If new Process created, Create ChartBoardItem, Chart, Series.
                         */
-                       else if (processChartboardMap.get(pid) == null) {
-                               final List<DAChartSeries> seriesList = createChartSeries();
-                               HeapChart childChart = new HeapChart();
-                               DAChartBoardItem childBoardItem = childChart
-                                               .createChildBoardItem(parentBoardItem);
-                               processChartboardMap.put(pid, childBoardItem);
-
-                               for (int i = 0; i < seriesList.size(); i++) {
-                                       childBoardItem.getChart().addSeries(seriesList.get(i));
-                               }
-                               parentBoardItem.unFoldChild();
-                       }
-
-                       final DAChartBoardItem curBoard = processChartboardMap.get(pid);
-
-                       String oldProcessName = processNameMap.get(pid);
-                       final String processName = AnalyzerUtil.getProcessName(pid.intValue());
-                       if (oldProcessName == null || !oldProcessName.equals(processName)) {
+                       else if (seriesPerProcessMap.get(pid) == null) {
+                               final Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+                               seriesPerProcessMap.put(pid, seriesMap);
                                Display.getDefault().syncExec(new Runnable() {
                                        @Override
                                        public void run() {
-                                               curBoard.getItemCell().setAdditionalInfo(
-                                                               processName + "\nPID : " + pid.intValue(),
+                                               HeapChart childChart = new HeapChart();
+                                               DAChartBoardItem childBoardItem = childChart.createChildBoardItem(parentBoardItem);
+                                               setChartSeries(childBoardItem.getChart(), seriesMap);
+                                               String processName = AnalyzerUtil.getProcessName(pid.intValue());
+                                               childBoardItem.getItemCell().setAdditionalInfo(processName + "\nPID : " + pid.intValue(),
                                                                ImageResources.CHART_HEAP_SMALL);
+                                               childBoardItemList.add(childBoardItem);
+                                               parentBoardItem.unFoldChild();
                                        }
                                });
                        }
 
-                       List<DAChartSeries> seriesList = curBoard.getChart().getSeriesList();
-                       List<List<Object>> data = processDataMap.get(pid);
+                       Map<String, DAChartSeries> seriesMap = seriesPerProcessMap.get(pid);
                        for (int i = 0; i < data.size(); i++) {
                                List<Object> row = data.get(i);
                                double time = (Long) row.get(TargetProcessDBTable.COLUMN.TIME.ordinal())
                                                / TimelineConstants.MEGA_DOUBLE;
-                               long totalAlloc = (Long) row
-                                               .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL.ordinal());
-                               long userAlloc = (Long) row
-                                               .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION.ordinal());
-
-                               seriesList.get(TOTAL_ALLOC).addSeriesItem(
-                                               new DAChartSeriesItem(time, totalAlloc, Formatter
-                                                               .toByteFormat(totalAlloc)));
-                               seriesList.get(USER_ALLOC).addSeriesItem(
-                                               new DAChartSeriesItem(time, userAlloc, Formatter
-                                                               .toByteFormat(userAlloc)));
+                               long totalAlloc = (Long) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal());
+
+                               @SuppressWarnings("unchecked")
+                               List<Object> binaryPathList = (List<Object>) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_NAME
+                                               .ordinal());
+                               @SuppressWarnings("unchecked")
+                               List<Object> binaryAllocList = (List<Object>) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_BYTE
+                                               .ordinal());
+
+                               DAChartSeries totalAllocSeries = seriesMap
+                                               .get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION);
+                               totalAllocSeries.addSeriesItem(new DAChartSeriesItem(time, totalAlloc, Formatter
+                                               .toByteFormat(totalAlloc)));
+                               long targetAlloc = (Long) binaryAllocList.get(0); // target
+                                                                                                                                       // allocation
+                                                                                                                                       // is
+                                                                                                                                       // located
+                                                                                                                                       // at first
+                                                                                                                                       // index.
+                               DAChartSeries appAllocSeries = seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
+                               appAllocSeries.addSeriesItem(new DAChartSeriesItem(time, targetAlloc, Formatter
+                                               .toByteFormat(targetAlloc)));
+
+                               /*
+                                * get total user allocation byte (app + library)
+                                */
+                               long totalUserAlloc = 0;
+                               for (int ii = 0; ii < binaryAllocList.size(); ii++) {
+                                       totalUserAlloc += (Long) binaryAllocList.get(ii);
+                               }
+                               /*
+                                * Set seriesItem for library allocation
+                                */
+                               long beforeLibraryAlloc = 0; // need to accumulate
+                               for (int ii = 0; ii < librarySequenceList.size(); ii++) {
+                                       String libraryPath = librarySequenceList.get(ii);
+                                       DAChartSeries allocSeries = seriesMap.get(libraryPath);
+                                       int index = binaryPathList.indexOf(libraryPath);
+                                       long libraryAlloc = 0;
+                                       if (index > 0) {
+                                               libraryAlloc = (Long) binaryAllocList.get(index);
+                                       }
+                                       allocSeries.addSeriesItem(new DAChartSeriesItem(time, totalUserAlloc - beforeLibraryAlloc,
+                                                       Formatter.toByteFormat(libraryAlloc)));
+                                       beforeLibraryAlloc = libraryAlloc;
+                               }
                        }
                }
        }
 
+       private void setChartSeries(DAChart chart, Map<String, DAChartSeries> seriesMap) {
+               chart.addSeries(seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION));
+               Iterator<String> iterSeries = seriesMap.keySet().iterator();
+               while (iterSeries.hasNext()) {
+                       String libraryPath = iterSeries.next();
+                       if (libraryPath.equals(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION)
+                                       || libraryPath.equals(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION)) {
+                               continue;
+                       }
+                       chart.addSeries(seriesMap.get(libraryPath));
+                       if (librarySequenceList.indexOf(libraryPath) < 0) {
+                               librarySequenceList.add(libraryPath);
+                       }
+               }
+               chart.addSeries(seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION));
+       }
+
        @Override
        public void clear() {
-               processChartboardMap.clear();
-               processNameMap.clear();
-               for (Map.Entry<Integer, DAChartBoardItem> entry : processChartboardMap.entrySet()) {
-                       DAChartBoardItem board = entry.getValue();
-                       if (board != parentBoardItem) {
-                               board.dispose();
-                       }
+               seriesPerProcessMap.clear();
+               for (int i = 0; i < childBoardItemList.size(); i++) {
+                       childBoardItemList.get(i).dispose();
                }
        }
 }
index 74db964..023ddc8 100644 (file)
@@ -30,6 +30,7 @@ package org.tizen.dynamicanalyzer.ui.timeline.common;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -39,9 +40,9 @@ import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
 import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
+import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
 import org.tizen.dynamicanalyzer.project.BinaryInfo;
 import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
 import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
@@ -54,7 +55,6 @@ import org.tizen.dynamicanalyzer.swap.model.data.ProcessProfileData;
 import org.tizen.dynamicanalyzer.swap.model.data.ScreenShotData;
 import org.tizen.dynamicanalyzer.swap.model.data.SystemData;
 import org.tizen.dynamicanalyzer.swap.model.data.UIEventData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
 import org.tizen.dynamicanalyzer.ui.info.screenshot.SocketClient;
@@ -112,11 +112,13 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
 
        private static final int MEM_API_TYPE_ALLOC = 0;
        private static final int MEM_API_TYPE_FREE = 1;
-       private static final int MEM_API_TYPE_MANAGE = 2;
        private static final int MEM_USER = 2;
 
-       private Map<Integer, Long> allocByteMap = new HashMap<Integer, Long>(); // Map<PID,
-                                                                                                                                                       // allocByte>
+       // Map<PID, target Allocation Byte>
+       private Map<Integer, Long> allocByteMap = new HashMap<Integer, Long>();
+       // Map<PID, Map<binaryPath, Allocation Byte>>
+       private Map<Integer, Map<String, Long>> libraryAllocByteMap = new HashMap<Integer, Map<String, Long>>();
+       // Map<Address, Allocation Byte>
        private HashMap<Long, Long> allocationSeriesDataSetMap = new HashMap<Long, Long>();
 
        public static TimelineChartManager getInstance() {
@@ -149,10 +151,10 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                initChartMap(ProcessMemoryChart.getInstance());
                initChartMap(SystemMemoryChart.getInstance());
                initChartMap(ScreenshotChart.getInstance());
-//             initChartMap(UIEventChart.getInstance());
+               // initChartMap(UIEventChart.getInstance());
                initChartMap(DiskIOChart.getInstance());
                initChartMap(NetworkIOChart.getInstance());
-//             initChartMap(DeviceChart.getInstance());
+               // initChartMap(DeviceChart.getInstance());
                initChartMap(EnergyChart.getInstance());
 
                loadSavedChartList();
@@ -257,8 +259,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                strSaveChartNameList.append(","); //$NON-NLS-1$
                        }
 
-                       ConfigureManager.getInstance().setValue(
-                                       ConfigureLabels.CONFIGUREMANAGER_CHART_AVAILABLE_ITEM_LIST,
+                       ConfigureManager.getInstance().setValue(ConfigureLabels.CONFIGUREMANAGER_CHART_AVAILABLE_ITEM_LIST,
                                        strSaveChartNameList.toString());
                }
        }
@@ -278,16 +279,14 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                DAChartBoardItem item = chart.createBoardItem(chartBoard);
 
                                DAChart chartWidget = item.getChart();
-                               chartWidget.getPlot().setAxisRangeX(chartBoard.getVisibleStartTime(),
-                                               chartBoard.getVisibleEndTime());
+                               chartWidget.getPlot().setAxisRangeX(chartBoard.getVisibleStartTime(), chartBoard.getVisibleEndTime());
 
                                chartWidget.getPlot().setMarkers(chartBoard.getMarkers());
                                TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
                                                chart.getPopupMenu(), chartBoard.getTimeline());
                                chartWidget.addMouseListener(timelineChartMouseEventListener);
                                chartWidget.addMouseMoveListener(timelineChartMouseEventListener);
-                               chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard
-                                               .getTimeline()));
+                               chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard.getTimeline()));
                        }
 
                        StringBuffer selectedChartNameList = new StringBuffer(""); //$NON-NLS-1$
@@ -295,8 +294,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                selectedChartNameList.append(selectedChart.getChartName());
                                selectedChartNameList.append(","); //$NON-NLS-1$
                        }
-                       ConfigureManager.getInstance().setValue(
-                                       ConfigureLabels.CONFIGUREMANAGER_CHART_SELECTED_ITEM_LIST,
+                       ConfigureManager.getInstance().setValue(ConfigureLabels.CONFIGUREMANAGER_CHART_SELECTED_ITEM_LIST,
                                        selectedChartNameList.toString());
 
                        // AnalyzerUtil.getTimelineComposite().resetItems();
@@ -305,8 +303,8 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                for (TimelineChart timelineChart : chartList) {
                        if (timelineChart instanceof UserCustomChart) {
                                UserCustomChart customChart = (UserCustomChart) timelineChart;
-                               ArrayList<DAChartSeries> tempSeriesList = (ArrayList<DAChartSeries>) customChart
-                                               .getTempSeries().clone();
+                               ArrayList<DAChartSeries> tempSeriesList = (ArrayList<DAChartSeries>) customChart.getTempSeries()
+                                               .clone();
                                ((UserCustomChart) timelineChart).getTempSeries().clear();
                                for (DAChartSeries series : tempSeriesList) {
                                        customChart.addSeries(series);
@@ -334,6 +332,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                customLogParser.clear();
 
                allocByteMap.clear();
+               libraryAllocByteMap.clear();
                allocationSeriesDataSetMap.clear();
        }
 
@@ -349,17 +348,29 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                MemoryData logData = (MemoryData) memoryLogList.get(i);
                                if (allocByteMap.get(logData.getPid()) == null) {
                                        allocByteMap.put(Integer.valueOf(logData.getPid()), new Long(0));
+                                       libraryAllocByteMap.put(Integer.valueOf(logData.getPid()), new HashMap<String, Long>());
                                }
 
                                int memApiType = logData.getMemoryApiType();
                                int internalFlag = logData.getInternalCall();
                                long errorNo = logData.getErrno();
+
+                               /*
+                                * Check library allocation
+                                */
+                               String binaryPath = null;
+                               Project project = AnalyzerManager.getProject();
+                               ProcessMemoryMap pmap = project.getProcessInformation(logData.getPid()).getProcessMemoryMap(
+                                               logData.getTime());
+                               LibraryObject lib = pmap.getLibraryByAddress(logData.getCallerPcAddr());
+                               if (lib != pmap.getMainbinary()) {
+                                       BinaryInfo binfo = project.getDeviceStatusInfo().getBinaryInfo(lib.getBinaryID());
+                                       binaryPath = binfo.getTargetBinaryPath();
+                               } 
                                
                                if (errorNo == 0 && MEM_USER == internalFlag) {
-                                       if (MEM_API_TYPE_ALLOC == memApiType || MEM_API_TYPE_FREE == memApiType
-                                                       || MEM_API_TYPE_MANAGE == memApiType) {
-
-                                               addNewSeriesUserAllocData(memApiType, logData);
+                                       if (MEM_API_TYPE_ALLOC == memApiType || MEM_API_TYPE_FREE == memApiType) {
+                                               addNewSeriesUserAllocData(memApiType, logData, binaryPath);
                                        }
                                }
                        }
@@ -425,10 +436,8 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                 */
                                ArrayList<Object> energyUsageDeviceList = new ArrayList<Object>();
                                ArrayList<Object> energyUsageAppList = new ArrayList<Object>();
-                               String[] deviceEnergyUsages = log.getDeviceEnergyUsage().split(
-                                               CommonConstants.COMMA);
-                               String[] deviceEnergyUsagesPerApp = log.getApplicationEnergyUsage().split(
-                                               CommonConstants.COMMA);
+                               String[] deviceEnergyUsages = log.getDeviceEnergyUsage().split(CommonConstants.COMMA);
+                               String[] deviceEnergyUsagesPerApp = log.getApplicationEnergyUsage().split(CommonConstants.COMMA);
                                for (int ii = 0; ii < deviceEnergyUsages.length; ii++) {
                                        energyUsageDeviceList.add(new Long(deviceEnergyUsages[ii]));
                                        energyUsageAppList.add(new Long(deviceEnergyUsagesPerApp[ii]));
@@ -476,14 +485,51 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                                dbTargetProcessData.add(new Long(process.getResidentMemory()));
                                                dbTargetProcessData.add(new Long(process.getSharedMemory()));
                                                dbTargetProcessData.add(new Long(process.getPssMemory()));
+                                               dbTargetProcessData.add(new Integer(process.getThreadCount()));
                                                dbTargetProcessData.add(new Long(process.getTotalAllocSize()));
 
+                                               /*
+                                                * Set inform for Heap allocation 
+                                                */
+                                               List<Object> binaryPathList = new ArrayList<Object>();
+                                               List<Object> allocByteList = new ArrayList<Object>();
+                                               binaryPathList.add(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
                                                if (allocByteMap.get(process.getPid()) == null) {
-                                                       dbTargetProcessData.add(new Long(0));
+                                                       allocByteList.add(new Long(0));
                                                } else {
-                                                       dbTargetProcessData.add(allocByteMap.get(process.getPid()));
+                                                       allocByteList.add(allocByteMap.get(process.getPid()));
                                                }
-
+                                               Map<String, Long> libraryList = libraryAllocByteMap.get(process.getPid());
+                                               if (libraryList == null) {
+                                                       libraryList = new HashMap<String, Long>();
+                                               }
+                                               Iterator<String> iter = libraryList.keySet().iterator();
+                                               while (iter.hasNext()) {
+                                                       String binaryPath = iter.next();
+                                                       binaryPathList.add(binaryPath);
+                                                       allocByteList.add(libraryList.get(binaryPath));
+                                               }
+                                               dbTargetProcessData.add(binaryPathList);
+                                               dbTargetProcessData.add(allocByteList);
+                                               
+                                               /*
+                                                * Set inform for Thread
+                                                */
+                                               List<Object> threadIdList = new ArrayList<Object>();
+                                               List<Object> threadLoadList = new ArrayList<Object>();
+                                               // TODO Remove unnecessary String parsing. first Fix in SystemData.java
+                                               String[] threadLoads = process.getThreadLoad().split(CommonConstants.COMMA);
+                                               for (int iii = 0; iii < threadLoads.length; iii++) {
+                                                       String threadLoad = threadLoads[iii];
+                                                       if (threadLoad == null || threadLoad.isEmpty()) {
+                                                               continue;
+                                                       }
+                                                       threadIdList.add(new Integer(threadLoad));
+                                                       threadLoadList.add(threadLoads[++iii]);
+                                               }
+                                               dbTargetProcessData.add(threadIdList);
+                                               dbTargetProcessData.add(threadLoadList);
+                                               
                                                targetProcessDataList.add(dbTargetProcessData);
                                        }
                                }
@@ -521,8 +567,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        }
 
        private void makeScreenShotDBTableData(Logs screenShotLogs) {
-               List<LogData> screenShotLogList = screenShotLogs == null ? null : screenShotLogs
-                               .getRawLogs();
+               List<LogData> screenShotLogList = screenShotLogs == null ? null : screenShotLogs.getRawLogs();
                if (screenShotLogList != null) {
                        ArrayList<List<Object>> screenShotDataList = new ArrayList<List<Object>>();
                        int size = screenShotLogList.size();
@@ -531,8 +576,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                ArrayList<Object> dbScreenShotData = new ArrayList<Object>();
                                String imagePathLog = null;
                                if (DACommunicator.isTargetEmulator() && SocketClient.getInstance().isConnected()) {
-                                       imagePathLog = GlobalInformation.getCurrentDeviceInfo().emulatorScreenshot
-                                                       .getFilePath();
+                                       imagePathLog = GlobalInformation.getCurrentDeviceInfo().emulatorScreenshot.getFilePath();
                                } else {
                                        imagePathLog = log.getImageFilePath();
                                }
@@ -551,7 +595,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                }
        }
 
-       private void addNewSeriesUserAllocData(int fdApiType, MemoryData log) {
+       private void addNewSeriesUserAllocData(int fdApiType, MemoryData log, String libraryPath) {
                long size = 0;
                Long allocByte = allocByteMap.get(log.getPid());
 
@@ -563,7 +607,15 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                if (MEM_API_TYPE_ALLOC == fdApiType) {
                        try {
                                size = log.getSize();
-                               allocByteMap.put(log.getPid(), allocByte + size);
+                               if (libraryPath == null) {
+                                       allocByteMap.put(log.getPid(), allocByte + size);
+                               } else {
+                                       Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
+                                       if (libraryAllocByte == null) {
+                                               libraryAllocByte = new Long(0);
+                                       }
+                                       libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte + size);
+                               }
                                allocationSeriesDataSetMap.put(address, size);
                        } catch (NumberFormatException ne) {
                                ne.printStackTrace();
@@ -573,7 +625,13 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                                return;
                        }
                        size = allocationSeriesDataSetMap.get(address);
-                       allocByteMap.put(log.getPid(), allocByte - size);
+
+                       if (libraryPath == null) {
+                               allocByteMap.put(log.getPid(), allocByte - size);
+                       } else {
+                               Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
+                               libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte - size);
+                       }
                }
        }
 
@@ -598,8 +656,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        }
 
        public List<List<Object>> getSystemDataFromDB(long start, long end) {
-               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
-                               + SystemDataDBTable.TIME;
+               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + SystemDataDBTable.TIME;
                List<List<Object>> result = systemDataTable.selectData(null, where);
 
                if (result != null) {
@@ -610,8 +667,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        }
 
        public List<List<Object>> getUIEventDataFromDB(long start, long end) {
-               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
-                               + UIEventDBTable.TIME;
+               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + UIEventDBTable.TIME;
                List<List<Object>> result = uiEventDBTable.selectData(null, where);
 
                if (result != null) {
@@ -622,8 +678,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        }
 
        public List<List<Object>> getScreenShotDataFromDB(long start, long end) {
-               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
-                               + ScreenShotDBTable.TIME;
+               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + ScreenShotDBTable.TIME;
                List<List<Object>> result = screenShotDBTable.selectData(null, where);
 
                if (result != null) {
@@ -634,8 +689,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        }
 
        public List<List<Object>> getCustomDataFromDB(long start, long end) {
-               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
-                               + CustomDataDBTable.TIME;
+               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + CustomDataDBTable.TIME;
                List<List<Object>> result = customDataDBTable.selectData(null, where);
 
                if (result != null) {
@@ -648,8 +702,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
        public Map<Integer, List<List<Object>>> getTargetProcessDataFromDB(long start, long end) {
                Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();
 
-               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
-                               + TargetProcessDBTable.TIME;
+               String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + TargetProcessDBTable.TIME;
                List<List<Object>> queryResult = targetProcessDBTable.selectData(null, where);
                if (queryResult == null) {
                        return processedResult;
@@ -677,8 +730,7 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                List<List<Object>> uiEventDBData = getUIEventDataFromDB(startTime, endTime);
                List<List<Object>> screenShotDBData = getScreenShotDataFromDB(startTime, endTime);
                List<List<Object>> customDBData = getCustomDataFromDB(startTime, endTime);
-               Map<Integer, List<List<Object>>> targetProcessDBData = getTargetProcessDataFromDB(
-                               startTime, endTime);
+               Map<Integer, List<List<Object>>> targetProcessDBData = getTargetProcessDataFromDB(startTime, endTime);
 
                /*
                 * 2. Make series of chart