1 /*******************************************************************************
2 * Copyright (c) 2014, 2016 École Polytechnique de Montréal and others
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
10 * Geneviève Bastien - Initial API and implementation
11 * Guilliano Molaire - Provide the requirements of the analysis
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.analysis
.memory
;
16 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.nullToEmptyString
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.jdt
.annotation
.Nullable
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.analysis
.memory
.UstMemoryStateProvider
;
24 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.LttngUstTrace
;
25 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.layout
.ILttngUstEventLayout
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAnalysisEventRequirement
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAbstractAnalysisRequirement
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAbstractAnalysisRequirement
.PriorityLevel
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
34 import com
.google
.common
.collect
.ImmutableSet
;
37 * This analysis build a state system from the libc memory instrumentation on a
40 * @author Geneviève Bastien
42 public class UstMemoryAnalysisModule
extends TmfStateSystemAnalysisModule
{
45 * Analysis ID, it should match that in the plugin.xml file
47 public static final @NonNull String ID
= "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$
49 /** The analysis's requirements. Only set after the trace is set. */
50 private @Nullable Set
<TmfAbstractAnalysisRequirement
> fAnalysisRequirements
;
53 protected ITmfStateProvider
createStateProvider() {
54 return new UstMemoryStateProvider(checkNotNull(getTrace()));
61 public boolean setTrace(ITmfTrace trace
) throws TmfAnalysisException
{
62 if (!(trace
instanceof LttngUstTrace
)) {
65 return super.setTrace(trace
);
72 public LttngUstTrace
getTrace() {
73 return (LttngUstTrace
) super.getTrace();
77 public Iterable
<TmfAbstractAnalysisRequirement
> getAnalysisRequirements() {
78 Set
<TmfAbstractAnalysisRequirement
> requirements
= fAnalysisRequirements
;
79 if (requirements
== null) {
80 LttngUstTrace trace
= getTrace();
81 ILttngUstEventLayout layout
;
83 layout
= ILttngUstEventLayout
.DEFAULT_LAYOUT
;
85 layout
= trace
.getEventLayout();
88 @NonNull Set
<@NonNull String
> requiredEvents
= ImmutableSet
.of(
89 layout
.eventLibcMalloc(),
90 layout
.eventLibcFree(),
91 layout
.eventLibcCalloc(),
92 layout
.eventLibcRealloc(),
93 layout
.eventLibcMemalign(),
94 layout
.eventLibcPosixMemalign()
97 /* Initialize the requirements for the analysis: domain and events */
98 TmfAbstractAnalysisRequirement eventsReq
= new TmfAnalysisEventRequirement(requiredEvents
, PriorityLevel
.MANDATORY
);
100 * In order to have these events, the libc wrapper with probes should be
103 eventsReq
.addInformation(nullToEmptyString(Messages
.UstMemoryAnalysisModule_EventsLoadingInformation
));
104 eventsReq
.addInformation(nullToEmptyString(Messages
.UstMemoryAnalysisModule_EventsLoadingExampleInformation
));
106 /* The domain type of the analysis */
107 // FIXME: The domain requirement should have a way to be verified. It is useless otherwise
108 // TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(nullToEmptyString(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN));
109 // domainReq.addValue(nullToEmptyString(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST), ValuePriorityLevel.MANDATORY);
111 requirements
= ImmutableSet
.of(eventsReq
);
112 fAnalysisRequirements
= requirements
;