TMF: Implementation of UstMemoryAnalysisModule requirements
authorGuilliano Molaire <guilliamo-jaime.molaire@polymtl.ca>
Wed, 23 Apr 2014 17:15:23 +0000 (13:15 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 2 May 2014 19:13:50 +0000 (15:13 -0400)
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>
org.eclipse.linuxtools.lttng2.ust.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/AllTests.java
org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ust.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties [new file with mode: 0644]

index 599a4fae1f7e14e3d3246e47e4d4e4b27c299a0b..c848fed0887e6034688d21aa884cd46b4bbd52e4 100644 (file)
@@ -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
index cd1cb1cae707f7e6230e1fa4c3a046313c48eab4..62e904d9f3794832fb1a2dd1a49c05ce5dde0382 100644 (file)
@@ -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/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java b/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/AllTests.java
new file mode 100644 (file)
index 0000000..98924bc
--- /dev/null
@@ -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/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java b/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java
new file mode 100644 (file)
index 0000000..cbf4563
--- /dev/null
@@ -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());
+    }
+
+}
index a07c7671ba4b7fc121a91bf730a46adb77a68527..1d29d34308bd41ab9f99b1c380dd744bedaaf359 100644 (file)
@@ -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/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/Messages.java
new file mode 100644 (file)
index 0000000..90f39b7
--- /dev/null
@@ -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() {
+    }
+}
index 50856d0eb339f0fc976bc927dbae9864b43cecfc..e4b3bd2167ca35c5b4310a3c3a14d9fc82cbd59f 100644 (file)
@@ -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/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/analysis/memory/messages.properties
new file mode 100644 (file)
index 0000000..fdc32e0
--- /dev/null
@@ -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.
This page took 0.032637 seconds and 5 git commands to generate.