Commit | Line | Data |
---|---|---|
2237fe8a | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2014, 2015 École Polytechnique de Montréal |
2237fe8a GB |
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 | 14 | package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory; |
2237fe8a | 15 | |
5db5a3a4 AM |
16 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; |
17 | ||
18 | import java.util.Set; | |
19 | ||
ba27dd38 | 20 | import org.eclipse.jdt.annotation.NonNull; |
116738ad AM |
21 | import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStateProvider; |
22 | import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings; | |
9bc60be7 AM |
23 | import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings; |
24 | import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace; | |
2bdf0193 AM |
25 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement; |
26 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel; | |
27 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; | |
28 | import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | |
29 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
30 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | |
2237fe8a | 31 | |
53e5d2d3 GM |
32 | import 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 | |
2237fe8a GB |
39 | */ |
40 | public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule { | |
41 | ||
42 | /** | |
43 | * Analysis ID, it should match that in the plugin.xml file | |
44 | */ | |
1d83ed07 | 45 | public static final @NonNull String ID = "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$ |
2237fe8a | 46 | |
53e5d2d3 GM |
47 | private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of( |
48 | UstMemoryStrings.MALLOC, | |
49 | UstMemoryStrings.FREE, | |
50 | UstMemoryStrings.CALLOC, | |
51 | UstMemoryStrings.REALLOC, | |
52 | UstMemoryStrings.MEMALIGN, | |
53 | UstMemoryStrings.POSIX_MEMALIGN | |
54 | ); | |
55 | ||
56 | /** The requirements as an immutable set */ | |
5db5a3a4 | 57 | private static final @NonNull Set<TmfAnalysisRequirement> REQUIREMENTS; |
53e5d2d3 GM |
58 | |
59 | static { | |
60 | /* Initialize the requirements for the analysis: domain and events */ | |
61 | TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY); | |
62 | /* | |
63 | * In order to have these events, the libc wrapper with probes should be | |
64 | * loaded | |
65 | */ | |
66 | eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation); | |
67 | eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation); | |
68 | ||
69 | /* The domain type of the analysis */ | |
70 | TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN); | |
71 | domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY); | |
72 | ||
5db5a3a4 | 73 | REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventsReq)); |
53e5d2d3 GM |
74 | } |
75 | ||
2237fe8a | 76 | @Override |
53e5d2d3 | 77 | protected ITmfStateProvider createStateProvider() { |
116738ad | 78 | return new UstMemoryStateProvider(checkNotNull(getTrace())); |
2237fe8a GB |
79 | } |
80 | ||
f479550c GB |
81 | /** |
82 | * @since 1.0 | |
83 | */ | |
2237fe8a | 84 | @Override |
f479550c | 85 | public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException { |
2237fe8a | 86 | if (!(trace instanceof LttngUstTrace)) { |
f479550c | 87 | return false; |
2237fe8a | 88 | } |
f479550c | 89 | return super.setTrace(trace); |
2237fe8a GB |
90 | } |
91 | ||
92 | @Override | |
93 | protected LttngUstTrace getTrace() { | |
94 | return (LttngUstTrace) super.getTrace(); | |
95 | } | |
96 | ||
53e5d2d3 GM |
97 | @Override |
98 | public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() { | |
99 | return REQUIREMENTS; | |
100 | } | |
2237fe8a | 101 | } |