Search in sources :

Example 1 with ITimeGraphArrow

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphView method getLinkList.

@Override
protected List<@NonNull ILinkEvent> getLinkList(long zoomStartTime, long zoomEndTime, long resolution, @NonNull IProgressMonitor monitor) {
    Collection<ITimeGraphDataProvider<? extends @NonNull TimeGraphEntryModel>> providers = getProviders(getTrace());
    if (providers.isEmpty()) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    List<@NonNull Long> times = StateSystemUtils.getTimes(zoomStartTime, zoomEndTime, resolution);
    Map<@NonNull String, @NonNull Object> parameters = getFetchArrowsParameters(times);
    for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providers) {
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(parameters, monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry prevEntry;
                ITimeGraphEntry nextEntry;
                synchronized (fEntries) {
                    prevEntry = fEntries.get(provider, arrow.getSourceId());
                    nextEntry = fEntries.get(provider, arrow.getDestinationId());
                }
                if (prevEntry != null && nextEntry != null) {
                    linkList.add(new TimeLinkEvent(arrow, prevEntry, nextEntry));
                }
            }
        }
    }
    return linkList;
}
Also used : ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent)

Example 2 with ITimeGraphArrow

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow in project tracecompass by tracecompass.

the class CallStackDataProvider method fetchTooltip.

@Override
@NonNull
public TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(Map<String, Object> parameters, @Nullable IProgressMonitor monitor) {
    CallStackAnalysis analysis = getAnalysisModule();
    Map<String, String> tooltips = new HashMap<>();
    List<@NonNull Long> selected = DataProviderParameterUtils.extractSelectedItems(parameters);
    List<@NonNull Long> times = DataProviderParameterUtils.extractTimeRequested(parameters);
    // This data provider doesn't have any annotations or arrows
    Object element = parameters.get(DataProviderParameterUtils.REQUESTED_ELEMENT_KEY);
    if (element instanceof IAnnotation || element instanceof ITimeGraphArrow) {
        return new TmfModelResponse<>(tooltips, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    if (selected != null && times != null) {
        Map<@NonNull Long, @NonNull Integer> md = getSelectedEntries(selected);
        ITmfTrace trace = getTrace();
        for (Long time : times) {
            for (Entry<@NonNull Long, @NonNull Integer> entry : md.entrySet()) {
                Long result = analysis.resolveDeviceId(entry.getValue(), time);
                if (result != null) {
                    String deviceId = String.valueOf(result);
                    String deviceType = analysis.resolveDeviceType(entry.getValue(), time);
                    tooltips.put(deviceType, deviceId);
                    Iterable<@NonNull CallsiteAnalysis> csas = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallsiteAnalysis.class);
                    for (CallsiteAnalysis csa : csas) {
                        List<@NonNull ITmfCallsite> res = csa.getCallsites(String.valueOf(trace.getUUID()), deviceType, deviceId, time);
                        if (!res.isEmpty()) {
                            tooltips.put(TmfStrings.source(), String.valueOf(res.get(0)));
                        }
                    }
                    return new TmfModelResponse<>(tooltips, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
                }
                ITmfStateSystem stateSystem = analysis.getStateSystem();
                if (stateSystem != null) {
                    try {
                        Collection<@NonNull ISymbolProvider> symbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(trace);
                        ITmfStateInterval interval = stateSystem.querySingleState(Objects.requireNonNull(time), Objects.requireNonNull(entry.getValue()));
                        Object value = interval.getValue();
                        if (value instanceof Number) {
                            long longValue = ((Number) value).longValue();
                            for (ISymbolProvider provider : symbolProviders) {
                                TmfResolvedSymbol symbol = provider.getSymbol(longValue);
                                if (symbol != null) {
                                    tooltips.put(Messages.CallStackDataProvider_toolTipState, symbol.getSymbolName());
                                    tooltips.put(Messages.CallStackDataProvider_toolTipAddress, String.format(ADDRESS_FORMAT, symbol.getBaseAddress()));
                                    break;
                                }
                            }
                            tooltips.computeIfAbsent(Messages.CallStackDataProvider_toolTipState, unused -> String.format(ADDRESS_FORMAT, longValue));
                        } else if (value != null) {
                            tooltips.put(Messages.CallStackDataProvider_toolTipState, interval.getValueString());
                        }
                    } catch (StateSystemDisposedException e) {
                        // $NON-NLS-1$
                        Activator.getInstance().logError("State System Disposed", e);
                    }
                }
            }
        }
    }
    return new TmfModelResponse<>(tooltips, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : IAnnotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IAnnotation) HashMap(java.util.HashMap) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfCallsite(org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite) CallsiteAnalysis(org.eclipse.tracecompass.internal.tmf.core.analysis.callsite.CallsiteAnalysis) ISymbolProvider(org.eclipse.tracecompass.tmf.core.symbols.ISymbolProvider) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) CallStackAnalysis(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfResolvedSymbol(org.eclipse.tracecompass.tmf.core.symbols.TmfResolvedSymbol) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with ITimeGraphArrow

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow in project tracecompass by tracecompass.

the class CriticalPathDataProvider method getLinkList.

/**
 * Critical path typically has relatively few links, so we calculate and save
 * them all, but just return those in range
 */
@Nullable
private List<@NonNull ITimeGraphArrow> getLinkList(long startTime, long endTime) {
    IGraphWorker current = getCurrent();
    List<@NonNull ITimeGraphArrow> graphLinks = fLinks;
    if (current == null) {
        if (graphLinks != null) {
            return graphLinks;
        }
        return Collections.emptyList();
    }
    CriticalPathVisitor visitor = fHorizontalVisitorCache.getIfPresent(current);
    if (visitor == null) {
        return Collections.emptyList();
    }
    graphLinks = visitor.getGraphLinks();
    fLinks = graphLinks;
    return getLinksInRange(graphLinks, startTime, endTime);
}
Also used : IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 4 with ITimeGraphArrow

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow in project tracecompass by tracecompass.

the class CriticalPathView method getLinkList.

@Override
protected List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
    List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
    if (traceEntries == null) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    TimeQueryFilter queryFilter = new TimeQueryFilter(startTime, endTime, 2);
    /*
         * group entries by critical path data provider as several hosts may refer to
         * the same data provider
         */
    Table<ITimeGraphDataProvider<?>, Long, TimeGraphEntry> table = HashBasedTable.create();
    for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
        for (TimeGraphEntry entry : Utils.flatten(traceEntry)) {
            table.put(traceEntry.getProvider(), entry.getEntryModel().getId(), entry);
        }
    }
    for (Map.Entry<ITimeGraphDataProvider<?>, Map<Long, TimeGraphEntry>> entry : table.rowMap().entrySet()) {
        ITimeGraphDataProvider<?> provider = entry.getKey();
        Map<Long, TimeGraphEntry> map = entry.getValue();
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(FetchParametersUtils.timeQueryToMap(queryFilter), monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (monitor.isCanceled()) {
            return null;
        }
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry src = map.get(arrow.getSourceId());
                ITimeGraphEntry dst = map.get(arrow.getDestinationId());
                if (src != null && dst != null) {
                    linkList.add(new TimeLinkEvent(src, dst, arrow.getStartTime(), arrow.getDuration(), arrow.getValue()));
                }
            }
        }
    }
    return linkList;
}
Also used : ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) ArrayList(java.util.ArrayList) List(java.util.List) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent) Map(java.util.Map)

Example 5 with ITimeGraphArrow

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow in project tracecompass by tracecompass.

the class ThreadStatusDataProviderTest method assertArrows.

private static void assertArrows(ThreadStatusDataProvider provider, Map<Long, String> idsToNames) throws IOException {
    TmfModelResponse<List<ITimeGraphArrow>> arrowResponse = provider.fetchArrows(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(1, 80, 80)), null);
    assertNotNull(arrowResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, arrowResponse.getStatus());
    List<ITimeGraphArrow> arrows = arrowResponse.getModel();
    assertNotNull(arrows);
    List<String> expectedStrings = Files.readAllLines(Paths.get("testfiles/kernel_analysis/expectedThreadStatusArrows"));
    assertEquals(expectedStrings.size(), arrows.size());
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(",");
        ITimeGraphArrow arrow = arrows.get(i);
        assertEquals(split[0], idsToNames.get(arrow.getSourceId()));
        assertEquals(split[1], idsToNames.get(arrow.getDestinationId()));
        assertEquals(Long.parseLong(split[2]), arrow.getStartTime());
        assertEquals(Long.parseLong(split[3]), arrow.getDuration());
    }
}
Also used : ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) List(java.util.List) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)

Aggregations

ITimeGraphArrow (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)3 NonNull (org.eclipse.jdt.annotation.NonNull)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)2 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)2 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)2 ITimeGraphDataProvider (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider)2 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)2 ILinkEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent)2 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)2 TimeLinkEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NavigableSet (java.util.NavigableSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Nullable (org.eclipse.jdt.annotation.Nullable)1