Commit | Line | Data |
---|---|---|
792d23c2 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | *******************************************************************************/ | |
9 | package org.eclipse.tracecompass.internal.lttng2.ust.ui.analysis.callstack; | |
10 | ||
11 | import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; | |
12 | ||
13 | import java.util.ArrayList; | |
14 | import java.util.List; | |
15 | import java.util.Set; | |
16 | ||
17 | import org.eclipse.jdt.annotation.NonNull; | |
18 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
19 | import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout; | |
20 | import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement; | |
21 | import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement; | |
22 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | |
23 | ||
24 | import com.google.common.collect.ImmutableSet; | |
25 | ||
26 | /** | |
27 | * Analysis requirement implementation for LTTng Call Stack Analysis. | |
28 | * | |
29 | * @author Bernd Hufmann | |
30 | * | |
31 | */ | |
32 | @NonNullByDefault | |
33 | public class LttngUstCallStackAnalysisRequirement extends TmfAnalysisRequirement { | |
34 | ||
35 | private static String REQUIRMENT_TYPE = "event & context"; //$NON-NLS-1$ | |
36 | ||
37 | private List<TmfAnalysisEventFieldRequirement> fEntryRequirements = new ArrayList<>(); | |
38 | private List<TmfAnalysisEventFieldRequirement> fExitRequirements = new ArrayList<>(); | |
39 | /** | |
40 | * Constructor | |
41 | * | |
42 | * @param layout | |
43 | * The event layout (non-null) | |
44 | */ | |
45 | public LttngUstCallStackAnalysisRequirement(ILttngUstEventLayout layout) { | |
46 | super(REQUIRMENT_TYPE); | |
47 | ||
48 | Set<@NonNull String> requiredEventsFields = ImmutableSet.of( | |
49 | layout.contextProcname(), | |
50 | layout.contextVtid()); | |
51 | TmfAnalysisEventFieldRequirement requirement = new TmfAnalysisEventFieldRequirement( | |
52 | layout.eventCygProfileFuncEntry(), | |
53 | requiredEventsFields, | |
54 | ValuePriorityLevel.MANDATORY); | |
55 | fEntryRequirements.add(requirement); | |
56 | ||
57 | requirement = new TmfAnalysisEventFieldRequirement( | |
58 | layout.eventCygProfileFastFuncEntry(), | |
59 | requiredEventsFields, | |
60 | ValuePriorityLevel.MANDATORY); | |
61 | fEntryRequirements.add(requirement); | |
62 | ||
63 | requirement = new TmfAnalysisEventFieldRequirement( | |
64 | layout.eventCygProfileFuncExit(), | |
65 | requiredEventsFields, | |
66 | ValuePriorityLevel.MANDATORY); | |
67 | fExitRequirements.add(requirement); | |
68 | ||
69 | requirement = new TmfAnalysisEventFieldRequirement( | |
70 | layout.eventCygProfileFastFuncExit(), | |
71 | requiredEventsFields, | |
72 | ValuePriorityLevel.MANDATORY); | |
73 | fExitRequirements.add(requirement); | |
74 | ||
75 | // Add mandatory values (event names and context names) | |
76 | addValue(layout.eventCygProfileFuncEntry(), ValuePriorityLevel.MANDATORY); | |
77 | addValue(layout.eventCygProfileFuncExit(), ValuePriorityLevel.MANDATORY); | |
78 | addValues(requiredEventsFields, ValuePriorityLevel.MANDATORY); | |
79 | addInformation(nullToEmptyString(Messages.LttnUstCallStackAnalysisModule_EventsLoadingInformation)); | |
80 | } | |
81 | ||
82 | @Override | |
83 | public boolean test(ITmfTrace trace) { | |
84 | boolean fullfilled = fEntryRequirements.stream().anyMatch(requirement -> { | |
85 | return requirement.test(trace); | |
86 | }); | |
87 | ||
88 | if (fullfilled) { | |
89 | fullfilled = fExitRequirements.stream().anyMatch(requirement -> { | |
90 | return requirement.test(trace); | |
91 | }); | |
92 | } | |
93 | return fullfilled; | |
94 | } | |
95 | } |