Skip to content

Commit 6dff891

Browse files
committed
callstack: add the possibility of having multiple callstacks having the same tid
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
1 parent b5bdbd3 commit 6dff891

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented

analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public TmfModelResponse<Map<String, String>> fetchTooltip(Map<String, Object> fe
289289
return new TmfModelResponse<>(tooltip, Status.COMPLETED, CommonStatusMessage.COMPLETED);
290290
}
291291
}
292+
292293
private @Nullable Map<String, String> getTooltip(Long entryId, FlameChartEntryModel entryModel, Long time) {
293294
switch (entryModel.getEntryType()) {
294295
case FUNCTION: {
@@ -579,23 +580,27 @@ private Map<Long, List<ITimeGraphState>> getKernelStates(List<TidInformation> ti
579580
Map<Long, List<ITimeGraphState>> kernelStates = new HashMap<>();
580581

581582
IHostModel model = ModelManager.getModelFor(getTrace().getHostId());
582-
Map<Integer, Long> threadIdsToEntryIds = tids.stream().collect(Collectors.toMap(tid -> tid.fTid.getTid(), tid -> tid.fLinked));
583+
Map<Integer, List<Long>> threadIdsToEntryIds = tids.stream().collect(Collectors.groupingBy(
584+
tid -> tid.fTid.getTid(),
585+
Collectors.mapping(tid -> tid.fLinked, Collectors.toList())));
583586
Map<Integer, Iterable<ProcessStatusInterval>> kernelStatuses = model.getThreadStatusIntervals(threadIdsToEntryIds.keySet(), times, monitor);
584587
for (Entry<Integer, Iterable<ProcessStatusInterval>> processStatuses : kernelStatuses.entrySet()) {
585-
Long linkedEntryId = threadIdsToEntryIds.get(processStatuses.getKey());
586-
if (linkedEntryId == null) {
588+
List<Long> linkedEntryIds = threadIdsToEntryIds.get(processStatuses.getKey());
589+
if (linkedEntryIds == null) {
587590
continue;
588591
}
589-
Long entryId = fLinkedEntries.get(linkedEntryId);
590-
if (entryId == null) {
591-
entryId = linkedEntryId;
592-
}
593-
List<ITimeGraphState> states = kernelStates.computeIfAbsent(linkedEntryId, k -> new ArrayList<>());
594-
for (ProcessStatusInterval processStatus : Objects.requireNonNull(processStatuses.getValue())) {
595-
OutputElementStyle style = new OutputElementStyle(
596-
FlameWithKernelPalette.getStyleFor(processStatus.getProcessStatus().getStateValue().unboxInt()));
597-
ITimeGraphState state = new TimeGraphState(processStatus.getStart(), processStatus.getLength(), processStatus.getSyscallName(), style);
598-
applyFilterAndAddState(states, state, entryId, predicates, monitor);
592+
for (Long linkedEntryId : linkedEntryIds) {
593+
Long entryId = fLinkedEntries.get(linkedEntryId);
594+
if (entryId == null) {
595+
entryId = linkedEntryId;
596+
}
597+
List<ITimeGraphState> states = kernelStates.computeIfAbsent(linkedEntryId, k -> new ArrayList<>());
598+
for (ProcessStatusInterval processStatus : Objects.requireNonNull(processStatuses.getValue())) {
599+
OutputElementStyle style = new OutputElementStyle(
600+
FlameWithKernelPalette.getStyleFor(processStatus.getProcessStatus().getStateValue().unboxInt()));
601+
ITimeGraphState state = new TimeGraphState(processStatus.getStart(), processStatus.getLength(), processStatus.getSyscallName(), style);
602+
applyFilterAndAddState(states, state, entryId, predicates, monitor);
603+
}
599604
}
600605
}
601606
return kernelStates;
@@ -727,7 +732,7 @@ public TmfModelResponse<OutputStyleModel> fetchStyle(Map<String, Object> fetchPa
727732

728733
@Override
729734
public TmfModelResponse<AnnotationCategoriesModel> fetchAnnotationCategories(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
730-
return new TmfModelResponse<>(new AnnotationCategoriesModel(Collections.singletonList( InstrumentedCallStackAnalysis.ANNOTATIONS)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
735+
return new TmfModelResponse<>(new AnnotationCategoriesModel(Collections.singletonList(InstrumentedCallStackAnalysis.ANNOTATIONS)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
731736
}
732737

733738
@Override
@@ -758,7 +763,7 @@ public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fe
758763
continue;
759764
}
760765
int parentQuark = ss.getParentAttributeQuark(ss.getParentAttributeQuark(cs.getQuark()));
761-
int markersQuark = ss.optQuarkRelative(parentQuark, InstrumentedCallStackAnalysis.ANNOTATIONS);
766+
int markersQuark = ss.optQuarkRelative(parentQuark, InstrumentedCallStackAnalysis.ANNOTATIONS);
762767
if (markersQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
763768
List<Long> times = DataProviderParameterUtils.extractTimeRequested(fetchParameters);
764769
for (ITmfStateInterval markerInterval : ss.query2D(Collections.singleton(markersQuark), times)) {
@@ -780,11 +785,11 @@ public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fe
780785
ITmfStateValue a = markerInterval.getStateValue();
781786
String annotValue = a.toString();
782787

783-
OutputElementStyle style = new OutputElementStyle(null, ImmutableMap.of(
784-
StyleProperties.COLOR, "#7D3D31", //$NON-NLS-1$
785-
StyleProperties.HEIGHT, 0.33f,
786-
StyleProperties.SYMBOL_TYPE, SymbolType.DIAMOND));
787-
annotations.add(new Annotation(startTime, 0, rowId, annotValue, style));
788+
OutputElementStyle style = new OutputElementStyle(null, ImmutableMap.of(
789+
StyleProperties.COLOR, "#7D3D31", //$NON-NLS-1$
790+
StyleProperties.HEIGHT, 0.33f,
791+
StyleProperties.SYMBOL_TYPE, SymbolType.DIAMOND));
792+
annotations.add(new Annotation(startTime, 0, rowId, annotValue, style));
788793
}
789794
}
790795
}
@@ -793,6 +798,6 @@ public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fe
793798
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, e.getMessage());
794799
}
795800

796-
return new TmfModelResponse<>(new AnnotationModel(Collections.singletonMap( InstrumentedCallStackAnalysis.ANNOTATIONS, annotations)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
801+
return new TmfModelResponse<>(new AnnotationModel(Collections.singletonMap(InstrumentedCallStackAnalysis.ANNOTATIONS, annotations)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
797802
}
798803
}

0 commit comments

Comments
 (0)