Commit | Line | Data |
---|---|---|
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 | ||
1996f571 | 14 | package org.eclipse.linuxtools.lttng2.ust.core.analysis.memory; |
2237fe8a GB |
15 | |
16 | import org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage.MemoryUsageStateProvider; | |
53e5d2d3 GM |
17 | import org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage.UstMemoryStrings; |
18 | import org.eclipse.linuxtools.lttng2.control.core.session.SessionConfigStrings; | |
2237fe8a | 19 | import org.eclipse.linuxtools.lttng2.ust.core.trace.LttngUstTrace; |
53e5d2d3 GM |
20 | import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement; |
21 | import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel; | |
2237fe8a GB |
22 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException; |
23 | import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; | |
24 | import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
25 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; | |
26 | ||
53e5d2d3 GM |
27 | import com.google.common.collect.ImmutableSet; |
28 | ||
2237fe8a GB |
29 | /** |
30 | * This analysis build a state system from the libc memory instrumentation on a | |
1996f571 | 31 | * UST trace |
2237fe8a GB |
32 | * |
33 | * @author Geneviève Bastien | |
34 | * @since 3.0 | |
35 | */ | |
36 | public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule { | |
37 | ||
38 | /** | |
39 | * Analysis ID, it should match that in the plugin.xml file | |
40 | */ | |
41 | public static String ID = "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$ | |
42 | ||
53e5d2d3 GM |
43 | private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of( |
44 | UstMemoryStrings.MALLOC, | |
45 | UstMemoryStrings.FREE, | |
46 | UstMemoryStrings.CALLOC, | |
47 | UstMemoryStrings.REALLOC, | |
48 | UstMemoryStrings.MEMALIGN, | |
49 | UstMemoryStrings.POSIX_MEMALIGN | |
50 | ); | |
51 | ||
52 | /** The requirements as an immutable set */ | |
53 | private static final ImmutableSet<TmfAnalysisRequirement> REQUIREMENTS; | |
54 | ||
55 | static { | |
56 | /* Initialize the requirements for the analysis: domain and events */ | |
57 | TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY); | |
58 | /* | |
59 | * In order to have these events, the libc wrapper with probes should be | |
60 | * loaded | |
61 | */ | |
62 | eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation); | |
63 | eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation); | |
64 | ||
65 | /* The domain type of the analysis */ | |
66 | TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN); | |
67 | domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY); | |
68 | ||
69 | REQUIREMENTS = ImmutableSet.of(domainReq, eventsReq); | |
70 | } | |
71 | ||
2237fe8a | 72 | @Override |
53e5d2d3 | 73 | protected ITmfStateProvider createStateProvider() { |
2237fe8a GB |
74 | return new MemoryUsageStateProvider(getTrace()); |
75 | } | |
76 | ||
2237fe8a GB |
77 | @Override |
78 | public void setTrace(ITmfTrace trace) throws TmfAnalysisException { | |
79 | if (!(trace instanceof LttngUstTrace)) { | |
80 | throw new IllegalStateException("UstMemoryAnalysisModule: trace should be of type LttngUstTrace"); //$NON-NLS-1$ | |
81 | } | |
82 | super.setTrace(trace); | |
83 | } | |
84 | ||
85 | @Override | |
86 | protected LttngUstTrace getTrace() { | |
87 | return (LttngUstTrace) super.getTrace(); | |
88 | } | |
89 | ||
53e5d2d3 GM |
90 | @Override |
91 | public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() { | |
92 | return REQUIREMENTS; | |
93 | } | |
2237fe8a | 94 | } |