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 ScreenShotDBTable extends DBTable {
private static final String TABLENAME = "TIMELINE_SCREENSHOT";
- private final static int MAX_IMAGEPATH_LEN = 1024;
+ private final static int MAX_IMAGEPATH_LEN = 32;
public static enum COLUMN {
CAPTURE_TIME,
public ScreenShotDBTable() {
addColumn(new DBColumn(CAPTURE_TIME, DBConstants.NOT_NULL, DBConstants.LONG));
- addColumn(new DBColumn(IMAGE_FILE_PATH, DBConstants.NOT_NULL, DBConstants.VARCHAR, MAX_IMAGEPATH_LEN));
+ addColumn(new DBColumn(IMAGE_FILE_PATH, DBConstants.EMPTY, DBConstants.VARCHAR, MAX_IMAGEPATH_LEN));
addColumn(new DBColumn(IMAGE_ORIENTATION, DBConstants.NOT_NULL, DBConstants.INTEGER));
setIndexColumn(COLUMN.CAPTURE_TIME.ordinal());
}
} else {
try {
prep.setLong(1, (Long) (rowData.get(COLUMN.CAPTURE_TIME.ordinal())));
- prep.setString(2, (String) (rowData.get(COLUMN.IMAGE_FILE_PATH.ordinal())));
+ // Check string overflow
+ String image_file = (String) (rowData.get(COLUMN.IMAGE_FILE_PATH.ordinal()));
+ if (image_file != null && image_file.length() > MAX_IMAGEPATH_LEN) {
+ Logger.error("Overflow occurs MAX_IMAGEPATH_LEN in ScreenShotDBTable : " + image_file);
+ image_file = null;
+ }
+ prep.setString(2, image_file);
prep.setInt(3, (Integer) (rowData.get(COLUMN.IMAGE_ORIENTATION.ordinal())));
} catch (SQLException e) {
e.printStackTrace();
MEMORY_PSS,
THREAD_COUNT,
HEAP_ALLOCATION_TOTAL_BYTE,
- HEAP_ALLOCATION_NAME,
+ HEAP_ALLOCATION_BINARY_ID,
HEAP_ALLOCATION_BYTE,
THREAD_ID,
THREAD_LOAD
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_NAME = "HEAP_ALLOCATION_NAME";
+ 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 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() {
addColumn(new DBColumn(MEMORY_PSS, 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_BINARY_ID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
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));
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_NAME.ordinal(),
- DBConstants.VARCHAR, prep, rowData);
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal())));
+ setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BINARY_ID.ordinal(),
+ DBConstants.INTEGER, prep, rowData);
setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BYTE.ordinal(),
DBConstants.LONG, prep, rowData);
setArrayToPreparedStatement(COLUMN.THREAD_ID.ordinal(), DBConstants.INTEGER, prep,
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, String.valueOf(0)));
+ 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)));
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 UIEventDBTable extends DBTable {
private static final String TABLENAME = "TIMELINE_UIEVENT";
- private final static int MAX_INFO_LEN = 256;
+ private final static int MAX_INFO_LEN = 64;
public static enum COLUMN {
EVENT_TIME,
prep.setInt(3, (Integer) (rowData.get(COLUMN.DETAIL_TYPE.ordinal())));
prep.setInt(4, (Integer) (rowData.get(COLUMN.POINT_X.ordinal())));
prep.setInt(5, (Integer) (rowData.get(COLUMN.POINT_Y.ordinal())));
- prep.setString(6, (String) (rowData.get(COLUMN.INFO_STRING.ordinal())));
+ // Check string overflow
+ String info = (String) (rowData.get(COLUMN.INFO_STRING.ordinal()));
+ if (info != null && info.length() > MAX_INFO_LEN) {
+ Logger.error("Overflow occurs INFO_STRING in UIEventDBTable : " + info);
+ info = info.substring(0, MAX_INFO_LEN);
+ }
+ prep.setString(6, info);
prep.setInt(7, (Integer) (rowData.get(COLUMN.INFO_INTEGER.ordinal())));
} catch (SQLException e) {
e.printStackTrace();
public class HeapChart extends TimelineChart {
private static HeapChart instance = null;
- 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 List<Integer> librarySequenceList = new ArrayList<Integer>();
+ // Map<PID, Map<binaryID, DAChartSeries>>
+ private Map<Integer, Map<Integer, DAChartSeries>> seriesPerProcessMap =
+ new HashMap<Integer, Map<Integer, DAChartSeries>>();
private DAChartBoardItem parentBoardItem;
private List<DAChartBoardItem> childBoardItemList = new ArrayList<DAChartBoardItem>();
+ private static final int totalAllocSeriesID = -100;
+ private static final int appAllocSeriesID = -10;
+
public static HeapChart getInstance() {
if (instance == null) {
instance = new HeapChart();
return instance;
}
- private Map<String, DAChartSeries> createChartSeries(int pid) {
- Map<String, DAChartSeries> chartSeriesMap = new HashMap<String, DAChartSeries>();
+ private Map<Integer, DAChartSeries> createChartSeries(int pid) {
+ Map<Integer, DAChartSeries> chartSeriesMap = new HashMap<Integer, DAChartSeries>();
/*
* Add total allocation
*/
DAChartSeries totalAllocationSeries = new DAChartSeries(
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);
+ chartSeriesMap.put(totalAllocSeriesID, totalAllocationSeries);
/*
* Add additional library allocation
*/
if (null != libObj) {
DAChartSeries libraryAllocSeries = new DAChartSeries(libraryPath,
DAChartSeries.SERIES_STYLE_AREA);
- chartSeriesMap.put(libraryPath, libraryAllocSeries);
+ chartSeriesMap.put(libObj.getBinaryID(), libraryAllocSeries);
}
}
}
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);
+ chartSeriesMap.put(appAllocSeriesID, targetAllocationSeries);
return chartSeriesMap;
}
/*
* Clear series items
*/
- Iterator<Map<String, DAChartSeries>> iterPerPID = seriesPerProcessMap.values().iterator();
+ Iterator<Map<Integer, DAChartSeries>> iterPerPID = seriesPerProcessMap.values().iterator();
while (iterPerPID.hasNext()) {
Iterator<DAChartSeries> iterSeries = iterPerPID.next().values().iterator();
while (iterSeries.hasNext()) {
* First process, use parentBoardItem.
*/
if (seriesPerProcessMap.isEmpty()) {
- Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+ Map<Integer, DAChartSeries> seriesMap = createChartSeries(pid);
seriesPerProcessMap.put(pid, seriesMap);
setChartSeries(chart, seriesMap);
final String processName = AnalyzerUtil.getProcessName(pid.intValue());
* If new Process created, Create ChartBoardItem, Chart, Series.
*/
else if (seriesPerProcessMap.get(pid) == null) {
- final Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+ final Map<Integer, DAChartSeries> seriesMap = createChartSeries(pid);
seriesPerProcessMap.put(pid, seriesMap);
Display.getDefault().syncExec(new Runnable() {
@Override
});
}
- Map<String, DAChartSeries> seriesMap = seriesPerProcessMap.get(pid);
+ Map<Integer, 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.SAMPLING_TIME.ordinal())
.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal());
@SuppressWarnings("unchecked")
- List<Object> binaryPathList = (List<Object>) row
- .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_NAME.ordinal());
+ List<Object> binaryIDList = (List<Object>) row
+ .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_BINARY_ID.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);
+ DAChartSeries totalAllocSeries = seriesMap.get(totalAllocSeriesID);
totalAllocSeries.addSeriesItem(new DAChartSeriesItem(time, totalAlloc, Formatter
.toByteFormat(totalAlloc)));
long targetAlloc = (Long) binaryAllocList.get(0); // target
// located
// at first
// index.
- DAChartSeries appAllocSeries = seriesMap
- .get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
+ DAChartSeries appAllocSeries = seriesMap.get(appAllocSeriesID);
appAllocSeries.addSeriesItem(new DAChartSeriesItem(time, targetAlloc, Formatter
.toByteFormat(targetAlloc)));
*/
long beforeLibraryAlloc = 0; // need to accumulate
for (int ii = 0; ii < librarySequenceList.size(); ii++) {
- String libraryPath = librarySequenceList.get(ii);
- DAChartSeries allocSeries = seriesMap.get(libraryPath);
+ Integer libraryID = librarySequenceList.get(ii);
+ DAChartSeries allocSeries = seriesMap.get(libraryID);
if (allocSeries == null) { // this process don't use this binary
continue;
}
- int index = binaryPathList.indexOf(libraryPath);
+ int index = binaryIDList.indexOf(libraryID);
long libraryAlloc = 0;
if (index > 0) {
libraryAlloc = (Long) binaryAllocList.get(index);
}
}
- 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();
+ private void setChartSeries(DAChart chart, Map<Integer, DAChartSeries> seriesMap) {
+ chart.addSeries(seriesMap.get(totalAllocSeriesID));
+ Iterator<Integer> 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)) {
+ Integer binaryID = iterSeries.next();
+ if (binaryID < 0) {
continue;
}
- chart.addSeries(seriesMap.get(libraryPath));
- if (librarySequenceList.indexOf(libraryPath) < 0) {
- librarySequenceList.add(libraryPath);
+ chart.addSeries(seriesMap.get(binaryID));
+ if (librarySequenceList.indexOf(binaryID) < 0) {
+ librarySequenceList.add(binaryID);
}
}
- chart.addSeries(seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION));
+ chart.addSeries(seriesMap.get(appAllocSeriesID));
}
@Override
import org.tizen.dynamicanalyzer.swap.model.data.UIEventData;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenShotDBTable;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.CustomDataDBTable;
import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable;
private static final int MEM_API_TYPE_ALLOC = 0;
private static final int MEM_API_TYPE_FREE = 1;
private static final int MEM_USER = 2;
+ private static final int appAllocSeriesID = -10;
// 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<PID, Map<binaryID, Allocation Byte>>
+ private Map<Integer, Map<Integer, Long>> libraryAllocByteMap = new HashMap<Integer, Map<Integer, Long>>();
// Map<Address, Allocation Byte>
private HashMap<Long, Long> allocationSeriesDataSetMap = new HashMap<Long, Long>();
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>());
+ new HashMap<Integer, Long>());
}
int memApiType = logData.getMemoryApiType();
/*
* Check library allocation
*/
- String binaryPath = null;
+ BinaryInfo binaryInfo = null;
Project project = Global.getProject();
ProcessMemoryMap pmap = project.getProcessInformation(logData.getPid())
.getProcessMemoryMap(logData.getTime());
if (pmap != null) {
LibraryObject lib = pmap.getLibraryByAddress(logData.getCallerPcAddr());
if (lib != null && lib != pmap.getMainbinary()) {
- BinaryInfo binfo = project.getDeviceStatusInfo().getBinaryInfo(
+ binaryInfo = 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) {
- addNewSeriesUserAllocData(memApiType, logData, binaryPath);
+ addNewSeriesUserAllocData(memApiType, logData, binaryInfo);
}
}
}
/*
* Set inform for Heap allocation
*/
- List<Object> binaryPathList = new ArrayList<Object>();
+ List<Object> binaryIDList = new ArrayList<Object>();
List<Object> allocByteList = new ArrayList<Object>();
- binaryPathList
- .add(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
+ binaryIDList.add(appAllocSeriesID);
if (allocByteMap.get(process.getPid()) == null) {
allocByteList.add(new Long(0));
} else {
allocByteList.add(allocByteMap.get(process.getPid()));
}
- Map<String, Long> libraryList = libraryAllocByteMap.get(process.getPid());
+ Map<Integer, Long> libraryList = libraryAllocByteMap.get(process.getPid());
if (libraryList == null) {
- libraryList = new HashMap<String, Long>();
+ libraryList = new HashMap<Integer, Long>();
}
- Iterator<String> iter = libraryList.keySet().iterator();
+ Iterator<Integer> iter = libraryList.keySet().iterator();
while (iter.hasNext()) {
- String binaryPath = iter.next();
- binaryPathList.add(binaryPath);
- allocByteList.add(libraryList.get(binaryPath));
+ Integer binaryID = iter.next();
+ binaryIDList.add(binaryID);
+ allocByteList.add(libraryList.get(binaryID));
}
- dbTargetProcessData.add(binaryPathList);
+ dbTargetProcessData.add(binaryIDList);
dbTargetProcessData.add(allocByteList);
/*
}
}
- private void addNewSeriesUserAllocData(int fdApiType, MemoryData log, String libraryPath) {
+ private void addNewSeriesUserAllocData(int fdApiType, MemoryData log, BinaryInfo libraryInfo) {
long size = 0;
Long allocByte = allocByteMap.get(log.getPid());
if (MEM_API_TYPE_ALLOC == fdApiType) {
try {
size = log.getSize();
- if (libraryPath == null) {
+ if (libraryInfo == null) {
allocByteMap.put(log.getPid(), allocByte + size);
} else {
- Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
+ Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryInfo.getID());
if (libraryAllocByte == null) {
libraryAllocByte = new Long(0);
}
- libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte + size);
+ libraryAllocByteMap.get(log.getPid()).put(libraryInfo.getID(), libraryAllocByte + size);
}
allocationSeriesDataSetMap.put(address, size);
} catch (NumberFormatException ne) {
}
size = allocationSeriesDataSetMap.get(address);
- if (libraryPath == null) {
+ if (libraryInfo == null) {
allocByteMap.put(log.getPid(), allocByte - size);
} else {
- Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
- libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte - size);
+ Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryInfo.getID());
+ libraryAllocByteMap.get(log.getPid()).put(libraryInfo.getID(), libraryAllocByte - size);
}
}
}