|
38 | 38 | import org.eclipse.tracecompass.analysis.profiling.core.base.FlameWithKernelPalette; |
39 | 39 | import org.eclipse.tracecompass.analysis.profiling.core.base.ICallStackElement; |
40 | 40 | import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICalledFunction; |
| 41 | +import org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis; |
41 | 42 | import org.eclipse.tracecompass.analysis.profiling.core.callstack2.CallStack; |
42 | 43 | import org.eclipse.tracecompass.analysis.profiling.core.callstack2.CallStackDepth; |
43 | 44 | import org.eclipse.tracecompass.analysis.profiling.core.callstack2.CallStackSeries; |
|
48 | 49 | import org.eclipse.tracecompass.internal.analysis.profiling.core.instrumented.FlameChartEntryModel.EntryType; |
49 | 50 | import org.eclipse.tracecompass.internal.analysis.profiling.core.model.ModelManager; |
50 | 51 | import org.eclipse.tracecompass.internal.analysis.profiling.core.model.ProcessStatusInterval; |
| 52 | +import org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils; |
51 | 53 | import org.eclipse.tracecompass.segmentstore.core.ISegment; |
| 54 | +import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; |
| 55 | +import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; |
52 | 56 | import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; |
53 | 57 | import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; |
54 | 58 | import org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderParameterUtils; |
|
57 | 61 | import org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider; |
58 | 62 | import org.eclipse.tracecompass.tmf.core.model.OutputElementStyle; |
59 | 63 | import org.eclipse.tracecompass.tmf.core.model.OutputStyleModel; |
| 64 | +import org.eclipse.tracecompass.tmf.core.model.StyleProperties; |
| 65 | +import org.eclipse.tracecompass.tmf.core.model.StyleProperties.SymbolType; |
| 66 | +import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation; |
| 67 | +import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationCategoriesModel; |
| 68 | +import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationModel; |
| 69 | +import org.eclipse.tracecompass.tmf.core.model.annotations.IOutputAnnotationProvider; |
| 70 | +import org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter; |
60 | 71 | import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow; |
61 | 72 | import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider; |
62 | 73 | import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel; |
|
70 | 81 | import org.eclipse.tracecompass.tmf.core.response.ITmfResponse; |
71 | 82 | import org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status; |
72 | 83 | import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse; |
| 84 | +import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; |
73 | 85 | import org.eclipse.tracecompass.tmf.core.symbols.ISymbolProvider; |
74 | 86 | import org.eclipse.tracecompass.tmf.core.symbols.SymbolProviderManager; |
75 | 87 | import org.eclipse.tracecompass.tmf.core.symbols.SymbolProviderUtils; |
|
84 | 96 | import com.google.common.collect.BiMap; |
85 | 97 | import com.google.common.collect.HashBiMap; |
86 | 98 | import com.google.common.collect.ImmutableList; |
| 99 | +import com.google.common.collect.ImmutableMap; |
87 | 100 | import com.google.common.collect.ImmutableList.Builder; |
88 | 101 | import com.google.common.collect.ImmutableMultimap; |
89 | 102 | import com.google.common.collect.Multimap; |
|
95 | 108 | * |
96 | 109 | * @author Geneviève Bastien |
97 | 110 | */ |
98 | | -public class FlameChartDataProvider extends AbstractTmfTraceDataProvider implements ITimeGraphDataProvider<FlameChartEntryModel>, IOutputStyleProvider { |
| 111 | +public class FlameChartDataProvider extends AbstractTmfTraceDataProvider implements ITimeGraphDataProvider<FlameChartEntryModel>, IOutputAnnotationProvider, IOutputStyleProvider { |
99 | 112 |
|
100 | 113 | /** |
101 | 114 | * Provider ID. |
@@ -345,7 +358,8 @@ public TmfModelResponse<TmfTreeModel<FlameChartEntryModel>> fetchTree(Map<String |
345 | 358 | boolean complete = fcProvider.isComplete(); |
346 | 359 | CallStackSeries callstack = fcProvider.getCallStackSeries(); |
347 | 360 | if (callstack == null) { |
348 | | - // Explicitly tell the client that the analysis is completed to prevent further polling |
| 361 | + // Explicitly tell the client that the analysis is completed to |
| 362 | + // prevent further polling |
349 | 363 | if (complete) { |
350 | 364 | return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), Collections.emptyList()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); |
351 | 365 | } |
@@ -710,4 +724,79 @@ public TmfModelResponse<OutputStyleModel> fetchStyle(Map<String, Object> fetchPa |
710 | 724 | Map<String, OutputElementStyle> styles = FlameWithKernelPalette.getInstance().getStyles(); |
711 | 725 | return new TmfModelResponse<>(new OutputStyleModel(styles), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); |
712 | 726 | } |
| 727 | + |
| 728 | + @Override |
| 729 | + public TmfModelResponse<AnnotationCategoriesModel> fetchAnnotationCategories(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) { |
| 730 | + return new TmfModelResponse<>(new AnnotationCategoriesModel(Collections.singletonList(CallStackAnalysis.ANNOTATIONS)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); |
| 731 | + } |
| 732 | + |
| 733 | + @Override |
| 734 | + public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) { |
| 735 | + |
| 736 | + if (!(fFcProvider instanceof TmfStateSystemAnalysisModule)) { |
| 737 | + return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED); |
| 738 | + } |
| 739 | + |
| 740 | + TmfStateSystemAnalysisModule csa = (TmfStateSystemAnalysisModule) fFcProvider; |
| 741 | + ITmfStateSystem ss = csa.getStateSystem(); |
| 742 | + if (ss == null) { |
| 743 | + return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED); |
| 744 | + } |
| 745 | + |
| 746 | + SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters); |
| 747 | + if (filter == null) { |
| 748 | + return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); |
| 749 | + } |
| 750 | + |
| 751 | + Map<Long, FlameChartEntryModel> selectedEntries = getSelectedEntries(fetchParameters); |
| 752 | + List<Annotation> annotations = new ArrayList<>(); |
| 753 | + |
| 754 | + try { |
| 755 | + for (Entry<@NonNull Long, @NonNull FlameChartEntryModel> entry : selectedEntries.entrySet()) { |
| 756 | + long csId = entry.getValue().getId(); |
| 757 | + CallStackDepth cs = fIdToCallstack.get(csId); |
| 758 | + if (cs == null) { |
| 759 | + continue; |
| 760 | + } |
| 761 | + |
| 762 | + int parentQuark = ss.getParentAttributeQuark(ss.getParentAttributeQuark(cs.getQuark())); |
| 763 | + if (parentQuark < 5) { |
| 764 | + new Object(); |
| 765 | + } |
| 766 | + int markersQuark = ss.optQuarkRelative(parentQuark, CallStackAnalysis.ANNOTATIONS); |
| 767 | + |
| 768 | + if (markersQuark != ITmfStateSystem.INVALID_ATTRIBUTE) { |
| 769 | + List<Long> times = DataProviderParameterUtils.extractTimeRequested(fetchParameters); |
| 770 | + for (ITmfStateInterval markerInterval : ss.query2D(Collections.singleton(markersQuark), times)) { |
| 771 | + if (!markerInterval.getStateValue().isNull()) { |
| 772 | + long startTime = markerInterval.getStartTime(); |
| 773 | + // Find callstack depth at marker start time |
| 774 | + int depth = 0; |
| 775 | + for (int i = 1; i <= ss.getNbAttributes(); i++) { |
| 776 | + int depthQuark = ss.optQuarkRelative(cs.getQuark(), String.valueOf(i)); |
| 777 | + if (depthQuark != ITmfStateSystem.INVALID_ATTRIBUTE) { |
| 778 | + ITmfStateInterval depthInterval = ss.querySingleState(startTime, depthQuark); |
| 779 | + if (!depthInterval.getStateValue().isNull()) { |
| 780 | + depth = i; |
| 781 | + } |
| 782 | + } |
| 783 | + } |
| 784 | + |
| 785 | + long entryId = entry.getKey(); |
| 786 | + long rowId = (depth > 0) ? entryId + depth : entryId; |
| 787 | + OutputElementStyle style = new OutputElementStyle(null, ImmutableMap.of( |
| 788 | + StyleProperties.COLOR, "#7D3D31", //$NON-NLS-1$ |
| 789 | + StyleProperties.HEIGHT, 0.5f, |
| 790 | + StyleProperties.SYMBOL_TYPE, SymbolType.DIAMOND)); |
| 791 | + annotations.add(new Annotation(startTime, 1, rowId,markerInterval.getStateValue().unboxStr(), style)); |
| 792 | + } |
| 793 | + } |
| 794 | + } |
| 795 | + } |
| 796 | + } catch (StateSystemDisposedException e) { |
| 797 | + return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, e.getMessage()); |
| 798 | + } |
| 799 | + |
| 800 | + return new TmfModelResponse<>(new AnnotationModel(Collections.singletonMap(CallStackAnalysis.ANNOTATIONS, annotations)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); |
| 801 | + } |
713 | 802 | } |
0 commit comments