org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Export-Package: org.tizen.dynamicanalyzer.callback,
+Export-Package: org.tizen.dynamicanalyzer.annotation,
+ org.tizen.dynamicanalyzer.callback,
org.tizen.dynamicanalyzer.constant,
org.tizen.dynamicanalyzer.model,
- org.tizen.dynamicanalyzer.util
+ org.tizen.dynamicanalyzer.util,
+ org.tizen.dynamicanalyzer.unittest
Import-Package: org.tizen.common.core.application
bin/,\\r
plugin.xml,\\r
META-INF/,\\r
-- theme/,\\r
plugin.properties,\\r
build.properties,\\r
Link/,\\r
name="%OpenTraceComplete">
</command>
<command
-- categoryId="org.tizen.dynamicanalyzer.commands"
-- id="org.tizen.dynamicanalyzer.handlers.ClearHandler"
-- name="%Clear">
-- </command>
-- <command
-- categoryId="org.tizen.dynamicanalyzer.commands"
-- id="org.tizen.dynamicanalyzer.handlers.StopHandler"
-- name="Stop">
-- </command>
-- <command
-- categoryId="org.tizen.dynamicanalyzer.commands"
-- id="org.tizen.dynamicanalyzer.handlers.StartHandler"
-- name="Start">
-- </command>
-- <command
defaultHandler="org.tizen.dynamicanalyzer.shortcut.ShortCutKeyBindingHandler"
id="Shortcut"
name="Shortcut">
class="org.tizen.dynamicanalyzer.handlers.OpenTraceCompleteHandler"
commandId="org.tizen.dynamicanalyzer.handlers.OpenTraceCompleteHandler">
</handler>
-- <handler
-- class="org.tizen.dynamicanalyzer.handlers.ClearHandler"
-- commandId="org.tizen.dynamicanalyzer.handlers.ClearHandler">
-- </handler>
-- <handler
-- class="org.tizen.dynamicanalyzer.handlers.StartHandler"
-- commandId="org.tizen.dynamicanalyzer.handlers.StartHandler">
-- </handler>
-- <handler
-- class="org.tizen.dynamicanalyzer.handlers.StopHandler"
-- commandId="org.tizen.dynamicanalyzer.handlers.StopHandler">
-- </handler>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
BaseView bv = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
bv.getMainTab().getView(viewId).updateView(selData);
}
- public static boolean isRunning() {
- return isRunning;
- }
-
- public static void setRunningState(boolean isRunning) {
- AnalyzerManager.isRunning = isRunning;
- }
-
- public static boolean isLogParsingComplete() {
- return isLogParsingComplete;
- }
-
- public static void setLogParsingComplete(boolean complete) {
- isLogParsingComplete = complete;
- }
-
- public static Map<Long, Integer> getFuncIDMapByPid(int pid) {
- ConcurrentHashMap<Integer, ConcurrentHashMap<Long, Integer>> temp = funcIDMapByPid;
- if (temp == null) {
- synchronized (AnalyzerManager.class) {
- temp = funcIDMapByPid;
- if (temp == null) {
- funcIDMapByPid = temp = new ConcurrentHashMap<Integer, ConcurrentHashMap<Long, Integer>>();
- }
- }
- }
-
- ConcurrentHashMap<Long, Integer> funcIDMap = temp.get(pid);
- if (funcIDMap == null) {
- funcIDMap = new ConcurrentHashMap<Long, Integer>();
- temp.put(pid, funcIDMap);
- }
- return funcIDMap;
- }
-
- public static int getProcessCount() {
- return processCount;
- }
-
- public static synchronized void increaseProcessCount() {
- processCount++;
- }
-
- public static synchronized void decreaseProcessCount() {
- processCount--;
- }
-
- public static synchronized void startScreenshotTimer() {
- stopScreenshotTimer();
- SettingDataManager setting = SettingDataManager.getInstance();
- int featureIndex = SettingConstants.FEATURE_NAME_INDEX_SCREENSHOT_PERIODICALLY;
- if (setting.isOptionsSelectedFeature(featureIndex)) {
- int value = setting.getOptionsFeatureValue(featureIndex);
- if (value > 0) {
- screenshotTimer = new Timer(AnalyzerConstants.SCREENSHOT_TIMER);
- screenshotTimer.scheduleAtFixedRate(new ScreenshotTimerTask(), 1000, value * 1000);
- }
- }
- }
-
- public static synchronized void stopScreenshotTimer() {
- if (null != screenshotTimer) {
- screenshotTimer.cancel();
- screenshotTimer = null;
- }
- }
+
}
}
if (readelfSize != uploadSize) {
Logger.debug("readelf file size is different!! "); //$NON-NLS-1$
- return HostResult.ERR_READELF_UPLOAD_FAILED;
+ return DAResult.ERR_READELF_UPLOAD_FAILED;
}
-
- return HostResult.printAndReturn(result);
++
+ result.printDebug();
+ return result;
}
public static boolean isCurrentDeviceArmArch() {
device.createForward(local, remote);
Thread.sleep(AnalyzerConstants.SOCKET_FORWARD_INTERVAL);
} catch (TimeoutException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
} catch (SdbCommandRejectedException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
} catch (IOException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
} catch (NullPointerException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
}
} else if (null == device) {
- result = HostResult.ERR_DEVICE_IS_NULL;
+ result = DAResult.ERR_DEVICE_IS_NULL;
} else if (!isOnline(device)) {
- result = HostResult.ERR_DEVICE_IS_OFFLINE;
+ result = DAResult.ERR_DEVICE_IS_OFFLINE;
} else {
- result = HostResult.ERR_UNDEFINED;
+ result = DAResult.ERR_UNKNOWN;
}
return result;
}
--- /dev/null
- e.printStackTrace();
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.control;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+public enum SideWorker implements Runnable {
+ INSTANCE;
+
+ private static Thread thread = null;
+
+ private BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>();
+
+ public static void start() {
+ if (null == thread || !thread.isAlive()) {
+ thread = new Thread(null, INSTANCE, AnalyzerConstants.SIDEWORKER_THREAD);
+ thread.start();
+ }
+ }
+
+ public static void stop() {
+ if (null != thread && thread.isAlive()) {
+ thread.interrupt();
+ try {
+ thread.join(AnalyzerConstants.THREAD_JOIN_WAIT_TIME);
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ }
+ thread = null;
+ }
+
+ public void offerWork(Runnable work) {
+ if (work != null) {
+ try {
+ workQueue.put(work);
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ while (!thread.isInterrupted()) {
+ Runnable runnable = null;
+ try {
+ runnable = workQueue.take();
+ } catch (InterruptedException e) {
++ Logger.exception(e);
+ break;
+ }
+
+ if (runnable != null) {
+ runnable.run();
+ }
+ }
+
+ Logger.debug(AnalyzerConstants.SIDEWORKER_THREAD + " is terminated");
+ }
+}
--- /dev/null
- progressDlg.open();
-
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.control;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DAResult;
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.common.Global.STATE;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.control.ProgressTable.PHASE;
+import org.tizen.dynamicanalyzer.control.ProgressTable.STAGE;
+import org.tizen.dynamicanalyzer.handlers.CommonAction;
+import org.tizen.dynamicanalyzer.handlers.ReplayManager;
+import org.tizen.dynamicanalyzer.handlers.UIAction;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.project.Project;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
+import org.tizen.dynamicanalyzer.swap.communicator.DataChannelThread;
+import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
+import org.tizen.dynamicanalyzer.swap.logparser.LogParser;
+import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
+import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotTimer;
+import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer;
+import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
+import org.tizen.dynamicanalyzer.ui.toolbar.setting.data.SettingConstants;
+import org.tizen.dynamicanalyzer.ui.toolbar.setting.data.SettingDataManager;
+import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
+import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog;
+import org.tizen.dynamicanalyzer.widgets.progress.Progress;
+import org.tizen.dynamicanalyzer.workbench.LayoutManager;
+
+public class StartTraceManager implements Runnable {
+ private static final int WAIT_GAP = 100;
+
+ private STAGE lastStage = STAGE.NONE;
+ private boolean cancelAction = false;
+ private ProgressDialog progressDlg = null;
+ private Thread startThread = null;
+ private IProgress progress = new IProgress() {
+ @Override
+ public boolean isCanceled() {
+ return cancelAction;
+ }
+
+ @Override
+ public void setStageComplete(STAGE stage) {
+ lastStage = stage;
+ int percent = ProgressTable.getPercent(PHASE.TRACE_START, lastStage);
+ setProgressPercent(percent);
+ }
+
+ @Override
+ public void checkCancel() throws InterruptedException {
+ StartTraceManager.this.checkCancel();
+ }
+ };
+
+ public StartTraceManager() {
+ // create progress dialog and open it
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ progressDlg = new ProgressDialog(shell, LayoutManager.getBaseComposite());
+
+ progressDlg.setStyle(SWT.ON_TOP);
+ progressDlg.setProgressStyle(Progress.PROGRESS_STYLE_CANCEL);
+ progressDlg.setProgressMessage(AnalyzerLabels.DLG_PREPARE_TRACE);
+ progressDlg.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT);
+ progressDlg.setCancelListener(new DACustomButtonClickEventListener() {
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ cancelAction = true;
+ if (startThread != null) {
+ startThread.interrupt();
+ }
+ }
+ });
++
++ progressDlg.open();
+ }
+ });
+ }
+
+ @Override
+ public void run() {
+ DAResult result = DAResult.SUCCESS;
+
+ try {
+ startThread = Thread.currentThread();
+
+ if (!CommonAction.checkDeviceValidness()) {
+ result = DAResult.ERR_DISCONNECTED;
+ return;
+ }
+ setStageComplete(STAGE.CHECK_DEV);
+
+ if (!CommonAction.checkApplicatinValidness()) {
+ result = DAResult.ERR_INVALID_APP;
+ return;
+ }
+ setStageComplete(STAGE.CHECK_APP);
+
+ if (!CommonAction.checkConfiguration()) {
+ result = DAResult.ERR_CONFIG_FAILED;
+ return;
+ }
+ setStageComplete(STAGE.CHECK_CONFIG);
+
+ AnalyzerManager.setRunningState(true);
+ CommonAction.clear();
+
+ // make and initialize new project
+ Project project = new Project();
+ Global.setProject(project);
+ project.init(progress);
+
+ // reset UI
+ UIAction.resetUI();
+ setStageComplete(STAGE.RESET_UI);
+
+ // start data receive thread
+ result = DataChannelThread.start();
+ if (!result.isSuccess()) {
+ // failed to start data channel thread
+ return;
+ }
+ setStageComplete(STAGE.CREATE_DATATHREAD);
+
+ // start message parser thread
+ MessageParser.start();
+ setStageComplete(STAGE.CREATE_MPARSER);
+
+ // start log parser thread
+ LogParser.start();
+ setStageComplete(STAGE.CREATE_LPARSER);
+
+ // start registered data manager thread and db inserters
+ DataManagerRegistry.startThreads();
+ setStageComplete(STAGE.CREATE_PAGEMGR);
+
+ // send start message to target
+ result = DACommunicator.startTrace(progress);
+ setStageComplete(STAGE.SEND_STARTMSG);
+ if (!result.isSuccess()) {
+ // failed to start trace (error from target)
+ return;
+ }
+
+ // wait until process info message is arrived (for a few seconds)
+ while (!AnalyzerManager.isExit()) {
+ if (AnalyzerManager.isRunning() && AnalyzerManager.isProcessInfoArrived()) {
+ break;
+ }
+
+ Thread.sleep(WAIT_GAP);
+ checkCancel();
+ }
+ setStageComplete(STAGE.WAIT_PROCINFO);
+
+ // start toolbar clock
+ ToolbarArea.getInstance().startTimer();
+ setStageComplete(STAGE.START_CLOCK);
+
+ // if it is replay mode, set stop alarm
+ ReplayManager.setStopAlarm();
+ setStageComplete(STAGE.CREATE_REPLAY_TIMER);
+
+ // start screenshot timer
+ SettingDataManager setting = SettingDataManager.getInstance();
+ int featureIndex = SettingConstants.FEATURE_NAME_INDEX_SCREENSHOT_PERIODICALLY;
+ if (setting.isOptionsSelectedFeature(featureIndex)) {
+ int value = setting.getOptionsFeatureValue(featureIndex);
+ if (value > 0) {
+ ScreenshotTimer.start(value);
+ }
+ }
+ setStageComplete(STAGE.CREATE_SCREENSHOT_TIMER);
+
+ // start update view timer
+ UpdateViewTimer.start();
+ setStageComplete(STAGE.CREATE_UPDATE_TIMER);
+
+ setStageComplete(STAGE.FINAL);
+ } catch (InterruptedException e) {
+ // operation is canceled
+ // re-interrupt thread to set the flag as 'interrupted'
+ Thread.currentThread().interrupt();
+
+ // set DA state to canceling
+ Global.setCurrentState(STATE.PREPARE_CANCEL);
+ result = DAResult.ERR_BY_USER_CANCEL;
+
+ /*********************************************************************
+ * cancel some operations
+ *********************************************************************/
+ switch (lastStage) {
+ case FINAL:
+ case CREATE_UPDATE_TIMER:
+ UpdateViewTimer.stop();
+ setCancelProgress(STAGE.CREATE_UPDATE_TIMER);
+ case CREATE_SCREENSHOT_TIMER:
+ ScreenshotTimer.stop();
+ setCancelProgress(STAGE.CREATE_SCREENSHOT_TIMER);
+ case CREATE_REPLAY_TIMER:
+ ReplayManager.resetStopAlarm();
+ setCancelProgress(STAGE.CREATE_REPLAY_TIMER);
+ case START_CLOCK:
+ ToolbarArea.getInstance().stopTimer();
+ setCancelProgress(STAGE.START_CLOCK);
+ case WAIT_PROCINFO:
+ case SEND_STARTMSG:
+ DACommunicator.stopTrace();
+ setCancelProgress(STAGE.SEND_STARTMSG);
+ case CREATE_PAGEMGR:
+ DataManagerRegistry.stopThreadsForced();
+ setCancelProgress(STAGE.CREATE_PAGEMGR);
+ case CREATE_LPARSER:
+ LogParser.stopForced();
+ setCancelProgress(STAGE.CREATE_LPARSER);
+ case CREATE_MPARSER:
+ MessageParser.stopForced();
+ setCancelProgress(STAGE.CREATE_MPARSER);
+ case CREATE_DATATHREAD:
+ DataChannelThread.stopForced();
+ setCancelProgress(STAGE.CREATE_DATATHREAD);
+ case RESET_UI:
+ case CREATE_DBTABLE:
+ case ESTABLISH_DB:
+ case CREATE_PROJECT:
+ // clear including project
+ CommonAction.clear();
+ setCancelProgress(STAGE.CREATE_PROJECT);
+ case CHECK_CONFIG:
+ case CHECK_APP:
+ case CHECK_DEV:
+ break;
+ default:
+ break;
+ }
+ } finally {
+ // set DA state as result of start progress
+ if (lastStage != STAGE.FINAL) {
+ AnalyzerManager.setRunningState(false);
+ Global.setCurrentState(STATE.DONE);
+ } else {
+ Global.setCurrentState(STATE.RUNNING);
+ }
+
+ // close progress dialog
+ if (progressDlg != null) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ progressDlg.close();
+ }
+ });
+ }
+
+ // if error occurred, show the error dialog
+ if (!result.isSuccess()) {
+ showError(result);
+ }
+
+ // set shortcut and toolbar UI as DA state
+ ShortCutManager.getInstance().setEnabled(true);
+ ToolbarArea.getInstance().changeUIState(Global.getCurrentState());
+ }
+ }
+
+ private void setProgressPercent(int percent) {
+ final int per = percent;
+ if (progressDlg != null) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ progressDlg.setValue(per);
+ }
+ });
+ }
+ }
+
+ private void setStageComplete(STAGE st) throws InterruptedException {
+ lastStage = st;
+
+ int percent = ProgressTable.getPercent(PHASE.TRACE_START, lastStage);
+ if (percent != 100) {
+ checkCancel();
+ }
+
+ setProgressPercent(percent);
+ }
+
+ private void setCancelProgress(STAGE st) {
+ int percent = ProgressTable.getPercent(PHASE.CANCEL_TRACE_START, st);
+ setProgressPercent(percent);
+ }
+
+ private void checkCancel() throws InterruptedException {
+ if (startThread.isInterrupted()) {
+ throw new InterruptedException();
+ }
+ }
+
+ private void showError(DAResult result) {
+ // open error dialog
+ final DAResult fResult = result;
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ DADialog warning = new DADialog(shell, SWT.NONE);
+ warning.setMessage(fResult.getMessage() + "(" + fResult.getErrorNumber() + ")");
+ warning.setIcon(ImageResources.DIALOG_WARNING_ICON);
+ warning.open();
+ }
+ });
+ }
+}
--- /dev/null
- CallStackInserter.getInstance().stopInserterThread();
+package org.tizen.dynamicanalyzer.control;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DAResult;
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.common.Global.STATE;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.control.ProgressTable.PHASE;
+import org.tizen.dynamicanalyzer.control.ProgressTable.STAGE;
+import org.tizen.dynamicanalyzer.handlers.ReplayManager;
+import org.tizen.dynamicanalyzer.handlers.UIAction;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.project.Project;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
+import org.tizen.dynamicanalyzer.swap.communicator.DataChannelThread;
+import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
+import org.tizen.dynamicanalyzer.swap.logparser.LogParser;
+import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
+import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotTimer;
+import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer;
+import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
+import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
++import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
+import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog;
+import org.tizen.dynamicanalyzer.workbench.LayoutManager;
+
+public class StopTraceManager implements Runnable {
+
+ private STAGE lastStage = STAGE.NONE;
+ private ProgressDialog progressDlg = null;
+ private DAResult error;
+ private boolean stopFromTarget = false;
+
+ public StopTraceManager(DAResult error, boolean stopFromTarget) {
+ AnalyzerManager.setRunningState(false);
+ this.error = error;
+ this.stopFromTarget = stopFromTarget;
+
+ // create progress dialog and open it
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ progressDlg = new ProgressDialog(shell, LayoutManager.getBaseComposite());
+ if (null != progressDlg) {
+ progressDlg.setStyle(SWT.ON_TOP);
+ progressDlg.setProgressMessage(AnalyzerLabels.DLG_SUMMARIZING_DATA);
+ progressDlg.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT);
+ progressDlg.open();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void run() {
+ DAResult result = DAResult.SUCCESS;
+
+ try {
+ // send stop message if necessary
+ if (!stopFromTarget) {
+ DACommunicator.stopTrace();
+ }
+ DACommunicator.setRunning(false);
+ setStageComplete(STAGE.SEND_STOPMSG);
+
+ // stop clock
+ ToolbarArea.getInstance().stopTimer();
+ setStageComplete(STAGE.STOP_CLOCK);
+
+ // stop replay timer
+ ReplayManager.resetStopAlarm();
+ setStageComplete(STAGE.STOP_REPLAY_TIMER);
+
+ // stop screenshot timer
+ ScreenshotTimer.stop();
+ setStageComplete(STAGE.STOP_SCREENSHOT_TIMER);
+
+ // stop update timer
+ UpdateViewTimer.stop();
+ setStageComplete(STAGE.STOP_UPDATE_TIMER);
+
+ // stop data channel
+ DataChannelThread.stopNormal();
+ setStageComplete(STAGE.STOP_DATATHREAD);
+
+ // stop message parser
+ MessageParser.stopNormal();
+ setStageComplete(STAGE.STOP_MPARSER);
+
+ // stop log parser
+ LogParser.stopNormal();
+ setStageComplete(STAGE.STOP_LPARSER);
+
+ // stop page data manager
+ DataManagerRegistry.stopThreadsNormal();
+ setStageComplete(STAGE.STOP_PAGEMGR);
+
+ // stop other db inserters
- e.printStackTrace();
++ CallStackInserter.stopInserterThread();
+
+ // save project and others
+ Project project = Global.getProject();
+ project.setTotalStopTime(ToolbarArea.getInstance().getTime());
+ FunctionUsageProfiler.getInstance().saveProfilingData();
+ FunctionUsageProfiler.getInstance().saveProfilingChildData();
+ project.save();
+ setStageComplete(STAGE.SAVE_PROJECT);
+
+ // change summary UI
+ // change to summary page
+ UIAction.summarizeUI();
+ AnalyzerUtil.changePage(SummaryPage.pageID);
+ setStageComplete(STAGE.SUMMARIZE_UI);
+ } catch (InterruptedException e) {
+ // canceled stop tracing
+ // never happened
++ Logger.exception(e);
+ } finally {
+ // set DA state as result of start progress
+ AnalyzerManager.setRunningState(false);
+ Global.setCurrentState(STATE.DONE);
+
+ // close progress dialog
+ if (progressDlg != null) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ progressDlg.close();
+ }
+ });
+ }
+
+ // if error occurred, show the error dialog
+ if (!result.isSuccess()) {
+ showError(result);
+ }
+
+ // set shortcut and toolbar UI as DA state
+ ShortCutManager.getInstance().setEnabled(true);
+ ToolbarArea.getInstance().changeUIState(Global.getCurrentState());
+ }
+ }
+
+ private void setProgressPercent(int percent) {
+ final int per = percent;
+ if (progressDlg != null) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ progressDlg.setValue(per);
+ }
+ });
+ }
+ }
+
+ private void setStageComplete(STAGE st) throws InterruptedException {
+ lastStage = st;
+
+ int percent = ProgressTable.getPercent(PHASE.TRACE_END, lastStage);
+ if (percent != 100) {
+ checkCancel();
+ }
+
+ setProgressPercent(percent);
+ }
+
+ private void checkCancel() throws InterruptedException {
+ // do nothing
+ }
+
+ private void showError(DAResult result) {
+ // open error dialog
+ final DAResult fResult = result;
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ DADialog warning = new DADialog(shell, SWT.NONE);
+ warning.setMessage(fResult.getMessage() + "(" + fResult.getErrorNumber() + ")");
+ warning.setIcon(ImageResources.DIALOG_WARNING_ICON);
+ warning.open();
+ }
+ });
+ }
+}
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+ import org.tizen.dynamicanalyzer.util.Logger;
+
public class DBInserter implements Runnable {
- private static List<List<Object>> END_OF_QUEUE = new ArrayList<List<Object>>();
+ public static List<List<Object>> END_OF_QUEUE = new ArrayList<List<Object>>();
private LinkedBlockingQueue<List<List<Object>>> dataQueue = new LinkedBlockingQueue<List<List<Object>>>();
private DBTable table = null;
this.table = table;
}
- public void startThread() {
- if (thread != null) {
- if (thread.isAlive()) {
- thread.interrupt();
- }
+ public void start() {
+ if (thread != null && thread.isAlive()) {
try {
- thread.join(AnalyzerConstants.THREAD_JOIN_WAIT_TIME);
+ thread.interrupt();
+ thread.join();
thread = null;
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
}
}
-
- clear();
thread = new Thread(this, table.getTableName() + " inserter");
thread.start();
}
- public void stopThread() {
- if (thread != null) {
- if (thread.isAlive()) {
- setToStop();
+ public void stopNormal() {
+ if (thread != null && thread.isAlive()) {
+ try {
+ thread.join();
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
}
+ }
+
+ clear();
+ }
+
+ public void stopForced() {
+ if (thread != null && thread.isAlive()) {
try {
- thread.join(AnalyzerConstants.THREAD_JOIN_WAIT_TIME);
+ thread.interrupt();
+ thread.join();
thread = null;
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
}
}
return success;
}
- // reset current project to null
- Global.setProject(null);
+
+ public static void startTrace() {
+ // only when trace is not running, trace can be started
+ STATE curState = Global.getCurrentState();
+ synchronized (curState) {
+ if (curState != STATE.INIT && curState != STATE.DONE) {
+ Logger.warning("Try to start trace though trace is not stopped completely");
+ return;
+ }
+
+ // set DA state to PREPARE_START
+ Global.setCurrentState(STATE.PREPARE_START);
+ }
+
+ // change UI state
+ ToolbarArea.getInstance().changeUIState(STATE.PREPARE_START);
+ ShortCutManager.getInstance().setEnabled(false);
+
++ // change page to timeline page
+ AnalyzerUtil.changePage(TimelinePage.pageID);
+
+ // make thread to prepare start
+ Thread thread = new Thread(new StartTraceManager());
+ thread.start();
+ }
+
+ // stop trace with result
+ // if result is success, then just stop trace
+ // else if result is error, then show error message and stop trace
+ public static void stopTrace(DAResult error, boolean stopFromTarget) {
+ // only when trace is running, trace can be stopped
+ STATE curState = Global.getCurrentState();
+ synchronized (curState) {
+ if (curState != STATE.RUNNING) {
+ Logger.warning("Try to stop trace though trace is not running");
+ return;
+ }
+
+ // set DA state to PREPARE_START
+ Global.setCurrentState(STATE.PREPARE_END);
+ }
+
+ // change UI state
+ ToolbarArea.getInstance().changeUIState(STATE.PREPARE_END);
+ ShortCutManager.getInstance().setEnabled(false);
+
+ // make thread to prepare start
+ Thread thread = new Thread(new StopTraceManager(error, stopFromTarget));
+ thread.start();
+ }
+
}
HEAP_MEMORY_WARNING_PRE=The profiling was stop for out of memory.\nIf you want to use more memory, increase the -xmx value in the\n
HEAP_MEMORY_WARNING_POST=/dynamic-analyzer.ini file.
-DETAIL_INFORMATION_APPLICATION_EXEC_PATH=Application Exec Path :
++<<<<<<< HEAD
+TIME_MS=ms
++=======
+ TIME_MS = ms
+
+ DETAIL_INFORMATION_PACKAGE_NAME=Package Name :
+ DETAIL_INFORMATION_PACKAGE_VERSION=Package Version :
+ DETAIL_INFORMATION_PACKAGE_INSTALL_TIME=Package Installed Time :
+ DETAIL_INFORMATION_APPLICATION_NAME=Application Name :
++DETAIL_INFORMATION_APPLICATION_EXEC_PATH=Application Exec Path :
++>>>>>>> tizen
return ret;
}
- private void setPageTabListInfo(String info) {
- BaseView bv = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
- String list[] = info.split(CommonConstants.COMMA);
- for (int i = 0; i < list.length; i++) {
- bv.addTabViewPage(list[i]);
- }
+ public void setPageTabListInfo() {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ BufferedReader in = getOpenReader(savePath);
+ String content = null;
+ if (in != null) {
+ try {
+ while (null != (content = in.readLine())) {
+ String list[] = content.split(CommonConstants.EQUAL);
+ if (list[0].equals(PAGE_TAB_LIST)) {
+ BaseView bv = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
+ String pageTabList[] = list[1].split(CommonConstants.COMMA);
+ for (int i = 0; i < pageTabList.length; i++) {
+ bv.addTabViewPage(pageTabList[i]);
+ }
+ break;
+ }
+ }
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(in);
+ }
+ }
+ }
+ });
}
-
+
private void openTargetStatusInfo(BufferedReader in) throws IOException {
String content = in.readLine();
if (content != null && content.equals(DEVICE_SECTION)) {
import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_START_ACK;
import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_STOP_ACK;
import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_TARGET_INFO_ACK;
-import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_GET_PROCESS_ADD_INFO_ACK;
import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import org.tizen.dynamicanalyzer.swap.channel.control.FunctionInst;
import org.tizen.dynamicanalyzer.swap.channel.control.RunTimeConfiguration;
import org.tizen.dynamicanalyzer.swap.channel.control.UserSpaceInst;
-import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.swap.logparser.SWAPLogParser;
import org.tizen.dynamicanalyzer.swap.model.DATime;
--import org.tizen.dynamicanalyzer.swap.model.data.LogDataUtils;
++import org.tizen.dynamicanalyzer.swap.model.data.ByteStreamData;
import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
import org.tizen.dynamicanalyzer.ui.info.screenshot.EmulatorScreenshot;
import org.tizen.dynamicanalyzer.ui.info.screenshot.SocketClient;
try {
becomeSuper = Global.getCurrentDeviceInfo().getIDevice().becomeSuperUser(true);
} catch (TimeoutException e) {
- e.printStackTrace();
+ Logger.exception(e);
} catch (SdbCommandRejectedException e) {
- e.printStackTrace();
+ Logger.exception(e);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.exception(e);
} finally {
if (!becomeSuper) {
- return HostResult.ERR_BY_SECURITY_REASON;
+ return DAResult.ERR_BY_SECURITY_REASON;
}
}
controlSock.setReuseAddress(true);
controlSock.setTcpNoDelay(true);
} catch (UnknownHostException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
} catch (SocketException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
} catch (IOException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
}
if (result.isSuccess()) {
// dataSock.getInputStream().read(testBuffer);
// ByteUtils.printByteArray(testBuffer);
} catch (UnknownHostException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
} catch (SocketException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
} catch (IOException e) {
- result = HostResult.ERR_EXCEPTION_OCCURRED;
- result.setMessage(e.getMessage());
+ result = DAResult.ERR_EXCEPTION_OCCURRED;
+ result.setDetailMessage(e.getMessage());
- e.printStackTrace();
+ Logger.exception(e);
}
if (result.isSuccess()) {
ByteUtil.getByte(AnalyzerConstants.MSG_TARGET_INFO, 0));
if (result != null && result.isCorrectID(MSG_TARGET_INFO_ACK)) {
if (result.isSuccess()) {
-- processTargetInfo(result.getPayload(), INT_SIZE, device.getDeviceStatusInfo());
- return HostResult.SUCCESS;
++ byte[] pbyte = result.getPayload();
++ ByteStreamData payload = new ByteStreamData(INT_SIZE, pbyte.length, pbyte);
++ processTargetInfo(payload, device.getDeviceStatusInfo());
+ return DAResult.SUCCESS;
}
}
return Global.getCurrentDeviceInfo().getDataSock();
}
-- private void processTargetInfo(byte[] payload, int index, DeviceStatusInfo tInfo) {
++ private void processTargetInfo(ByteStreamData payload, DeviceStatusInfo tInfo) {
long systemMemorySize = 0;
long storageSize = 0;
int bluetoothSupport = 0;
int numberOfDevice = 0;
String deviceList = CommonConstants.EMPTY;
-- systemMemorySize = ByteUtil.toLong(payload, index);
-- index += LONG_SIZE;
-- storageSize = ByteUtil.toLong(payload, index);
-- index += LONG_SIZE;
-- bluetoothSupport = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- gpsSupport = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- wifiSupport = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- cameraCount = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- networkType = ByteUtil.getString(payload, index);
-- index += ByteUtil.getStringLength(payload, index);
-- maxBrightness = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- numberOfCPU = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- numberOfDevice = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
++ systemMemorySize = payload.getLong();
++ storageSize = payload.getLong();
++ bluetoothSupport = payload.getInt();
++ gpsSupport = payload.getInt();
++ wifiSupport = payload.getInt();
++ cameraCount = payload.getInt();
++ networkType = payload.getString();
++ maxBrightness = payload.getInt();
++ numberOfCPU = payload.getInt();
++ numberOfDevice = payload.getInt();
for (int i = 0; i < numberOfDevice; i++) {
- int length = LogDataUtils.getStringLength(index, payload);
- deviceList += new String(payload, index, length);
- deviceList += LogDataUtils.getString(index, payload);
++ deviceList += payload.getString();
if (i + 1 != numberOfDevice) {
deviceList += CommonConstants.COMMA;
}
- index += length;
- index += LogDataUtils.getStringLength(index, payload);
}
tInfo.setSystemMemorySize(systemMemorySize);
localHashCode = parseMd5Result(line);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_BIN_INFO_GET_FAIL;
+ result = DAResult.ERR_BIN_INFO_GET_FAIL;
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
- result = HostResult.ERR_BIN_INFO_GET_FAIL;
+ result = DAResult.ERR_BIN_INFO_GET_FAIL;
}
if (localHashCode == null || 0 != localHashCode.compareTo(binInfo.getMd5sumValue())) {
*/
package org.tizen.dynamicanalyzer.swap.communicator;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InterruptedIOException;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DALimit;
+import org.tizen.dynamicanalyzer.common.DAResult;
+import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.control.SideWorker;
+import org.tizen.dynamicanalyzer.handlers.CommandAction;
+import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
+import org.tizen.dynamicanalyzer.swap.model.data.LogData;
+import org.tizen.dynamicanalyzer.swap.model.data.LogDataFactory;
+import org.tizen.dynamicanalyzer.util.Logger;
public class DataChannelThread implements Runnable {
- e.printStackTrace();
+ private static final int RECEIVE_BUF_SIZE = 2097152; // 2MB
+ private static final int LOCAL_BUF_SIZE = 1024;
+
+ private static Thread mThread = null;
+
+ private Object waitObject = new Object();
+ boolean throughMode = false;
+
+ private enum STATE {
+ INITIALIZED, ACTIVATED, TERMINATED;
+ }
+
+ private STATE state = STATE.INITIALIZED;
+
+ public static DAResult start() {
+ if (mThread != null && mThread.isAlive()) {
+ try {
+ mThread.interrupt();
+ mThread.join();
+ mThread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_START_DATA_CHANNEL;
+ }
+ }
+
+ DataChannelThread mRunnable = new DataChannelThread();
+ mThread = new Thread(null, mRunnable, AnalyzerConstants.COMMUNICATOR_RECEIVE_THREAD);
+ mThread.start();
+
+ synchronized (mRunnable.waitObject) {
+ try {
+ if (mRunnable.state == STATE.INITIALIZED) {
+ mRunnable.waitObject.wait();
+ }
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ }
+
+ if (mRunnable.state == STATE.ACTIVATED) {
+ return DAResult.SUCCESS;
+ } else {
+ return DAResult.ERR_START_DATA_CHANNEL;
+ }
+ }
+
+ public static DAResult stopNormal() {
+ // do nothing to stop thread
+ // just wait the thread is terminated by itself
+ if (mThread != null && mThread.isAlive()) {
+ // wait until data channel thread is terminated
+ try {
+ mThread.join(); // wait forever
+ mThread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_STOP_DATA_CHANNEL;
+ }
+ }
+
+ return DAResult.SUCCESS;
+ }
+
+ public static DAResult stopForced() {
+ // if thread is not terminated, interrupt it and wait to terminate
+ if (mThread != null && mThread.isAlive()) {
+ // wait until data channel thread is terminated
+ try {
+ mThread.interrupt();
+ mThread.join(); // wait forever
+ mThread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_STOP_DATA_CHANNEL;
+ }
+ }
+
+ clearSocketReceiveBuffer(DACommunicator.getDataSocket());
+
+ return DAResult.SUCCESS;
+ }
+
+ private void changeToThroughMode() {
+ Socket dataSocket = DACommunicator.getDataSocket();
+ try {
+ dataSocket.setSoTimeout(AnalyzerConstants.DATA_SOCKET_TIMEOUT_TERMINATE);
+ } catch (SocketException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+
+ throughMode = true;
+ }
+
+ public static void clearSocketReceiveBuffer(Socket socket) {
+ try {
+ socket.setSoTimeout(AnalyzerConstants.DATA_SOCKET_TIMEOUT_CLEAR);
+ InputStream inputStream = socket.getInputStream();
+
+ byte[] buffer = new byte[LOCAL_BUF_SIZE];
+ int readSize;
+ while (true) {
+ readSize = inputStream.read(buffer, 0, LOCAL_BUF_SIZE);
+ if (readSize == -1) {
+ break;
+ }
+ }
+ } catch (SocketTimeoutException e) {
+ // expected result
+ // do nothing
+ Logger.debug("data socket cleared");
+ } catch (SocketException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ } catch (IOException e) {
++ Logger.exception(e);
+ }
+ }
@Override
public void run() {
- MessageParser.getInstance().startMessageParsing(
- DACommunicator.getDataSocket());
+ try {
+ Socket dataSocket = DACommunicator.getDataSocket();
+ clearSocketReceiveBuffer(dataSocket);
+
+ BufferedInputStream inputStream = null;
+ byte[] header = new byte[DataChannelConstants.HEADER_SIZE];
+ byte[] buffer = new byte[LOCAL_BUF_SIZE];
+ long curSeq, prevSeq = -1;
+ Thread curThread = Thread.currentThread();
+
+ try {
+ dataSocket.setSoTimeout(AnalyzerConstants.DATA_SOCKET_TIMEOUT_NORMAL);
+ dataSocket.setReceiveBufferSize(RECEIVE_BUF_SIZE);
+ inputStream = new BufferedInputStream(dataSocket.getInputStream());
+
+ // notify that data channel thread is activated and ready to read
+ synchronized (waitObject) {
+ state = STATE.ACTIVATED;
+ waitObject.notifyAll();
+ }
+
+ while (curThread == mThread) {
+ if (!throughMode) {
+ // read data message header
+ if (!getByte(inputStream, header, DataChannelConstants.HEADER_SIZE)) {
+ break;
+ }
+
+ LogData log = LogDataFactory.createInstance(header);
+
+ // check for continuity of sequence number
+ curSeq = log.getSeq();
+ boolean continuity = checkContinuity(prevSeq, curSeq);
+ if (prevSeq > curSeq) { // sequence number exceed MAX_SEQ_NUMBER
+ Global.getProject().incSeqRotation();
+ }
+ prevSeq = curSeq;
+ log.adjustSeq(Global.getProject().getSeqRotation());
+
+ if (!continuity) {
+ // if sequence continuity is broken, then send stop work to side worker
+ notifyStopWork(DAResult.ERR_CONTINUITY_BROKEN);
+ }
+
+ // check for payload size
+ int payloadsize = log.getPayloadSize();
+ if (payloadsize < 0 || payloadsize > DALimit.MAX_PAYLOAD_SIZE) {
+ // wrong message format, stop profiling
+ notifyStopWork(DAResult.ERR_WRONG_MESSAGE_FORMAT);
+ changeToThroughMode();
+
+ // this means there is no more data to parse, so push EOQ
+ pushEOQ();
+ } else {
+ // read payload from socket
+ if (!getByte(inputStream, log.getPayload(), payloadsize)) {
+ break;
+ }
+
+ try {
+ MessageParser.pushLog(log);
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ break;
+ }
+
+ // check for msg id MSG_DATA_TERMINATE
+ int msgID = log.getMsgID();
+ if (checkMsgID(msgID)) {
+ break;
+ }
+ }
+ } else { // through mode
+ int readSize = inputStream.read(buffer, 0, LOCAL_BUF_SIZE);
+ if (readSize == -1) {
+ // reached end of stream (never happened I guess)
+ AnalyzerManager.setDataSocketClosed(true);
+ break;
+ }
+ }
+ }
+ } catch (SocketTimeoutException e) {
+ // timeout to read (there is no more data to read)
+ // do nothing
- e.printStackTrace();
++ Logger.exception(e);
+ } catch (InterruptedIOException e) {
+ // thread is interrupted by other thread during reading from socket
- e.printStackTrace();
++ Logger.exception(e);
+ } catch (IOException e) {
+ // data socket is closed
+ AnalyzerManager.setDataSocketClosed(true);
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ } finally {
+ pushEOQ();
+
+ if (AnalyzerManager.isDataSocketClosed()) {
+ notifyStopWork(DAResult.ERR_DATA_SOCKET_CLOSED);
+ }
+
+ synchronized (waitObject) {
+ state = STATE.TERMINATED;
+ waitObject.notifyAll();
+ }
+ }
+ }
+
+ private boolean getByte(InputStream input, byte[] buffer, int length) throws IOException {
+ // read data message header
+ int toRead = length;
+ int readSize;
+ while (toRead > 0) {
+ readSize = input.read(buffer, length - toRead, toRead);
+ toRead -= readSize;
+ if (readSize == -1) {
+ // reached end of stream (never happened I guess)
+ AnalyzerManager.setDataSocketClosed(true);
+ break;
+ }
+ }
+
+ if (AnalyzerManager.isDataSocketClosed()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private boolean checkContinuity(long prevSeq, long curSeq) {
+ if (curSeq != prevSeq + 1) {
+ // continuity of seq number is broken
+ Logger.error("Contunuity failed (%d) (%d)", prevSeq, curSeq);
+ return false;
+ } else {
+ return true;
+ }
}
- e.printStackTrace();
+ private boolean pushEOQ() {
+ try {
+ MessageParser.pushLog(LogData.END_OF_QUEUE);
+ return true;
+ } catch (InterruptedException e) {
++ Logger.exception(e);
+ return false;
+ }
+ }
+
+ // return true if last log is arrived
+ // return false otherwise
+ private boolean checkMsgID(int msgID) {
+ if (msgID == DataChannelConstants.MSG_DATA_PROCESS_INFO) {
+ Global.getProject().incActiveProcessCount();
+ } else if (msgID == DataChannelConstants.MSG_DATA_TERMINATE) {
+ Global.getProject().descActiveProcessCount();
+ if (Global.getProject().getActiveProcessCount() == 0) {
+ // if there is no active process, no more message from target
+ AnalyzerManager.setTerminateMsgArrived(true);
+ // exit data channel thread
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void notifyStopWork(DAResult result) {
+ final DAResult fresult = result;
+ SideWorker.INSTANCE.offerWork(new Runnable() {
+ @Override
+ public void run() {
+ CommandAction.stopTrace(fresult, false);
+ }
+ });
+ }
}
private int DEFAULT_IMG_WIDTH = 480;
private int DEFAULT_IMG_HEIGHT = 800;
- public static synchronized LogQueue getLogQueue() {
- if (null == logQueue) {
- logQueue = new LogQueue();
+ public static DAResult start() {
+ if (thread != null && thread.isAlive()) {
+ try {
+ thread.interrupt();
+ thread.join();
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_START_LOG_PARSER;
+ }
}
- return logQueue;
+
+ instance = new LogParser();
+ thread = new Thread(null, instance, AnalyzerConstants.LOG_QUEUE_OBSERVING_THREAD);
+ thread.start();
+
+ return DAResult.SUCCESS;
}
- public List<Long> getFunctionEntryStack(int tid) {
- List<Long> functionEntryStack = functionEntryStackByTidMap.get(tid);
- if (null == functionEntryStack) {
- functionEntryStack = new ArrayList<Long>();
- functionEntryStackByTidMap.put(tid, functionEntryStack);
+ public static DAResult stopNormal() {
+ // do nothing to stop thread
+ // just wait the thread is terminated by itself
+ if (thread != null && thread.isAlive()) {
+ // wait until data channel thread is terminated
+ try {
+ thread.join(); // wait forever
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_START_LOG_PARSER;
+ }
}
- return functionEntryStack;
- }
- public static synchronized void startLogParser() {
- getLogQueue().clear();
- // why here?
- // dropCallTraceLog = true;
- if (null == logParser || !logParser.isAlive()) {
- logParser = new Thread(null, new SWAPLogParser(),
- AnalyzerConstants.LOG_QUEUE_OBSERVING_THREAD);
- logParser.start();
+ if (instance != null) {
+ instance.clear();
}
+ instance = null;
+
+ return DAResult.SUCCESS;
}
- public static void stopLogParser() {
- if (null != logParser && logParser.isAlive()) {
- LogQueue logQueue = getLogQueue();
- synchronized (logQueue) {
- AnalyzerManager.setRunningState(false);
- logQueue.notifyAll();
- }
+ public static DAResult stopForced() {
+ if (thread != null && thread.isAlive()) {
+ // wait until data channel thread is terminated
try {
- Logger.debug("wait for log parser join");//$NON-NLS-1$
- logParser.join(AnalyzerConstants.THREAD_JOIN_WAIT_TIME);
+ thread.interrupt();
+ thread.join(); // wait forever
+ thread = null;
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
+ return DAResult.ERR_START_LOG_PARSER;
}
}
+
+ if (instance != null) {
+ instance.clear();
+ }
+ instance = null;
+
+ return DAResult.SUCCESS;
+ }
+
+ public static void pushLog(LogList loglist) throws InterruptedException {
+ if (instance != null) {
+ instance.queue.put(loglist);
+ }
+ }
+
+ private void clear() {
+ queue.clear();
+ functionEntryStackByTidMap.clear();
+ }
+
+ public Deque<Long> getFunctionEntryStack(int tid) {
+ Deque<Long> functionEntryStack = functionEntryStackByTidMap.get(tid);
+ if (null == functionEntryStack) {
+ functionEntryStack = new ArrayDeque<Long>();
+ functionEntryStackByTidMap.put(tid, functionEntryStack);
+ }
+ return functionEntryStack;
}
/*** log parsing thread ***/
@Override
public void run() {
- AnalyzerManager.setLogParsingComplete(false);
- LogQueue logQueue = getLogQueue();
- while (!AnalyzerManager.isExit()) {
- List<LogData> logs = logQueue.getFirst();
- if (null == logs) {
- break;
+ try {
+ LogList loglist;
+ while (true) {
+ try {
+ loglist = queue.take();
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ break;
+ }
+
+ if (loglist == LogList.END_OF_QUEUE) {
+ break;
+ }
+
+ logParsing(loglist);
}
- logSlicing(logs);
+ } finally {
+ DataManagerRegistry.updateLog(LogPackage.END_OF_QUEUE);
}
- /* log for debug */
Logger.debug("log parsing thread end!!"); //$NON-NLS-1$
-
- functionEntryStackByTidMap.clear();
- DataManagerRegistry.stopThreads();
-
- AnalyzerManager.setLogParsingComplete(true);
}
- private void logSlicing(List<LogData> logLumb) {
- int size = logLumb.size();
+ private void logParsing(LogList loglist) {
+ int size = loglist.size();
LogPackage logPack = new LogPackage();
for (int i = 0; i < size; i++) {
- if (null == logLumb.get(i)) {
+ LogData log = loglist.get(i);
+ if (null == log) {
continue;
}
- LogData log = logLumb.get(i);
- int id = log.getId();
- long seqNum = log.getSeq();
- if (log instanceof SystemData) {
- // System.out
- // .println("=========systemData is slicing===========\n");
- pushLog(log, logPack);
- } else if (log instanceof ProfileData) {
+
+ int id = log.getMsgID();
+ boolean ret;
+ switch (id) {
+ case MSG_DATA_SAMPLE:
if (!AnalyzerManager.isProcessInfoArrived()) {
- continue;
+ break;
}
-
- if (id != DataChannelConstants.MSG_DATA_SAMPLE) {
- ProfileData pData = (ProfileData) log;
-
- List<Long> functionStack = getFunctionEntryStack(pData.getTid());
- // entry / exit pair matching
- if (id == DataChannelConstants.MSG_FUNCTION_ENTRY) {
- functionStack.add(seqNum);
- } else { // msg_function_exit
- int stackSize = functionStack.size();
- if (stackSize > 0) {
- pData.setEntrySeq(functionStack.get(stackSize - 1));
- functionStack.remove(stackSize - 1);
- } else { // size <= 0 : bug (exit without entry)
- Logger.error("function exit log without entry log");
- }
- }
-
- // function_exit log doesn't have probe type yet
- // if (pData.getProbeType()
- // == AnalyzerConstants.FUNCTION_TYPE_APPINST) {
-
- // ProcessInformation process = Global.getProject()
- // .getProcessInformation(pData.getPid());
- if (pData.getProbeType() != AnalyzerConstants.FUNCTION_TYPE_FILE) {
- int apiId = SymbolManager.getFuncId(pData, pData.getPcAddr(),
- pData.getPid(), pData.getTime());
- String apiName = Global.getFunctionName(apiId);
- // TODO : <unknown function> check with apiId
- if (apiId == -1 || apiName.equals("<unknown function>")) {
- continue;
- } else {
- pData.setApiId(apiId);
- }
-
- // if (process.isDropLog()) {
- // if (apiName.contains("main")) {
- // process.setDropLog(false);
- // } else {
- // continue;
- // }
- // }
-
- pushLog(log, logPack);
- AnalyzerManager.getCallstackManager().makeUserCallstack(
- pData,
- FunctionUsageProfiler.getInstance().getProfileDataMakerByPid(
- pData.getPid()));
- // } else { // system call enter/exit : not used yet
- // pushLog(log, logPack);
- // }
- } else {
- pushLog(log, logPack);
- }
- } else { // sample log
- pushLog(log, logPack);
+ packLog(log, logPack);
+ break;
+ case MSG_FUNCTION_ENTRY:
+ case MSG_FUNCTION_EXIT:
+ if (!AnalyzerManager.isProcessInfoArrived()) {
+ break;
}
- } else if (log instanceof ReplayData) {
- pushLog(log, logPack);
- } else if (log instanceof ContextSwitchData) {
- pushLog(log, logPack);
- } else {
- if (log instanceof ScreenShotData) {
- // get image file from target or ecs
- boolean bECS = false;
- String remoteImgPath;
- if (DACommunicator.isTargetEmulator()
- && SocketClient.getInstance().isConnected()) {
- Global.getCurrentDeviceInfo().emulatorScreenshot.send();
- remoteImgPath = Global.getCurrentDeviceInfo().emulatorScreenshot
- .getFilePath();
- bECS = true;
- } else {
- remoteImgPath = ((ScreenShotData) log).getImageFilePath();
- }
-
- int rotate = ((ScreenShotData) log).getOrientation();
- // TODO : fix
- if (bECS) {
- processImagefromECS(remoteImgPath, rotate);
- } else {
- processImage(remoteImgPath, rotate);
- }
+ ret = processFunctionData((ProfileData) log);
+ if (ret) {
+ packLog(log, logPack);
}
- pushLog(log, logPack);
+ break;
+ case MSG_DATA_SYSTEM:
+ case MSG_DATA_RECORD:
+ case MSG_CONTEXT_SWITCH_ENTRY:
+ case MSG_CONTEXT_SWITCH_EXIT:
+ packLog(log, logPack);
+ break;
+ case MSG_PROBE_SCREENSHOT:
+ processScreenshotData((ScreenShotData) log);
+ packLog(log, logPack);
AnalyzerManager.getCallstackManager().makeCallstackWithoutBacktrace(log);
- // if (id == DataChannelConstants.MSG_PROBE_FILE
- // || id == DataChannelConstants.MSG_PROBE_MEMORY) {
- // AnalyzerManager.getLeakDetector().runLeakDectect(log);
- // }
- //
- // AnalyzerManager.getFailedChecker().check(log);
+ break;
+ default:
+ packLog(log, logPack);
+ AnalyzerManager.getCallstackManager().makeCallstackWithoutBacktrace(log);
+ break;
}
}
*/
package org.tizen.dynamicanalyzer.swap.logparser;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
import org.tizen.dynamicanalyzer.swap.model.DATime;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogDataFactory;
--import org.tizen.dynamicanalyzer.swap.model.data.LogDataUtils;
import org.tizen.dynamicanalyzer.ui.thread.data.ThreadDataManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.StartProcessManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.StopLogProcessor;
-import org.tizen.dynamicanalyzer.ui.toolbar.StopProcessManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
--import org.tizen.dynamicanalyzer.util.ByteUtil;
import org.tizen.dynamicanalyzer.util.CommonUtil;
import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
-
-public class MessageParser {
- static final boolean PRINT_DATA_LOG_TOFILE = false;
- static final int MSG_ID_INDEX = 0;
- static final int MSG_LENGTH_INDEX = 1;
- static final int MSG_PAYLOAD_INDEX = 2;
- static final int MSG_SPLIT_SIZE = 3;
+public class MessageParser implements Runnable {
+ private static boolean PRINT_DATA_LOG_TOFILE = false;
/* Message Buffer max length */
- static final int MSG_BUFFER_MAX = 5000;
- static final int MSG_BUFFER_TIMER_DELAY = 5;
- static final int MSG_BUFFER_TIMER_PERIOD = 1000; // 1 second
- static final int WAITING_TIME = 10;
-
- private static final int SOCKET_TIMEOUT_NORMAL = 5000; // 5 second
- private static final int SOCKET_TIMEOUT_ABNORMAL = 1000; // 1 second
- private static final int EMPTY_BUFFER_SIZE = 1024;
-
- 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;
-
- @Override
- public void run() {
- if (!buffer.isEmpty()) {
- addBufferToList();
- count = 0;
- } else {
- count++;
- if (count >= WAITING_TIME) {
- ToolbarArea.getInstance().stopTrace();
- }
+ private static final int MSG_BUFFER_MAX = 5000;
+ private static final int MSG_BUFFER_TIMER_DELAY = 5;
+ private static final int MSG_BUFFER_TIMER_PERIOD = 1000; // 1 second
+
+ private static Thread thread = null;
+ private static MessageParser instance = null;
+
+ private BlockingQueue<LogData> queue = new LinkedBlockingQueue<LogData>();
+ private LogList sendBuffer = new LogList();
+ private Lock lock = new ReentrantLock();
+ private Timer timer = null;
+
+ public static DAResult start() {
+ if (thread != null && thread.isAlive()) {
+ try {
+ thread.interrupt();
+ thread.join();
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_START_MESSAGE_PARSER;
}
}
+
+ instance = new MessageParser();
+ thread = new Thread(null, instance, AnalyzerConstants.MESSAGE_PARSER_THREAD);
+ thread.start();
+
+ return DAResult.SUCCESS;
}
- private List<LogData> buffer = new ArrayList<LogData>();
- private Lock lock = new ReentrantLock();
- private Timer timer = null;
+ public static DAResult stopNormal() {
+ // do nothing to stop thread
+ // just wait the thread is terminated by itself
+ if (thread != null && thread.isAlive()) {
+ // wait until data channel thread is terminated
+ try {
+ thread.join(); // wait forever
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_STOP_MESSAGE_PARSER;
+ }
+ }
- private static MessageParser receivedMessage = new MessageParser();
- private int messageCount = 0;
+ if (instance != null) {
+ instance.clear();
+ }
+ instance = null;
- public static MessageParser getInstance() {
- return receivedMessage;
+ return DAResult.SUCCESS;
}
- public void startTimer() {
+ public static DAResult stopForced() {
+ if (thread != null && thread.isAlive()) {
+ // wait until data channel thread is terminated
+ try {
+ thread.interrupt();
+ thread.join(); // wait forever
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return DAResult.ERR_STOP_MESSAGE_PARSER;
+ }
+ }
+
+ if (instance != null) {
+ instance.clear();
+ }
+ instance = null;
+
+ return DAResult.SUCCESS;
+ }
+
+ public static void pushLog(LogData data) throws InterruptedException {
+ if (instance != null) {
+ instance.queue.put(data);
+ }
+ }
+
+ private void startTimer() {
timer = new Timer(AnalyzerConstants.HANDOVER_TIMER);
- timer.scheduleAtFixedRate(new AddBufferTimerTask(), MSG_BUFFER_TIMER_DELAY,
- MSG_BUFFER_TIMER_PERIOD);
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ if (!sendBuffer.isEmpty()) {
+ sendDataToLogParser();
+ }
+ }
+ }, MSG_BUFFER_TIMER_DELAY, MSG_BUFFER_TIMER_PERIOD);
}
- public void stopTimer() {
+ private void stopTimer() {
if (null != timer) {
timer.cancel();
timer = null;
}
}
- private void addBufferToList() {
+ private void sendDataToLogParser() {
lock.lock();
try {
- if (null != buffer && 0 != buffer.size()) {
- SWAPLogParser.getLogQueue().putLog(buffer);
+ try {
+ if (null != sendBuffer && 0 != sendBuffer.size()) {
+ LogParser.pushLog(sendBuffer);
+ }
+
+ sendBuffer = new LogList();
+ } catch (InterruptedException e) {
+ // do not reset send buffer
- e.printStackTrace();
++ Logger.exception(e);
}
- buffer = new ArrayList<LogData>();
} finally {
lock.unlock();
}
}
- private void processProcessInfo(byte[] data) {
+ private boolean pushEOQ() {
+ try {
+ LogParser.pushLog(LogList.END_OF_QUEUE);
+ return true;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return false;
+ }
+ }
+
+ private void clear() {
+ stopTimer();
+ queue.clear();
+ sendBuffer.clear();
+ }
+
+ @Override
+ public void run() {
+ PrintWriter printWriter = getDebugWriter();
+
+ try {
+ synchronized (AnalyzerManager.waitStartAck) {
+ try {
+ while (Global.getProject().getProfilingStartTime() == null) {
+ AnalyzerManager.waitStartAck.wait();
+ }
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return;
+ }
+ }
+
+ startTimer();
+
+ LogData log;
+ while (true) {
+ try {
+ log = queue.take();
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ break;
+ }
+
+ if (log == LogData.END_OF_QUEUE) {
+ break;
+ }
+
+ printLog(printWriter, log);
+
+ processMessage(log);
+ }
+ } finally {
+ stopTimer();
+ sendDataToLogParser();
+ pushEOQ();
+
+ if (printWriter != null) {
+ CommonUtil.tryClose(printWriter);
+ }
+ }
+ }
+
+ private PrintWriter getDebugWriter() {
+ PrintWriter printWriter = null;
+
+ if (PRINT_DATA_LOG_TOFILE) {
+ File logPath = new File(PathManager.DA_DEBUG_DATA_CHANNEL_LOG_FILE);
+ if (logPath.exists()) {
+ logPath.delete();
+ }
+
+ try {
+ printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true);
+ } catch (IOException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ }
+
+ return printWriter;
+ }
+
+ private void printLog(PrintWriter printWriter, LogData log) {
+ if (printWriter != null) {
+ int payloadSize = log.getPayloadSize();
+ byte[] payload = log.getPayload();
+ printWriter.printf("%d %d %d %d :", log.getMsgID(), log.getSeq(), log.getTime(),
+ payloadSize);
+ for (int i = 0; i < payloadSize; i++)
+ printWriter.printf("%02x ", payload[i]);
+ printWriter.printf("\n");
+ }
+ }
+
- // private void endingSteps() {
- // Logger.debug("Ending steps!");
- // DACommunicator.setRunning(false);
- // AnalyzerManager.setRunningState(false);
- // Global.setCurrentState(STATE.PREPARE_END);
- //
- // ToolbarArea.getInstance().changeUIState(STATE.PREPARE_END);
- //
- // stopTimer();
- // Logger.performance("TEST", "DA end", "Stop timer");
- // sendDataToLogParser();
- // Logger.performance("TEST", "DA end", "Add buffer to list");
- //
- // // stop DB insert thread
- // DBInsertManager.stopInserters();
- //
- // // if (!StartProcessManager.getInstance().isCancelled()) {
- // // Logger.debug("start!! : stop log process");//$NON-NLS-1$
- // // StopLogProcessor.runStopLogProcessThread();
- // // }
- //
- // AnalyzerUtil.executeCommand(StopHandler.ID);
- // Logger.performance("TEST", "DA end", "Execute command - StopHandler");
- // AnalyzerManager.setProcessInfoArrived(false);
- // ReplayManager.reset();
- // }
-
+ // return false if message id is unknown
+ private boolean processMessage(LogData log) {
+ boolean bret = true;
+ int id = log.getMsgID();
+ switch (id) {
+ case DataChannelConstants.MSG_DATA_PROCESS_INFO:
+ // setting process info
+ processProcessInfo(log);
+ break;
+ case DataChannelConstants.MSG_PROCESS_MAP:
+ case DataChannelConstants.MSG_PROCESS_UNMAP:
+ memoryMapChanged(log);
+ break;
+ case DataChannelConstants.MSG_DATA_TERMINATE:
+ processTerminate();
+ break;
+ case DataChannelConstants.MSG_DATA_ERROR:
+ // process error message
+ break;
+ case DataChannelConstants.MSG_DATA_SYSTEM:
+ case DataChannelConstants.MSG_FUNCTION_ENTRY:
+ case DataChannelConstants.MSG_FUNCTION_EXIT:
+ case DataChannelConstants.MSG_DATA_SAMPLE:
+ case DataChannelConstants.MSG_CONTEXT_SWITCH_ENTRY:
+ case DataChannelConstants.MSG_CONTEXT_SWITCH_EXIT:
+ case DataChannelConstants.MSG_DATA_RECORD:
+ if (AnalyzerManager.isProcessInfoArrived()) {
+ log.makeDataPublic(Global.getProject().getProfilingStartTime());
+ sendBuffer.add(log);
+ }
+ break;
+ case DataChannelConstants.MSG_PROCESS_COMM:
+ processAddInfo(log);
+ break;
+ case DataChannelConstants.MSG_DATA_IMAGE:
+ // process image message
+ break;
+ default:
+ if (id >= DataChannelConstants.MSG_PROBE_MIN
+ && id <= DataChannelConstants.MSG_PROBE_MAX) { // MSG_PROBE
+ if (AnalyzerManager.isProcessInfoArrived()) {
+ log.makeDataPublic(Global.getProject().getProfilingStartTime());
+ sendBuffer.add(log);
+ }
+ } else {
+ // unknown message id
+ bret = false;
+ }
+ break;
+ }
+
+ if (MSG_BUFFER_MAX <= sendBuffer.size()) {
+ sendDataToLogParser();
+ }
+
+ return bret;
+ }
+
+ private void processProcessInfo(LogData log) {
Project project = Global.getProject();
- byte[] data = log.getPayload();
- int index = 0;
- int pid = 0;
- int ppid = 0;
- long lowAddr = 0;
- long highAddr = 0;
- String targetBinaryPath = null;
- int dependantLibCount = 0;
- String commandLineName = null;
--
- int pid = ByteUtil.toInt(data, index);
- int index = MSG_HEADER_SIZE;
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-
- int length = LogDataUtils.getStringLength(index, data);
- String commandLineName = new String(data, index, length);
- index += length;
-
- int ppid = ByteUtil.toInt(data, index);
- commandLineName = ByteUtil.getString(data, index);
- index += ByteUtil.getStringLength(data, index);
- ppid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-
-- int sec = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-- int nano = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-
- long lowAddr = ByteUtil.toLong(data, index);
- lowAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
- long highAddr = ByteUtil.toLong(data, index);
- highAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-
- length = LogDataUtils.getStringLength(index, data);
- String targetBinaryPath = new String(data, index, length);
- index += length;
-
- int dependantLibCount = ByteUtil.toInt(data, index);
- targetBinaryPath = ByteUtil.getString(data, index);
- index += ByteUtil.getStringLength(data, index);
- dependantLibCount = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
++ int pid = log.getInt();
++ String commandLineName = log.getString();
++ int ppid = log.getInt();
++ int sec = log.getInt();
++ int nano = log.getInt();
++ long lowAddr = log.getLong();
++ long highAddr = log.getLong();
++ String targetBinaryPath = log.getString();
++ int dependantLibCount = log.getInt();
DATime capturedTime = new DATime(sec, nano);
DATime profileStartTime = project.getProfilingStartTime();
pinfo.addProcessMemoryMap(pMap);
for (int i = 0; i < dependantLibCount; i++) {
-- long lowestAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-- long highestAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-
- length = LogDataUtils.getStringLength(index, data);
- String libPath = new String(data, index, length);
- index += length;
- String libPath = ByteUtil.getString(data, index);
++ long lowestAddr = log.getLong();
++ long highestAddr = log.getLong();
++ String libPath = log.getString();
LibraryObject libObj = new LibraryObject(project.getDeviceStatusInfo()
.getBinaryInfo(libPath).getID(), lowestAddr, highestAddr);
ThreadDataManager.getInstance().getThreadDataMaker().createMainThreadItem(pid);
}
- private void memoryMapChanged(byte[] data) {
+ private void memoryMapChanged(LogData log) {
Project project = Global.getProject();
- byte[] data = log.getPayload();
- int index = 0;
-
+ int msgID = log.getMsgID();
+
/** parsing */
- int index = 0;
- int id = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- // int seq = ByteUtils.toInt(data, index);
- index += INT_SIZE;
- int sec = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- int nano = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- // int length = ByteUtils.toInt(data, index);
- index += INT_SIZE;
-
-- int pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-- long lowAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-- long highAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
++ int pid = log.getInt();
++ long lowAddr = log.getLong();
++ long highAddr = log.getLong();
ProcessInformation pinfo = project.getProcessInformation(pid);
if (null == pinfo) {
}
ProcessMemoryMap lastMap = pinfo.getLastProcessMemoryMap();
- if (id == DataChannelConstants.MSG_PROCESS_MAP) {
+ if (lastMap != null) {
- String libPath = LogDataUtils.getString(index, data);
- index += LogDataUtils.getStringLength(index, data);
++ if (msgID == DataChannelConstants.MSG_PROCESS_MAP) {
+ // update to last memory map
++ String libPath = log.getString();
+
+ BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(libPath);
+ LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr, highAddr);
+ if (!lastMap.addLibraryMap(libObj)) {
+ Logger.error("exist library");
+ }
- if (msgID == DataChannelConstants.MSG_PROCESS_MAP) {
- // update to last memory map
- int length = LogDataUtils.getStringLength(index, data);
- String libPath = new String(data, index, length);
- index += length;
-
- BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(libPath);
- LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr, highAddr);
- if (!lastMap.addLibraryMap(libObj)) {
- Logger.error("exist library");
- }
-
- pinfo.setMappingState(true);
- } else {
- DATime changeTime = new DATime(log.getSec(), log.getNano());
- DATime profileStartTime = project.getProfilingStartTime();
- DATime subTime = changeTime.subtract(profileStartTime);
-
- if (pinfo.isMapping()) {
- // make new memory map
- ProcessMemoryMap newMap = new ProcessMemoryMap(pinfo.getPid(),
- subTime.getLongTime());
- pinfo.addProcessMemoryMap(newMap);
- newMap.copy(lastMap);
-
- // remove from new map
- newMap.removeLibrary(lowAddr, highAddr);
+ pinfo.setMappingState(true);
} else {
- // update captured time of last memory map
- pinfo.updateProcessMemoryMap(lastMap, subTime.getLongTime());
- DATime changeTime = new DATime(sec, nano);
++ DATime changeTime = new DATime(log.getSec(), log.getNano());
+ DATime profileStartTime = project.getProfilingStartTime();
+ DATime subTime = changeTime.subtract(profileStartTime);
+
+ if (pinfo.isMapping()) {
+ // make new memory map
+ ProcessMemoryMap newMap = new ProcessMemoryMap(pinfo.getPid(),
+ subTime.getLongTime());
+ pinfo.addProcessMemoryMap(newMap);
+ newMap.copy(lastMap);
+
+ // remove from new map
+ newMap.removeLibrary(lowAddr, highAddr);
+ } else {
+ // update captured time of last memory map
+ pinfo.updateProcessMemoryMap(lastMap, subTime.getLongTime());
+
+ // remove from map
+ lastMap.removeLibrary(lowAddr, highAddr);
+ }
- // remove from map
- lastMap.removeLibrary(lowAddr, highAddr);
+ pinfo.setMappingState(false);
}
-
- pinfo.setMappingState(false);
}
}
- private void processTerminate() {
- AnalyzerManager.decreaseProcessCount();
- }
-
- public void startMessageParsing(Socket dataSocket) {
- InputStream inputStream = null;
- PrintWriter printWriter = null;
-
- if (PRINT_DATA_LOG_TOFILE) {
- File logPath = new File(PathManager.DA_DEBUG_DATA_CHANNEL_LOG_FILE);
- if (logPath.exists()) {
- logPath.delete();
- }
-
- try {
- printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true);
- } catch (IOException e) {
- Logger.exception(e);
- }
- }
-
- startTimer();
- // start DB insert threads
- DBInsertManager.startInserters();
-
- try {
- long prevSeq = -1;
- byte[] header = new byte[MSG_HEADER_SIZE];
- boolean normalTerminate = true;
-
- dataSocket.setSoTimeout(SOCKET_TIMEOUT_NORMAL);
- inputStream = dataSocket.getInputStream();
-
- while (true) {
- 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) {
- normalTerminate = false;
- break;
- }
-
- // LOG!
- // Logger.debug("header log");
- // ByteUtils.printByteArrayForStart(header);
-
- boolean continuity = true;
- int id = ByteUtil.toInt(header, 0);
- long seq = ByteUtil.toUIntByLong(header, INT_SIZE);
- if (seq == 0) {
- Global.getProject().incSeqRotation();
- if (prevSeq != -1) {
- // if continuity of seq number is broken
- Logger.error("Contunuity failed (%d) (%d)", prevSeq, seq);
- continuity = false;
- }
- } else {
- if (seq != prevSeq + 1) {
- // continuity of seq number is broken
- Logger.error("Contunuity failed (%d) (%d)", prevSeq, seq);
- continuity = false;
- }
- }
- prevSeq = seq;
-
- if (!continuity) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- final Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
- DADialog dialog = new DADialog(shell, SWT.NONE, 550, 153);
- dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
- dialog.setMessage(UserErrorWarningLabels.WARNING_OVERHEAD_EXPLODE);
- dialog.open();
- }
- });
-
- normalTerminate = false;
- break;
- }
-
- int payloadSize = ByteUtil.toInt(header, MSG_PAYLOAD_SIZE_INDEX);
- if (payloadSize < 0 || payloadSize > DALimit.MAX_PAYLOAD_SIZE) {
- // wrong message format, stop profiling
- normalTerminate = false;
- break;
- }
-
- byte[] payload = null;
-
- try {
- payload = new byte[payloadSize];
- } catch (NegativeArraySizeException e) {
- Logger.exception(e);
- }
-
- 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) {
- normalTerminate = false;
- break;
- }
+ private void processAddInfo(LogData log) {
+ // process command line name is changed (/proc/<pid>/cmdline)
+ Project project = Global.getProject();
- byte[] data = log.getPayload();
- int index = 0;
-
- int pid = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- int length = LogDataUtils.getStringLength(index, data);
- String name = new String(data, index, length);
- index += length;
- 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);
++ int pid = log.getInt();
++ String name = log.getString();
- if (PRINT_DATA_LOG_TOFILE && printWriter != null) {
- printWriter.printf("%d %d %d %d %d :", id, ByteUtil.toInt(header, 4),
- ByteUtil.toInt(header, 8), ByteUtil.toInt(header, 12), payloadSize);
- for (int k = 0; k < payloadSize; k++)
- printWriter.printf("%02x ", payload[k]);
- printWriter.printf("\n");
- }
-
- if (!processMessage(buffer)) {
- // unknown message id
- normalTerminate = false;
- break;
- }
-
- if (id == DataChannelConstants.MSG_DATA_TERMINATE) {
- Logger.debug("message data terminate arrived!!!");
- Logger.performance("TEST", "While tracing", "Terminate Application");
- if (AnalyzerManager.getProcessCount() == 0) {
- normalTerminate = true;
- break;
- }
- }
- } // end while()
-
- if (!normalTerminate) {
- // send stop message to swap manager
- DACommunicator.stopTrace();
-
- // wait until receive all remaining packet from data socket
- int readSize = 0;
- byte[] tempbuf = new byte[EMPTY_BUFFER_SIZE];
-
- // exit if no data is receive in timeout
- dataSocket.setSoTimeout(SOCKET_TIMEOUT_ABNORMAL);
- while (true) {
- try {
- readSize = inputStream.read(tempbuf, 0, EMPTY_BUFFER_SIZE);
- if (readSize <= 0)
- break;
- } catch (IOException e) {
- break;
- }
- }
- }
-
- Logger.debug("Receive thread end!!");
- Logger.performance("TEST", "DA end", "End receive thread");
- if (!StartProcessManager.getInstance().isCancelled()) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- StopProcessManager.getInstance().stopProcessStart(
- AnalyzerLabels.STOP_PROCESS_DLG_SUMMARIZING_DATA); // socket
- // timeout
- }
- });
- }
- } catch (IOException e) {
- Logger.debug("### socket timeout - TODO: show this as a dialog."); //$NON-NLS-1$
-
- if (AnalyzerManager.isRunning()) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- StopProcessManager.getInstance().stopProcessStart(
- AnalyzerLabels.STOP_PROCESS_DLG_DEVICE_DISCONNECTED); // socket
- // timeout
- }
- });
- }
- } finally {
- endingSteps();
- if (printWriter != null) {
- CommonUtil.tryClose(printWriter);
- }
+ ProcessInformation process = project.getProcessInformation(pid);
+ if (null != process) {
+ process.setProcessName(name);
}
}
return name;
}
- public final void updateLog(LogPackage logPack) {
- try {
- logPackQueue.put(logPack);
- } catch (InterruptedException e) {
- Logger.exception(e);
+ public synchronized final void startThread() {
+ if (thread != null && thread.isAlive()) {
+ try {
+ thread.interrupt();
+ thread.join();
+ thread = null;
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ return;
+ }
}
- }
- private final LogPackage pollPack() {
- LogPackage pack = null;
- try {
- if (state == State.RUNNING)
- pack = logPackQueue.take(); // wait if empty
- else if (state == State.TO_BE_STOPED)
- pack = logPackQueue.poll(); // return null if empty
- } catch (InterruptedException e) {
- Logger.exception(e);
- }
+ thread = new Thread(null, this, getName());
+ thread.start();
- return pack;
+ startInserters();
}
- public synchronized final void startThread() {
- if (thread == null || !thread.isAlive()) {
- thread = new Thread(null, this, getName());
- state = State.RUNNING;
- thread.start();
+ public synchronized final void stopNormal() {
+ if (thread != null && thread.isAlive()) {
+ try {
+ thread.join();
+ thread = null;
+ Logger.debug(getName() + " thread joined!"); //$NON-NLS-1$
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
}
- clearAll();
+
++ clearQueue();
+
+ stopInsertersNormal();
}
- // "called stopThread" means that there is no more data
- // coming in this page data manager
- // It means that this function should be called only in data offerer
- // when all data offer is finished.
- public synchronized final void stopThread() {
+ public synchronized final void stopForced() {
if (thread != null && thread.isAlive()) {
try {
- state = State.TO_BE_STOPED;
- sendNotify();
- thread.join(AnalyzerConstants.THREAD_JOIN_WAIT_TIME);
+ thread.interrupt();
+ thread.join();
thread = null;
Logger.debug(getName() + " thread joined!"); //$NON-NLS-1$
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
}
}
- }
- clearAll();
- private final void clear() {
- state = State.NOT_RUNNING;
- logPackQueue.clear();
++ clearQueue();
+
+ stopInsertersForced();
}
public final boolean isThreadAlive() {
return true;
}
- private void sendNotify() {
- LogPackage endOfStream = new LogPackage();
- endOfStream.setEndOfStream();
+ public final void updateLog(LogPackage logPack) {
+ try {
+ logPackQueue.put(logPack);
+ } catch (InterruptedException e) {
- e.printStackTrace();
++ Logger.exception(e);
+ }
+ }
+ private final LogPackage pollPack() {
+ LogPackage pack = null;
try {
- logPackQueue.put(endOfStream);
+ pack = logPackQueue.take(); // wait if empty
} catch (InterruptedException e) {
- e.printStackTrace();
+ Logger.exception(e);
}
- private final void clearAll() {
+
+ return pack;
+ }
+
++ private final void clearQueue() {
+ logPackQueue.clear();
+ }
+
+ public final DBInserter makeInserter(DBTable table) {
+ DBInserter ret = null;
+ String tablename = table.getTableName();
+ if (!insertThreads.containsKey(tablename)) {
+ DBInserter thread = new DBInserter(table);
+ table.setDBInserter(thread);
+ insertThreads.put(tablename, thread);
+ ret = thread;
+ } else {
+ ret = insertThreads.get(tablename);
+ }
+ return ret;
+ }
+
+ public final DBInserter getInserter(String tablename) {
+ return insertThreads.get(tablename);
+ }
+
+ private final void startInserters() {
+ for (Map.Entry<String, DBInserter> entry : insertThreads.entrySet()) {
+ DBInserter inserter = entry.getValue();
+ inserter.start();
+ }
+ }
+
+ private final void stopInsertersNormal() {
+ for (Map.Entry<String, DBInserter> entry : insertThreads.entrySet()) {
+ DBInserter thread = entry.getValue();
+ thread.stopNormal();
+ }
+ }
+
+ private final void stopInsertersForced() {
+ for (Map.Entry<String, DBInserter> entry : insertThreads.entrySet()) {
+ DBInserter thread = entry.getValue();
+ thread.stopForced();
+ }
+ }
+
+ private final void setToStopInserter() {
+ for (Map.Entry<String, DBInserter> entry : insertThreads.entrySet()) {
+ DBInserter thread = entry.getValue();
+ thread.setToStop();
+ }
}
@Override
onThreadStop();
- Logger.debug(getName() + " thread end!!"); //$NON-NLS-1$
+ setToStopInserter();
+
- clearAll();
++ clearQueue();
- clear();
+ /* log for debug */
+ Logger.debug(getName() + " thread end!!"); //$NON-NLS-1$
+ }
++
++ public void clear() {
++
+ }
protected abstract void makeData(LogPackage pack);
--- /dev/null
--- /dev/null
++/*
++ * Dynamic Analyzer
++ *
++ * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
++ *
++ * Contact:
++ * Jaewon Lim <jaewon81.lim@samsung.com>
++ * Jooyoul Lee <jy.exe.lee@samsung.com>
++ * Juyoung Kim <j0.kim@samsung.com>
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ *
++ * Contributors:
++ * - S-Core Co., Ltd
++ *
++ */
++package org.tizen.dynamicanalyzer.swap.model.data;
++
++import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
++import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
++import static org.tizen.dynamicanalyzer.constant.CommonConstants.FLOAT_SIZE;
++import static org.tizen.dynamicanalyzer.constant.CommonConstants.DOUBLE_SIZE;
++
++import org.tizen.dynamicanalyzer.constant.CommonConstants;
++import org.tizen.dynamicanalyzer.util.ByteUtil;
++import org.tizen.dynamicanalyzer.util.UnsignedInt;
++import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
++
++public class ByteStreamData {
++
++ private int index = 0;
++ private int payloadSize = 0;
++ private byte[] payload = null;
++
++ protected ByteStreamData() {
++ }
++
++ public ByteStreamData(int index, int payloadSize, byte[] payload) {
++ this.index = index;
++ this.payloadSize = payloadSize;
++ this.payload = payload;
++ }
++
++ protected void initPayload(int size) {
++ payloadSize = size;
++ if (payloadSize > 0) {
++ payload = new byte[payloadSize];
++ }
++ }
++
++ protected void releasePayload() {
++ payload = null;
++ }
++
++ public final int getPayloadSize() {
++ return payloadSize;
++ }
++
++ public final byte[] getPayload() {
++ return payload;
++ }
++
++ public final int getShort() {
++ byte[] temp = new byte[4];
++ System.arraycopy(payload, index, temp, 0, 2);
++ int ret = ByteUtil.toInt(temp, 0);
++ index += 2;
++ return ret;
++ }
++
++ public final int getInt() {
++ int ret = ByteUtil.toInt(payload, index);
++ index += INT_SIZE;
++ return ret;
++ }
++
++ public final UnsignedInt getUnsignedInt() {
++ UnsignedInt ret = ByteUtil.toUnsignedInt(payload, index);
++ index += INT_SIZE;
++ return ret;
++ }
++
++ public final long getLong() {
++ long ret = ByteUtil.toLong(payload, index);
++ index += LONG_SIZE;
++ return ret;
++ }
++
++ public final float getFloat() {
++ float ret = ByteUtil.toFloat(payload, index);
++ index += FLOAT_SIZE;
++ return ret;
++ }
++
++ public final double getDouble() {
++ double ret = ByteUtil.toDouble(payload, index);
++ index += DOUBLE_SIZE;
++ return ret;
++ }
++
++ public final String getString() {
++ int length = getStringLength();
++ String ret = new String(payload, index, length - 1); // exclude last null character
++ index += length;
++ return ret;
++ }
++
++ private int getStringLength() {
++ int length = 0;
++ for (int i = index; i < payload.length; i++, length++) {
++ if (payload[i] == 0) {
++ length++;
++ break;
++ }
++ }
++ return length;
++ }
++
++ protected final String getByteString(int size) {
++ String ret = new String(payload, index, size);
++ index += size;
++ return ret;
++ }
++
++ protected final String parseArgs() {
++ int countOfArgs = getInt();
++
++ StringBuffer buffer = new StringBuffer();
++ for (int ii = 0; ii < countOfArgs; ii++) {
++ parseSingleArg(buffer);
++
++ if (ii + 1 != countOfArgs) {
++ buffer.append(CommonConstants.COMMA).append(CommonConstants.SPACE);
++ }
++ }
++
++ return buffer.toString();
++ }
++
++ protected String parseReturn() {
++ StringBuffer buffer = new StringBuffer();
++ parseSingleArg(buffer);
++ return buffer.toString();
++ }
++
++ private void parseSingleArg(StringBuffer buffer) {
++ char c = (char) payload[index];
++ index += 1;
++
++ switch (c) {
++ case 'c': {
++ buffer.append((payload[index]));
++ index += 1;
++ break;
++ }
++
++ case 'd': {
++ int iValue = getInt();
++ buffer.append(iValue);
++ break;
++ }
++
++ case 'x': {
++ long lValue = getLong();
++ buffer.append(lValue);
++ break;
++ }
++
++ case 'p': {
++ long pValue = getLong();
++ buffer.append(AnalyzerUtil.toHexdecimal(pValue));
++ break;
++ }
++
++ case 'f': {
++ float fValue = getFloat();
++ buffer.append(fValue);
++ break;
++ }
++
++ case 'w': {
++ double dValue = getDouble();
++ buffer.append(dValue);
++ break;
++ }
++
++ case 'b': {
++ byte b = payload[index++];
++ if (b == 0) {
++ buffer.append("false");
++ } else {
++ buffer.append("true");
++ }
++ break;
++ }
++
++ case 's': {
++ for (int iii = index; iii < payload.length; iii++) {
++ if (payload[iii] != 0) {
++ buffer.append((char) payload[iii]);
++ } else {
++ index = iii + 1;
++ break;
++ }
++ }
++ break;
++ }
++
++ case 'F': {
++ long object = getLong();
++ buffer.append(AnalyzerUtil.toHexdecimal(object));
++ int arrarySize = getInt();
++ buffer.append(CommonConstants.OPEN_SQUARE_BRACKET);
++ for (int i = 0; i < arrarySize; i++) {
++ float fValue = getFloat();
++ buffer.append(fValue);
++ if (i != arrarySize - 1) {
++ buffer.append(CommonConstants.COMMA);
++ }
++ }
++ buffer.append(CommonConstants.CLOSE_SQUARE_BRACKET);
++ }
++
++ default:
++ break;
++ }
++ }
++
++}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ContextSwitchData extends LogData {
-
- long pcAddr = 0;
- int pid = 0;
- int tid = 0;
- int cpuNum = 0;
+ protected long pcAddr = 0;
+ protected int pid = 0;
+ protected int tid = 0;
+ protected int cpuNum = 0;
public ContextSwitchData() {
}
return log;
}
- public boolean makeData(byte[] data) {
- super.makeData(data);
- index = MessageParser.MSG_HEADER_SIZE;
-
- pcAddr = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
- pid = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- tid = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- cpuNum = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- pcAddr = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
- pid = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
- tid = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
- cpuNum = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
++ pcAddr = getLong();
++ pid = getInt();
++ tid = getInt();
++ cpuNum = getInt();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ControlData extends ProbeCommonData {
private String parentName = null;
public ControlData() {
}
+
+ @Override
+ public ControlData clone() throws CloneNotSupportedException {
+ ControlData log = (ControlData) super.clone();
+ log.parentName = this.parentName;
+ log.parentClassName = this.parentClassName;
+ log.parentPointer = this.parentPointer;
+ log.childName = this.childName;
+ log.childClassName = this.childClassName;
+ log.childPointer = this.childPointer;
+
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- int length = LogDataUtils.getStringLength(index, payload);
- parentName = new String(payload, index, length);
- public boolean 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, payload);
- parentClassName = new String(payload, 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 = ByteUtil.toLong(payload, index);
- parentPointer = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
--
- length = LogDataUtils.getStringLength(index, payload);
- childName = new String(payload, index, length);
- 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, payload);
- childClassName = new String(payload, 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 = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
- childPointer = ByteUtil.toLong(data, index);
--
++ parentName = getString();
++ parentClassName = getString();
++ parentPointer = getLong();
++ childName = getString();
++ childClassName = getString();
++ childPointer = getLong();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
- import static org.tizen.dynamicanalyzer.constant.CommonConstants.DOUBLE_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class CustomData extends ProbeCommonData {
- int handle = 0;
- int type = 0;
- String name = null;
- int color = 0;
- double value = 0;
+ protected int handle = 0;
+ protected int type = 0;
+ protected String name = null;
+ protected int color = 0;
+ protected double value = 0;
- public CustomData(){}
+ public CustomData(){
+ }
- public boolean makeData(byte[] data) {
- super.makeData(data);
-
- handle = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- type = ByteUtil.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 = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- value = ByteUtil.toDouble(data, index);
-
+ @Override
+ public CustomData clone() throws CloneNotSupportedException {
+ CustomData log = (CustomData) super.clone();
+ log.handle = this.handle;
+ log.type = this.type;
+ log.name = this.name;
+ log.color = this.color;
+ log.value = this.value;
+
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- handle = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- type = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- int length = LogDataUtils.getStringLength(index, payload);
- name = new String(payload, index, length);
- index += length;
-
- color = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- value = ByteUtil.toDouble(payload, index);
- index += DOUBLE_SIZE;
-
++ handle = getInt();
++ type = getInt();
++ name = getString();
++ color = getInt();
++ value = getDouble();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class FileData extends ProbeCommonData {
protected int fdApiType = 0; // TODO: short
protected long fileSize = 0;
protected String filePath = null;
-
+
+ public FileData() {
+ }
+
+ @Override
+ public FileData clone() throws CloneNotSupportedException {
+ FileData log = (FileData) super.clone();
+ log.size = this.size;
+ log.fdValue = this.fdValue;
+ log.fdApiType = this.fdApiType;
+ log.fileSize = this.fileSize;
+ log.filePath = this.filePath;
+
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- size = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- fdValue = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- fdApiType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- fileSize = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- int length = LogDataUtils.getStringLength(index, payload);
- filePath = new String(payload, index, length);
- index += length;
-
++ size = getLong();
++ fdValue = getLong();
++ fdApiType = getInt();
++ fileSize = getLong();
++ filePath = getString();
+ return true;
+ }
+
public long getSize() {
return size;
}
package org.tizen.dynamicanalyzer.swap.model.data;
--import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class GLES20LogData extends ProbeCommonData {
protected long glCurrentContextName = 0;
- int apiType = 0;
- long elapsedTime = 0;
- String contextValue = "";
+ protected int apiType = 0;
+ protected long elapsedTime = 0;
+ protected String contextValue = null;
@Override
- public boolean makeData(byte[] data) {
- super.makeData(data);
- glCurrentContextName = ByteUtil.toLong(data, index);
- index += CommonConstants.LONG_SIZE;
+ public GLES20LogData clone() throws CloneNotSupportedException {
+ GLES20LogData log = (GLES20LogData) super.clone();
+ log.glCurrentContextName = this.glCurrentContextName;
+ log.apiType = this.apiType;
+ log.elapsedTime = this.elapsedTime;
+ log.contextValue = this.contextValue;
- apiType = ByteUtil.toInt(data, index);
- index += CommonConstants.INT_SIZE;
+ return log;
+ }
- elapsedTime = ByteUtil.toLong(data, index)/1000;
- index += CommonConstants.LONG_SIZE;
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- glCurrentContextName = ByteUtil.toLong(payload, index);
- index += CommonConstants.LONG_SIZE;
-
- apiType = ByteUtil.toInt(payload, index);
- index += CommonConstants.INT_SIZE;
-
- elapsedTime = ByteUtil.toLong(payload, index) / 1000L;
- index += CommonConstants.LONG_SIZE;
-
- int length = LogDataUtils.getStringLength(index, payload);
- contextValue = new String(payload, index, length);
- index += length;
-
- int length = LogDataUtils.getStringLength(index, data);
- byte[] temp = new byte[length];
- System.arraycopy(data, index, temp, 0, length);
- contextValue = new String(temp);
-
++ glCurrentContextName = getLong();
++ apiType = getInt();
++ elapsedTime = getLong() / 1000L;
++ contextValue = getString();
return true;
}
import org.tizen.dynamicanalyzer.swap.model.DATime;
import org.tizen.dynamicanalyzer.util.ByteUtil;
import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.util.UnsignedInt;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
- public class LogData implements Cloneable {
-public abstract class LogData implements Cloneable {
- public static boolean isSWAP = false;
- public static int STATE_COUNT = 4;
-
- protected int index = 0;
++public class LogData extends ByteStreamData implements Cloneable {
+ public static final LogData END_OF_QUEUE = new LogData();
- protected int index = 0;
-
- int id = -1;
+ protected int msgID = -1;
protected long seq = -1;
+ protected int sec = 0;
+ protected int nano = 0;
protected long time = 0;
- private int payloadSize = 0;
- protected byte[] payload = null;
- protected String libName = null;
--
public LogData() {
}
public LogData clone() throws CloneNotSupportedException {
LogData log = (LogData) super.clone();
-- log.index = this.index;
- log.id = this.id;
+ log.msgID = this.msgID;
log.seq = this.seq;
+ log.sec = this.sec;
+ log.nano = this.nano;
log.time = this.time;
- log.libName = this.libName;
return log;
}
- public boolean makeData(byte[] data) {
- isSWAP = DACommunicator.isSWAPVersion();
-
- id = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ public final void init(byte[] header) {
+ msgID = ByteUtil.toInt(header, DataChannelConstants.MSGID_INDEX);
+ seq = ByteUtil.toUIntByLong(header, DataChannelConstants.SEQNUM_INDEX);
+ sec = ByteUtil.toInt(header, DataChannelConstants.TIME_SEC_INDEX);
+ nano = ByteUtil.toInt(header, DataChannelConstants.TIME_NANO_INDEX);
-
- payloadSize = ByteUtil.toInt(header, DataChannelConstants.PAYLOADLEN_INDEX);
- if (payloadSize > 0) {
- payload = new byte[payloadSize];
- }
+
- int seqRot = Global.getProject().getSeqRotation();
- UnsignedInt subSeq = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- seq = (((long)seqRot) << 32 | subSeq.getValue());
-
- long sec = ByteUtil.toInt(data, index);
- index += INT_SIZE;
- long nano = ByteUtil.toInt(data, index);
- index += INT_SIZE;
++ initPayload(ByteUtil.toInt(header, DataChannelConstants.PAYLOADLEN_INDEX));
+ }
- DATime startTime = Global.getProject().getProfilingStartTime();
- long startSec = startTime.getSec();
- long startNano = startTime.getNano();
- long resultSec = sec - startSec;
- long resultNano = nano - startNano;
+ protected boolean makeData(DATime startTime) {
+ long resultSec = sec - startTime.getSec();
+ long resultNano = nano - startTime.getNano();
time = resultSec * 1000000 + resultNano / 1000;
- if (time <= 0) {
- Logger.warning("id : " + AnalyzerUtil.toHexdecimal(id)
- + " time : " + time);
- Logger.warning("profile start time : "
- + startTime.toString() + " time : " + sec + ","
+ if (time < 0) {
+ Logger.warning("id : " + AnalyzerUtil.toHexdecimal(msgID) + " time : " + time);
+ Logger.warning("profile start time : " + startTime.toString() + " time : " + sec + ","
+ nano);
}
return true;
}
- public int getKey() {
- Long key = getSeq();
- return key.hashCode();
+ public boolean makeDataPublic(DATime startTime) {
+ boolean result = makeData(startTime);
+ // release payload buffer for GC
- payload = null;
++ releasePayload();
+
+ return result;
}
- public int getPayloadSize() {
- return payloadSize;
- }
-
- // indicate DB row number
- public int getLogNum() {
- return 0;
+ public int getKey() {
+ return (int) (seq ^ (seq >>> 32));
}
- public int getId() {
- return id;
+ public final int getMsgID() {
+ return msgID;
}
- public void setId(int id) {
- this.id = id;
+ public final void setMsgID(int id) {
+ this.msgID = id;
}
- public long getSeq() {
+ public final long getSeq() {
return seq;
}
this.time = time;
}
- public final byte[] getPayload() {
- return payload;
- }
-
- public abstract int getPid();
+ public int getPid() {
+ return 0;
+ }
- public String getLibName() {
- return libName;
+ public int getSec() {
+ return sec;
}
- public void setLibName(String libName) {
- this.libName = libName;
+ public int getNano() {
+ return nano;
}
}
+++ /dev/null
--/*
-- * Dynamic Analyzer
-- *
-- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
-- *
-- * Contact:
-- * Jaewon Lim <jaewon81.lim@samsung.com>
-- * Jooyoul Lee <jy.exe.lee@samsung.com>
-- * Juyoung Kim <j0.kim@samsung.com>
-- *
-- * Licensed under the Apache License, Version 2.0 (the "License");
-- * you may not use this file except in compliance with the License.
-- * You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- *
-- * Contributors:
-- * - S-Core Co., Ltd
-- *
-- */
--package org.tizen.dynamicanalyzer.swap.model.data;
--
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.DOUBLE_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.FLOAT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
--import org.tizen.dynamicanalyzer.constant.CommonConstants;
--import org.tizen.dynamicanalyzer.util.ByteUtil;
--import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
--
--public class LogDataUtils {
--
-- public static ArgsInfo parseArgs(byte[] payload, int index) {
-- ArgsInfo args = new ArgsInfo();
-- int countOfArgs = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- StringBuffer buffer = new StringBuffer();
-- for (int ii = 0; ii < countOfArgs; ii++) {
-- char c = (char) payload[index];
-- index += 1;
-- switch (c) {
-- case 'c': {
-- buffer.append((payload[index]));
-- index += 1;
-- break;
-- }
--
-- case 'd': {
-- int iValue = ByteUtil.toInt(payload, index);
-- buffer.append(iValue);
-- index += Integer.SIZE / Byte.SIZE;
-- break;
-- }
--
-- case 'x': {
-- long lValue = ByteUtil.toLong(payload, index);
-- buffer.append(lValue);
-- index += LONG_SIZE;
-- break;
-- }
--
-- case 'p': {
-- long pValue = ByteUtil.toLong(payload, index);
-- buffer.append(AnalyzerUtil.toHexdecimal(pValue));
-- index += LONG_SIZE;
-- break;
-- }
--
-- case 'f': {
-- float fValue = ByteUtil.toFloat(payload, index);
-- buffer.append(fValue);
-- index += FLOAT_SIZE;
-- break;
-- }
-- case 'w': {
-- double dValue = ByteUtil.toDouble(payload, index);
-- buffer.append(dValue);
-- index += DOUBLE_SIZE;
-- break;
-- }
--
-- case 'b': {
-- byte b = payload[index++];
-- if (b == 0) {
-- buffer.append("false");
-- } else {
-- buffer.append("true");
-- }
-- break;
-- }
--
-- case 's': {
-- // Logger.debug("args payload size : " + payload.length);
-- for (int iii = index; iii < payload.length; iii++) {
-- if (payload[iii] != 0) {
-- buffer.append((char) payload[iii]);
-- } else {
-- index = iii + 1;
-- break;
-- }
-- }
-- break;
-- }
-- case 'F': {
-- long object = ByteUtil.toLong(payload, index);
-- buffer.append(AnalyzerUtil.toHexdecimal(object));
-- index += LONG_SIZE;
-- int arrarySize = ByteUtil.toInt(payload, index);
-- index += INT_SIZE;
-- buffer.append(CommonConstants.OPEN_SQUARE_BRACKET);
-- for (int i = 0; i < arrarySize; i++) {
-- float fValue = ByteUtil.toFloat(payload, index);
-- buffer.append(fValue);
-- index += FLOAT_SIZE;
-- if (i != arrarySize - 1) {
-- buffer.append(CommonConstants.COMMA);
-- }
-- }
-- buffer.append(CommonConstants.CLOSE_SQUARE_BRACKET);
-- }
--
-- default:
-- break;
-- }
-- if (ii + 1 != countOfArgs) {
-- buffer.append(CommonConstants.COMMA).append(
-- CommonConstants.SPACE);
-- }
-- }
--
-- args.setArgs(buffer.toString());
-- args.setLastIndex(index);
--
-- // Logger.debug("Args result :" + buffer.toString());
--
-- return args;
-- }
--
-- public static ArgsInfo parseReturn(byte[] payload, int index) {
-- ArgsInfo args = new ArgsInfo();
-- StringBuffer buffer = new StringBuffer();
-- char c = (char) payload[index];
-- index += 1;
-- switch (c) {
-- case 'c':
-- buffer.append((payload[index]));
-- index += 1;
-- break;
-- case 'd':
-- int iValue = ByteUtil.toInt(payload, index);
-- buffer.append(iValue);
-- index += Integer.SIZE / Byte.SIZE;
-- break;
-- case 'x':
-- long lValue = ByteUtil.toLong(payload, index);
-- buffer.append(lValue);
-- index += LONG_SIZE;
-- break;
-- case 'p':
-- long pValue = ByteUtil.toLong(payload, index);
-- buffer.append(AnalyzerUtil.toHexdecimal(pValue));
-- index += LONG_SIZE;
-- break;
-- case 'f':
-- float fValue = ByteUtil.toFloat(payload, index);
-- buffer.append(fValue);
-- index += FLOAT_SIZE;
-- break;
-- case 'w':
-- double dValue = ByteUtil.toDouble(payload, index);
-- buffer.append(dValue);
-- index += DOUBLE_SIZE;
-- break;
-- case 'b':
-- byte b = payload[index++];
-- if (b == 0) {
-- buffer.append("false");
-- } else {
-- buffer.append("true");
-- }
-- break;
-- case 's':
-- // Logger.debug("args payload size : " + payload.length);
-- for (int iii = index; iii < payload.length; iii++) {
-- if (payload[iii] != 0) {
-- buffer.append((char) payload[iii]);
-- } else {
-- index = iii + 1;
-- break;
-- }
-- }
-- break;
-- default:
-- break;
-- }
--
-- args.setArgs(buffer.toString());
-- args.setLastIndex(index);
-- return args;
-- }
--
-- public static int getStringLength(int start, byte[] payload) {
-- int length = 0;
-- for (int i = start; i < payload.length; i++, length++) {
-- if (payload[i] == 0) {
-- length++;
-- break;
-- }
-- }
-- return length;
- }
-
- public static String getString(int start, byte[] payload) {
- int length = LogDataUtils.getStringLength(start, payload);
- byte[] temp = new byte[length];
- System.arraycopy(payload, start, temp, 0, length);
- String str = new String(temp);
- str = str.substring(0, str.length() - 1);
- return str;
-- }
--}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class MemoryData extends ProbeCommonData {
- long size = 0;
- int apiType = 0; // TODO: short
- long address = 0;
+ protected long size = 0;
+ protected int apiType = 0; // TODO: short
+ protected long address = 0;
public MemoryData() {
}
- public boolean makeData(byte[] data) {
- super.makeData(data);
- size = ByteUtil.toInt(data, index);
+ @Override
+ public MemoryData clone() throws CloneNotSupportedException {
+ MemoryData log = (MemoryData) super.clone();
+ log.size = this.size;
+ log.apiType = this.apiType;
+ log.address = this.address;
- index += LONG_SIZE;
- apiType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- size = ByteUtil.toInt(payload, index);
- index += LONG_SIZE;
-
- apiType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- address = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- address = ByteUtil.toLong(data, index);
-
++ size = getInt();
++ apiType = getInt();
++ address = getLong();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class NetworkData extends ProbeCommonData {
- long objectAddress = 0;
- long fdValue = 0;
+ protected long objectAddress = 0;
+ protected long fdValue = 0;
protected int fdApiType = 0;
- int destinationIPAddress = 0;
- int destinationPortAddress = 0;
- protected String packetMessage = CommonConstants.EMPTY;
+ protected int destinationIPAddress = 0;
+ protected int destinationPortAddress = 0;
protected int messageSize = 0;
- objectAddress = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- fdValue = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- fdApiType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- destinationIPAddress = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- destinationPortAddress = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
+ protected String packetMessage = null;
+
+ @Override
+ public NetworkData clone() throws CloneNotSupportedException {
+ NetworkData log = (NetworkData) super.clone();
+ log.objectAddress = this.objectAddress;
+ log.fdValue = this.fdValue;
+ log.fdApiType = this.fdApiType;
+ log.destinationIPAddress = this.destinationIPAddress;
+ log.destinationPortAddress = this.destinationPortAddress;
+ log.packetMessage = this.packetMessage;
+ log.messageSize = this.messageSize;
+
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- messageSize = (int) ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
++ objectAddress = getLong();
++ fdValue = getLong();
++ fdApiType = getInt();
++ destinationIPAddress = getInt();
++ destinationPortAddress = getInt();
+
+ // TODO : may data loss by messageSize cast to int
- packetMessage = new String(payload, index, messageSize);
++ messageSize = (int) getLong();
+ if (messageSize > 0) {
++ packetMessage = getByteString(messageSize);
+ }
+
+ return true;
+ }
public long getObjectAddress() {
return objectAddress;
@Override
public int getKey() {
- return (int)(fdValue ^ (fdValue >>> 32));
- Long key = getFdValue();
- return key.hashCode();
++ return (int) (fdValue ^ (fdValue >>> 32));
}
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.DALimit;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
-import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
-import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ProbeCommonData extends LogData {
-
- public static int STATE_COUNT = LogData.STATE_COUNT + 11;
-
- protected int apiId = 0;
+ protected int apiID = 0;
protected int pid = 0;
protected int tid = 0;
protected String args = null;
}
@Override
- public boolean makeData(byte[] data) {
- super.makeData(data);
- index = MessageParser.MSG_HEADER_SIZE;
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- apiID = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- pid = ByteUtil.toInt(payload, index);
- apiId = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
++ apiID = getInt();
++ pid = getInt();
++ tid = getInt();
- tid = ByteUtil.toInt(payload, index);
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
--
- ArgsInfo argInfo = LogDataUtils.parseArgs(payload, index);
- tid = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- ArgsInfo argInfo = LogDataUtils.parseArgs(data, index);
-- args = argInfo.getArgs();
-- index = argInfo.getLastIndex();
++ args = parseArgs();
if (args.length() > DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH) {
args = args.substring(0, DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH);
}
- ArgsInfo retInfo = LogDataUtils.parseReturn(payload, index);
- ArgsInfo retInfo = LogDataUtils.parseReturn(data, index);
-- ret = retInfo.getArgs();
-- index = retInfo.getLastIndex();
++ ret = parseReturn();
if (ret.length() > DALimit.FUNCTION_RETURN_VALUE_LENGTH) {
ret = ret.substring(0, DALimit.FUNCTION_RETURN_VALUE_LENGTH);
}
- errno = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- internalCall = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- callerAddress = ByteUtil.toLong(payload, index);
- errno = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-
- reserved1 = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
--
- reserved2 = ByteUtil.toInt(payload, index);
- internalCall = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
++ errno = getLong();
++ internalCall = getInt();
++ callerAddress = getLong();
++ reserved1 = getInt();
++ reserved2 = getInt();
- callerAddress = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
-
- reserved1 = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- reserved2 = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- ProcessInformation process = Global.getProject().getProcessInformation(pid);
- if (time > 0) {
- LibraryObject obj = null;
- ProcessMemoryMap pmap = process.getProcessMemoryMap(time);
- if (pmap == null || (obj = pmap.getLibraryByAddress(callerAddress)) == null) {
- libName = "unknown";
- } else {
- BinaryInfo binInfo = Global.getProject().getDeviceStatusInfo()
- .getBinaryInfo(obj.getBinaryID());
- libName = binInfo.getTargetBinaryPath();
- }
- // Logger.debug("lib name : " + libName);
- }
+ int binID = Global.getBinaryID(pid, time, callerAddress);
+ libName = Global.getLibraryName(binID);
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
import static org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants.MSG_CONTEXT_SWITCH_ENTRY;
import static org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants.MSG_CONTEXT_SWITCH_EXIT;
import static org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants.MSG_DATA_SAMPLE;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
-import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
-import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ProfileData extends LogData {
public static int logCount = 0;
return log;
}
- public boolean makeData(byte[] data) {
- super.makeData(data);
-
- byte[] temp = new byte[4];
- switch (id) {
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- byte[] temp = new byte[4];
+ switch (msgID) {
case MSG_FUNCTION_ENTRY:
logCount++;
- pid = ByteUtil.toInt(payload, index);
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- tid = ByteUtil.toInt(payload, index);
- tid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
--
- System.arraycopy(payload, index, temp, 0, 2);
- System.arraycopy(data, index, temp, 0, 2);
-- probeType = ByteUtil.toInt(temp, 0);
-- index += 2;
- System.arraycopy(payload, index, temp, 0, 2);
- System.arraycopy(data, index, temp, 0, 2);
-- probeSubType = ByteUtil.toInt(temp, 0);
-- index += 2;
--
- pcAddr = ByteUtil.toLong(payload, index);
- pcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
- callerPcAddr = ByteUtil.toLong(payload, index);
- callerPcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
--
- cpuNum = ByteUtil.toInt(payload, index);
- cpuNum = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- ArgsInfo info = LogDataUtils.parseArgs(payload, index);
- ArgsInfo info = LogDataUtils.parseArgs(data, index);
-- args = info.getArgs();
-- index = info.getLastIndex();
++ pid = getInt();
++ tid = getInt();
++
++ probeType = getShort();
++ probeSubType = getShort();
++
++ pcAddr = getLong();
++ callerPcAddr = getLong();
++
++ cpuNum = getInt();
++ args = parseArgs();
break;
case MSG_FUNCTION_EXIT:
logCount++;
- pid = ByteUtil.toInt(payload, index);
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- tid = ByteUtil.toInt(payload, index);
- tid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
-
- System.arraycopy(payload, index, temp, 0, 2);
-
- System.arraycopy(data, index, temp, 0, 2);
-- probeType = ByteUtil.toInt(temp, 0);
-- index += 2;
- System.arraycopy(payload, index, temp, 0, 2);
- System.arraycopy(data, index, temp, 0, 2);
-- probeSubType = ByteUtil.toInt(temp, 0);
-- index += 2;
-
- pcAddr = ByteUtil.toLong(payload, index);
-
- pcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
- callerPcAddr = ByteUtil.toLong(payload, index);
- callerPcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
-
- cpuNum = ByteUtil.toInt(payload, index);
- cpuNum = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- ArgsInfo retInfo = LogDataUtils.parseReturn(payload, index);
- ArgsInfo retInfo = LogDataUtils.parseReturn(data, index);
-- ret = retInfo.getArgs();
-- index = retInfo.getLastIndex();
++ pid = getInt();
++ tid = getInt();
++
++ probeType = getShort();
++ probeSubType = getShort();
++
++ pcAddr = getLong();
++ callerPcAddr = getLong();
++
++ cpuNum = getInt();
++ ret = parseReturn();
break;
case MSG_CONTEXT_SWITCH_ENTRY:
case MSG_CONTEXT_SWITCH_EXIT:
- pcAddr = ByteUtil.toLong(payload, index);
- pcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
- pid = ByteUtil.toInt(payload, index);
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- tid = ByteUtil.toInt(payload, index);
- tid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- cpuNum = ByteUtil.toInt(payload, index);
- cpuNum = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
++ pcAddr = getLong();
++ pid = getInt();
++ tid = getInt();
++ cpuNum = getInt();
break;
case MSG_DATA_SAMPLE:
- pid = ByteUtil.toInt(payload, index);
- pid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- pcAddr = ByteUtil.toLong(payload, index);
- pcAddr = ByteUtil.toLong(data, index);
-- index += LONG_SIZE;
- tid = ByteUtil.toInt(payload, index);
- tid = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- cpuNum = ByteUtil.toInt(payload, index);
- cpuNum = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
++ pid = getInt();
++ pcAddr = getLong();
++ tid = getInt();
++ cpuNum = getInt();
break;
-
default:
break;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--
import java.util.ArrayList;
import java.util.List;
import org.tizen.dynamicanalyzer.swap.model.DATime;
import org.tizen.dynamicanalyzer.swap.model.RecordEventObject;
--import org.tizen.dynamicanalyzer.util.ByteUtil;
-import org.tizen.dynamicanalyzer.util.Logger;
public class ReplayData extends LogData {
public ReplayData() {
}
- public boolean makeData(byte[] data) {
- super.makeData(data);
-
- int internalIndex = INT_SIZE * 2;
+ @Override
+ public ReplayData clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
-
++
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
-
+
- int sec = ByteUtil.toInt(data, internalIndex);
- internalIndex += INT_SIZE;
- int nano = ByteUtil.toInt(data, internalIndex);
- internalIndex += INT_SIZE;
DATime eventTime = new DATime();
eventTime.setSec(sec);
eventTime.setNano(nano);
- int count = ByteUtil.toInt(payload, index);
- int count = ByteUtil.toInt(data, index);
-- index += INT_SIZE;
- setObjectCount(count);
++ int count = getInt();
+ objectCount = count;
for (int i = 0; i < count; i++) {
RecordEventObject recordObj = new RecordEventObject();
-
- recordObj.setId(id);
- recordObj.setSeq(seq);
+ recordObj.setMsgID(msgID);
- // recordObj.setSeq(seq);
++ // recordObj.setSeq(seq);
recordObj.setTime(time);
// event time
recordObj.setEventTime(eventTime);
++ recordObj.setEventId(getInt());
++ recordObj.setEventType(getInt());
++ recordObj.setEventCode(getInt());
++ recordObj.setEventValue(getInt());
-- // event id
- int value = ByteUtil.toInt(payload, index);
- int value = ByteUtil.toInt(data, index);
-- recordObj.setEventId(value);
-- index += INT_SIZE;
--
-- // event type
- value = ByteUtil.toInt(payload, index);
- value = ByteUtil.toInt(data, index);
-- recordObj.setEventType(value);
-- index += INT_SIZE;
--
-- // eventy code
- value = ByteUtil.toInt(payload, index);
- value = ByteUtil.toInt(data, index);
-- recordObj.setEventCode(value);
-- index += INT_SIZE;
--
- value = ByteUtil.toInt(payload, index);
- value = ByteUtil.toInt(data, index);
-- recordObj.setEventValue(value);
-- index += INT_SIZE;
-
- Logger.debug(
- "Sec : " + recordObj.getEventTime().getSec()+
- " Nano : " + recordObj.getEventTime().getNano() +
- " ID : "+ recordObj.getEventId() +
- " TYPE : "+ recordObj.getEventType() +
- " CODE : "+ recordObj.getEventCode() +
- " VALUE : "+ recordObj.getEventValue());
- getRecordEvent().add(recordObj);
+ recordEvent.add(recordObj);
}
--
++
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class SceneData extends ProbeCommonData {
- String sceneName = null;
- String formName = null;
- long formPointer = 0;
- String panelName = null;
- long panelPointer = 0;
- int transitionTime = 0;
- int userTransitionTime = 0;
-
- public SceneData(){}
-
- public boolean 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;
+ protected String sceneName = null;
+ protected String formName = null;
+ protected long formPointer = 0;
+ protected String panelName = null;
+ protected long panelPointer = 0;
+ protected int transitionTime = 0;
+ protected int userTransitionTime = 0;
- length = LogDataUtils.getStringLength(index, data);
- temp = new byte[length];
- System.arraycopy(data, index, temp, 0, length);
- formName = new String(temp);
- index += length;
-
- formPointer = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
+ public SceneData() {
+ }
- length = LogDataUtils.getStringLength(index, data);
- temp = new byte[length];
- System.arraycopy(data, index, temp, 0, length);
- panelName = new String(temp);
- index += length;
+ @Override
+ public SceneData clone() throws CloneNotSupportedException {
+ SceneData log = (SceneData) super.clone();
+ log.sceneName = this.sceneName;
+ log.formName = this.formName;
+ log.formPointer = this.formPointer;
+ log.panelName = this.panelName;
+ log.panelPointer = this.panelPointer;
+ log.transitionTime = this.transitionTime;
+ log.userTransitionTime = this.userTransitionTime;
- panelPointer = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
+ return log;
+ }
- transitionTime = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- int length = LogDataUtils.getStringLength(index, payload);
- sceneName = new String(payload, index, length);
- index += length;
-
- length = LogDataUtils.getStringLength(index, payload);
- formName = new String(payload, index, length);
- index += length;
-
- formPointer = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- length = LogDataUtils.getStringLength(index, payload);
- panelName = new String(payload, index, length);
- index += length;
-
- panelPointer = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- transitionTime = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- userTransitionTime = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- userTransitionTime = ByteUtil.toInt(data, index);
-
++ sceneName = getString();
++ formName = getString();
++ formPointer = getLong();
++ panelName = getString();
++ panelPointer = getLong();
++ transitionTime = getInt();
++ userTransitionTime = getInt();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
- import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
-
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ScreenShotData extends ProbeCommonData {
- String imageFilePath = null;
- int orientation = 0;
+ protected String imageFilePath = null;
+ protected int orientation = 0;
- public ScreenShotData(){}
- public boolean makeData(byte[] data) {
- super.makeData(data);
+ public ScreenShotData() {
+ }
+
+ @Override
+ public ScreenShotData clone() throws CloneNotSupportedException {
+ ScreenShotData log = (ScreenShotData) super.clone();
+ log.imageFilePath = this.imageFilePath;
+ log.orientation = this.orientation;
+
+ return log;
+ }
- imageFilePath = ByteUtil.getString(data, index);
- index += ByteUtil.getStringLength(data, index);
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- int length = LogDataUtils.getStringLength(index, payload);
- imageFilePath = new String(payload, index, length);
- index += length;
-
- orientation = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- orientation = ByteUtil.toInt(data, index);
-
++ imageFilePath = getString();
++ orientation = getInt();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class SyncData extends ProbeCommonData {
- long syncValue = 0;
- int syncType = 0;
- int apiType = 0;
+ protected long syncValue = 0;
+ protected int syncType = 0;
+ protected int apiType = 0;
+
+ public SyncData() {
- public SyncData(){}
-
- public boolean makeData(byte[] data) {
- super.makeData(data);
+ }
- syncValue = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
+ @Override
+ public SyncData clone() throws CloneNotSupportedException {
+ SyncData log = (SyncData) super.clone();
+ log.syncValue = this.syncValue;
+ log.syncType = this.syncType;
+ log.apiType = this.apiType;
+
+ return log;
+ }
- syncType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
- syncValue = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- syncType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- apiType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- apiType = ByteUtil.toInt(data, index);
-
++ syncValue = getLong();
++ syncType = getInt();
++ apiType = getInt();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.FLOAT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
+ import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.util.UnsignedInt;
public class SystemData extends LogData {
public SystemData() {
}
- public boolean makeData(byte[] data) {
- super.makeData(data);
- // index = MessageParser.MSG_HEADER_SIZE;
- int coreCount = Global.getProject().getDeviceStatusInfo()
- .getCpuCount();
- int deviceCount = Global.getProject().getDeviceStatusInfo()
- .getDeviceCount();
-
- cpuFrequency = parseCpu(index, data);
- index += (FLOAT_SIZE * coreCount);
-
- cpuLoad = parseCpu(index, data);
- index += (FLOAT_SIZE * coreCount);
-
- systemMemoryUsed = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
-
- targetProcessCount = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- parseTargetProcessInfo(data, targetProcessCount);
-
- otherProcessCount = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- otherProcessLoad = parseLoad(index, data);
- index += (otherProcessCount * (INT_SIZE + FLOAT_SIZE));
-
- totalUsedDrive = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- diskReadOpCount = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- diskReadByteSize = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- diskWriteOpCount = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- diskWrittenByteSize = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- networkSendSize = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- networkReceiveSize = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
-
- wifi = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- btStatus = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- gpsStatus = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- brightness = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- camera = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- sound = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- audio = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- vibration = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- voltage = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- rssi = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- video = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- call = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- dnet = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- energyUsage = ByteUtil.toUnsignedInt(data, index);
- index += INT_SIZE;
+ @Override
+ public SystemData clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
- deviceEnergyUsage = parseUsage(index, data);
- index += (INT_SIZE * deviceCount);
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- cpuFrequency = parseCpu(payload);
-
- cpuLoad = parseCpu(payload);
-
- systemMemoryUsed = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- targetProcessCount = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- parseTargetProcessInfo(payload, targetProcessCount);
-
- otherProcessCount = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- otherProcessLoad = parseLoad(otherProcessCount, payload);
-
- totalUsedDrive = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- diskReadOpCount = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- diskReadByteSize = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- diskWriteOpCount = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- diskWrittenByteSize = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- networkSendSize = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- networkReceiveSize = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- wifi = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- btStatus = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- gpsStatus = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- brightness = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- camera = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- sound = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- audio = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- vibration = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- voltage = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- rssi = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- video = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- call = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- dnet = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- energyUsage = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
-
- deviceEnergyUsage = parseUsage(payload);
-
- applicationEnergyUsage = parseUsage(payload);
++ cpuFrequency = parseCpu();
++ cpuLoad = parseCpu();
++ systemMemoryUsed = getLong();
++ targetProcessCount = getInt();
++
++ parseTargetProcessInfo(targetProcessCount);
++
++ otherProcessCount = getInt();
++ otherProcessLoad = parseLoad(otherProcessCount);
++
++ totalUsedDrive = getUnsignedInt();
++ diskReadOpCount = getUnsignedInt();
++ diskReadByteSize = getUnsignedInt();
++ diskWriteOpCount = getUnsignedInt();
++ diskWrittenByteSize = getUnsignedInt();
++ networkSendSize = getUnsignedInt();
++ networkReceiveSize = getUnsignedInt();
++
++ wifi = getInt();
++ btStatus = getInt();
++ gpsStatus = getInt();
++ brightness = getInt();
++ camera = getInt();
++ sound = getInt();
++ audio = getInt();
++ vibration = getInt();
++ voltage = getInt();
++ rssi = getInt();
++ video = getInt();
++ call = getInt();
++ dnet = getInt();
++ energyUsage = getUnsignedInt();
++
++ deviceEnergyUsage = parseUsage();
++ applicationEnergyUsage = parseUsage();
- applicationEnergyUsage = parseUsage(index, data);
- index += (INT_SIZE * deviceCount);
-
return true;
}
- private String parseLoad(int count, byte[] payload) {
- private static String parseLoad(int start, byte[] payload) {
- int pos = start;
- int backPos = start - INT_SIZE;
- int count = ByteUtil.toInt(payload, backPos);
++ private String parseLoad(int count) {
StringBuffer outBuf = new StringBuffer();
for (int ii = 0; ii < count; ii++) {
try {
- int tid = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
- int tid = ByteUtil.toInt(payload, pos);
- pos += INT_SIZE;
++ int tid = getInt();
outBuf.append(tid).append(CommonConstants.COMMA);
- float f = ByteUtil.toFloat(payload, pos);
+
- float f = ByteUtil.toFloat(payload, index);
- index += FLOAT_SIZE;
++ float f = getFloat();
outBuf.append(f);
- pos += FLOAT_SIZE;
+
if (ii + 1 != count) {
outBuf.append(CommonConstants.COMMA);
}
return outBuf.toString();
}
- private String parseCpu(byte[] payload) {
- private static String parseCpu(int start, byte[] payload) {
- int coreCount = Global.getProject().getDeviceStatusInfo()
- .getCpuCount();
++ private String parseCpu() {
+ int coreCount = Global.getProject().getDeviceStatusInfo().getCpuCount();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < coreCount; i++) {
- float value = ByteUtil.toFloat(payload, index);
- index += FLOAT_SIZE;
- float value = ByteUtil.toFloat(payload, start);
- start += FLOAT_SIZE;
++ float value = getFloat();
buffer.append(value);
if (i + 1 != coreCount) {
buffer.append(',');
return buffer.toString();
}
- private String parseUsage(byte[] payload) {
- private static String parseUsage(int start, byte[] payload) {
- int count = Global.getProject().getDeviceStatusInfo()
- .getDeviceCount();
++ private String parseUsage() {
+ int count = Global.getProject().getDeviceStatusInfo().getDeviceCount();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < count; i++) {
- UnsignedInt value = ByteUtil.toUnsignedInt(payload, index);
- index += INT_SIZE;
- UnsignedInt value = ByteUtil.toUnsignedInt(payload, start);
- start += INT_SIZE;
++ UnsignedInt value = getUnsignedInt();
buffer.append(value.getValue());
if (i + 1 != count) {
buffer.append(',');
return buffer.toString();
}
-- private void parseTargetProcessInfo(byte[] payload, int targetProcessCount) {
++ private void parseTargetProcessInfo(int targetProcessCount) {
processProfileDataList = new ProcessProfileData[targetProcessCount];
for (int i = 0; i < targetProcessCount; i++) {
ProcessProfileData processData = new ProcessProfileData();
-- processData.setPid(ByteUtil.toInt(payload, index));
-- index += INT_SIZE;
-- processData.setProcessLoad(ByteUtil.toFloat(payload, index));
-- index += FLOAT_SIZE;
-- processData.setVirtualMemory(ByteUtil.toLong(payload, index));
-- index += LONG_SIZE;
-- processData.setResidentMemory(ByteUtil.toLong(payload, index));
-- index += LONG_SIZE;
-- processData.setSharedMemory(ByteUtil.toLong(payload, index));
-- index += LONG_SIZE;
-- processData.setPssMemory(ByteUtil.toLong(payload, index));
-- index += LONG_SIZE;
-- processData.setTotalAllocSize(ByteUtil.toLong(payload, index));
-- index += LONG_SIZE;
-- processData.setThreadCount(ByteUtil.toInt(payload, index));
-- index += INT_SIZE;
- processData.setThreadLoad(parseLoad(processData.getThreadCount(), payload));
- processData.setThreadLoad(parseLoad(index, payload));
- index += (processData.getThreadCount() * (INT_SIZE + FLOAT_SIZE));
++ processData.setPid(getInt());
++ processData.setProcessLoad(getFloat());
++ processData.setVirtualMemory(getLong());
++ processData.setResidentMemory(getLong());
++ processData.setSharedMemory(getLong());
++ processData.setPssMemory(getLong());
++ processData.setTotalAllocSize(getLong());
++ processData.setThreadCount(getInt());
++ processData.setThreadLoad(parseLoad(processData.getThreadCount()));
processProfileDataList[i] = processData;
}
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.LONG_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class ThreadData extends ProbeCommonData {
- long pThreadId = 0;
- long ospThreadId = 0;
- int threadType = 0; // TODO: short
- int apiType = 0;// TODO: short
- String className = null;
-
- public ThreadData(){}
-
- public boolean makeData(byte[] data) {
- super.makeData(data);
-
- pThreadId = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
-
- ospThreadId = ByteUtil.toLong(data, index);
- index += LONG_SIZE;
-
- threadType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- apiType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- className = ByteUtil.getString(data, index);
-
+ protected long pThreadId = 0;
+ protected long ospThreadId = 0;
+ protected int threadType = 0; // TODO: short
+ protected int apiType = 0;// TODO: short
+ protected String className = null;
+
+ public ThreadData() {
+
+ }
+
+ @Override
+ public ThreadData clone() throws CloneNotSupportedException {
+ ThreadData log = (ThreadData) super.clone();
+ log.pThreadId = this.pThreadId;
+ log.ospThreadId = this.ospThreadId;
+ log.threadType = this.threadType;
+ log.apiType = this.apiType;
+ log.className = this.className;
+
+ return log;
+ }
+
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- pThreadId = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- ospThreadId = ByteUtil.toLong(payload, index);
- index += LONG_SIZE;
-
- threadType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- apiType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- int length = LogDataUtils.getStringLength(index, payload);
- className = new String(payload, index, length);
- index += length;
-
++ pThreadId = getLong();
++ ospThreadId = getLong();
++ threadType = getInt();
++ apiType = getInt();
++ className = getString();
return true;
}
*/
package org.tizen.dynamicanalyzer.swap.model.data;
--import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE;
--
-import org.tizen.dynamicanalyzer.util.ByteUtil;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
- import org.tizen.dynamicanalyzer.util.ByteUtil;
public class UIEventData extends ProbeCommonData {
- int eventType = 0;
- int detailType = 0;
- int x = 0;
- int y = 0;
- String info1 = null;
- int info2 = 0;
-
- public UIEventData(){}
-
- public boolean makeData(byte[] data) {
- super.makeData(data);
-
- eventType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ protected int eventType = 0;
+ protected int detailType = 0;
+ protected int x = 0;
+ protected int y = 0;
+ protected String info1 = null;
+ protected int info2 = 0;
- detailType = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ public UIEventData() {
- x = ByteUtil.toInt(data, index);
- index += INT_SIZE;
-
- y = ByteUtil.toInt(data, index);
- index += INT_SIZE;
+ }
- info1 = ByteUtil.getString(data, index);
- index += ByteUtil.getStringLength(data, index);
+ @Override
+ public UIEventData clone() throws CloneNotSupportedException {
+ UIEventData log = (UIEventData) super.clone();
+ log.eventType = this.eventType;
+ log.detailType = this.detailType;
+ log.x = this.x;
+ log.y = this.y;
+ log.info1 = this.info1;
+ log.info2 = this.info2;
+
+ return log;
+ }
- info2 = ByteUtil.toInt(data, index);
-
+ @Override
+ protected boolean makeData(DATime startTime) {
+ super.makeData(startTime);
+
- eventType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- detailType = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- x = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- y = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
- int length = LogDataUtils.getStringLength(index, payload);
- info1 = new String(payload, index, length);
- index += length;
-
- info2 = ByteUtil.toInt(payload, index);
- index += INT_SIZE;
-
++ eventType = getInt();
++ detailType = getInt();
++ x = getInt();
++ y = getInt();
++ info1 = getString();
++ info2 = getInt();
return true;
}
Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
dialog = new ProgressDialog(shell, LayoutManager.getBaseComposite());
if (null != dialog) {
- dialog.open();
dialog.setProgressMessage(waitMessage);
- dialog.setProgressInfo(AnalyzerLabels.STOP_PROCESS_DLG_PLEASE_WAIT);
+ dialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT);
+ dialog.open();
}
}
}
cpuUsage.clear();
for (int i = 0; i < cpuLoadList.length; i++) {
-- double cpu = (Double)cpuLoadList[i];
-- long value = (long)cpu;
++ double cpu = (Double) cpuLoadList[i];
++ long value = (long) cpu;
cpuUsage.add(value);
}
--
-- long totalMem = Global.getProject().getDeviceStatusInfo().getSystemMemorySize();
-- maxMem = totalMem;
--
++
++ Project project = Global.getProject();
++// if (project != null) {
++ maxMem = project.getDeviceStatusInfo().getSystemMemorySize();
++// } else {
++// maxMem = 0;
++// }
++
processMem = TimelineChartManager.getInstance().getProcessMemoriesFromDB(startTime);
}
setStartTime(selectTime);
updateView(false);
} else {
--// if (selStartTime > lastStartTime) {
--// selStartTime = lastStartTime;
--// }
++ // if (selStartTime > lastStartTime) {
++ // selStartTime = lastStartTime;
++ // }
setSelectTime(selStartTime);
setStartTime(selectTime);
updateView(true);
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.DBColumn;
import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBInsertManager;
-import org.tizen.dynamicanalyzer.database.DBInserter;
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.swap.model.data.SyncData;
+ import org.tizen.dynamicanalyzer.util.Logger;
public class SyncAPIDBTable extends DBTable {
public static final String TABLENAME = "SYNCAPI";
insertRowData.add(new Integer(syncData.getParentID()));
insertData.add(insertRowData);
} catch (ArrayIndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.exception(e);
}
}
- if (insertData.size() > 0) {
+ if (insertData.size() > 0 && dbInserter != null) {
dbInserter.pushData(insertData);
}
}
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.DBColumn;
import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBInsertManager;
-import org.tizen.dynamicanalyzer.database.DBInserter;
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.ui.thread.type.ThreadPageThreadDataEvent;
+ import org.tizen.dynamicanalyzer.util.Logger;
public class ThreadEventDBTable extends DBTable {
public static final String TABLENAME = "THREADEVENT";
import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceDialog;
import org.tizen.dynamicanalyzer.ui.toolbar.replayEditor.ReplayEditDialog;
import org.tizen.dynamicanalyzer.ui.toolbar.setting.SettingDialog;
-import org.tizen.dynamicanalyzer.ui.toolbar.setting.SettingDialogManager;
+ import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
}
- public boolean isSourceViewEnabled() {
- return viewSourceButton.isToggled();
+ // ============================================================================================
+ // SEE : refactored from below ( start at 15/01/22 )
+ // ============================================================================================
+
+ public void startTimer() {
+ timerClock.start();
}
- public void setStartButtonEnablement(final boolean enabled) {
- Display.getDefault().syncExec(new Runnable() {
+ public void stopTimer() {
+ timerClock.stop();
+ }
- @Override
- public void run() {
- if (!enabled) {
- // startButton.setButtonEnabled(false);
- setStartButtonState(false);
- return;
- }
+ @UIMethod
+ public void clearTimer() {
+ timerClock.clear();
+ }
- DeviceInfo curDev = Global.getCurrentDeviceInfo();
- if (curDev == null) {
- setStartButtonState(false);
- return;
- }
+ public void setTimerAlarm(long time, IAlarm alarm) {
+ timerClock.setAlarm(time, alarm);
+ }
- String text = deviceCombo.getText();
- String device = curDev.getIDevice().getSerialNumber();
- if (!device.equals(text)) {
- // startButton.setButtonEnabled(false);
- setStartButtonState(false);
- return;
- }
+ public void removeTimerAlarm() {
+ timerClock.removeAlarm();
+ }
- PackageInfo packInfo = Global.getCurrentApplication();
- if (packInfo == null) {
- setStartButtonState(false);
- return;
+ public int getSelectedPid() {
+ int ret = 0;
+ String pid = processCombo.getText();
+ if (!pid.equals(ALL_PROCESS)) {
+ int index = pid.indexOf(PROCESS_SPLITER);
+ String str = pid.substring(0, index);
+ if (null != str && !str.isEmpty()) {
+ try {
+ ret = Integer.parseInt(str);
+ } catch (NumberFormatException e) {
- e.printStackTrace();
++ Logger.exception(e);
}
-
- setStartButtonState(true);
- // startButton.setButtonEnabled(true);
}
- });
- // startButton.setButtonEnabled(enabled);
+ }
+ return ret;
}
- public void checkStartButtonAndAppListEnablement() {
+ /*************************************************************************************************
+ * methods to change state of controls major controls : device / app combo, save / open / replay
+ * buttons minor controls : process combo, source view / screenshot / setting / about buttons
+ * special control : start button
+ *************************************************************************************************/
+
+ /**
+ * change the availability of toolbar UI controls by DA state
+ *
+ * @param state
+ * DA state
+ */
+ public void changeUIState(STATE state) {
+ final STATE fState = state;
Display.getDefault().syncExec(new Runnable() {
-
@Override
public void run() {
- String text = deviceCombo.getText();
- String device = null;
- DeviceInfo curDev = Global.getCurrentDeviceInfo();
- if (curDev != null)
- device = curDev.getIDevice().getSerialNumber();
- if (device == null || !device.equals(text)) {
- // startButton.setButtonEnabled(false);
- setStartButtonState(false);
- appCombo.setEnabled(false);
- return;
+ if (fState == STATE.PREPARE_START) {
+ setAllControlState(false);
+ } else if (fState == STATE.RUNNING) {
+ toggleStartButtonUI(true);
+ setStartButtonState(true);
+ setMajorControlState(false);
+ setMinorControlState(true);
+ } else if (fState == STATE.PREPARE_END) {
+ setAllControlState(false);
+ } else if (fState == STATE.PREPARE_CANCEL) {
+ setAllControlState(false);
+ } else if (fState == STATE.DONE || fState == STATE.INIT) {
+ toggleStartButtonUI(false);
+ setAllControlState(true);
+ } else {
+ // known state
+ setAllControlState(false);
}
- // startButton.setButtonEnabled(true);
- setStartButtonState(true);
- appCombo.setEnabled(true);
}
});
}
import org.tizen.dynamicanalyzer.handlers.OpenTraceHandler;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.project.Project;
-import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
+ import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog;
public void run() {
state = OPEN_TRACE_PROCESS_START;
Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
-- dialog = new ProgressDialog(shell, LayoutManager
-- .getBaseComposite());
++ dialog = new ProgressDialog(shell, LayoutManager.getBaseComposite());
if (null != dialog) {
- dialog.open();
dialog.setProgressMessage(EndMessage);
- dialog.setProgressInfo(AnalyzerLabels.STOP_PROCESS_DLG_PLEASE_WAIT);
+ dialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT);
+ dialog.open();
}
}
});
public void openTraceComplete() {
if (null != dialog) {
--// waitingThreads();
++ // waitingThreads();
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
-- dialog.errorOccurred(errMsg,
-- AnalyzerLabels.OPEN_TRACE_PROGRESS_ERROR);
++ dialog.errorOccurred(errMsg, AnalyzerLabels.OPEN_TRACE_PROGRESS_ERROR);
dialog.setValue(50);
}
});
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
-import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+ import org.tizen.dynamicanalyzer.communicator.IDECommunicator;
+import org.tizen.dynamicanalyzer.handlers.CommonAction;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
import org.tizen.dynamicanalyzer.nl.WidgetLabels;