Search in sources :

Example 1 with ThreadEntryModel

use of org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel in project tracecompass by tracecompass.

the class ThreadStatusDataProviderTest method assertAndGetTree.

private static Map<Long, String> assertAndGetTree(ThreadStatusDataProvider provider) throws IOException {
    TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), null);
    assertNotNull(treeResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
    TmfTreeModel<@NonNull TimeGraphEntryModel> treeModel = treeResponse.getModel();
    assertNotNull(treeModel);
    List<@NonNull TimeGraphEntryModel> treeEntries = treeModel.getEntries();
    List<String> expectedStrings = Files.readAllLines(Paths.get("testfiles/kernel_analysis/expectedThreadStatusTree"));
    assertEquals(expectedStrings.size(), treeEntries.size());
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(",");
        TimeGraphEntryModel threadEntry = treeEntries.get(i);
        // Assert common fields
        assertEquals(split[0], threadEntry.getName());
        assertEquals(Long.parseLong(split[1]), threadEntry.getStartTime());
        assertEquals(Long.parseLong(split[2]), threadEntry.getEndTime());
        if (threadEntry instanceof ThreadEntryModel) {
            // Verify the thread entry fields
            ThreadEntryModel threadEntryModel = (ThreadEntryModel) threadEntry;
            assertEquals(Integer.parseInt(split[3]), threadEntryModel.getThreadId());
            assertEquals(Integer.parseInt(split[4]), threadEntryModel.getProcessId());
            assertEquals(Integer.parseInt(split[5]), threadEntryModel.getParentThreadId());
        } else {
            // Make sure there is no extra expected fields
            assertEquals(3, split.length);
        }
    }
    Map<Long, String> map = new HashMap<>();
    for (TimeGraphEntryModel threadModel : treeEntries) {
        map.put(threadModel.getId(), threadModel.getName());
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) NonNull(org.eclipse.jdt.annotation.NonNull) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)

Example 2 with ThreadEntryModel

use of org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel in project tracecompass by tracecompass.

the class ControlFlowView method fillTimeGraphEntryContextMenu.

/**
 * @since 2.0
 */
@Override
protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) {
    ISelection selection = getSite().getSelectionProvider().getSelection();
    if (selection instanceof StructuredSelection) {
        StructuredSelection sSel = (StructuredSelection) selection;
        if (sSel.getFirstElement() instanceof TimeGraphEntry) {
            TimeGraphEntry entry = (TimeGraphEntry) sSel.getFirstElement();
            ITmfTreeDataModel entryModel = entry.getEntryModel();
            if (entryModel instanceof ThreadEntryModel) {
                menuManager.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), ((ThreadEntryModel) entryModel).getThreadId(), getTrace(entry)));
            }
        }
    }
}
Also used : ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) FollowThreadAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)

Example 3 with ThreadEntryModel

use of org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel in project tracecompass by tracecompass.

the class ActiveThreadsFilter method select.

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (!fEnabled || !(element instanceof TimeGraphEntry)) {
        return true;
    }
    TimeGraphEntry entry = (TimeGraphEntry) element;
    ThreadEntryModel entryModel = ControlFlowView.getThreadEntryModel(entry);
    if (entryModel == null) {
        return true;
    }
    ITmfTrace trace = BaseDataProviderTimeGraphView.getTrace(entry);
    Set<Long> onCpusThreadForTimeRange = fCachedOnCpusThreadForTimeRange.get(trace);
    Set<Long> activeThreadForTimeRange = fCachedActiveThreadForTimeRange.get(trace);
    /* Check if on CPU */
    if (fCpuRangesBasedFiltering && (onCpusThreadForTimeRange != null) && onCpusThreadForTimeRange.contains(entryModel.getId())) {
        return true;
    } else if ((activeThreadForTimeRange != null) && activeThreadForTimeRange.contains(entryModel.getId())) {
        return true;
    }
    /* Not active per see. Check children if any is active */
    for (TimeGraphEntry child : entry.getChildren()) {
        if (select(viewer, entry, child)) {
            return true;
        }
    }
    /* No children are active */
    return false;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)

Example 4 with ThreadEntryModel

use of org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel in project tracecompass by tracecompass.

the class ControlFlowCheckActiveProvider method isActive.

@Override
public boolean isActive(ITimeGraphEntry element) {
    ThreadEntryModel model = ControlFlowView.getThreadEntryModel(element);
    if (model != null) {
        TmfTraceManager traceManager = TmfTraceManager.getInstance();
        TmfTraceContext traceContext = traceManager.getCurrentTraceContext();
        TmfTimeRange range = traceContext.getSelectionRange();
        /* Take precedence of selection over window range. */
        if (Objects.equals(range.getStartTime(), range.getEndTime())) {
            range = traceContext.getWindowRange();
        }
        Set<Long> ids = getActiveIds((TimeGraphEntry) element, range);
        return ids.contains(model.getId());
    }
    return false;
}
Also used : TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 5 with ThreadEntryModel

use of org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel in project tracecompass by tracecompass.

the class ControlFlowPresentationProvider method getEventHoverToolTipInfo.

@Override
public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) {
    Map<String, String> retMap = super.getEventHoverToolTipInfo(event, hoverTime);
    if (retMap == null) {
        retMap = new LinkedHashMap<>(1);
    }
    ThreadEntryModel entryModel = ControlFlowView.getThreadEntryModel(event.getEntry());
    if (!(event instanceof TimeEvent) || !((TimeEvent) event).hasValue() || entryModel == null) {
        return retMap;
    }
    ITimeGraphDataProvider<? extends TimeGraphEntryModel> dataProvider = BaseDataProviderTimeGraphView.getProvider((TimeGraphEntry) event.getEntry());
    TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> response = dataProvider.fetchTooltip(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(hoverTime, hoverTime, 1, Collections.singletonList(entryModel.getId()))), null);
    Map<@NonNull String, @NonNull String> tooltipModel = response.getModel();
    if (tooltipModel != null) {
        retMap.putAll(tooltipModel);
    }
    return retMap;
}
Also used : SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) NonNull(org.eclipse.jdt.annotation.NonNull) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ThreadEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel)5 NonNull (org.eclipse.jdt.annotation.NonNull)2 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)2 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 FollowThreadAction (org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction)1 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)1 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)1 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)1 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)1 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)1 TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)1 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)1