use of org.eclipse.tracecompass.internal.tmf.core.analysis.callsite.CallsiteAnalysis 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.internal.tmf.core.analysis.callsite.CallsiteAnalysis in project tracecompass by tracecompass.
the class CallsiteTest method testCallsiteAnalysis.
/**
* Test the {@link ThreadStatusDataProvider} for the XML kernel test trace
*/
@Test
public void testCallsiteAnalysis() {
TmfXmlKernelTraceStub trace = fTrace;
assertNotNull(trace);
CallsiteAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, CallsiteAnalysis.class, CallsiteAnalysis.ID);
assertNotNull(module);
assertTrue(module.schedule().isOK());
assertTrue(module.waitForCompletion());
String uuid = String.valueOf(fTrace.getUUID());
String cpu = "cpu";
assertEquals(Collections.emptyList(), module.getCallsites(uuid, cpu, "0", 39));
assertEquals(EXPECTED_40, module.getCallsites(uuid, cpu, "0", 40));
assertEquals(EXPECTED_40, module.getCallsites(uuid, cpu, "0", 41));
assertEquals(EXPECTED_40, module.getCallsites(uuid, cpu, "0", 70));
assertEquals(EXPECTED_71, module.getCallsites(uuid, cpu, "0", 71));
assertEquals(EXPECTED_71, module.getCallsites(uuid, cpu, "0", 72));
assertEquals(Collections.emptyList(), module.getCallsites("Hello", cpu, "0", 42));
assertEquals(Collections.emptyList(), module.getCallsites(uuid, cpu, "1", 42));
assertEquals(Collections.emptyList(), module.getCallsites(uuid, cpu, "0", 12));
assertEquals(Collections.emptyList(), module.getCallsites(uuid, cpu, "..", 42));
}
use of org.eclipse.tracecompass.internal.tmf.core.analysis.callsite.CallsiteAnalysis in project tracecompass by tracecompass.
the class CallsiteTest method testIterator.
/**
* Test callsite iterator
*/
@Test
public void testIterator() {
TmfXmlKernelTraceStub trace = fTrace;
assertNotNull(trace);
CallsiteAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, CallsiteAnalysis.class, CallsiteAnalysis.ID);
assertNotNull(module);
assertTrue(module.schedule().isOK());
assertTrue(module.waitForCompletion());
UUID uuid = trace.getUUID();
assertNotNull(uuid);
String cpu = "cpu";
ITmfCallsiteIterator iter = module.iterator(uuid.toString(), cpu, "0", 1);
evaluateNextIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
evaluateNextIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
evaluateEmptyNextIterator(iter);
evaluateEmptyNextIterator(iter);
iter = module.iterator(uuid.toString(), cpu, "0", 40);
evaluateNextIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
iter = module.iterator(uuid.toString(), cpu, "0", 71);
evaluateNextIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
iter = module.iterator(uuid.toString(), cpu, "0", 72);
evaluateEmptyNextIterator(iter);
iter = module.iterator(uuid.toString(), cpu, "0", 99);
evaluatePrevIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
evaluatePrevIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
evaluateEmptyPrevIterator(iter);
evaluateEmptyPrevIterator(iter);
iter = module.iterator(uuid.toString(), cpu, "0", 71);
evaluatePrevIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
iter = module.iterator(uuid.toString(), cpu, "0", 40);
evaluatePrevIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
iter = module.iterator(uuid.toString(), cpu, "0", 39);
evaluateEmptyPrevIterator(iter);
iter = module.iterator(uuid.toString(), cpu, "0", 42);
for (int i = 0; i < 10; i++) {
evaluateNextIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
evaluateEmptyNextIterator(iter);
evaluatePrevIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
evaluateEmptyPrevIterator(iter);
}
iter = module.iterator(uuid.toString(), cpu, "0", 42);
for (int i = 0; i < 10; i++) {
evaluatePrevIterator(iter, 40, new TmfCallsite("fs/open.c", 0L));
evaluateEmptyPrevIterator(iter);
evaluateNextIterator(iter, 71, new TmfCallsite("fs/read_write.c", 0L));
evaluateEmptyNextIterator(iter);
}
iter = module.iterator("", cpu, "0", 42);
evaluateEmptyNextIterator(iter);
evaluateEmptyPrevIterator(iter);
iter = module.iterator(uuid.toString(), cpu, "elephant", 42);
evaluateEmptyNextIterator(iter);
evaluateEmptyPrevIterator(iter);
}
Aggregations