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