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;
}
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);
}
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);
}
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;
}
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());
}
}
Aggregations