/*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
/**
* The Control Flow view main object
*/
public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$
- /**
- * Initial time range
- */
- private static final long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
-
private static final String PROCESS_COLUMN = Messages.ControlFlowView_processColumn;
private static final String TID_COLUMN = Messages.ControlFlowView_tidColumn;
private static final String PTID_COLUMN = Messages.ControlFlowView_ptidColumn;
TRACE_COLUMN
};
+ private final String[] FILTER_COLUMN_NAMES = new String[] {
+ PROCESS_COLUMN,
+ TID_COLUMN
+ };
+
/**
* Redraw state enum
*/
return Integer.toString(entry.getParentThreadId());
}
} else if (columnIndex == 3) {
- return Utils.formatTime(entry.getBirthTime(), TimeFormat.ABSOLUTE, Resolution.NANOSEC);
+ return Utils.formatTime(entry.getStartTime(), TimeFormat.CALENDAR, Resolution.NANOSEC);
} else if (columnIndex == 4) {
return entry.getTrace().getName();
}
// ViewPart
// ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createPartControl(Composite parent) {
fTimeGraphCombo = new TimeGraphCombo(parent, SWT.NONE);
fTimeGraphCombo.setTreeColumns(COLUMN_NAMES);
+ fTimeGraphCombo.setFilterContentProvider(new TreeContentProvider());
+
+ fTimeGraphCombo.setFilterLabelProvider(new TreeLabelProvider());
+
+ fTimeGraphCombo.setFilterColumns(FILTER_COLUMN_NAMES);
+
fTimeGraphCombo.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
@Override
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
}
});
- fTimeGraphCombo.getTimeGraphViewer().setTimeCalendarFormat(true);
+ fTimeGraphCombo.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
// View Action Handling
makeActions();
contributeToActionBars();
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor instanceof ITmfTraceEditor) {
- ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
- if (trace != null) {
- traceSelected(new TmfTraceSelectedSignal(this, trace));
- }
+ ITmfTrace trace = getActiveTrace();
+ if (trace != null) {
+ traceSelected(new TmfTraceSelectedSignal(this, trace));
}
+
+ // make selection available to other views
+ getSite().setSelectionProvider(fTimeGraphCombo.getTreeViewer());
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
@Override
public void setFocus() {
fTimeGraphCombo.setFocus();
} else {
fStartTime = fTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
fEndTime = fTrace.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- refresh(INITIAL_WINDOW_OFFSET);
+ refresh();
}
}
}
if (fZoomThread != null) {
fZoomThread.cancel();
}
- refresh(INITIAL_WINDOW_OFFSET);
+ refresh();
}
}
final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
int thread = -1;
- ITmfTrace[] traces;
- if (fTrace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) fTrace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { fTrace };
- }
- for (ITmfTrace trace : traces) {
+ for (ITmfTrace trace : fTrace.getTraces()) {
if (thread > 0) {
break;
}
if (trace instanceof CtfKernelTrace) {
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
for (int currentThreadQuark : currentThreadQuarks) {
if (signal.getSource() == this || fTrace == null) {
return;
}
+ if (signal.getCurrentRange().getIntersection(fTrace.getTimeRange()) == null) {
+ return;
+ }
final long startTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
final long endTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
private void buildEventList(final ITmfTrace trace, IProgressMonitor monitor) {
fStartTime = Long.MAX_VALUE;
fEndTime = Long.MIN_VALUE;
- ITmfTrace[] traces;
- if (trace instanceof TmfExperiment) {
- TmfExperiment experiment = (TmfExperiment) trace;
- traces = experiment.getTraces();
- } else {
- traces = new ITmfTrace[] { trace };
- }
ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();
- for (ITmfTrace aTrace : traces) {
+ for (ITmfTrace aTrace : trace.getTraces()) {
if (monitor.isCanceled()) {
return;
}
if (aTrace instanceof CtfKernelTrace) {
ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
if (monitor.isCanceled()) {
return;
}
- long birthTime = -1;
+ ControlFlowEntry entry = null;
for (ITmfStateInterval execNameInterval : execNameIntervals) {
if (monitor.isCanceled()) {
return;
}
- if (!execNameInterval.getStateValue().isNull() && execNameInterval.getStateValue().getType() == 1) {
+ if (!execNameInterval.getStateValue().isNull() &&
+ execNameInterval.getStateValue().getType() == ITmfStateValue.Type.STRING) {
String execName = execNameInterval.getStateValue().unboxStr();
long startTime = execNameInterval.getStartTime();
long endTime = execNameInterval.getEndTime() + 1;
- if (birthTime == -1) {
- birthTime = startTime;
- }
int ppid = -1;
if (ppidQuark != -1) {
ITmfStateInterval ppidInterval = ssq.querySingleState(startTime, ppidQuark);
ppid = ppidInterval.getStateValue().unboxInt();
}
- ControlFlowEntry entry = new ControlFlowEntry(threadQuark, ctfKernelTrace, execName, threadId, ppid, birthTime, startTime, endTime);
- entryList.add(entry);
+ if (entry == null) {
+ entry = new ControlFlowEntry(threadQuark, ctfKernelTrace, execName, threadId, ppid, startTime, endTime);
+ entryList.add(entry);
+ } else {
+ // update the name of the entry to the latest execName
+ entry.setName(execName);
+ }
entry.addEvent(new TimeEvent(entry, startTime, endTime - startTime));
} else {
- birthTime = -1;
+ entry = null;
}
}
} catch (AttributeNotFoundException e) {
fEntryListMap.put(trace, (ArrayList<ControlFlowEntry>) rootList.clone());
}
if (trace == fTrace) {
- refresh(INITIAL_WINDOW_OFFSET);
+ refresh();
}
}
for (ControlFlowEntry entry : rootList) {
}
private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
long start = ssq.getStartTime();
long end = ssq.getCurrentEndTime() + 1;
long resolution = Math.max(1, (end - start) / fDisplayWidth);
private static List<ITimeEvent> getEventList(ControlFlowEntry entry,
long startTime, long endTime, long resolution,
IProgressMonitor monitor) {
- startTime = Math.max(startTime, entry.getStartTime());
- endTime = Math.min(endTime, entry.getEndTime());
- if (endTime <= startTime) {
+ final long realStart = Math.max(startTime, entry.getStartTime());
+ final long realEnd = Math.min(endTime, entry.getEndTime());
+ if (realEnd <= realStart) {
return null;
}
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
List<ITimeEvent> eventList = null;
try {
int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
- List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);
+ List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, realStart, realEnd - 1, resolution, monitor);
eventList = new ArrayList<ITimeEvent>(statusIntervals.size());
long lastEndTime = -1;
for (ITmfStateInterval statusInterval : statusIntervals) {
e.printStackTrace();
}
if (lastEndTime != time && lastEndTime != -1) {
- eventList.add(new ControlFlowEvent(entry, lastEndTime, time - lastEndTime, 0));
+ eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));
}
eventList.add(new ControlFlowEvent(entry, time, duration, status));
lastEndTime = time + duration;
return eventList;
}
- private void refresh(final long windowRange) {
+ private void refresh() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
fTimeGraphCombo.setInput(entries);
fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);
- long endTime = fStartTime + windowRange;
+ long timestamp = fTrace == null ? 0 : fTrace.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ long startTime = fTrace == null ? 0 : fTrace.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ long endTime = fTrace == null ? 0 : fTrace.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ startTime = Math.max(startTime, fStartTime);
+ endTime = Math.min(endTime, fEndTime);
+ fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(timestamp, false);
+ fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
- if (fEndTime < endTime) {
- endTime = fEndTime;
- }
- fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(fStartTime, endTime);
for (TreeColumn column : fTimeGraphCombo.getTreeViewer().getTree().getColumns()) {
column.pack();
}
- startZoomThread(fStartTime, endTime);
+ startZoomThread(startTime, endTime);
}
});
}
}
private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(fTimeGraphCombo.getShowFilterAction());
manager.add(fTimeGraphCombo.getTimeGraphViewer().getShowLegendAction());
manager.add(new Separator());
manager.add(fTimeGraphCombo.getTimeGraphViewer().getResetScaleAction());