tmf: Null-annotate state system API classes
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / lttng2 / ust / core / analysis / memory / UstMemoryAnalysisModule.java
CommitLineData
2237fe8a
GB
1/*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
53e5d2d3 11 * Guilliano Molaire - Provide the requirements of the analysis
2237fe8a
GB
12 *******************************************************************************/
13
9bc60be7 14package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory;
2237fe8a 15
5db5a3a4
AM
16import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
17
18import java.util.Set;
19
ba27dd38 20import org.eclipse.jdt.annotation.NonNull;
9bc60be7
AM
21import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.MemoryUsageStateProvider;
22import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
23import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
24import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
2bdf0193
AM
25import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
26import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
27import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
28import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
29import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
30import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
2237fe8a 31
53e5d2d3
GM
32import com.google.common.collect.ImmutableSet;
33
2237fe8a
GB
34/**
35 * This analysis build a state system from the libc memory instrumentation on a
1996f571 36 * UST trace
2237fe8a
GB
37 *
38 * @author Geneviève Bastien
39 * @since 3.0
40 */
41public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
42
43 /**
44 * Analysis ID, it should match that in the plugin.xml file
45 */
46 public static String ID = "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$
47
53e5d2d3
GM
48 private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of(
49 UstMemoryStrings.MALLOC,
50 UstMemoryStrings.FREE,
51 UstMemoryStrings.CALLOC,
52 UstMemoryStrings.REALLOC,
53 UstMemoryStrings.MEMALIGN,
54 UstMemoryStrings.POSIX_MEMALIGN
55 );
56
57 /** The requirements as an immutable set */
5db5a3a4 58 private static final @NonNull Set<TmfAnalysisRequirement> REQUIREMENTS;
53e5d2d3
GM
59
60 static {
61 /* Initialize the requirements for the analysis: domain and events */
62 TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
63 /*
64 * In order to have these events, the libc wrapper with probes should be
65 * loaded
66 */
67 eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation);
68 eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation);
69
70 /* The domain type of the analysis */
71 TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
72 domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY);
73
5db5a3a4 74 REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventsReq));
53e5d2d3
GM
75 }
76
2237fe8a 77 @Override
53e5d2d3 78 protected ITmfStateProvider createStateProvider() {
d0c7e4ba 79 return new MemoryUsageStateProvider(checkNotNull(getTrace()));
2237fe8a
GB
80 }
81
2237fe8a
GB
82 @Override
83 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
84 if (!(trace instanceof LttngUstTrace)) {
85 throw new IllegalStateException("UstMemoryAnalysisModule: trace should be of type LttngUstTrace"); //$NON-NLS-1$
86 }
87 super.setTrace(trace);
88 }
89
90 @Override
91 protected LttngUstTrace getTrace() {
92 return (LttngUstTrace) super.getTrace();
93 }
94
53e5d2d3
GM
95 @Override
96 public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
97 return REQUIREMENTS;
98 }
2237fe8a 99}
This page took 0.042457 seconds and 5 git commands to generate.