From: jooyoul_lee Date: Thu, 5 Sep 2013 04:48:17 +0000 (+0900) Subject: [Title] log save format modified X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0ee6f04809fbd85f26ce468363548ac96af28cb;p=sdk%2Ftools%2Fdynamic-analyzer.git [Title] log save format modified [Desc.] - [Issue] - --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogInserter.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogInserter.java index c8708ad..018d910 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogInserter.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogInserter.java @@ -33,7 +33,9 @@ import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.sql.SqlManager; import org.tizen.dynamicanalyzer.swap.logparser.LogPackage; +import org.tizen.dynamicanalyzer.swap.logparser.Logs; import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import org.tizen.dynamicanalyzer.swap.model.probe2.LogData; import org.tizen.dynamicanalyzer.swap.model.probe2.LogDataFactory; /** log insert into database **/ @@ -107,22 +109,14 @@ public class LogInserter implements Runnable { } for (int i = 0; i < size; i++) { int logId = logIds.get(i); - List msgs = logPack.getMessages(logId); - if (null != msgs) { - List newMsgs = new ArrayList(); - newMsgs.addAll(msgs); - getLogPackage().putMessages(logId, msgs); + Logs logs = logPack.getLogs(logId); + if (null != logs) { + List newLogs = new ArrayList(); + newLogs.addAll(logs.getLogs()); + SqlManager.getInstance().insert(logId, newLogs); } } // for - for (int i = 0; i < size; i++) { - int logId = logIds.get(i); - List msgs = getLogPackage().getMessages( - logId); - if (null != msgs) { - SqlManager.getInstance().insert(logId, msgs); - } - } initLogPackage(); } catch (InterruptedException e) { System.out.println("insert log thread interrupted"); //$NON-NLS-1$ diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogParser.java index 5f784a0..457248b 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogParser.java @@ -216,133 +216,133 @@ public class LogParser implements Runnable { } private void logSlicing(List logLumb) { - String[] slicedLog2 = null; - Project project = AnalyzerManager.getProject(); - - int size = logLumb.size(); - LogPackage logPack = new LogPackage(); - - for (int i = 0; i < size; i++) { - if (logLumb.get(i).isEmpty()) { - continue; - } - String[] input = logLumb.get(i).split(CommonConstants.NEW_LINE); - - slicedLog2 = input[0].split(AnalyzerConstants.DATA_PARSING_TOKEN); - - BasicDataMessage message = new BasicDataMessage(); - message.makeData(slicedLog2); - if (message.getId() == AnalyzerConstants.MSG_DATA_SAMPLE) { - message.setCallstack(input[1]); - } - LogData log = LogDataFactory.createInstance(message); - int id = log.getId(); - - // if (log instanceof SystemData) { - // testSystemData(input, log); - // } else if (log instanceof ScreenShotData) { - // testScreenshotData(input, log); - // } - - if (log instanceof ProbeCommonData) { - if (-1 == pid) { - pid = ((ProbeCommonData) log).getPid(); - } else { - int p = ((ProbeCommonData) log).getPid(); - if (pid != p) { - continue; - } - } - } - - // ADJUST TIME -// long longTime = log.getTime(); -// DATime startTime = project.getStartTime(); +// String[] slicedLog2 = null; +// Project project = AnalyzerManager.getProject(); +// +// int size = logLumb.size(); +// LogPackage logPack = new LogPackage(); // -// if (0 == startTime.getSec() && 0 == startTime.getNano()) { -// long sec = longTime / 10000; -// long nano = longTime % 10000; -// nano *= 100000; -// startTime.setSec(sec); -// startTime.setNano(nano); -// project.setStartTime(startTime); +// for (int i = 0; i < size; i++) { +// if (logLumb.get(i).isEmpty()) { +// continue; // } -// long lastTime = longTime - startTime; -// lastTime *= 100; -// log.setTime(lastTime); - - int seqNum = log.getSeq(); - if (log instanceof UserFunctionData) { - UserFunctionData ufData = (UserFunctionData) log; - String apiName = ufData.getApiName(); - if (null == apiName || apiName.isEmpty() - || apiName.equals("_end")) { //$NON-NLS-1$ - setFuncName(ufData); - } - - if (LogParser.isDrapCallTraceLog()) { - apiName = ufData.getApiName(); - if (!apiName.equals(OSP_MAIN)) { - continue; - } - LogParser.setDropCallTraceLog(false); - } - long binaryStartAddr = ufData.getLowPc(); - long binaryEndAddr = ufData.getHighPc(); - - if (binaryStartAddr > 0 && binaryEndAddr > 0 - && !AnalyzerManager.isBinStartEndSet()) { - AnalyzerManager.setBinaryStartEndAddr(binaryStartAddr, - binaryEndAddr); - } - - if (AnalyzerManager.getCallstackManager().isIrregularUserCall( - ufData)) { - continue; - } - pushLog(log, message, logPack); - /* user callstack create by entry and exit */ - AnalyzerManager.getCallstackManager().makeUserCallstack( - ufData, - FunctionUsageProfiler.getInstance() - .getProfileDataMaker()); - } else if (log instanceof SystemData) { - if (seqNum == 1) { - UIRecorderPlayThread rp = UIRecorderTool.getInstance() - .getPlayThead(); - if (null != rp && rp.isAlive()) { - UIRecorderTool.getInstance().getPlayThead().interrupt(); - } - } - pushLog(log, message, logPack); - } else if (log instanceof ProfileData) { - pushLog(log, message, logPack); - } else { - if (log instanceof ScreenShotData) { - String remoteImgPath = ((ScreenShotData) log) - .getImageFilePath(); - String rotate = Integer.toString(((ScreenShotData) log) - .getOrientation()); - // TODO : fix - processImage(remoteImgPath, rotate); - } - pushLog(log, message, logPack); - AnalyzerManager.getCallstackManager() - .makeCallstackWithoutBacktrace(log); - if (id == AnalyzerConstants.MSG_PROBE_FILE - || id == AnalyzerConstants.MSG_PROBE_MEMORY) { - AnalyzerManager.getLeakDetector().runLeakDectect(log); - } - - AnalyzerManager.getFailedChecker().check(log, - AnalyzerManager.getCallstackManager()); - } - - // set last log number - AnalyzerManager.getProject().setLastLogNum(seqNum, id); - } - - updateLog(logPack); +// String[] input = logLumb.get(i).split(CommonConstants.NEW_LINE); +// +// slicedLog2 = input[0].split(AnalyzerConstants.DATA_PARSING_TOKEN); +// +// BasicDataMessage message = new BasicDataMessage(); +// message.makeData(slicedLog2); +// if (message.getId() == AnalyzerConstants.MSG_DATA_SAMPLE) { +// message.setCallstack(input[1]); +// } +// LogData log = LogDataFactory.createInstance(message); +// int id = log.getId(); +// +// // if (log instanceof SystemData) { +// // testSystemData(input, log); +// // } else if (log instanceof ScreenShotData) { +// // testScreenshotData(input, log); +// // } +// +// if (log instanceof ProbeCommonData) { +// if (-1 == pid) { +// pid = ((ProbeCommonData) log).getPid(); +// } else { +// int p = ((ProbeCommonData) log).getPid(); +// if (pid != p) { +// continue; +// } +// } +// } +// +// // ADJUST TIME +//// long longTime = log.getTime(); +//// DATime startTime = project.getStartTime(); +//// +//// if (0 == startTime.getSec() && 0 == startTime.getNano()) { +//// long sec = longTime / 10000; +//// long nano = longTime % 10000; +//// nano *= 100000; +//// startTime.setSec(sec); +//// startTime.setNano(nano); +//// project.setStartTime(startTime); +//// } +//// long lastTime = longTime - startTime; +//// lastTime *= 100; +//// log.setTime(lastTime); +// +// int seqNum = log.getSeq(); +// if (log instanceof UserFunctionData) { +// UserFunctionData ufData = (UserFunctionData) log; +// String apiName = ufData.getApiName(); +// if (null == apiName || apiName.isEmpty() +// || apiName.equals("_end")) { //$NON-NLS-1$ +// setFuncName(ufData); +// } +// +// if (LogParser.isDrapCallTraceLog()) { +// apiName = ufData.getApiName(); +// if (!apiName.equals(OSP_MAIN)) { +// continue; +// } +// LogParser.setDropCallTraceLog(false); +// } +// long binaryStartAddr = ufData.getLowPc(); +// long binaryEndAddr = ufData.getHighPc(); +// +// if (binaryStartAddr > 0 && binaryEndAddr > 0 +// && !AnalyzerManager.isBinStartEndSet()) { +// AnalyzerManager.setBinaryStartEndAddr(binaryStartAddr, +// binaryEndAddr); +// } +// +// if (AnalyzerManager.getCallstackManager().isIrregularUserCall( +// ufData)) { +// continue; +// } +// pushLog(log, message, logPack); +// /* user callstack create by entry and exit */ +// AnalyzerManager.getCallstackManager().makeUserCallstack( +// ufData, +// FunctionUsageProfiler.getInstance() +// .getProfileDataMaker()); +// } else if (log instanceof SystemData) { +// if (seqNum == 1) { +// UIRecorderPlayThread rp = UIRecorderTool.getInstance() +// .getPlayThead(); +// if (null != rp && rp.isAlive()) { +// UIRecorderTool.getInstance().getPlayThead().interrupt(); +// } +// } +// pushLog(log, message, logPack); +// } else if (log instanceof ProfileData) { +// pushLog(log, message, logPack); +// } else { +// if (log instanceof ScreenShotData) { +// String remoteImgPath = ((ScreenShotData) log) +// .getImageFilePath(); +// String rotate = Integer.toString(((ScreenShotData) log) +// .getOrientation()); +// // TODO : fix +// processImage(remoteImgPath, rotate); +// } +// pushLog(log, message, logPack); +// AnalyzerManager.getCallstackManager() +// .makeCallstackWithoutBacktrace(log); +// if (id == AnalyzerConstants.MSG_PROBE_FILE +// || id == AnalyzerConstants.MSG_PROBE_MEMORY) { +// AnalyzerManager.getLeakDetector().runLeakDectect(log); +// } +// +// AnalyzerManager.getFailedChecker().check(log, +// AnalyzerManager.getCallstackManager()); +// } +// +// // set last log number +// AnalyzerManager.getProject().setLastLogNum(seqNum, id); +// } +// +// updateLog(logPack); } private void processImage(final String from, String rotate) { @@ -452,7 +452,6 @@ public class LogParser implements Runnable { } logPack.setLogs(log.getId(), log); - logPack.setMessages(msg.getId(), msg); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java index 28be99f..dd4a795 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java @@ -32,6 +32,7 @@ import java.util.List; import org.tizen.dynamicanalyzer.common.CommonConstants; import org.tizen.dynamicanalyzer.common.ElfSymbolExtracter; import org.tizen.dynamicanalyzer.model.AddrSymbolPair; +import org.tizen.dynamicanalyzer.swap.model.control.ApplicationInfo; import org.tizen.dynamicanalyzer.swap.model.control.BinaryInfo; public class AppInfo { @@ -102,12 +103,16 @@ public class AppInfo { return symbolExtractor.getAddrSymbolPairs(); } - public String getExecFileName() { + public String getExecFileName(int type) { if (null == execFileName) { String execPath = appInfo.get(EXEC_INDEX); String[] splitPath = execPath.split(CommonConstants.SLASH); - execFileName = splitPath[splitPath.length - 1] - + CommonConstants.EXTENSION_EXEC_FILE; + if (type == ApplicationInfo.APPTYPE_TIZEN) { + execFileName = splitPath[splitPath.length - 1] + + CommonConstants.EXTENSION_EXEC_FILE; + } else { + execFileName = splitPath[splitPath.length - 1]; + } } return execFileName; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java index 8a42a7e..570664f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java @@ -243,15 +243,16 @@ public class Project { // create table SqlManager.getInstance().createProjectTable(this); - List ids = LogDataFactory.getLogList(); - int size = ids.size(); - for (int i = 0; i < size; i++) { - if (AnalyzerManager.isExit()) { - return; - } - SqlManager.getInstance().createTable(ids.get(i)); - } +// List ids = LogDataFactory.getLogList(); +// int size = ids.size(); +// for (int i = 0; i < size; i++) { +// if (AnalyzerManager.isExit()) { +// return; +// } +// SqlManager.getInstance().createTable(ids.get(i)); +// } // create save tables + SqlManager.getInstance().createProbeTable(); SqlManager.getInstance().createTables(); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java index dc70e1b..52e2701 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java @@ -50,16 +50,18 @@ import org.tizen.dynamicanalyzer.common.CommonConstants; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; import org.tizen.dynamicanalyzer.model.LogCenter; import org.tizen.dynamicanalyzer.project.Project; -import org.tizen.dynamicanalyzer.swap.model.ByteUtils; +import org.tizen.dynamicanalyzer.swap.model.RecordEventObject; import org.tizen.dynamicanalyzer.swap.model.control.TargetInfo; import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager; import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; import org.tizen.dynamicanalyzer.swap.model.data.LibraryObject; import org.tizen.dynamicanalyzer.swap.model.data.ProcessInfo; +import org.tizen.dynamicanalyzer.swap.model.probe.LogFormat; import org.tizen.dynamicanalyzer.swap.model.probe2.FailedData2; import org.tizen.dynamicanalyzer.swap.model.probe2.LeakData2; import org.tizen.dynamicanalyzer.swap.model.probe2.LogData; import org.tizen.dynamicanalyzer.swap.model.probe2.LogDataFactory; +import org.tizen.dynamicanalyzer.swap.model.probe2.ReplayData; import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData; import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit; import org.tizen.dynamicanalyzer.ui.summary.failed.FailedChecker; @@ -147,18 +149,47 @@ public class SqlManager { } // create query - public synchronized void createTable(int id) { + // public synchronized void createTable(int id) { + // Statement stat = null; + // try { + // Connection conn = getConnection(); + // if (null == conn) { + // return; + // } + // semaphoreAcquire(); + // stat = conn.createStatement(); + // stat.executeUpdate(createDropTableQuery(LogDataFactory + // .getTableNamebyId(id))); + // stat.executeUpdate(createTableQuery(id)); + // } catch (SQLException e) { + // e.printStackTrace(); + // } finally { + // AnalyzerUtil.tryClose(stat); + // semaphoreRelease(); + // } + // } + + public synchronized void createProbeTable() { Statement stat = null; try { Connection conn = getConnection(); if (null == conn) { return; } + + List logFormats = LogFormat.getLogFormats(); + int size = logFormats.size(); semaphoreAcquire(); stat = conn.createStatement(); - stat.executeUpdate(createDropTableQuery(LogDataFactory - .getTableNamebyId(id))); - stat.executeUpdate(createTableQuery(id)); + for (int i = 0; i < size; i++) { + if (AnalyzerManager.isExit()) { + break; + } + LogFormat lf = logFormats.get(i); + String tableName = lf.getName(); + stat.executeUpdate(createDropTableQuery(tableName)); + stat.executeUpdate(createTableQuery(lf)); + } } catch (SQLException e) { e.printStackTrace(); } finally { @@ -167,18 +198,35 @@ public class SqlManager { } } - private String createTableQuery(int id) { + private String createTableQuery(LogFormat logFormat) { StringBuffer query = new StringBuffer(); query.append("create table "); //$NON-NLS-1$ - String name = LogDataFactory.getTableNamebyId(id); + String name = logFormat.getName(); query.append(name); query.append(CommonConstants.SPACE + CommonConstants.OPEN_BRACKET); - // TODO: constants - String column = "Rid INTEGER, ID INTEGER, SeqNumber INTEGER PRIMARY KEY NOT NULL, Time TEXT, payload BLOB"; + List dbColumns = logFormat.getDBColumnNames(); + List dbTypes = logFormat.getDBColumntypes(); + int size = dbColumns.size(); - query.append(column).append(CommonConstants.CLOSE_BRACKET) - .append(CommonConstants.SEMICOLON); + for (int i = 0; i < size; i++) { + query.append(dbColumns.get(i)).append(CommonConstants.SPACE); + String type = "TEXT"; + if (dbTypes.get(i) == LogFormat.I) { + type = "INTEGER"; + } else if (dbTypes.get(i) == LogFormat.L) { + type = "LONG"; + } + query.append(type); + if (i + 1 == size) { + query.append(CommonConstants.CLOSE_BRACKET).append( + CommonConstants.SEMICOLON); + } else { + query.append(CommonConstants.COMMA); + } + } + + System.out.println(query.toString()); return query.toString(); } @@ -273,10 +321,9 @@ public class SqlManager { * insert data * @return success/failed */ - public boolean insertLogQuery(int id, String query, - List input) { + public boolean insertLogQuery(String query, List input) { PreparedStatement prep = null; - BasicDataMessage msg = null; + LogData logData = null; try { Connection conn = getConnection(); if (null == conn || null == query || null == input) { @@ -287,27 +334,29 @@ public class SqlManager { prep = conn.prepareStatement(query); int dataRowSize = input.size(); for (int i = 0; i < dataRowSize; i++) { - msg = input.get(i); - int logNum = LogDataFactory.getLogCountById(id); - if (id == 0x2007) { - System.out.println("[!!!]insert to system : " + msg.getId() - + " " + msg.getSeq() + " " + msg.getTime() - + " size :" + msg.getPayload().length); - ByteUtils.printByteArray(msg.getPayload()); + logData = input.get(i); + if (logData.getId() != AnalyzerConstants.MSG_DATA_RECORD) { + logData.makePreparedStatement(prep); + prep.addBatch(); + } else { + ReplayData replayData = (ReplayData) logData; + int count = replayData.getObjectCount(); + List events = replayData + .getRecordEvent(); + RecordEventObject reo = null; + for (int ii = 0; ii < count; ii++) { + reo = events.get(ii); + reo.makePreparedStatement(prep); + prep.addBatch(); + } } - prep.setInt(1, logNum); - prep.setInt(2, msg.getId()); - prep.setInt(3, msg.getSeq()); - prep.setLong(4, msg.getTime()); - prep.setBytes(5, msg.getPayload()); - prep.addBatch(); } conn.setAutoCommit(false); prep.executeBatch(); conn.setAutoCommit(true); } catch (SQLException e) { - System.out.println("[Error insert] id = " + msg.getId() - + " seq : " + msg.getSeq()); + // System.out.println("[Error insert] id = " + logData.getId() + // + " seq : " + logData.getSeq()); e.printStackTrace(); } finally { if (null != prep) { @@ -447,13 +496,24 @@ public class SqlManager { return true; } - public void insert(int logId, List input) + public void insert(int logId, List input) throws InterruptedException { - String tableName = LogDataFactory.getTableNamebyId(logId); - String insertQuery = "insert into " + tableName - + " values( ?, ?, ?, ?, ?);"; - // System.out.println("inser query : " + insertQuery); - insertLogQuery(logId, insertQuery, input); + LogFormat logFormat = LogDataFactory.getLogFormatById(logId); + + StringBuffer buffer = new StringBuffer(); + buffer.append("insert into ").append(logFormat.getName()) + .append(" values( "); + + int columnCount = logFormat.getDBTotalColumnCount(); + for (int i = 0; i < columnCount; i++) { + if (i + 1 == columnCount) { + buffer.append(" ? );"); + } else { + buffer.append("?, "); + } + } + + insertLogQuery(buffer.toString(), input); } @@ -786,20 +846,8 @@ public class SqlManager { } while (rs.next()) { - // int rowId = rs.getInt(1); - int id = rs.getInt(2); - int seq = rs.getInt(3); - long time = rs.getLong(4); - byte[] payload = rs.getBytes(5); - BasicDataMessage basicData = new BasicDataMessage(); - basicData.setId(id); - basicData.setSeq(seq); - basicData.setTime(time); - basicData.setPayload(payload); - - LogData logdata = LogDataFactory.createInstance(basicData); - - dbInfo.add(logdata); + LogData logData = LogDataFactory.createInstance(rs); + dbInfo.add(logData); } } catch (SQLException e) { System.out.println("SQLException - selecte : " + query); @@ -840,7 +888,7 @@ public class SqlManager { } StringBuilder columns = new StringBuilder(); - columns.append("Rid , ID , SeqNumber , Time , payload "); + columns.append("* "); String queryOption = CommonConstants.EMPTY; if (null != option) { queryOption = option; @@ -855,18 +903,8 @@ public class SqlManager { } logs = new ArrayList(); while (rs.next()) { - BasicDataMessage bdm = new BasicDataMessage(); - bdm.setId(rs.getInt(2)); - bdm.setSeq(rs.getInt(3)); - bdm.setTime(rs.getLong(4)); - bdm.setPayload(rs.getBytes(5)); - LogData log = LogDataFactory.createInstance(bdm); + LogData log = LogDataFactory.createInstance(rs); logs.add(log); - if (bdm.getId() == 0x2007) { - System.out.println("read system data seq = " - + bdm.getSeq()); - ByteUtils.printByteArray(bdm.getPayload()); - } } } catch (SQLException e) { System.out.println("SQLException - selecte : " + query); @@ -1192,7 +1230,7 @@ public class SqlManager { } public int getRangeMinSeq(int logId, long time) { - String tableName = LogDataFactory.getTableNamebyId(logId); + String tableName = LogDataFactory.getLogFormatById(logId).getName(); String queryOption = " where time >= " + time; //$NON-NLS-1$ List> dbInfo = selectQuery(null, new String[] { "min(seqnumber)" }, tableName, queryOption); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1203,7 +1241,7 @@ public class SqlManager { } public int getRangeMaxSeq(int logId, long time) { - String tableName = LogDataFactory.getTableNamebyId(logId); + String tableName = LogDataFactory.getLogFormatById(logId).getName(); String queryOption = " where time <= " + time; //$NON-NLS-1$ List> dbInfo = selectQuery(null, new String[] { "max(seqnumber)" }, tableName, queryOption); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1215,7 +1253,7 @@ public class SqlManager { public List selectArea(int logId, long from, long to) { - String tableName = LogDataFactory.getTableNamebyId(logId); + String tableName = LogDataFactory.getLogFormatById(logId).getName(); StringBuffer queryOption = new StringBuffer(); queryOption.append(" where SeqNumber >= "); //$NON-NLS-1$ queryOption.append(from); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java index 25f6871..49cf7a1 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java @@ -288,7 +288,6 @@ public class Communicator30 extends BaseCommunicator { byte[] msgBinInfo = ByteUtils .toBytes(AnalyzerConstants.MSG_BINARY_INFO); ApplicationInfo appInfo = new ApplicationInfo(); - // AppInfo selectedApp = DACommunicator.getSelectedApp(); String appType = selectedApp.getInfo(AppInfo.APPTYPE_INDEX); if (appType.contains(AppInfo.APPTYPE_CPP)) { appInfo.setAppType(ApplicationInfo.APPTYPE_TIZEN); @@ -309,12 +308,16 @@ public class Communicator30 extends BaseCommunicator { return HostResult.ERR_BIN_INFO_GET_FAIL; } + // parse binary info byte[] payload = getMessagePayload(result.getRet()); BinaryInfo binInfo = new BinaryInfo(); selectedApp.setBinInfo(binInfo); int binaryType = ByteUtils.toInt(payload, 0); String targetPath = selectedApp.getInfo(AppInfo.EXEC_INDEX); + if (appInfo.getAppType() == ApplicationInfo.APPTYPE_TIZEN) { + targetPath += CommonConstants.EXTENSION_EXEC_FILE; + } String binaryDir = ByteUtils.getString(payload, INT_SIZE).trim(); String binaryPath = null; if (null == binaryDir) { @@ -324,7 +327,7 @@ public class Communicator30 extends BaseCommunicator { StringBuffer strBuf = new StringBuffer(); strBuf.append(binaryDir).append(File.separator) - .append(selectedApp.getExecFileName()); + .append(selectedApp.getExecFileName(appInfo.getAppType())); binaryPath = strBuf.toString(); binInfo.setType(binaryType); @@ -332,8 +335,8 @@ public class Communicator30 extends BaseCommunicator { // change binary file path of host File binFile = new File(binaryPath); if (!binFile.exists()) { - String name = selectedApp.getInfo(AppInfo.LABEL_INDEX); - binaryPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator + name; + binaryPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator + + selectedApp.getExecFileName(appInfo.getAppType()); SyncResult res = CommunicatorUtils.pull(targetPath, binaryPath); if (null != res && res.isOk()) { System.out.println("binary copy success!!");//$NON-NLS-1$ @@ -342,13 +345,12 @@ public class Communicator30 extends BaseCommunicator { return HostResult.ERR_BIN_INFO_GET_FAIL; } binInfo.setPath(binaryPath); - // selectedApp.setBinInfo(binInfo); return result; } // host has binary then compare binary hash target and local String command = AnalyzerShellCommands.CMD_DA_MD_5_SUM + targetPath; - // + CommonConstants.EXTENSION_EXEC_FILE; + CommunicatorUtils.execHostCommand(command, new MultiLineReceiver() { @Override public void processNewLines(String[] appLines) { @@ -364,11 +366,9 @@ public class Communicator30 extends BaseCommunicator { .split(CommonConstants.SPACE); String targetHashCode = new String(splitResult[0]); String localHashCode = null; - // command = AnalyzerShellCommands.CMD_MD_5_SUM + "\"" + binaryPath + - // "\""; + command = AnalyzerShellCommands.CMD_MD_5_SUM + "\"" + binaryPath + "\""; try { Runtime rt = Runtime.getRuntime(); - // Process process = rt.exec(command); Process process = rt.exec(new String[] { AnalyzerShellCommands.CMD_MD_5_SUM, binaryPath }); process.waitFor(); @@ -397,27 +397,23 @@ public class Communicator30 extends BaseCommunicator { // FIXME: permission denied problem - // if (!targetHashCode.equals(localHashCode)) { - // String name = selectedApp.getInfo(AppInfo.LABEL_INDEX); - // String destFilePath = AnalyzerPaths.TEMP_FOLDER_PATH - // + File.separator + name - // + CommonConstants.EXTENSION_EXEC_FILE; - // SyncResult res = CommunicatorUtils.pull(targetPath, - // destFilePath); - // if (null != res && res.isOk()) { - // System.out.println("binary copy success!!");//$NON-NLS-1$ - // } else { - // System.out.println("Failed to get " + targetPath + " step 2"); //$NON-NLS-1$ - // return HostResult.ERR_BIN_INFO_GET_FAIL; - // } - // String[] splitName = binaryPath.split(CommonConstants.SLASH); - // binaryPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator - // + new String(splitName[splitName.length - 1]); - // binInfo.setPath(binaryPath); - // // selectedApp.setBinInfo(binInfo); - // } + if (!targetHashCode.equals(localHashCode)) { + String destFilePath = AnalyzerPaths.TEMP_FOLDER_PATH + + File.separator + selectedApp.getExecFileName(appInfo.getAppType()); + + SyncResult res = CommunicatorUtils.pull(targetPath, destFilePath); + if (null != res && res.isOk()) { + System.out.println("binary copy success!!");//$NON-NLS-1$ + } else { + System.out.println("Failed to get " + targetPath + " step 2"); //$NON-NLS-1$ + return HostResult.ERR_BIN_INFO_GET_FAIL; + } + String[] splitName = binaryPath.split(CommonConstants.SLASH); + binaryPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator + + new String(splitName[splitName.length - 1]); + binInfo.setPath(binaryPath); + } binInfo.setPath(binaryPath); - // selectedApp.setBinInfo(binInfo); return result; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogPackage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogPackage.java index 9d19467..b9bf3de 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogPackage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogPackage.java @@ -26,25 +26,19 @@ package org.tizen.dynamicanalyzer.swap.logparser; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; import org.tizen.dynamicanalyzer.swap.model.probe2.LogData; public class LogPackage { private HashMap logMap; - private HashMap> messageMap; public void clear() { getLogMap().clear(); - getMessageMap().clear(); } public LogPackage() { logMap = new HashMap(); - messageMap = new HashMap>(); } private HashMap getLogMap() { @@ -54,13 +48,6 @@ public class LogPackage { return logMap; } - private HashMap> getMessageMap() { - if (null == messageMap) { - messageMap = new HashMap>(); - } - return messageMap; - } - public boolean isEmpty() { return getLogMap().isEmpty(); } @@ -74,15 +61,6 @@ public class LogPackage { logs.getLogs().add(input); } - public void setMessages(int id, BasicDataMessage msg) { - List msgs = getMessageMap().get(id); - if (null == msgs) { - msgs = new ArrayList(); - getMessageMap().put(id, msgs); - } - msgs.add(msg); - } - public void setLogs(int id, Logs logs) { if (null != getLogMap().get(id)) { logMap.remove(id); @@ -94,10 +72,6 @@ public class LogPackage { return getLogMap().get(id); } - public List getMessages(int id) { - return getMessageMap().get(id); - } - public void putLogs(Logs logs) { if (null != logs) { int id = logs.getId(); @@ -110,14 +84,4 @@ public class LogPackage { } } - public void putMessages(int id, List msgs) { - if (null != msgs) { - List base = getMessageMap().get(id); - if (null == base) { - messageMap.put(id, msgs); - } else { - base.addAll(msgs); - } - } - } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogQueue.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogQueue.java index d12b3e7..6693e14 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogQueue.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/LogQueue.java @@ -30,18 +30,18 @@ import java.util.ArrayList; import java.util.List; import org.tizen.dynamicanalyzer.common.AnalyzerManager; -import org.tizen.dynamicanalyzer.swap.model.LogContainer; +import org.tizen.dynamicanalyzer.swap.model.probe2.LogData; /** log queue model **/ public class LogQueue { private static final int FULL_COUNT = 10000; - private List> data = null; + private List> data = null; public LogQueue() { - data = new ArrayList>(); + data = new ArrayList>(); } - public synchronized List getFirst() { + public synchronized List getFirst() { while (isEmpty()) { try { if (!AnalyzerManager.isRunning()) { @@ -54,13 +54,13 @@ public class LogQueue { } } - List output = data.get(0); + List output = data.get(0); data.remove(0); notifyAll(); return output; } - public synchronized void putLog(List input) { + public synchronized void putLog(List input) { while (isFull()) { try { wait(); @@ -77,7 +77,7 @@ public class LogQueue { public boolean isEmpty() { if (null == data) { - data = new ArrayList>(); + data = new ArrayList>(); } return data.isEmpty(); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java index ca46526..244c275 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java @@ -50,8 +50,6 @@ import org.tizen.dynamicanalyzer.handlers.StopHandler; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.swap.model.ByteUtils; import org.tizen.dynamicanalyzer.swap.model.DATime; -import org.tizen.dynamicanalyzer.swap.model.LogContainer; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; import org.tizen.dynamicanalyzer.swap.model.data.DataChannelConstants; import org.tizen.dynamicanalyzer.swap.model.data.LibraryObject; import org.tizen.dynamicanalyzer.swap.model.data.ProcessInfo; @@ -78,8 +76,9 @@ public class MessageParser { final int MSG_BUFFER_TIMER_PERIOD = 1000; // 1 second final int WAITING_TIME = 100; - final int MSG_HEADER_SIZE = 20; + public static final int MSG_HEADER_SIZE = 20; final int MSG_PAYLOAD_SIZE_INDEX = 16; + boolean exit = false; class AddBufferTimerTask extends TimerTask { private int count = 0; @@ -98,7 +97,7 @@ public class MessageParser { } } - private List buffer = new ArrayList(); + private List buffer = new ArrayList(); private Lock lock = new ReentrantLock(); private Timer timer = null; @@ -129,12 +128,11 @@ public class MessageParser { return; } SWAPLogParser.getLogQueue().putLog(buffer); - buffer = new ArrayList(); + buffer = new ArrayList(); lock.unlock(); } - private void processProcessInfo(BasicDataMessage message) { - byte[] payload = message.getPayload(); + private void processProcessInfo(byte[] data) { ProcessInfo pInfo = AnalyzerManager.getProject().getProcessInfo(); int pid = 0; @@ -146,35 +144,35 @@ public class MessageParser { String binaryPath = null; int dependantLibCount = 0; - int index = 0; - pid = ByteUtils.toInt(payload, index); + int index = MSG_HEADER_SIZE; + pid = ByteUtils.toInt(data, index); index += INT_SIZE; - long sec = ByteUtils.toInt(payload, index); + long sec = ByteUtils.toInt(data, index); index += INT_SIZE; - long nano = ByteUtils.toInt(payload, index); + long nano = ByteUtils.toInt(data, index); index += INT_SIZE; startTime.setSec(sec); startTime.setNano(nano); - lowAddr = ByteUtils.toLong(payload, index); + lowAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; - highAddr = ByteUtils.toLong(payload, index); + highAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; - binaryType = ByteUtils.toInt(payload, index); + binaryType = ByteUtils.toInt(data, index); index += INT_SIZE; - binaryPath = ByteUtils.getString(payload, index); - index += ByteUtils.getStringLength(payload, index); - dependantLibCount = ByteUtils.toInt(payload, index); + binaryPath = ByteUtils.getString(data, index); + index += ByteUtils.getStringLength(data, index); + dependantLibCount = ByteUtils.toInt(data, index); index += INT_SIZE; List libObjs = pInfo.getLibObjs(); for (int i = 0; i < dependantLibCount; i++) { LibraryObject libObj = new LibraryObject(); - long lowestAddr = ByteUtils.toLong(payload, index); + long lowestAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; - long highestAddr = ByteUtils.toLong(payload, index); + long highestAddr = ByteUtils.toLong(data, index); index += LONG_SIZE; - String libPath = ByteUtils.getString(payload, index); - index += ByteUtils.getStringLength(payload, index); + String libPath = ByteUtils.getString(data, index); + index += ByteUtils.getStringLength(data, index); libObj.setLowestAddress(lowestAddr); libObj.setHighestAddress(highestAddr); libObj.setLibPath(libPath); @@ -254,79 +252,59 @@ public class MessageParser { startTimer(); try { - BasicDataMessage dataMessage = null; byte[] header = new byte[MSG_HEADER_SIZE]; - byte[] payload = null; while (true) { - // int available = inputStream.available(); - // if (available < 20) { - // System.out.println("not available : " + available); - // continue; - // } - // System.out.println(" Available size : " + available); - int readSize = inputStream.read(header); - if (!DACommunicator.isRunning() && readSize == -1) { - // manager socket closed!! + int readSize = 0; + int toRead = MSG_HEADER_SIZE; + while (toRead > 0) { + readSize = inputStream.read(header, MSG_HEADER_SIZE + - toRead, toRead); + toRead -= readSize; + if (!DACommunicator.isRunning() && readSize == -1) { + // manager socket closed!! + exit = true; + break; + } + } + + if (exit) { break; } - if (readSize <= 0) { - continue; - } else { - ByteUtils.printByteArray(header); - - // for (int i = 0; i < 100; i++) { - // System.out.print(" "); - // } - // System.out.println(); - - int id = ByteUtils.toInt(header, 0); - int seq = ByteUtils.toInt(header, 4); - - long sec = ByteUtils.toInt(header, 8); - long nano = ByteUtils.toInt(header, 12); - DATime startTime = AnalyzerManager.getProject() - .getStartTime(); - long startSec = startTime.getSec(); - long startNano = startTime.getNano(); - long resultSec = sec - startSec; - long resultNano = nano - startNano; - - long time = resultSec * 1000000 + resultNano / 1000; - int payloadSize = ByteUtils.toInt(header, - MSG_PAYLOAD_SIZE_INDEX); - try { - payload = new byte[payloadSize]; - } catch (OutOfMemoryError e) { - System.out - .println("======================== wrong read data ================================="); - System.out - .println("read data start with garbages!!!\n header log(20byte) is :"); - ByteUtils.printByteArray(header); - System.out - .println("======================== wrong read data ================================="); - } catch (NegativeArraySizeException e) { - System.out - .println("======================== wrong read data ================================="); - System.out - .println("read data start with garbages!!!\n header log(20byte) is :"); - ByteUtils.printByteArray(header); - System.out - .println("======================== wrong read data ================================="); - } - readSize = inputStream.read(payload); - - dataMessage = new BasicDataMessage(); - dataMessage.setId(id); - dataMessage.setSeq(seq); - dataMessage.setTime(time); - dataMessage.setPayload(payload); - processMessage(dataMessage); - if (id == AnalyzerConstants.MSG_DATA_TERMINATE) { - System.out.println("message data terminate arrived!!!"); + + int id = ByteUtils.toInt(header, 0); + int payloadSize = ByteUtils.toInt(header, + MSG_PAYLOAD_SIZE_INDEX); + byte[] payload = null; + + payload = new byte[payloadSize]; + + toRead = payloadSize; + while (toRead > 0) { + readSize = inputStream.read(payload, payloadSize - toRead, + toRead); + toRead -= readSize; + if (!DACommunicator.isRunning() && readSize == -1) { + // manager socket closed!! + exit = true; break; } } + + if (exit) { + break; + } + + byte[] buffer = new byte[MSG_HEADER_SIZE + payloadSize]; + System.arraycopy(header, 0, buffer, 0, MSG_HEADER_SIZE); + System.arraycopy(payload, 0, buffer, MSG_HEADER_SIZE, + payloadSize); + + processMessage(buffer); + if (id == AnalyzerConstants.MSG_DATA_TERMINATE) { + System.out.println("message data terminate arrived!!!"); + break; + } } // end while() System.out.println("Receive thread end!!"); Display.getDefault().asyncExec(new Runnable() { @@ -377,21 +355,18 @@ public class MessageParser { ReplayTraceHandler.startTime = null; } - private void processMessage(BasicDataMessage data) { - int messageId = data.getId(); + private void processMessage(byte[] data) { + int id = ByteUtils.toInt(data, 0); LogData log = null; - switch (messageId) { + switch (id) { case DataChannelConstants.MSG_PROCESS_INFO: // setting process info - data.printMessage(); processProcessInfo(data); break; case DataChannelConstants.MSG_TERMINATE: - data.printMessage(); processTerminate(); break; case DataChannelConstants.MSG_ERROR: - data.printMessage(); // process error message break; case DataChannelConstants.MSG_SYSTEM: @@ -402,22 +377,20 @@ public class MessageParser { case DataChannelConstants.MSG_CONTEXT_SWITCH_EXIT: case DataChannelConstants.MSG_RECORD: if (AnalyzerManager.isProcessInfoArrived()) { - data.printMessage(); // make log log = LogDataFactory.createInstance(data); if (null != log) { - buffer.add(new LogContainer(log, data)); + buffer.add(log); messageCount += 1; } } break; default: // MSG_PROBE - if (AnalyzerManager.isProcessInfoArrived() && messageId > 0x3000 - && messageId < 0x4000) { - data.printMessage(); + if (AnalyzerManager.isProcessInfoArrived() && id > 0x3000 + && id < 0x4000) { log = LogDataFactory.createInstance(data); if (null != log) { - buffer.add(new LogContainer(log, data)); + buffer.add(log); messageCount++; } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java index 98182b0..76416ad 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java @@ -38,9 +38,7 @@ import org.tizen.dynamicanalyzer.logparser.LogInserter; import org.tizen.dynamicanalyzer.logparser.LogParser; import org.tizen.dynamicanalyzer.model.ImageInfo; import org.tizen.dynamicanalyzer.nl.InformationViewLabels; -import org.tizen.dynamicanalyzer.swap.model.LogContainer; import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; import org.tizen.dynamicanalyzer.swap.model.probe2.ContextSwitchData; import org.tizen.dynamicanalyzer.swap.model.probe2.LogData; import org.tizen.dynamicanalyzer.swap.model.probe2.ProbeCommonData; @@ -122,7 +120,7 @@ public class SWAPLogParser implements Runnable { AnalyzerManager.setLogParsingComplete(false); LogQueue logQueue = getLogQueue(); while (!AnalyzerManager.isExit()) { - List logs = logQueue.getFirst(); + List logs = logQueue.getFirst(); if (null == logs) { break; } @@ -138,17 +136,15 @@ public class SWAPLogParser implements Runnable { } } - private void logSlicing(List logLumb) { + private void logSlicing(List logLumb) { int size = logLumb.size(); LogPackage logPack = new LogPackage(); - System.out.println(" log lumb size " + size ); + System.out.println(" log lumb size " + size); for (int i = 0; i < size; i++) { if (null == logLumb.get(i)) { continue; } - LogContainer logContainer = logLumb.get(i); - LogData log = logContainer.getLogData(); - BasicDataMessage msg = logContainer.getMessage(); + LogData log = logLumb.get(i); int id = log.getId(); // check main process!! @@ -173,7 +169,7 @@ public class SWAPLogParser implements Runnable { UIRecorderTool.getInstance().getPlayThead().interrupt(); } } - pushLog(log, msg, logPack); + pushLog(log, logPack); } else if (log instanceof ProfileData) { if (!AnalyzerManager.isProcessInfoArrived()) { continue; @@ -197,7 +193,7 @@ public class SWAPLogParser implements Runnable { pData)) { continue; } - pushLog(log, msg, logPack); + pushLog(log, logPack); /* user callstack create by entry and exit */ AnalyzerManager.getCallstackManager().makeUserCallstack( pData, @@ -205,7 +201,7 @@ public class SWAPLogParser implements Runnable { .getProfileDataMaker()); } else if (log instanceof ReplayData || log instanceof ContextSwitchData) { - pushLog(log, msg, logPack); + pushLog(log, logPack); } else { if (log instanceof ScreenShotData) { String remoteImgPath = ((ScreenShotData) log) @@ -223,7 +219,7 @@ public class SWAPLogParser implements Runnable { AnalyzerManager.getImageSet() .put(imgInfo.getSeq(), imgInfo); } - pushLog(log, msg, logPack); + pushLog(log, logPack); AnalyzerManager.getCallstackManager() .makeCallstackWithoutBacktrace(log); if (id == AnalyzerConstants.MSG_PROBE_FILE @@ -239,7 +235,7 @@ public class SWAPLogParser implements Runnable { AnalyzerManager.getProject().setLastLogNum(seqNum, id); } -// System.out.println("update logs"); + // System.out.println("update logs"); updateLog(logPack); } @@ -317,11 +313,12 @@ public class SWAPLogParser implements Runnable { } private void setFuncName(ProfileData input) { -// boolean isPieBuild = AnalyzerManager.getProject().isPieBuild(); - boolean isPieBuild = (DACommunicator.getSelectedApp().getBinInfo().getType() == 1)?true:false; + // boolean isPieBuild = AnalyzerManager.getProject().isPieBuild(); + boolean isPieBuild = (DACommunicator.getSelectedApp().getBinInfo() + .getType() == 1) ? true : false; String baseAddr = Long.toString(AnalyzerManager.getProject() .getBaseAddress()); -// String path = AnalyzerManager.getProject().getBinaryPath(); + // String path = AnalyzerManager.getProject().getBinaryPath(); String path = DACommunicator.getSelectedApp().getBinInfo().getPath(); // String path = DACommunicator.getSelectedApp().getBinInfo().getPath(); String pcAddr = Long.toString(input.getPcAddr()); @@ -341,9 +338,7 @@ public class SWAPLogParser implements Runnable { input.setApiName(functionName); } - private void pushLog(LogData logData, BasicDataMessage msg, - LogPackage logPack) { + private void pushLog(LogData logData, LogPackage logPack) { logPack.setLogs(logData.getId(), logData); - logPack.setMessages(msg.getId(), msg); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java index b2402f5..8c57d43 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/RecordEventObject.java @@ -1,5 +1,11 @@ package org.tizen.dynamicanalyzer.swap.model; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.swap.model.probe2.LogDataFactory; + public class RecordEventObject { private DATime eventTime = null; private int eventId = 0; @@ -46,4 +52,19 @@ public class RecordEventObject { public void setEventTime(DATime eventTime) { this.eventTime = eventTime; } + + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + + int logNum = LogDataFactory + .getLogCountById(AnalyzerConstants.MSG_DATA_RECORD); + + prep.setInt(1, logNum); + prep.setLong(2, eventTime.getSec()); + prep.setLong(3, eventTime.getNano()); + prep.setInt(4, eventId); + prep.setInt(5, eventType); + prep.setInt(6, eventCode); + prep.setInt(7, eventValue); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CommonColumns.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CommonColumns.java index 145d53f..1b9be79 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CommonColumns.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CommonColumns.java @@ -11,11 +11,11 @@ import java.util.List; public class CommonColumns { private static String[] dcn = { "APPID", "PID", "TID", "args", "Return", - "Errno", "InternalCall", "CallerPCAddr", "Reserved", "Reserved" }; - private static Integer[] dct = { I, I, I, T, T, T, I, T, I, I, I, I }; + "Errno", "InternalCall", "CallerPCAddr", "Reserved1", "Reserved2" }; + private static Integer[] dct = { I, I, I, T, L, L, I, L, I, I }; private static String[] tcn = { "App ID", "PID", "TID", "Args", "Return", - "Errno", "Internal Call", "Caller PCAddr", "Reserved", "Reserved" }; - private static Integer[] logTypes = { I, I, I, T, L, I, I, L, I, I }; + "Errno", "Internal Call", "Caller PCAddr", "Reserved1", "Reserved2" }; + private static Integer[] logTypes = { I, I, I, T, L, L, I, L, I, I }; private static List dbColumnNames = null; private static List dbColumnTypes = null; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ContextSwitchLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ContextSwitchLogFormat.java new file mode 100644 index 0000000..e28a56b --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ContextSwitchLogFormat.java @@ -0,0 +1,36 @@ +package org.tizen.dynamicanalyzer.swap.model.probe; + +import java.util.Arrays; + +public class ContextSwitchLogFormat extends LogFormat { + public static final String NAME = "ContextSwitch"; + + private static ContextSwitchLogFormat instance = null; + + public static ContextSwitchLogFormat getInstance() { + if (null == instance) { + instance = new ContextSwitchLogFormat(); + } + return instance; + } + + private ContextSwitchLogFormat() { + setName(NAME); + + String[] dcn = { "PCAddr", "Pid", "Tid", "CpuNum" }; + dbColumnNames = HeaderColumns.getDBColumnNames(); + dbColumnNames.addAll(Arrays.asList(dcn)); + + Integer[] dct = { L, I, I, I }; + dbColumnTypes = HeaderColumns.getDBColumntypes(); + dbColumnTypes.addAll(Arrays.asList(dct)); + + String[] tcn = { "PCAddr", "Pid", "Tid", "CpuNum" }; + tableColumnNames = HeaderColumns.getTableColumnNames(); + tableColumnNames.addAll(Arrays.asList(tcn)); + + Integer[] types = { L, I, I, I }; + logColumnTypes = HeaderColumns.getLogColumnTypes(); + logColumnTypes.addAll(Arrays.asList(types)); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ControlLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ControlLogFormat.java index 6528ef5..b5514d3 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ControlLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ControlLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class ControlLogFormat extends LogFormat { - public static final int ID = 0x3002; public static final String NAME = "Control"; private static ControlLogFormat instance = null; @@ -16,14 +15,13 @@ public class ControlLogFormat extends LogFormat { } private ControlLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "ParentName", "ParentClass", "ParentPointer", "ChildName", "ChildClass", "ChildPointer" }; dbColumnNames = CommonColumns.getDBColumnNames(); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, T, T, T, T, T }; + Integer[] dct = { T, T, L, T, T, L }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CustomChartLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CustomChartLogFormat.java index e00d92a..ce95515 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CustomChartLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/CustomChartLogFormat.java @@ -16,7 +16,6 @@ public class CustomChartLogFormat extends LogFormat { } private CustomChartLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "Handle", "Type", "Name", "Color", "Value" }; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/FileLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/FileLogFormat.java index 16ba80d..b98afb3 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/FileLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/FileLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class FileLogFormat extends LogFormat { - public static final int ID = 0x3004; public static final String NAME = "File"; private static FileLogFormat instance = null; @@ -16,7 +15,6 @@ public class FileLogFormat extends LogFormat { } private FileLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "Size", "FDValue", "FDApiType", "FileSize", @@ -24,7 +22,7 @@ public class FileLogFormat extends LogFormat { dbColumnNames = CommonColumns.getDBColumnNames(); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, T, I, T, T }; + Integer[] dct = { L, L, I, L, T }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/HeaderColumns.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/HeaderColumns.java index 6760f2e..43f2068 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/HeaderColumns.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/HeaderColumns.java @@ -2,7 +2,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import static org.tizen.dynamicanalyzer.swap.model.probe.LogFormat.I; import static org.tizen.dynamicanalyzer.swap.model.probe.LogFormat.L; -import static org.tizen.dynamicanalyzer.swap.model.probe.LogFormat.T; import java.util.ArrayList; import java.util.Arrays; @@ -10,15 +9,15 @@ import java.util.List; public class HeaderColumns { private static String[] dcn = { "RID", "MessageId", "Seq", "Time" }; - private static Integer[] dct = { I, I, I, T }; - private static String[] tcn = { "Message ID", "Sequence", "Time" }; - private static Integer[] logTypes = { I, I, L }; - + private static Integer[] dct = { I, I, I, L }; + private static String[] tcn = { "Row Id", "Message ID", "Sequence", "Time" }; + private static Integer[] logTypes = { I, I, I, L }; + private static List dbColumnNames = null; private static List dbColumnTypes = null; private static List tableColumnNames = null; private static List types = null; - + public static List getDBColumnNames() { if (null == dbColumnNames) { dbColumnNames = new ArrayList(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LifeCycleLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LifeCycleLogFormat.java index 0411f41..3a6a76f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LifeCycleLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LifeCycleLogFormat.java @@ -1,7 +1,7 @@ package org.tizen.dynamicanalyzer.swap.model.probe; + public class LifeCycleLogFormat extends LogFormat { - public static final int ID = 0x3005; public static final String NAME = "LifeCycle"; private static LifeCycleLogFormat instance = null; @@ -14,7 +14,6 @@ public class LifeCycleLogFormat extends LogFormat { } private LifeCycleLogFormat() { - setId(ID); setName(NAME); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LogFormat.java index 4413ba1..76e8eae 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/LogFormat.java @@ -11,7 +11,7 @@ public class LogFormat { public static final int T = 5; // TEXT public static final int F = 6; // Float public static final int SI = 7; // Short int - + // for system logs public static final int CL = 8; // CPU load public static final int CF = 9; // CPU frequency @@ -33,10 +33,6 @@ public class LogFormat { return id; } - protected void setId(int id) { - this.id = id; - } - public String getName() { return name; } @@ -81,16 +77,22 @@ public class LogFormat { if (null == logFormats) { logFormats = new ArrayList(); - logFormats.add(MemoryLogFormat.getInstance()); + logFormats.add(ContextSwitchLogFormat.getInstance()); logFormats.add(ControlLogFormat.getInstance()); - logFormats.add(UIEventLogFormat.getInstance()); + logFormats.add(CustomChartLogFormat.getInstance()); logFormats.add(FileLogFormat.getInstance()); logFormats.add(LifeCycleLogFormat.getInstance()); - logFormats.add(ScreenShotLogFormat.getInstance()); + logFormats.add(MemoryLogFormat.getInstance()); + logFormats.add(ProfilingLogFormat.getInstance()); + logFormats.add(ReplayLogFormat.getInstance()); logFormats.add(SceneLogFormat.getInstance()); - logFormats.add(ThreadLogFormat.getInstance()); - logFormats.add(CustomChartLogFormat.getInstance()); + logFormats.add(ScreenShotLogFormat.getInstance()); logFormats.add(SyncLogFormat.getInstance()); + logFormats.add(SystemLogFormat.getInstance()); + logFormats.add(ThreadLogFormat.getInstance()); + logFormats.add(UIEventLogFormat.getInstance()); + logFormats.add(UserFunctionLogFormat.getInstance()); + } return logFormats; } @@ -105,4 +107,5 @@ public class LogFormat { } return null; } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/MemoryLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/MemoryLogFormat.java index f449d44..15c4f5f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/MemoryLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/MemoryLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class MemoryLogFormat extends LogFormat { - public static final int ID = 0x3001; public static final String NAME = "Memory"; private static MemoryLogFormat instance = null; @@ -16,7 +15,6 @@ public class MemoryLogFormat extends LogFormat { } private MemoryLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "Size", "MemoryAPIType", "Address" }; @@ -26,7 +24,7 @@ public class MemoryLogFormat extends LogFormat { } // dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, I, T }; + Integer[] dct = { L, I, L }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); @@ -35,9 +33,9 @@ public class MemoryLogFormat extends LogFormat { for (String str : tcn) { tableColumnNames.add(str); } -// tableColumnNames.addAll(Arrays.asList(tcn)); + // tableColumnNames.addAll(Arrays.asList(tcn)); - Integer[] types = { I, I, L }; + Integer[] types = { L, I, L }; logColumnTypes = CommonColumns.getLogColumnTypes(); logColumnTypes.addAll(Arrays.asList(types)); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ProfilingLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ProfilingLogFormat.java new file mode 100644 index 0000000..ef22f80 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ProfilingLogFormat.java @@ -0,0 +1,38 @@ +package org.tizen.dynamicanalyzer.swap.model.probe; + +import java.util.Arrays; + +public class ProfilingLogFormat extends LogFormat { + public static final String NAME = "Profiling"; + + private static ProfilingLogFormat instance = null; + + public static ProfilingLogFormat getInstance() { + if (null == instance) { + instance = new ProfilingLogFormat(); + } + return instance; + } + + private ProfilingLogFormat() { + setName(NAME); + + String[] dcn = { "PCAddr", "CallerPcAddr", "ProbeType", "ProbeSubType", + "Pid", "Tid", "CpuNum", "Args", "Ret", "ApiName", "CallStack" }; + dbColumnNames = HeaderColumns.getDBColumnNames(); + dbColumnNames.addAll(Arrays.asList(dcn)); + + Integer[] dct = { L, L, I, I, I, I, I, T, L, T, T }; + dbColumnTypes = HeaderColumns.getDBColumntypes(); + dbColumnTypes.addAll(Arrays.asList(dct)); + + String[] tcn = { "PCAddr", "CallerPcAddr", "ProbeType", "ProbeSubType", + "Pid", "Tid", "CpuNum", "Args", "Ret", "ApiName", "CallStack" }; + tableColumnNames = HeaderColumns.getTableColumnNames(); + tableColumnNames.addAll(Arrays.asList(tcn)); + + Integer[] types = { L, L, I, I, I, I, I, S, L, S, S }; + logColumnTypes = HeaderColumns.getLogColumnTypes(); + logColumnTypes.addAll(Arrays.asList(types)); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ReplayLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ReplayLogFormat.java new file mode 100644 index 0000000..75be91b --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ReplayLogFormat.java @@ -0,0 +1,38 @@ +package org.tizen.dynamicanalyzer.swap.model.probe; + +import java.util.ArrayList; +import java.util.Arrays; + +public class ReplayLogFormat extends LogFormat { + public static final String NAME = "Replay"; + + private static ReplayLogFormat instance = null; + + public static ReplayLogFormat getInstance() { + if (null == instance) { + instance = new ReplayLogFormat(); + } + return instance; + } + + private ReplayLogFormat() { + setName(NAME); + String[] dcn = { "Rid", "Sec", "Nano", "EventId", "EventType", + "EventCode", "EventValue" }; + dbColumnNames = new ArrayList(); + dbColumnNames.addAll(Arrays.asList(dcn)); + + Integer[] dct = { I, L, L, I, I, I, I }; + dbColumnTypes = new ArrayList(); + dbColumnTypes.addAll(Arrays.asList(dct)); + + String[] tcn = { "Sec", "Nano", "EventId", "EventType", "EventCode", + "EventValue" }; + tableColumnNames = new ArrayList(); + tableColumnNames.addAll(Arrays.asList(tcn)); + + Integer[] types = { I, L, L, I, I, I, I }; + logColumnTypes = new ArrayList(); + logColumnTypes.addAll(Arrays.asList(types)); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SceneLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SceneLogFormat.java index 1ed83c7..4fc4e12 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SceneLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SceneLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class SceneLogFormat extends LogFormat { - public static final int ID = 0x3007; public static final String NAME = "Scene"; private static SceneLogFormat instance = null; @@ -16,7 +15,6 @@ public class SceneLogFormat extends LogFormat { } private SceneLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "SceneName", "FormName", "FormPointer", "PanelName", @@ -24,7 +22,7 @@ public class SceneLogFormat extends LogFormat { dbColumnNames = CommonColumns.getDBColumnNames(); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, T, T, T, T, I, I }; + Integer[] dct = { T, T, L, T, L, I, I }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ScreenShotLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ScreenShotLogFormat.java index f40f8f9..318efae 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ScreenShotLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ScreenShotLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class ScreenShotLogFormat extends LogFormat { - public static final int ID = 0x3006; public static final String NAME = "ScreenShot"; private static ScreenShotLogFormat instance = null; @@ -16,7 +15,6 @@ public class ScreenShotLogFormat extends LogFormat { } private ScreenShotLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "ImageFilePath", "Orientation" }; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SyncLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SyncLogFormat.java index ecc9115..394106f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SyncLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SyncLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class SyncLogFormat extends LogFormat { - public static final int ID = 0x3010; public static final String NAME = "Sync"; private static SyncLogFormat instance = null; @@ -16,14 +15,13 @@ public class SyncLogFormat extends LogFormat { } private SyncLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "SyncValue", "SyncType", "ApiType" }; dbColumnNames = CommonColumns.getDBColumnNames(); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, I, I }; + Integer[] dct = { L, I, I }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SystemLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SystemLogFormat.java index 96dba4e..af0d8fd 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SystemLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/SystemLogFormat.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.List; public class SystemLogFormat extends LogFormat { - public static final int ID = 0x2007; public static final String NAME = "System"; private static SystemLogFormat instance = null; @@ -18,54 +17,56 @@ public class SystemLogFormat extends LogFormat { } private SystemLogFormat() { - setId(ID); setName(NAME); - String[] dcn = { "RID", "Energy", "WiFi status", "BT status", - "GPS status", "Brightness status", "Camera status", - "Sound status", "Audio status", "Vibration status", - "Voltage status", "RSSI status", "Video status", "Call status", - "DNet status", "CPU frequency", "App CPU usage", "CPU load", - "Virtual memory", "Resident memory", "Shared memory", - "PSS memory", "Total alloc size", "System memory total", - "System memory used", "Total used drive", "Count of threads", - "Thread load", "count of processes", "Process load", - "DISK read size", "DISK write size", "Network send size", - "Network receive size" }; + String[] dcn = { "AppCpuUsage", "CpuFrequency", "CpuLoad","ThreadCount", "ThreadLoad", + "ProcessCount", "ProcessLoad","VirtualMemory", "ResidentMemory", "SharedMemory", + "PssMemory","TotalAllocSize", "SystemMemoryTotal", "SystemMemoryUsed","TotalUsedDrive", + "DiskReads", "DiskSectorsRead", "DiskWrites","DiskSectorsWritten", "NetworkSendSize", + "NetworkReceiveSize","WiFi", "BlueTooth", "GPS", "Brightness", + "Camera", "Sound","Audio", "Vibration", "Voltage", + "Rssi", "Video", "Call","Dnet", "Energy", + "CallAlpha", "RssiAlpha"}; dbColumnNames = new ArrayList(); + dbColumnNames.addAll(HeaderColumns.getDBColumnNames()); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { I, I, I, I, I, I, // 1 + 5 : 1 is RID - I, I, I, I, I,// 10 - I, I, I, I, CF, // 15 - F, CL, I, I, I, // 20 - I, I, I, I, I, // 25 - I, TL, I, PL, I, // 30 - I, I, I }; // 33 + Integer[] dct = { T, T, T,I, T, + I, T, + I, I, I, I,I, L, L, + I, I,I, I, I, + I, I, + I, I, I, I, I, + I, I, I, I, I, + I, I, I, + I, I, I}; dbColumnTypes = new ArrayList(); + dbColumnTypes.addAll(HeaderColumns.getDBColumntypes()); dbColumnTypes.addAll(Arrays.asList(dct)); - String[] tcn = { "Energy", "WiFi status", "BT status", "GPS status", - "Brightness status", "Camera status", "Sound status", - "Audio status", "Vibration status", "Voltage status", - "RSSI status", "Video status", "Call status", "DNet status", - "CPU frequency", "App CPU usage", "CPU load", "Virtual memory", - "Resident memory", "Shared memory", "PSS memory", - "Total alloc size", "System memory total", - "System memory used", "Total used drive", "Count of threads", - "Thread load", "count of processes", "Process load", - "DISK read size", "DISK write size", "Network send size", - "Network receive size" }; + String[] tcn = { "App Cpu Usage", "Cpu Frequency", "Cpu Load", + "Thread Count", "Thread Load", "Process Count", "Process Load", + "Virtual Memory", "Resident Memory", "Shared Memory", "Pss Memory", + "Total Alloc Size", "System Memory Total", "System Memory Used", + "Total Used Drive", "Disk Reads", "Disk Sectors Read", "Disk Writes", + "Disk Sectors Written", "Network Send Size,", "Network Receive Size", + "WiFi", "BlueTooth", "GPS", "Brightness", "Camera", "Sound", + "Audio", "Vibration", "Voltage", "Rssi", "Video", "Call", + "Dnet", "Energy", "CallAlpha", "RssiAlpha" }; tableColumnNames = new ArrayList(); + tableColumnNames.addAll(HeaderColumns.getTableColumnNames()); tableColumnNames.addAll(Arrays.asList(tcn)); - Integer[] types = { I, I, I, I, I, // 5 - I, I, I, I, I,// 10 - I, I, I, I, CF, // 15 - F, CL, I, I, I, // 20 - I, I, I, I, I, // 25 - I, TL, I, PL, I, // 30 - I, I, I }; // 33 + Integer[] types = {F, S, S,I, S, + I, S, + I, I, I, I,I, L, L, + I, I,I, I, I, + I, I, + I, I, I, I, I, + I, I, I, I, I, + I, I, I, + I, I, I}; logColumnTypes = new ArrayList(); + logColumnTypes.addAll(HeaderColumns.getLogColumnTypes()); logColumnTypes.addAll(Arrays.asList(types)); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ThreadLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ThreadLogFormat.java index c6283f4..2bb02bc 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ThreadLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/ThreadLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class ThreadLogFormat extends LogFormat { - public static final int ID = 0x3008; public static final String NAME = "Thread"; private static ThreadLogFormat instance = null; @@ -16,14 +15,13 @@ public class ThreadLogFormat extends LogFormat { } private ThreadLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "PThreadID", "OspThreadID", "ThreadType", "ApiType" }; dbColumnNames = CommonColumns.getDBColumnNames(); dbColumnNames.addAll(Arrays.asList(dcn)); - Integer[] dct = { T, T, I, I }; + Integer[] dct = { L, L, I, I }; dbColumnTypes = CommonColumns.getDBColumntypes(); dbColumnTypes.addAll(Arrays.asList(dct)); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UIEventLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UIEventLogFormat.java index dc210b4..fff8c49 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UIEventLogFormat.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UIEventLogFormat.java @@ -3,7 +3,6 @@ package org.tizen.dynamicanalyzer.swap.model.probe; import java.util.Arrays; public class UIEventLogFormat extends LogFormat { - public static final int ID = 0x3003; public static final String NAME = "UIEvent"; private static UIEventLogFormat instance = null; @@ -16,7 +15,6 @@ public class UIEventLogFormat extends LogFormat { } private UIEventLogFormat() { - setId(ID); setName(NAME); String[] dcn = { "EventType", "DetailType", "X", "Y", "Info1", "Info2" }; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UserFunctionLogFormat.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UserFunctionLogFormat.java new file mode 100644 index 0000000..bced715 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe/UserFunctionLogFormat.java @@ -0,0 +1,36 @@ +package org.tizen.dynamicanalyzer.swap.model.probe; + +import java.util.Arrays; + +public class UserFunctionLogFormat extends LogFormat { + public static final String NAME = "UserFunction"; + + private static UserFunctionLogFormat instance = null; + + public static UserFunctionLogFormat getInstance() { + if (null == instance) { + instance = new UserFunctionLogFormat(); + } + return instance; + } + + private UserFunctionLogFormat() { + setName(NAME); + + String[] dcn = { "LowPC", "HighPC", "Type", "ElapsedTime", "PCAddr" }; + dbColumnNames = CommonColumns.getDBColumnNames(); + dbColumnNames.addAll(Arrays.asList(dcn)); + + Integer[] dct = { L, L, I, L, L }; + dbColumnTypes = CommonColumns.getDBColumntypes(); + dbColumnTypes.addAll(Arrays.asList(dct)); + + String[] tcn = { "LogPC", "HighPC", "Type", "ElapsedTime", "PCAddr" }; + tableColumnNames = CommonColumns.getTableColumnNames(); + tableColumnNames.addAll(Arrays.asList(tcn)); + + Integer[] types = { L, L, I, L, L }; + logColumnTypes = CommonColumns.getLogColumnTypes(); + logColumnTypes.addAll(Arrays.asList(types)); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ContextSwitchData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ContextSwitchData.java index 0338452..c3d6485 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ContextSwitchData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ContextSwitchData.java @@ -1,6 +1,14 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.logparser.MessageParser; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class ContextSwitchData extends LogData { @@ -9,9 +17,20 @@ public class ContextSwitchData extends LogData { int tid = 0; int cpuNum = 0; - public ContextSwitchData(BasicDataMessage data) { - super(data); - // TODO Auto-generated constructor stub + public ContextSwitchData() { + } + + public void makeData(byte[] data) { + super.makeData(data); + index = MessageParser.MSG_HEADER_SIZE; + + pcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + cpuNum = ByteUtils.toInt(data, index); } public long getPcAddr() { @@ -45,4 +64,25 @@ public class ContextSwitchData extends LogData { public void setCpuNum(int cpuNum) { this.cpuNum = cpuNum; } + + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = LogData.STATE_COUNT + 1; + prep.setLong(index++, pcAddr); + prep.setInt(index++, pid); + prep.setInt(index++, tid); + prep.setInt(index++, cpuNum); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = LogData.STATE_COUNT + 1; + pcAddr = rs.getLong(index++); + pid = rs.getInt(index++); + tid = rs.getInt(index++); + cpuNum = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ControlData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ControlData.java index 1e9fdd2..fcc04f6 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ControlData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ControlData.java @@ -1,6 +1,12 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class ControlData extends ProbeCommonData { private String parentName = null; @@ -10,8 +16,40 @@ public class ControlData extends ProbeCommonData { private String childClassName = null; private long childPointer = 0; - public ControlData(BasicDataMessage data) { - super(data); + public ControlData() { + } + + public void makeData(byte[] data) { + super.makeData(data); + + int length = LogDataUtils.getStringLength(index, data); + byte[] temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + parentName = new String(temp); + index += length; + + length = LogDataUtils.getStringLength(index, data); + temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + parentClassName = new String(temp); + index += length; + + parentPointer = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + length = LogDataUtils.getStringLength(index, data); + temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + childName = new String(temp); + index += length; + + length = LogDataUtils.getStringLength(index, data); + temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + childClassName = new String(temp); + index += length; + + childPointer = ByteUtils.toLong(data, index); } public String getParentName() { @@ -62,4 +100,29 @@ public class ControlData extends ProbeCommonData { this.childPointer = childPointer; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setString(index++, parentName); + prep.setString(index++, parentClassName); + prep.setLong(index++, parentPointer); + prep.setString(index++, childName); + prep.setString(index++, childClassName); + prep.setLong(index++, childPointer); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + parentName = rs.getString(index++); + parentClassName = rs.getString(index++); + parentPointer = rs.getLong(index++); + childName = rs.getString(index++); + childClassName = rs.getString(index++); + childPointer = rs.getLong(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/CustomData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/CustomData.java index 92414f3..dda3345 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/CustomData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/CustomData.java @@ -1,6 +1,12 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class CustomData extends ProbeCommonData { @@ -10,8 +16,27 @@ public class CustomData extends ProbeCommonData { int color = 0; double value = 0; - public CustomData(BasicDataMessage data) { - super(data); + public CustomData(){} + + public void makeData(byte[] data) { + super.makeData(data); + + handle = ByteUtils.toInt(data, index); + index += INT_SIZE; + + type = ByteUtils.toInt(data, index); + index += INT_SIZE; + + int length = LogDataUtils.getStringLength(index, data); + byte[] temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + name = new String(temp); + index += length; + + color = ByteUtils.toInt(data, index); + index += INT_SIZE; + + value = ByteUtils.toDouble(data, index); } public int getHandle() { @@ -54,4 +79,27 @@ public class CustomData extends ProbeCommonData { this.value = value; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setInt(index++, handle); + prep.setInt(index++, type); + prep.setString(index++, name); + prep.setInt(index++, color); + prep.setDouble(index++, value); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + handle = rs.getInt(index++); + type = rs.getInt(index++); + name = rs.getString(index++); + color = rs.getInt(index++); + value = rs.getDouble(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/DataFactory.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/DataFactory.java index ce17eb5..9a5c000 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/DataFactory.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/DataFactory.java @@ -23,17 +23,18 @@ import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; import org.tizen.dynamicanalyzer.common.CommonConstants; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.swap.logparser.MessageParser; import org.tizen.dynamicanalyzer.swap.model.ByteUtils; import org.tizen.dynamicanalyzer.swap.model.DATime; import org.tizen.dynamicanalyzer.swap.model.RecordEventObject; import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager; public class DataFactory { - private static int index = 0; + private static int index = MessageParser.MSG_HEADER_SIZE; public static void createData(LogData data, byte[] paylaod) { int id = data.getId(); - index = 0; + index = MessageParser.MSG_HEADER_SIZE; switch (id) { case MSG_PROBE_MEMORY: @@ -496,7 +497,7 @@ public class DataFactory { data.setProcessLoad(processLoad); data.setDiskReadSize(diskReadSize); data.setDiskWriteSize(diskWriteSize); - data.setDisSectorsWritten(diskSectorsWritten); + data.setDiskSectorsWritten(diskSectorsWritten); data.setNetworkSendSize(networkSendSize); data.setNetworkReceiveSize(networkReceiveSize); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/FileData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/FileData.java index 1a52220..cbec732 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/FileData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/FileData.java @@ -1,6 +1,13 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class FileData extends ProbeCommonData { @@ -50,8 +57,25 @@ public class FileData extends ProbeCommonData { this.filePath = filePath; } - public FileData(BasicDataMessage data) { - super(data); + public FileData() { + } + + public void makeData(byte[] data) { + super.makeData(data); + + size = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + fdValue = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + fdApiType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + fileSize = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + filePath = LogDataUtils.getString(index, data); } @Override @@ -59,4 +83,28 @@ public class FileData extends ProbeCommonData { Long key = getFdValue(); return key.hashCode(); } + + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setLong(index++, size); + prep.setLong(index++, fdValue); + prep.setInt(index++, fdApiType); + prep.setLong(index++, fileSize); + prep.setString(index++, filePath); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + size = rs.getLong(index++); + fdValue = rs.getLong(index++); + fdApiType = rs.getInt(index++); + fileSize = rs.getLong(index++); + filePath = rs.getString(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LifeCycleData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LifeCycleData.java index d469817..cb03938 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LifeCycleData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LifeCycleData.java @@ -1,10 +1,7 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; - public class LifeCycleData extends ProbeCommonData { - public LifeCycleData(BasicDataMessage data) { - super(data); + public LifeCycleData() { } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogData.java index 28b6e9e..05f69d5 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogData.java @@ -1,128 +1,59 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.communicator.DACommunicator; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; +import org.tizen.dynamicanalyzer.swap.model.DATime; public class LogData { public static boolean isSWAP = false; + public static int STATE_COUNT = 4; + + protected int index = 0; int id = -1; int seq = -1; long time = 0; - public LogData(BasicDataMessage data) { - isSWAP = DACommunicator.isSWAPVersion(); - id = data.getId(); - seq = data.getSeq(); - time = data.getTime(); + public LogData() { } - // public int getId() { - // return basicData.getId(); - // } - // - // public int getSeq() { - // return basicData.getSeq(); - // } - // - // public long getTime() { - // return basicData.getTime(); - // } - // - // public void setTime(long time) { - // basicData.setTime(time); - // } - // - // public byte[] getPayload() { - // return payload; - // } - // - // protected int getStringLength(int start) { - // int length = 0; - // for (int i = start; i < payload.length; i++, length++) { - // if (payload[i] == 0) { - // return length + 1; - // } - // } - // return payload.length; - // } - - // protected String makeArgs(int start) { - // int countOfArgs = ByteUtils.toInt(payload, start); - // start += CommonConstants.INT_SIZE; - // StringBuffer buffer = new StringBuffer(); - // for (int ii = 0; ii < countOfArgs; ii++) { - // char c = (char) payload[start]; - // start += 1; - // switch (c) { - // case 'c': - // buffer.append((payload[start])); - // start += 1; - // break; - // case 'd': - // int iValue = ByteUtils.toInt(payload, start); - // buffer.append(iValue); - // start += Integer.SIZE / Byte.SIZE; - // break; - // case 'x': - // long lValue = ByteUtils.toLong(payload, start); - // buffer.append(lValue); - // start += Long.SIZE / Byte.SIZE; - // break; - // case 'p': - // long pValue = ByteUtils.toLong(payload, start); - // buffer.append(Long.toHexString(pValue)); - // start += Long.SIZE / Byte.SIZE; - // break; - // case 'f': - // float fValue = ByteUtils.toFloat(payload, start); - // buffer.append(fValue); - // start += Float.SIZE / Byte.SIZE; - // break; - // case 'w': - // double dValue = ByteUtils.toDouble(payload, start); - // buffer.append(dValue); - // start += Double.SIZE / Byte.SIZE; - // break; - // case 's': - // for (int iii = start; iii < payload.length; iii++) { - // if (payload[iii] != 0) { - // buffer.append((char) payload[iii]); - // } else { - // start = iii + 1; - // } - // } - // break; - // default: - // break; - // } - // if (ii + 1 != countOfArgs) { - // buffer.append(','); - // } - // } - // return buffer.toString(); - // } + public void makeData(byte[] data) { + isSWAP = DACommunicator.isSWAPVersion(); + + id = ByteUtils.toInt(data, index); + index += INT_SIZE; + + seq = ByteUtils.toInt(data, index); + index += INT_SIZE; + + long sec = ByteUtils.toInt(data, index); + index += INT_SIZE; + long nano = ByteUtils.toInt(data, index); + index += INT_SIZE; + + DATime startTime = AnalyzerManager.getProject().getStartTime(); + long startSec = startTime.getSec(); + long startNano = startTime.getNano(); + long resultSec = sec - startSec; + long resultNano = nano - startNano; + + time = resultSec * 1000000 + resultNano / 1000; + + index += INT_SIZE; // payload length field offset + } public int getKey() { Integer key = getSeq(); return key.hashCode(); } - // protected static String getQuestionMarks(int count) { - // // row number - // // id - // // seq - // // time - // StringBuffer buf = new StringBuffer(); - // for (int i = 0; i < count; i++) { - // buf.append("? "); - // if (i + 1 != count) { - // buf.append(CommonConstants.COMMA); - // } - // } - // return buf.toString(); - // } - // indicate DB row number public int getLogNum() { return 0; @@ -151,4 +82,19 @@ public class LogData { public void setTime(long time) { this.time = time; } + + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + int logNum = LogDataFactory.getLogCountById(id); + prep.setInt(1, logNum); + prep.setInt(2, id); + prep.setInt(3, seq); + prep.setLong(4, time); + } + + public void loadData(ResultSet rs) throws SQLException { + id = rs.getInt(2); + seq = rs.getInt(3); + time = rs.getLong(4); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogDataFactory.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogDataFactory.java index dbf7d0d..ec38343 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogDataFactory.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogDataFactory.java @@ -1,11 +1,46 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_CONTEXT_SWITCH_ENTRY; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_CONTEXT_SWITCH_EXIT; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_DATA_RECORD; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_DATA_SAMPLE; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_DATA_SYSTEM; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_FUNCTION_ENTRY; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_FUNCTION_EXIT; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_CUSTOM; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_FILE; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_LIFECYCLE; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_MEMORY; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_SCENE; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_SCREENSHOT; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_SYNC; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_THREAD; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_UICONTROL; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_PROBE_UIEVENT; + +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.*; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; +import org.tizen.dynamicanalyzer.swap.model.probe.ContextSwitchLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.ControlLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.CustomChartLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.FileLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.LifeCycleLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.LogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.MemoryLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.ProfilingLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.ReplayLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.SceneLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.ScreenShotLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.SyncLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.SystemLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.ThreadLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.UIEventLogFormat; +import org.tizen.dynamicanalyzer.swap.model.probe.UserFunctionLogFormat; public class LogDataFactory { private static List logList = new ArrayList(); @@ -51,137 +86,220 @@ public class LogDataFactory { logList.add(MSG_DATA_SAMPLE); logList.add(MSG_DATA_SYSTEM); logList.add(LogCenterConstants.LOG_USER_FUNCTION); - logList.add(MSG_RECORD); + logList.add(MSG_DATA_RECORD); + logList.add(MSG_FUNCTION_ENTRY); + logList.add(MSG_FUNCTION_EXIT); + logList.add(MSG_DATA_RECORD); + logList.add(MSG_CONTEXT_SWITCH_ENTRY); + logList.add(MSG_CONTEXT_SWITCH_EXIT); } - public static LogData createInstance(BasicDataMessage input) { - int id = input.getId(); - byte[] payload = input.getPayload(); + public static LogData createInstance(byte[] data) { + int id = ByteUtils.toInt(data, 0); LogData output = null; switch (id) { case MSG_PROBE_MEMORY: // memory - output = new MemoryData(input); + output = new MemoryData(); break; case MSG_PROBE_UICONTROL: // ui control - output = new ControlData(input); + output = new ControlData(); break; case MSG_PROBE_UIEVENT: - output = new UIEventData(input); + output = new UIEventData(); break; case MSG_PROBE_FILE: // file - output = new FileData(input); + output = new FileData(); break; case MSG_PROBE_LIFECYCLE: // life cycle - output = new LifeCycleData(input); + output = new LifeCycleData(); break; case MSG_PROBE_SCREENSHOT: // screenshot - output = new ScreenShotData(input); + output = new ScreenShotData(); break; case MSG_PROBE_SCENE: // scene - output = new SceneData(input); + output = new SceneData(); break; case MSG_PROBE_THREAD: // thread - output = new ThreadData(input); + output = new ThreadData(); break; case MSG_PROBE_CUSTOM: // custom - output = new CustomData(input); + output = new CustomData(); break; case MSG_PROBE_SYNC: // sync - output = new SyncData(input); + output = new SyncData(); break; case LogCenterConstants.LOG_USER_FUNCTION: // user fucntion entry/exit - output = new UserFunctionData(input); + output = new UserFunctionData(); break; case MSG_DATA_SAMPLE: case MSG_FUNCTION_ENTRY: case MSG_FUNCTION_EXIT: // profiling sample log - output = new ProfileData(input); - ((ProfileData) output).setCallstack(input.getCallstack()); + output = new ProfileData(); + // ((ProfileData) output).setCallstack(data.getCallstack()); break; case MSG_DATA_SYSTEM: // system log - output = new SystemData(input); + output = new SystemData(); break; - case MSG_RECORD: + case MSG_DATA_RECORD: // replay log - output = new ReplayData(input); + output = new ReplayData(); break; case MSG_CONTEXT_SWITCH_ENTRY: case MSG_CONTEXT_SWITCH_EXIT: - output = new ContextSwitchData(input); + output = new ContextSwitchData(); break; default: return null; } - DataFactory.createData(output, payload); + output.makeData(data); return output; } - public static String getTableNamebyId(int id) { - String name = null; + + public static LogData createInstance(ResultSet rs) throws SQLException{ + int id = rs.getInt(2); + LogData output = null; + switch (id) { + case MSG_PROBE_MEMORY: + // memory + output = new MemoryData(); + break; + case MSG_PROBE_UICONTROL: + // ui control + output = new ControlData(); + break; + case MSG_PROBE_UIEVENT: + output = new UIEventData(); + break; + case MSG_PROBE_FILE: + // file + output = new FileData(); + break; + case MSG_PROBE_LIFECYCLE: + // life cycle + output = new LifeCycleData(); + break; + case MSG_PROBE_SCREENSHOT: + // screenshot + output = new ScreenShotData(); + break; + case MSG_PROBE_SCENE: + // scene + output = new SceneData(); + break; + case MSG_PROBE_THREAD: + // thread + output = new ThreadData(); + break; + case MSG_PROBE_CUSTOM: + // custom + output = new CustomData(); + break; + case MSG_PROBE_SYNC: + // sync + output = new SyncData(); + break; + case LogCenterConstants.LOG_USER_FUNCTION: + // user fucntion entry/exit + output = new UserFunctionData(); + break; + case MSG_DATA_SAMPLE: + case MSG_FUNCTION_ENTRY: + case MSG_FUNCTION_EXIT: + // profiling sample log + output = new ProfileData(); + // ((ProfileData) output).setCallstack(data.getCallstack()); + break; + case MSG_DATA_SYSTEM: + // system log + output = new SystemData(); + break; + case MSG_DATA_RECORD: + // replay log + output = new ReplayData(); + break; + case MSG_CONTEXT_SWITCH_ENTRY: + case MSG_CONTEXT_SWITCH_EXIT: + output = new ContextSwitchData(); + break; + default: + return null; + } + output.loadData(rs); + return output; + } + + public static LogFormat getLogFormatById(int id) { + LogFormat format = null; switch (id) { case MSG_PROBE_MEMORY: - name = "memory"; + format = MemoryLogFormat.getInstance(); break; case MSG_PROBE_UICONTROL: - name = "control"; + format = ControlLogFormat.getInstance(); break; case MSG_PROBE_UIEVENT: - name = "uievent"; + format = UIEventLogFormat.getInstance(); break; case MSG_PROBE_FILE: - name = "file"; + format = FileLogFormat.getInstance(); break; case MSG_PROBE_LIFECYCLE: - name = "lifecycle"; + format = LifeCycleLogFormat.getInstance(); break; case MSG_PROBE_SCREENSHOT: - name = "screenshot"; + format = ScreenShotLogFormat.getInstance(); break; case MSG_PROBE_SCENE: - name = "scene"; + format = SceneLogFormat.getInstance(); break; case MSG_PROBE_THREAD: - name = "thread"; + format = ThreadLogFormat.getInstance(); break; case MSG_PROBE_CUSTOM: - name = "custom"; + format = CustomChartLogFormat.getInstance(); break; case MSG_PROBE_SYNC: - name = "sync"; + format = SyncLogFormat.getInstance(); break; case LogCenterConstants.LOG_USER_FUNCTION: // user fucntion entry/exit - name = "user_function"; + format = UserFunctionLogFormat.getInstance(); break; case MSG_DATA_SAMPLE: + case MSG_FUNCTION_ENTRY: + case MSG_FUNCTION_EXIT: // profiling sample log // function enter/exit - // context enstr/exit - name = "profiling"; + format = ProfilingLogFormat.getInstance(); + break; + case MSG_CONTEXT_SWITCH_ENTRY: + case MSG_CONTEXT_SWITCH_EXIT: + format = ContextSwitchLogFormat.getInstance(); break; case MSG_DATA_SYSTEM: // system log - name = "system"; + format = SystemLogFormat.getInstance(); break; - case MSG_RECORD: - name = "replay"; + case MSG_DATA_RECORD: + format = ReplayLogFormat.getInstance(); break; default: break; } - return name; + return format; } public static int getLogColumnCountbyId(int id) { @@ -286,7 +404,7 @@ public class LogDataFactory { return sampleLogNum++; case MSG_DATA_SYSTEM: return systemLogNum++; - case MSG_RECORD: + case MSG_DATA_RECORD: return recordLogNum++; default: break; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/MemoryData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/MemoryData.java index b9f185b..4798623 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/MemoryData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/MemoryData.java @@ -1,51 +1,80 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class MemoryData extends ProbeCommonData { long size = 0; int apiType = 0; // TODO: short - long address = 0; - + long address = 0; - public MemoryData(BasicDataMessage data) { - super(data); + public MemoryData() { } + public void makeData(byte[] data) { + super.makeData(data); + size = ByteUtils.toInt(data, index); + + index += LONG_SIZE; + apiType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + address = ByteUtils.toLong(data, index); + } public long getSize() { return size; } - public void setSize(long size) { this.size = size; } - public int getMemoryApiType() { return apiType; } - public void setApitype(int apiType) { this.apiType = apiType; } - public long getAddress() { return address; } - public void setAddress(long address) { this.address = address; } - @Override public int getKey() { Long key = getAddress(); return key.hashCode(); } + + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setLong(index++, size); + prep.setInt(index++, apiType); + prep.setLong(index++, address); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + size = rs.getLong(index++); + apiType = rs.getInt(index++); + address = rs.getLong(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProbeCommonData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProbeCommonData.java index 9f98883..2856ba5 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProbeCommonData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProbeCommonData.java @@ -1,10 +1,20 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.logparser.MessageParser; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; public class ProbeCommonData extends LogData { + public static int STATE_COUNT = LogData.STATE_COUNT + 10; + protected int apiId = 0; protected int pid = 0; protected int tid = 0; @@ -18,8 +28,44 @@ public class ProbeCommonData extends LogData { private String apiName = null; - public ProbeCommonData(BasicDataMessage data) { - super(data); + public ProbeCommonData() { + } + + @Override + public void makeData(byte[] data) { + super.makeData(data); + index = MessageParser.MSG_HEADER_SIZE; + + apiId = ByteUtils.toInt(data, index); + index += INT_SIZE; + + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + + ArgsInfo argInfo = LogDataUtils.parseArgs(data, index); + args = argInfo.getArgs(); + index = argInfo.getLastIndex(); + + ret = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + errno = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + internalCall = ByteUtils.toInt(data, index); + index += INT_SIZE; + + callerAddress = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + reserved1 = ByteUtils.toInt(data, index); + index += INT_SIZE; + + reserved2 = ByteUtils.toInt(data, index); + index += INT_SIZE; } public int getApiId() { @@ -113,4 +159,38 @@ public class ProbeCommonData extends LogData { this.apiName = apiName; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = LogData.STATE_COUNT + 1; + + prep.setInt(index++, apiId); + prep.setInt(index++, pid); + prep.setInt(index++, tid); + prep.setString(index++, args); + prep.setLong(index++, ret); + prep.setLong(index++, errno); + prep.setInt(index++, internalCall); + prep.setLong(index++, callerAddress); + prep.setInt(index++, reserved1); + prep.setInt(index++, reserved2); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = LogData.STATE_COUNT + 1; + + apiId = rs.getInt(index++); + pid = rs.getInt(index++); + tid = rs.getInt(index++); + args = rs.getString(index++); + ret = rs.getLong(index++); + errno = rs.getLong(index++); + internalCall = rs.getInt(index++); + callerAddress = rs.getLong(index++); + reserved1 = rs.getInt(index++); + reserved2 = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProfileData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProfileData.java index 42ef620..8a02b71 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProfileData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ProfileData.java @@ -1,6 +1,18 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_CONTEXT_SWITCH_ENTRY; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_CONTEXT_SWITCH_EXIT; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_DATA_SAMPLE; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_FUNCTION_ENTRY; +import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_FUNCTION_EXIT; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class ProfileData extends LogData { @@ -17,8 +29,69 @@ public class ProfileData extends LogData { String callstack = null; - public ProfileData(BasicDataMessage data) { - super(data); + public ProfileData(){} + + public void makeData(byte[] data) { + super.makeData(data); + switch (id) { + case MSG_FUNCTION_ENTRY: + pcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + callerPcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + byte[] temp = new byte[4]; + System.arraycopy(data, index, temp, 0, 2); + probeType = ByteUtils.toInt(temp, 0); + index += 2; + + System.arraycopy(data, index, temp, 0, 2); + probeSubType = ByteUtils.toInt(temp, 0); + index += 2; + + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + cpuNum = ByteUtils.toInt(data, index); + index += INT_SIZE; + ArgsInfo info = LogDataUtils.parseArgs(data, index); + args = info.getArgs(); + break; + case MSG_FUNCTION_EXIT: + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + pcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + cpuNum = ByteUtils.toInt(data, index); + index += INT_SIZE; + ret = ByteUtils.toLong(data, index); + break; + case MSG_CONTEXT_SWITCH_ENTRY: + case MSG_CONTEXT_SWITCH_EXIT: + pcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + cpuNum = ByteUtils.toInt(data, index); + break; + case MSG_DATA_SAMPLE: + pid = ByteUtils.toInt(data, index); + index += INT_SIZE; + pcAddr = ByteUtils.toLong(data, index); + index += LONG_SIZE; + tid = ByteUtils.toInt(data, index); + index += INT_SIZE; + cpuNum = ByteUtils.toInt(data, index); + break; + + default: + break; + } } public long getPcAddr() { @@ -108,6 +181,40 @@ public class ProfileData extends LogData { public void setApiName(String apiName) { this.apiName = apiName; } - - + + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = LogData.STATE_COUNT + 1; + + prep.setLong(index++, pcAddr); + prep.setLong(index++, callerPcAddr); + prep.setInt(index++, probeType); + prep.setInt(index++, probeSubType); + prep.setInt(index++, pid); + prep.setInt(index++, tid); + prep.setInt(index++, cpuNum); + prep.setLong(index++, ret); + prep.setString(index++, args); + prep.setString(index++, apiName); + prep.setString(index++, callstack); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = LogData.STATE_COUNT + 1; + pcAddr = rs.getLong(index++); + callerPcAddr = rs.getLong(index++); + probeType = rs.getInt(index++); + probeSubType = rs.getInt(index++); + pid = rs.getInt(index++); + tid = rs.getInt(index++); + cpuNum = rs.getInt(index++); + ret = rs.getLong(index++); + args = rs.getString(index++); + apiName = rs.getString(index++); + callstack = rs.getString(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ReplayData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ReplayData.java index f097c2a..1e1b0c8 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ReplayData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ReplayData.java @@ -1,18 +1,81 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; + import java.util.ArrayList; import java.util.List; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.communicator.DACommunicator; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; +import org.tizen.dynamicanalyzer.swap.model.DATime; import org.tizen.dynamicanalyzer.swap.model.RecordEventObject; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; public class ReplayData extends LogData { private int objectCount = 0; private List recordEvent = new ArrayList(); - public ReplayData(BasicDataMessage data) { - super(data); + public ReplayData() { + } + + public void makeData(byte[] data) { + // super.makeData(data); + isSWAP = DACommunicator.isSWAPVersion(); + + id = ByteUtils.toInt(data, index); + index += INT_SIZE; + + seq = ByteUtils.toInt(data, index); + index += INT_SIZE; + + long sec = ByteUtils.toInt(data, index); + index += INT_SIZE; + long nano = ByteUtils.toInt(data, index); + index += INT_SIZE; + DATime eventTime = new DATime(); + eventTime.setSec(sec); + eventTime.setNano(nano); + + DATime startTime = AnalyzerManager.getProject().getStartTime(); + long startSec = startTime.getSec(); + long startNano = startTime.getNano(); + long resultSec = sec - startSec; + long resultNano = nano - startNano; + + time = resultSec * 1000000 + resultNano / 1000; + + index += INT_SIZE; // payload length field offset + + int count = ByteUtils.toInt(data, index); + index += INT_SIZE; + setObjectCount(count); + + for (int i = 0; i < count; i++) { + RecordEventObject recordObj = new RecordEventObject(); + // event time + recordObj.setEventTime(eventTime); + + // event id + int value = ByteUtils.toInt(data, index); + recordObj.setEventId(value); + index += INT_SIZE; + + // event type + value = ByteUtils.toInt(data, index); + recordObj.setEventType(value); + index += INT_SIZE; + + // eventy code + value = ByteUtils.toInt(data, index); + recordObj.setEventCode(value); + index += INT_SIZE; + + value = ByteUtils.toInt(data, index); + recordObj.setEventValue(value); + + getRecordEvent().add(recordObj); + } } public int getObjectCount() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SceneData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SceneData.java index a17f2b6..0846af8 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SceneData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SceneData.java @@ -1,6 +1,13 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class SceneData extends ProbeCommonData { String sceneName = null; @@ -11,8 +18,39 @@ public class SceneData extends ProbeCommonData { int transitionTime = 0; int userTransitionTime = 0; - public SceneData(BasicDataMessage data) { - super(data); + public SceneData(){} + + public void makeData(byte[] data) { + super.makeData(data); + + int length = LogDataUtils.getStringLength(index, data); + byte[] temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + sceneName = new String(temp); + index += length; + + length = LogDataUtils.getStringLength(index, data); + temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + formName = new String(temp); + index += length; + + formPointer = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + length = LogDataUtils.getStringLength(index, data); + temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + panelName = new String(temp); + index += length; + + panelPointer = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + transitionTime = ByteUtils.toInt(data, index); + index += INT_SIZE; + + userTransitionTime = ByteUtils.toInt(data, index); } public String getSceneName() { @@ -71,4 +109,31 @@ public class SceneData extends ProbeCommonData { this.userTransitionTime = userTransitionTime; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setString(index++, sceneName); + prep.setString(index++, formName); + prep.setLong(index++, formPointer); + prep.setString(index++, panelName); + prep.setLong(index++, panelPointer); + prep.setInt(index++, transitionTime); + prep.setInt(index++, userTransitionTime); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + sceneName = rs.getString(index++); + formName = rs.getString(index++); + formPointer = rs.getLong(index++); + panelName = rs.getString(index++); + panelPointer = rs.getLong(index++); + transitionTime = rs.getInt(index++); + userTransitionTime = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ScreenShotData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ScreenShotData.java index d9fa30b..23764ed 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ScreenShotData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ScreenShotData.java @@ -1,13 +1,26 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class ScreenShotData extends ProbeCommonData { String imageFilePath = null; int orientation = 0; - public ScreenShotData(BasicDataMessage data) { - super(data); + public ScreenShotData(){} + public void makeData(byte[] data) { + super.makeData(data); + + int length = LogDataUtils.getStringLength(index, data); + byte[] temp = new byte[length]; + System.arraycopy(data, index, temp, 0, length); + imageFilePath = new String(temp); + index += length; + + orientation = ByteUtils.toInt(data, index); } public String getImageFilePath() { @@ -26,4 +39,21 @@ public class ScreenShotData extends ProbeCommonData { this.orientation = orientation; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setString(index++, imageFilePath); + prep.setInt(index++, orientation); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + imageFilePath = rs.getString(index++); + orientation = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SyncData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SyncData.java index 8c62b46..27edab0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SyncData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SyncData.java @@ -1,14 +1,31 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class SyncData extends ProbeCommonData { long syncValue = 0; int syncType = 0; int apiType = 0; - public SyncData(BasicDataMessage data) { - super(data); + public SyncData(){} + + public void makeData(byte[] data) { + super.makeData(data); + + syncValue = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + syncType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + apiType = ByteUtils.toInt(data, index); } public long getSyncValue() { @@ -35,4 +52,23 @@ public class SyncData extends ProbeCommonData { this.apiType = apiType; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setLong(index++, syncValue); + prep.setInt(index++, syncType); + prep.setInt(index++, apiType); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + syncValue = rs.getLong(index++); + syncType = rs.getInt(index++); + apiType = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SystemData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SystemData.java index 309bd56..a845814 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SystemData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/SystemData.java @@ -1,6 +1,17 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.FLOAT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.common.CommonConstants; +import org.tizen.dynamicanalyzer.communicator.DACommunicator; +import org.tizen.dynamicanalyzer.swap.logparser.MessageParser; +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class SystemData extends LogData { @@ -21,7 +32,7 @@ public class SystemData extends LogData { int totalUsedDrive = 0; int diskReadSize = 0; int diskWriteSize = 0; - int disSectorsWritten = 0; + int diskSectorsWritten = 0; int networkSendSize = 0; int networkReceiveSize = 0; int wifi = 0; @@ -42,8 +53,156 @@ public class SystemData extends LogData { int callAlpha = 0; int rssiAlpha = 0; - public SystemData(BasicDataMessage data) { - super(data); + public SystemData(){} + + public void makeData(byte[] data) { + super.makeData(data); +// index = MessageParser.MSG_HEADER_SIZE; + int coreCount = DACommunicator.getSelectedDevice().getTargetInfo() + .getCpuCount(); + appCpuUsage = ByteUtils.toFloat(data, index); + index += FLOAT_SIZE; + + cpuFrequency = parseCpu(index, data); + index += (FLOAT_SIZE * coreCount); + + cpuLoad = parseCpu(index, data); + index += (FLOAT_SIZE * coreCount); + + threadCount = ByteUtils.toInt(data, index); + index += INT_SIZE; + + threadLoad = parseLoad(index, data); + index += (threadCount * (INT_SIZE + FLOAT_SIZE)); + + processCount = ByteUtils.toInt(data, index); + index += INT_SIZE; + + processLoad = parseLoad(index, data); + index += (processCount * (INT_SIZE + FLOAT_SIZE)); + + virtualMemory = ByteUtils.toInt(data, index); + index += INT_SIZE; + + residentMemory = ByteUtils.toInt(data, index); + index += INT_SIZE; + + sharedMemory = ByteUtils.toInt(data, index); + index += INT_SIZE; + + pssMemory = ByteUtils.toInt(data, index); + index += INT_SIZE; + + totalAllocSize = ByteUtils.toInt(data, index); + index += INT_SIZE; + + systemMemoryTotal = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + systemMemoryUsed = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + totalUsedDrive = ByteUtils.toInt(data, index); + index += INT_SIZE; + + diskReadSize = ByteUtils.toInt(data, index); + index += INT_SIZE; + + diskWriteSize = ByteUtils.toInt(data, index); + index += INT_SIZE; + + diskSectorsWritten = ByteUtils.toInt(data, index); + index += INT_SIZE; + + networkSendSize = ByteUtils.toInt(data, index); + index += INT_SIZE; + + networkReceiveSize = ByteUtils.toInt(data, index); + index += INT_SIZE; + + wifi = ByteUtils.toInt(data, index); + index += INT_SIZE; + + btStatus = ByteUtils.toInt(data, index); + index += INT_SIZE; + + gpsStatus = ByteUtils.toInt(data, index); + index += INT_SIZE; + + brightness = ByteUtils.toInt(data, index); + index += INT_SIZE; + + camera = ByteUtils.toInt(data, index); + index += INT_SIZE; + + sound = ByteUtils.toInt(data, index); + index += INT_SIZE; + + audio = ByteUtils.toInt(data, index); + index += INT_SIZE; + + vibration = ByteUtils.toInt(data, index); + index += INT_SIZE; + + voltage = ByteUtils.toInt(data, index); + index += INT_SIZE; + + rssi = ByteUtils.toInt(data, index); + index += INT_SIZE; + + video = ByteUtils.toInt(data, index); + index += INT_SIZE; + + call = ByteUtils.toInt(data, index); + index += INT_SIZE; + + dnet = ByteUtils.toInt(data, index); + index += INT_SIZE; + + energy = ByteUtils.toInt(data, index); + } + + private static String parseLoad(int start, byte[] payload) { + int pos = start; + int backPos = start - INT_SIZE; + int count = ByteUtils.toInt(payload, backPos); + StringBuffer outBuf = new StringBuffer(); + for (int ii = 0; ii < count; ii++) { + try { + if (pos == 180) { + System.out.println(); + } + int tid = ByteUtils.toInt(payload, pos); + pos += INT_SIZE; + outBuf.append(tid).append(CommonConstants.COMMA); + float f = ByteUtils.toFloat(payload, pos); + outBuf.append(f); + pos += FLOAT_SIZE; + if (ii + 1 != count) { + outBuf.append(','); + } + } catch (ArrayIndexOutOfBoundsException e) { + e.printStackTrace(); + break; + } + } + + return outBuf.toString(); + } + + private static String parseCpu(int start, byte[] payload) { + int coreCount = DACommunicator.getSelectedDevice().getTargetInfo() + .getCpuCount(); + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < coreCount; i++) { + float value = ByteUtils.toFloat(payload, start); + start += FLOAT_SIZE; + buffer.append(value); + if (i + 1 != coreCount) { + buffer.append(','); + } + } + return buffer.toString(); } public int getEnergy() { @@ -158,12 +317,12 @@ public class SystemData extends LogData { this.dnet = dnet; } - public int getDisSectorsWritten() { - return disSectorsWritten; + public int getDiskSectorsWritten() { + return diskSectorsWritten; } - public void setDisSectorsWritten(int disSectorsWritten) { - this.disSectorsWritten = disSectorsWritten; + public void setDiskSectorsWritten(int disSectorsWritten) { + this.diskSectorsWritten = disSectorsWritten; } public int getNetworkSendSize() { @@ -334,4 +493,92 @@ public class SystemData extends LogData { this.rssiAlpha = rssiAlpha; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = LogData.STATE_COUNT + 1; + + prep.setFloat(index++, appCpuUsage); + prep.setString(index++, cpuFrequency); + prep.setString(index++, cpuLoad); + prep.setInt(index++, threadCount); + prep.setString(index++, threadLoad); + prep.setInt(index++, processCount); + prep.setString(index++, processLoad); + prep.setInt(index++, virtualMemory); + prep.setInt(index++, residentMemory); + prep.setInt(index++, sharedMemory); + prep.setInt(index++, pssMemory); + prep.setInt(index++, totalAllocSize); + prep.setLong(index++, systemMemoryTotal); + prep.setLong(index++, systemMemoryUsed); + prep.setInt(index++, totalUsedDrive); + prep.setInt(index++, diskReadSize); + prep.setInt(index++, diskWriteSize); + prep.setInt(index++, diskSectorsWritten); + prep.setInt(index++, networkSendSize); + prep.setInt(index++, networkReceiveSize); + prep.setInt(index++, wifi); + prep.setInt(index++, btStatus); + prep.setInt(index++, gpsStatus); + prep.setInt(index++, brightness); + prep.setInt(index++, camera); + prep.setInt(index++, sound); + prep.setInt(index++, audio); + prep.setInt(index++, vibration); + prep.setInt(index++, voltage); + prep.setInt(index++, rssi); + prep.setInt(index++, video); + prep.setInt(index++, call); + prep.setInt(index++, dnet); + prep.setInt(index++, energy); + + prep.setInt(index++, callAlpha); + prep.setInt(index++, rssiAlpha); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = LogData.STATE_COUNT + 1; + + appCpuUsage = rs.getFloat(index++); + cpuFrequency = rs.getString(index++); + cpuLoad = rs.getString(index++); + threadCount = rs.getInt(index++); + threadLoad = rs.getString(index++); + processCount = rs.getInt(index++); + processLoad = rs.getString(index++); + virtualMemory = rs.getInt(index++); + residentMemory = rs.getInt(index++); + sharedMemory = rs.getInt(index++); + pssMemory = rs.getInt(index++); + totalAllocSize = rs.getInt(index++); + systemMemoryTotal = rs.getLong(index++); + systemMemoryUsed = rs.getLong(index++); + totalUsedDrive = rs.getInt(index++); + diskReadSize = rs.getInt(index++); + diskWriteSize = rs.getInt(index++); + diskSectorsWritten = rs.getInt(index++); + networkSendSize = rs.getInt(index++); + networkReceiveSize = rs.getInt(index++); + wifi = rs.getInt(index++); + btStatus = rs.getInt(index++); + gpsStatus = rs.getInt(index++); + brightness = rs.getInt(index++); + camera = rs.getInt(index++); + sound = rs.getInt(index++); + audio = rs.getInt(index++); + vibration = rs.getInt(index++); + voltage = rs.getInt(index++); + rssi = rs.getInt(index++); + video = rs.getInt(index++); + call = rs.getInt(index++); + dnet = rs.getInt(index++); + energy = rs.getInt(index++); + + callAlpha = rs.getInt(index++); + rssiAlpha = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ThreadData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ThreadData.java index a120714..f445fe3 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ThreadData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/ThreadData.java @@ -1,6 +1,13 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class ThreadData extends ProbeCommonData { long pThreadId = 0; @@ -8,8 +15,21 @@ public class ThreadData extends ProbeCommonData { int threadType = 0; // TODO: short int apiType = 0;// TODO: short - public ThreadData(BasicDataMessage data) { - super(data); + public ThreadData(){} + + public void makeData(byte[] data) { + super.makeData(data); + + pThreadId = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + ospThreadId = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + threadType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + apiType = ByteUtils.toInt(data, index); } public long getPThreadId() { @@ -44,4 +64,25 @@ public class ThreadData extends ProbeCommonData { this.apiType = apiType; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setLong(index++, pThreadId); + prep.setLong(index++, ospThreadId); + prep.setInt(index++, threadType); + prep.setInt(index++, apiType); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + pThreadId = rs.getLong(index++); + ospThreadId = rs.getLong(index++); + threadType = rs.getInt(index++); + apiType = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UIEventData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UIEventData.java index 9dc8df6..5b3b156 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UIEventData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UIEventData.java @@ -1,6 +1,12 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class UIEventData extends ProbeCommonData { @@ -11,6 +17,29 @@ public class UIEventData extends ProbeCommonData { String info1 = null; int info2 = 0; + public UIEventData(){} + + public void makeData(byte[] data) { + super.makeData(data); + + eventType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + detailType = ByteUtils.toInt(data, index); + index += INT_SIZE; + + x = ByteUtils.toInt(data, index); + index += INT_SIZE; + + y = ByteUtils.toInt(data, index); + index += INT_SIZE; + + info1 = ByteUtils.getString(data, index); + index += ByteUtils.getStringLength(data, index); + + info2 = ByteUtils.toInt(data, index); + } + public int getEventType() { return eventType; } @@ -61,12 +90,35 @@ public class UIEventData extends ProbeCommonData { private int logNum = 0; - public UIEventData(BasicDataMessage data) { - super(data); - } - @Override public int getLogNum() { return logNum++; } + + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setInt(index++, eventType); + prep.setInt(index++, detailType); + prep.setInt(index++, x); + prep.setInt(index++, y); + prep.setString(index++, info1); + prep.setInt(index++, info2); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + + eventType = rs.getInt(index++); + detailType = rs.getInt(index++); + x = rs.getInt(index++); + y = rs.getInt(index++); + info1 = rs.getString(index++); + info2 = rs.getInt(index++); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UserFunctionData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UserFunctionData.java index 51556a9..3538773 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UserFunctionData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/UserFunctionData.java @@ -1,6 +1,13 @@ package org.tizen.dynamicanalyzer.swap.model.probe2; -import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage; +import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE; +import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.tizen.dynamicanalyzer.swap.model.ByteUtils; public class UserFunctionData extends ProbeCommonData { @@ -10,8 +17,25 @@ public class UserFunctionData extends ProbeCommonData { long elapsedTime = 0; long pcAddr = 0; - public UserFunctionData(BasicDataMessage data) { - super(data); + public UserFunctionData() { + + } + + public void makeData(byte[] data) { + super.makeData(data); + lowPc = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + highPc = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + type = ByteUtils.toInt(data, index); + index += INT_SIZE; + + elapsedTime = ByteUtils.toLong(data, index); + index += LONG_SIZE; + + pcAddr = ByteUtils.toLong(data, index); } public long getLowPc() { @@ -54,4 +78,27 @@ public class UserFunctionData extends ProbeCommonData { this.pcAddr = pcAddr; } + @Override + public void makePreparedStatement(PreparedStatement prep) + throws SQLException { + super.makePreparedStatement(prep); + int index = ProbeCommonData.STATE_COUNT + 1; + + prep.setLong(index++, lowPc); + prep.setLong(index++, highPc); + prep.setInt(index++, type); + prep.setLong(index++, elapsedTime); + prep.setLong(index++, pcAddr); + } + + @Override + public void loadData(ResultSet rs) throws SQLException { + super.loadData(rs); + int index = ProbeCommonData.STATE_COUNT + 1; + lowPc = rs.getLong(index++); + highPc = rs.getLong(index++); + type = rs.getInt(index++); + elapsedTime = rs.getLong(index++); + pcAddr = rs.getLong(index++); + } }