1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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
.linuxtools
.lttng2
.ust
.core
.analysis
.memory
;
16 import org
.eclipse
.linuxtools
.internal
.lttng2
.ust
.core
.memoryusage
.MemoryUsageStateProvider
;
17 import org
.eclipse
.linuxtools
.internal
.lttng2
.ust
.core
.memoryusage
.UstMemoryStrings
;
18 import org
.eclipse
.linuxtools
.lttng2
.control
.core
.session
.SessionConfigStrings
;
19 import org
.eclipse
.linuxtools
.lttng2
.ust
.core
.trace
.LttngUstTrace
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAnalysisRequirement
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAnalysisRequirement
.ValuePriorityLevel
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
27 import com
.google
.common
.collect
.ImmutableSet
;
30 * This analysis build a state system from the libc memory instrumentation on a
33 * @author Geneviève Bastien
36 public class UstMemoryAnalysisModule
extends TmfStateSystemAnalysisModule
{
39 * Analysis ID, it should match that in the plugin.xml file
41 public static String ID
= "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$
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
52 /** The requirements as an immutable set */
53 private static final ImmutableSet
<TmfAnalysisRequirement
> REQUIREMENTS
;
56 /* Initialize the requirements for the analysis: domain and events */
57 TmfAnalysisRequirement eventsReq
= new TmfAnalysisRequirement(SessionConfigStrings
.CONFIG_ELEMENT_EVENT
, REQUIRED_EVENTS
, ValuePriorityLevel
.MANDATORY
);
59 * In order to have these events, the libc wrapper with probes should be
62 eventsReq
.addInformation(Messages
.UstMemoryAnalysisModule_EventsLoadingInformation
);
63 eventsReq
.addInformation(Messages
.UstMemoryAnalysisModule_EventsLoadingExampleInformation
);
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
);
69 REQUIREMENTS
= ImmutableSet
.of(domainReq
, eventsReq
);
73 protected ITmfStateProvider
createStateProvider() {
74 return new MemoryUsageStateProvider(getTrace());
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$
82 super.setTrace(trace
);
86 protected LttngUstTrace
getTrace() {
87 return (LttngUstTrace
) super.getTrace();
91 public Iterable
<TmfAnalysisRequirement
> getAnalysisRequirements() {