aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilliano Molaire2014-04-23 13:15:23 (EDT)
committerGenevieve Bastien2014-05-02 15:13:50 (EDT)
commitc122e48c48dfa1f66b810e863210f1bc7048dca5 (patch)
treed7e98ef6cc7c868f44ae92bc052dbb07ed561289
parentc3a8495e6d61655d65fe604d09081d7dee9634f9 (diff)
downloadorg.eclipse.linuxtools-c122e48c48dfa1f66b810e863210f1bc7048dca5.zip
org.eclipse.linuxtools-c122e48c48dfa1f66b810e863210f1bc7048dca5.tar.gz
org.eclipse.linuxtools-c122e48c48dfa1f66b810e863210f1bc7048dca5.tar.bz2
TMF: Implementation of UstMemoryAnalysisModule requirementsrefs/changes/24/23424/15
The events needed by the analysis are added as requirements. We also add the information that the libc with probes should be loaded prior to starting the trace session. Change-Id: Idcfb13d7ae43bb73f6631c12f4eeb52fe74976d5 Signed-off-by: Guilliano Molaire <guilliamo-jaime.molaire@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/23424 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF4
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java1
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java27
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java101
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java38
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java43
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties2
8 files changed, 217 insertions, 5 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF
index 599a4fa..c848fed 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF
@@ -14,6 +14,8 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.linuxtools.tmf.core.tests;bundle-version="3.0.0",
org.eclipse.linuxtools.tmf.ctf.core,
org.eclipse.linuxtools.tmf.ctf.core.tests,
- org.eclipse.linuxtools.lttng2.ust.core
+ org.eclipse.linuxtools.lttng2.ust.core,
+ org.eclipse.linuxtools.lttng2.control.core
Export-Package: org.eclipse.linuxtools.lttng2.ust.core.tests,
org.eclipse.linuxtools.lttng2.ust.core.tests.trace.callstack
+Import-Package: com.google.common.collect
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java
index cd1cb1c..62e904d 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java
@@ -21,6 +21,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
ActivatorTest.class,
+ org.eclipse.linuxtools.lttng2.ust.core.tests.analysis.memory.AllTests.class,
org.eclipse.linuxtools.lttng2.ust.core.tests.trace.callstack.AllTests.class
})
public class AllTests { }
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java
new file mode 100644
index 0000000..98924bc
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guilliano Molaire - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.ust.core.tests.analysis.memory;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ UstMemoryAnalysisModuleTest.class
+})
+public class AllTests {
+
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java
new file mode 100644
index 0000000..cbf4563
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guilliano Molaire - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.ust.core.tests.analysis.memory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
+import org.eclipse.linuxtools.lttng2.control.core.session.SessionConfigStrings;
+import org.eclipse.linuxtools.lttng2.ust.core.analysis.memory.UstMemoryAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests for the {@link UstMemoryAnalysisModule}
+ *
+ * @author Guilliano Molaire
+ */
+public class UstMemoryAnalysisModuleTest {
+
+ /** The analysis module */
+ private UstMemoryAnalysisModule fUstAnalysisModule;
+
+ /**
+ * Set-up the test
+ */
+ @Before
+ public void setup() {
+ fUstAnalysisModule = new UstMemoryAnalysisModule();
+ }
+
+ /**
+ * Test for {@link UstMemoryAnalysisModule#getAnalysisRequirements()}
+ */
+ @Test
+ public void testGetAnalysisRequirements() {
+ Iterable<TmfAnalysisRequirement> requirements = fUstAnalysisModule.getAnalysisRequirements();
+ assertNotNull(requirements);
+ assertTrue(requirements.iterator().hasNext());
+
+ /* There should be the event and domain type */
+ TmfAnalysisRequirement eventReq = null;
+ TmfAnalysisRequirement domainReq = null;
+ int numberOfRequirement = 0;
+ for (TmfAnalysisRequirement requirement : requirements) {
+ ++numberOfRequirement;
+ if (requirement.getType().equals(SessionConfigStrings.CONFIG_ELEMENT_EVENT)) {
+ eventReq = requirement;
+ } else if (requirement.getType().equals(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN)) {
+ domainReq = requirement;
+ }
+ }
+ assertNotNull(eventReq);
+ assertNotNull(domainReq);
+
+ /* There should be two requirements */
+ assertEquals(2, numberOfRequirement);
+
+ /* Verify the content of the requirements themselves */
+ /* Domain should be kernel */
+ assertEquals(1, domainReq.getValues().size());
+ for (String domain : domainReq.getValues()) {
+ assertEquals(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, domain);
+ }
+
+ /* Events */
+ Set<String> expectedEvents = ImmutableSet.of(
+ UstMemoryStrings.MALLOC,
+ UstMemoryStrings.FREE,
+ UstMemoryStrings.CALLOC,
+ UstMemoryStrings.REALLOC,
+ UstMemoryStrings.MEMALIGN,
+ UstMemoryStrings.POSIX_MEMALIGN
+ );
+
+ assertEquals(6, eventReq.getValues().size());
+ for (String event : eventReq.getValues()) {
+ assertTrue("Unexpected event " + event, expectedEvents.contains(event));
+ }
+
+ Set<String> infos = eventReq.getInformation();
+ assertEquals(2, infos.size());
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF
index a07c767..1d29d34 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF
@@ -9,7 +9,7 @@ Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.ust.core.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.eclipse.linuxtools.internal.lttng2.ust.core;x-internal:=true,
- org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui",
+ org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui,org.eclipse.linuxtools.lttng2.ust.core.tests",
org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui,org.eclipse.linuxtools.lttng2.ust.core.tests",
org.eclipse.linuxtools.lttng2.ust.core.analysis.memory,
org.eclipse.linuxtools.lttng2.ust.core.trace
@@ -17,4 +17,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0",
org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
- org.eclipse.linuxtools.tmf.ctf.core
+ org.eclipse.linuxtools.tmf.ctf.core,
+ org.eclipse.linuxtools.lttng2.control.core
+Import-Package: com.google.common.collect
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java
new file mode 100644
index 0000000..90f39b7
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guilliano Molaire - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.lttng2.ust.core.analysis.memory;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Message bundle for the ust memory analysis module
+ *
+ * @author Guilliano Molaire
+ * @since 3.0
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng2.ust.core.analysis.memory.messages"; //$NON-NLS-1$
+
+ /** Information regarding events loading prior to the analysis execution */
+ public static String UstMemoryAnalysisModule_EventsLoadingInformation;
+
+ /** Example of how to execute the application with the libc wrapper */
+ public static String UstMemoryAnalysisModule_EventsLoadingExampleInformation;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
index 50856d0..e4b3bd2 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
@@ -8,17 +8,24 @@
*
* Contributors:
* Geneviève Bastien - Initial API and implementation
+ * Guilliano Molaire - Provide the requirements of the analysis
*******************************************************************************/
package org.eclipse.linuxtools.lttng2.ust.core.analysis.memory;
import org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage.MemoryUsageStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
+import org.eclipse.linuxtools.lttng2.control.core.session.SessionConfigStrings;
import org.eclipse.linuxtools.lttng2.ust.core.trace.LttngUstTrace;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import com.google.common.collect.ImmutableSet;
+
/**
* This analysis build a state system from the libc memory instrumentation on a
* UST trace
@@ -33,9 +40,37 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
*/
public static String ID = "org.eclipse.linuxtools.lttng2.ust.analysis.memory"; //$NON-NLS-1$
+ private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of(
+ UstMemoryStrings.MALLOC,
+ UstMemoryStrings.FREE,
+ UstMemoryStrings.CALLOC,
+ UstMemoryStrings.REALLOC,
+ UstMemoryStrings.MEMALIGN,
+ UstMemoryStrings.POSIX_MEMALIGN
+ );
+
+ /** The requirements as an immutable set */
+ private static final ImmutableSet<TmfAnalysisRequirement> REQUIREMENTS;
+
+ static {
+ /* Initialize the requirements for the analysis: domain and events */
+ TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
+ /*
+ * In order to have these events, the libc wrapper with probes should be
+ * loaded
+ */
+ eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation);
+ eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation);
+
+ /* The domain type of the analysis */
+ TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
+ domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY);
+
+ REQUIREMENTS = ImmutableSet.of(domainReq, eventsReq);
+ }
+
@Override
- protected
- ITmfStateProvider createStateProvider() {
+ protected ITmfStateProvider createStateProvider() {
return new MemoryUsageStateProvider(getTrace());
}
@@ -52,4 +87,8 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
return (LttngUstTrace) super.getTrace();
}
+ @Override
+ public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
+ return REQUIREMENTS;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties
new file mode 100644
index 0000000..fdc32e0
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties
@@ -0,0 +1,2 @@
+UstMemoryAnalysisModule_EventsLoadingInformation=The libc wrapper should be loaded in order to get the events in the trace output.
+UstMemoryAnalysisModule_EventsLoadingExampleInformation=Start the application to trace with: LD_PRELOAD=/path/to/liblttng-ust-libc-wrapper.so ./myProgram.