lttng: Update package and file names in lttng2.ust.core
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 23 Apr 2015 17:34:11 +0000 (13:34 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 27 Apr 2015 17:06:43 +0000 (13:06 -0400)
Harmonize the naming of the the UST memory analysis files and
packages.

Also renamed the "core.trace.callstack" package to just
"core.callstack". It is not specific to the trace package, and
its not an analysis module either (the Callstack is a public
TMF concept).

Change-Id: I0f2d085801a522f62bba09ae623f55043af24a03
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/46374
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
21 files changed:
org.eclipse.tracecompass.lttng2.ust.core.tests/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/AllTests.java
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/memory/UstMemoryAnalysisModuleTest.java
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AbstractProviderTest.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AllTests.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderFastTest.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderTest.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AllTests.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderFastTest.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderTest.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStrings.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/callstack/LttngUstCallStackProvider.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/MemoryUsageStateProvider.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/UstMemoryStrings.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java [deleted file]
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
org.eclipse.tracecompass.lttng2.ust.ui/src/org/eclipse/tracecompass/internal/lttng2/ust/ui/views/memusage/MemoryUsageViewer.java
org.eclipse.tracecompass.lttng2.ust.ui/src/org/eclipse/tracecompass/lttng2/ust/ui/analysis/callstack/LttngUstCallStackAnalysis.java

index bd00ec9c8ac6b5c7ed0c8d1ef97eb5bf1fbbac4a..16eade25903640ae615f6af786f5d9668ff722f6 100644 (file)
@@ -18,5 +18,5 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.tracecompass.lttng2.ust.core,
  org.eclipse.tracecompass.lttng2.control.core
 Export-Package: org.eclipse.tracecompass.lttng2.ust.core.tests,
- org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack
+ org.eclipse.tracecompass.lttng2.ust.core.tests.callstack
 Import-Package: com.google.common.collect
index 6ad9a45624e00bd1db11fa0162d5420292e2574a..36ed9f199185e1e78909ef8a7a86e4b7737b0536 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.runner.RunWith;
 @DebugSuite.SuiteClasses({
     ActivatorTest.class,
     org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.memory.AllTests.class,
-    org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack.AllTests.class
+    org.eclipse.tracecompass.lttng2.ust.core.tests.callstack.AllTests.class
 })
 public class AllTests {
 
index 964816b6f17f952ad279faf0be7487682408d1db..0ec8f10c939ecdbcd6b486fbe86b3c4c1730ef76 100644 (file)
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.Set;
 
-import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.memory.UstMemoryAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AbstractProviderTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AbstractProviderTest.java
new file mode 100644 (file)
index 0000000..d5b979b
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 Ericsson
+ *
+ * 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:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.tests.callstack;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackProvider;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
+import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
+import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.rules.Timeout;
+
+/**
+ * Base class for the UST callstack state provider tests.
+ *
+ * @author Alexandre Montplaisir
+ */
+public abstract class AbstractProviderTest {
+
+    /** Time-out tests after 20 seconds */
+    @Rule public TestRule globalTimeout= new Timeout(20000);
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private static final CtfTmfTestTrace otherUstTrace = CtfTmfTestTrace.HELLO_LOST;
+
+    private CtfTmfTrace fTrace = null;
+    private ITmfStateSystem fSS = null;
+    private TestLttngCallStackModule fModule;
+
+
+    // ------------------------------------------------------------------------
+    // Abstract methods
+    // ------------------------------------------------------------------------
+
+    /**
+     * @return The test trace to use for this test
+     */
+    protected abstract CtfTmfTestTrace getTestTrace();
+
+    /**
+     * @return The name of the executable process in that particular trace
+     */
+    protected abstract String getProcName();
+
+    /**
+     * Get the list of timestamps to query in that trace.
+     *
+     * @param index
+     *            Which of the test timestamps?
+     * @return That particular timestamp
+     */
+    protected abstract long getTestTimestamp(int index);
+
+    // ------------------------------------------------------------------------
+    // Maintenance
+    // ------------------------------------------------------------------------
+
+    /**
+     * Perform pre-class initialization.
+     */
+    @Before
+    public void setUp() {
+        CtfTmfTestTrace testTrace = getTestTrace();
+
+        CtfTmfTrace trace = testTrace.getTrace();
+        fTrace = trace;
+        fModule = new TestLttngCallStackModule();
+        try {
+            assertTrue(fModule.setTrace(trace));
+        } catch (TmfAnalysisException e) {
+            fail();
+        }
+        fModule.schedule();
+        assertTrue(fModule.waitForCompletion());
+
+        fSS = fModule.getStateSystem();
+        assertNotNull(fSS);
+    }
+
+    /**
+     * Perform post-class clean-up.
+     */
+    @After
+    public void tearDown() {
+        fModule.dispose();
+        if (fTrace != null) {
+            fTrace.dispose();
+            File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(fTrace));
+            deleteDirectory(suppDir);
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Test methods
+    // ------------------------------------------------------------------------
+
+    /**
+     * Test the handling of generic UST traces who do not contain the required
+     * information.
+     */
+    @Test
+    public void testOtherUstTrace() {
+        /* Initialize the trace and analysis module */
+        File suppDir;
+        try (CtfTmfTrace ustTrace = otherUstTrace.getTrace();) {
+            TestLttngCallStackModule module = null;
+            try {
+                module = new TestLttngCallStackModule();
+                try {
+                    assertTrue(module.setTrace(ustTrace));
+                } catch (TmfAnalysisException e) {
+                    fail();
+                }
+                module.schedule();
+                assertTrue(module.waitForCompletion());
+
+                /* Make sure the generated state system exists, but is empty */
+                ITmfStateSystem ss = module.getStateSystem();
+                assertNotNull(ss);
+                assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
+                assertEquals(0, ss.getNbAttributes());
+            } finally {
+                if (module != null) {
+                    module.dispose();
+                }
+            }
+            suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
+        }
+        deleteDirectory(suppDir);
+        assertFalse(suppDir.exists());
+    }
+
+    /**
+     * Test that the callstack state system is there and contains data.
+     */
+    @Test
+    public void testConstruction() {
+        assertNotNull(fSS);
+        assertTrue(fSS.getNbAttributes() > 0);
+    }
+
+    /**
+     * Test the callstack at the beginning of the state system.
+     */
+    @Test
+    public void testCallStackBegin() {
+        long start = fSS.getStartTime();
+        String[] cs = getCallStack(fSS, getProcName(), start);
+        assertEquals(1, cs.length);
+
+        assertEquals("40472b", cs[0]);
+    }
+
+    /**
+     * Test the callstack somewhere in the trace.
+     */
+    @Test
+    public void testCallStack1() {
+        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(0));
+        assertEquals(2, cs.length);
+
+        assertEquals("40472b", cs[0]);
+        assertEquals("403d60", cs[1]);
+    }
+
+    /**
+     * Test the callstack somewhere in the trace.
+     */
+    @Test
+    public void testCallStack2() {
+        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(1));
+        assertEquals(3, cs.length);
+
+        assertEquals("40472b", cs[0]);
+        assertEquals("403b14", cs[1]);
+        assertEquals("401b23", cs[2]);
+    }
+
+    /**
+     * Test the callstack somewhere in the trace.
+     */
+    @Test
+    public void testCallStack3() {
+        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(2));
+        assertEquals(4, cs.length);
+
+        assertEquals("40472b", cs[0]);
+        assertEquals("4045c8", cs[1]);
+        assertEquals("403760", cs[2]);
+        assertEquals("401aac", cs[3]);
+    }
+
+    /**
+     * Test the callstack at the end of the trace/state system.
+     */
+    @Test
+    public void testCallStackEnd() {
+        long end = fSS.getCurrentEndTime();
+        String[] cs = getCallStack(fSS, getProcName(), end);
+        assertEquals(3, cs.length);
+
+        assertEquals("40472b", cs[0]);
+        assertEquals("4045c8", cs[1]);
+        assertEquals("403760", cs[2]);
+    }
+
+    // ------------------------------------------------------------------------
+    // Utility methods
+    // ------------------------------------------------------------------------
+
+    /** Empty and delete a directory */
+    private static void deleteDirectory(File dir) {
+        /* Assuming the dir only contains file or empty directories */
+        for (File file : dir.listFiles()) {
+            file.delete();
+        }
+        dir.delete();
+    }
+
+    /** Get the callstack for the given timestamp, for this particular trace */
+    private static String[] getCallStack(ITmfStateSystem ss, String processName, long timestamp) {
+        try {
+            int stackAttribute = ss.getQuarkAbsolute("Threads", processName, "CallStack");
+            List<ITmfStateInterval> state = ss.queryFullState(timestamp);
+            int depth = state.get(stackAttribute).getStateValue().unboxInt();
+
+            int stackTop = ss.getQuarkRelative(stackAttribute, String.valueOf(depth));
+            ITmfStateValue expectedValue = state.get(stackTop).getStateValue();
+            ITmfStateInterval interval = StateSystemUtils.querySingleStackTop(ss, timestamp, stackAttribute);
+            assertNotNull(interval);
+            assertEquals(expectedValue, interval.getStateValue());
+
+            String[] ret = new String[depth];
+            for (int i = 0; i < depth; i++) {
+                int quark = ss.getQuarkRelative(stackAttribute, String.valueOf(i + 1));
+                ret[i] = state.get(quark).getStateValue().unboxStr();
+            }
+            return ret;
+
+        } catch (AttributeNotFoundException e) {
+            fail(e.getMessage());
+        } catch (StateSystemDisposedException e) {
+            fail(e.getMessage());
+        }
+        fail();
+        return null;
+    }
+
+    private class TestLttngCallStackModule extends TmfStateSystemAnalysisModule {
+
+        @Override
+        protected ITmfStateProvider createStateProvider() {
+            return new LttngUstCallStackProvider(checkNotNull(getTrace()));
+        }
+    }
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AllTests.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AllTests.java
new file mode 100644 (file)
index 0000000..70b2807
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2015 Ericsson
+ *
+ * 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:
+ *   Alexandre Montplaisir - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.tests.callstack;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    LttngUstCallStackProviderFastTest.class,
+    LttngUstCallStackProviderTest.class
+})
+public class AllTests {
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderFastTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderFastTest.java
new file mode 100644 (file)
index 0000000..56935ac
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Ericsson
+ *
+ * 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:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.tests.callstack;
+
+import static org.junit.Assume.assumeTrue;
+
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.junit.BeforeClass;
+
+/**
+ * Test suite for the UST callstack state provider, using the trace of a program
+ * instrumented with lttng-ust-cyg-profile-fast.so tracepoints. These do not
+ * contain the function addresses in the func_exit events.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class LttngUstCallStackProviderFastTest extends AbstractProviderTest {
+
+    private static final long[] timestamps = { 1379361250310000000L,
+                                               1379361250498400000L,
+                                               1379361250499759000L };
+
+    /**
+     * Class setup
+     */
+    @BeforeClass
+    public static void setUpClass() {
+        assumeTrue(CtfTmfTestTrace.CYG_PROFILE_FAST.exists());
+    }
+
+    @Override
+    protected CtfTmfTestTrace getTestTrace() {
+        return CtfTmfTestTrace.CYG_PROFILE_FAST;
+    }
+
+    @Override
+    protected String getProcName() {
+        return "glxgears-29822";
+    }
+
+    @Override
+    protected long getTestTimestamp(int index) {
+        return timestamps[index];
+    }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LttngUstCallStackProviderTest.java
new file mode 100644 (file)
index 0000000..b5d2792
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Ericsson
+ *
+ * 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:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.tests.callstack;
+
+import static org.junit.Assume.assumeTrue;
+
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.junit.BeforeClass;
+
+/**
+ * Test suite for the UST callstack state provider, using the trace of a program
+ * instrumented with lttng-ust-cyg-profile.so tracepoints.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class LttngUstCallStackProviderTest extends AbstractProviderTest {
+
+    private static final long[] timestamps = { 1378850463600000000L,
+                                               1378850463770000000L,
+                                               1378850463868753000L };
+
+    /**
+     * Class setup
+     */
+    @BeforeClass
+    public static void setUpClass() {
+        assumeTrue(CtfTmfTestTrace.CYG_PROFILE.exists());
+    }
+
+    @Override
+    protected CtfTmfTestTrace getTestTrace() {
+        return CtfTmfTestTrace.CYG_PROFILE;
+    }
+
+    @Override
+    protected String getProcName() {
+        return "glxgears-16073";
+    }
+
+    @Override
+    protected long getTestTimestamp(int index) {
+        return timestamps[index];
+    }
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java
deleted file mode 100644 (file)
index 92f01f3..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 Ericsson
- *
- * 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:
- *   Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
-import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
-import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
-import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-/**
- * Base class for the UST callstack state provider tests.
- *
- * @author Alexandre Montplaisir
- */
-public abstract class AbstractProviderTest {
-
-    /** Time-out tests after 20 seconds */
-    @Rule public TestRule globalTimeout= new Timeout(20000);
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    private static final CtfTmfTestTrace otherUstTrace = CtfTmfTestTrace.HELLO_LOST;
-
-    private CtfTmfTrace fTrace = null;
-    private ITmfStateSystem fSS = null;
-    private TestLttngCallStackModule fModule;
-
-
-    // ------------------------------------------------------------------------
-    // Abstract methods
-    // ------------------------------------------------------------------------
-
-    /**
-     * @return The test trace to use for this test
-     */
-    protected abstract CtfTmfTestTrace getTestTrace();
-
-    /**
-     * @return The name of the executable process in that particular trace
-     */
-    protected abstract String getProcName();
-
-    /**
-     * Get the list of timestamps to query in that trace.
-     *
-     * @param index
-     *            Which of the test timestamps?
-     * @return That particular timestamp
-     */
-    protected abstract long getTestTimestamp(int index);
-
-    // ------------------------------------------------------------------------
-    // Maintenance
-    // ------------------------------------------------------------------------
-
-    /**
-     * Perform pre-class initialization.
-     */
-    @Before
-    public void setUp() {
-        CtfTmfTestTrace testTrace = getTestTrace();
-
-        CtfTmfTrace trace = testTrace.getTrace();
-        fTrace = trace;
-        fModule = new TestLttngCallStackModule();
-        try {
-            assertTrue(fModule.setTrace(trace));
-        } catch (TmfAnalysisException e) {
-            fail();
-        }
-        fModule.schedule();
-        assertTrue(fModule.waitForCompletion());
-
-        fSS = fModule.getStateSystem();
-        assertNotNull(fSS);
-    }
-
-    /**
-     * Perform post-class clean-up.
-     */
-    @After
-    public void tearDown() {
-        fModule.dispose();
-        if (fTrace != null) {
-            fTrace.dispose();
-            File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(fTrace));
-            deleteDirectory(suppDir);
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // Test methods
-    // ------------------------------------------------------------------------
-
-    /**
-     * Test the handling of generic UST traces who do not contain the required
-     * information.
-     */
-    @Test
-    public void testOtherUstTrace() {
-        /* Initialize the trace and analysis module */
-        File suppDir;
-        try (CtfTmfTrace ustTrace = otherUstTrace.getTrace();) {
-            TestLttngCallStackModule module = null;
-            try {
-                module = new TestLttngCallStackModule();
-                try {
-                    assertTrue(module.setTrace(ustTrace));
-                } catch (TmfAnalysisException e) {
-                    fail();
-                }
-                module.schedule();
-                assertTrue(module.waitForCompletion());
-
-                /* Make sure the generated state system exists, but is empty */
-                ITmfStateSystem ss = module.getStateSystem();
-                assertNotNull(ss);
-                assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
-                assertEquals(0, ss.getNbAttributes());
-            } finally {
-                if (module != null) {
-                    module.dispose();
-                }
-            }
-            suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
-        }
-        deleteDirectory(suppDir);
-        assertFalse(suppDir.exists());
-    }
-
-    /**
-     * Test that the callstack state system is there and contains data.
-     */
-    @Test
-    public void testConstruction() {
-        assertNotNull(fSS);
-        assertTrue(fSS.getNbAttributes() > 0);
-    }
-
-    /**
-     * Test the callstack at the beginning of the state system.
-     */
-    @Test
-    public void testCallStackBegin() {
-        long start = fSS.getStartTime();
-        String[] cs = getCallStack(fSS, getProcName(), start);
-        assertEquals(1, cs.length);
-
-        assertEquals("40472b", cs[0]);
-    }
-
-    /**
-     * Test the callstack somewhere in the trace.
-     */
-    @Test
-    public void testCallStack1() {
-        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(0));
-        assertEquals(2, cs.length);
-
-        assertEquals("40472b", cs[0]);
-        assertEquals("403d60", cs[1]);
-    }
-
-    /**
-     * Test the callstack somewhere in the trace.
-     */
-    @Test
-    public void testCallStack2() {
-        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(1));
-        assertEquals(3, cs.length);
-
-        assertEquals("40472b", cs[0]);
-        assertEquals("403b14", cs[1]);
-        assertEquals("401b23", cs[2]);
-    }
-
-    /**
-     * Test the callstack somewhere in the trace.
-     */
-    @Test
-    public void testCallStack3() {
-        String[] cs = getCallStack(fSS, getProcName(), getTestTimestamp(2));
-        assertEquals(4, cs.length);
-
-        assertEquals("40472b", cs[0]);
-        assertEquals("4045c8", cs[1]);
-        assertEquals("403760", cs[2]);
-        assertEquals("401aac", cs[3]);
-    }
-
-    /**
-     * Test the callstack at the end of the trace/state system.
-     */
-    @Test
-    public void testCallStackEnd() {
-        long end = fSS.getCurrentEndTime();
-        String[] cs = getCallStack(fSS, getProcName(), end);
-        assertEquals(3, cs.length);
-
-        assertEquals("40472b", cs[0]);
-        assertEquals("4045c8", cs[1]);
-        assertEquals("403760", cs[2]);
-    }
-
-    // ------------------------------------------------------------------------
-    // Utility methods
-    // ------------------------------------------------------------------------
-
-    /** Empty and delete a directory */
-    private static void deleteDirectory(File dir) {
-        /* Assuming the dir only contains file or empty directories */
-        for (File file : dir.listFiles()) {
-            file.delete();
-        }
-        dir.delete();
-    }
-
-    /** Get the callstack for the given timestamp, for this particular trace */
-    private static String[] getCallStack(ITmfStateSystem ss, String processName, long timestamp) {
-        try {
-            int stackAttribute = ss.getQuarkAbsolute("Threads", processName, "CallStack");
-            List<ITmfStateInterval> state = ss.queryFullState(timestamp);
-            int depth = state.get(stackAttribute).getStateValue().unboxInt();
-
-            int stackTop = ss.getQuarkRelative(stackAttribute, String.valueOf(depth));
-            ITmfStateValue expectedValue = state.get(stackTop).getStateValue();
-            ITmfStateInterval interval = StateSystemUtils.querySingleStackTop(ss, timestamp, stackAttribute);
-            assertNotNull(interval);
-            assertEquals(expectedValue, interval.getStateValue());
-
-            String[] ret = new String[depth];
-            for (int i = 0; i < depth; i++) {
-                int quark = ss.getQuarkRelative(stackAttribute, String.valueOf(i + 1));
-                ret[i] = state.get(quark).getStateValue().unboxStr();
-            }
-            return ret;
-
-        } catch (AttributeNotFoundException e) {
-            fail(e.getMessage());
-        } catch (StateSystemDisposedException e) {
-            fail(e.getMessage());
-        }
-        fail();
-        return null;
-    }
-
-    private class TestLttngCallStackModule extends TmfStateSystemAnalysisModule {
-
-        @Override
-        protected ITmfStateProvider createStateProvider() {
-            return new LttngUstCallStackProvider(checkNotNull(getTrace()));
-        }
-    }
-}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AllTests.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/AllTests.java
deleted file mode 100644 (file)
index 9f42e3c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2015 Ericsson
- *
- * 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:
- *   Alexandre Montplaisir - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    LttngUstCallStackProviderFastTest.class,
-    LttngUstCallStackProviderTest.class
-})
-public class AllTests {
-
-}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderFastTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderFastTest.java
deleted file mode 100644 (file)
index e2bbd57..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
- *
- * 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:
- *   Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack;
-
-import static org.junit.Assume.assumeTrue;
-
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.junit.BeforeClass;
-
-/**
- * Test suite for the UST callstack state provider, using the trace of a program
- * instrumented with lttng-ust-cyg-profile-fast.so tracepoints. These do not
- * contain the function addresses in the func_exit events.
- *
- * @author Alexandre Montplaisir
- */
-public class LttngUstCallStackProviderFastTest extends AbstractProviderTest {
-
-    private static final long[] timestamps = { 1379361250310000000L,
-                                               1379361250498400000L,
-                                               1379361250499759000L };
-
-    /**
-     * Class setup
-     */
-    @BeforeClass
-    public static void setUpClass() {
-        assumeTrue(CtfTmfTestTrace.CYG_PROFILE_FAST.exists());
-    }
-
-    @Override
-    protected CtfTmfTestTrace getTestTrace() {
-        return CtfTmfTestTrace.CYG_PROFILE_FAST;
-    }
-
-    @Override
-    protected String getProcName() {
-        return "glxgears-29822";
-    }
-
-    @Override
-    protected long getTestTimestamp(int index) {
-        return timestamps[index];
-    }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderTest.java b/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/trace/callstack/LttngUstCallStackProviderTest.java
deleted file mode 100644 (file)
index 7aa1d66..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
- *
- * 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:
- *   Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.lttng2.ust.core.tests.trace.callstack;
-
-import static org.junit.Assume.assumeTrue;
-
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.junit.BeforeClass;
-
-/**
- * Test suite for the UST callstack state provider, using the trace of a program
- * instrumented with lttng-ust-cyg-profile.so tracepoints.
- *
- * @author Alexandre Montplaisir
- */
-public class LttngUstCallStackProviderTest extends AbstractProviderTest {
-
-    private static final long[] timestamps = { 1378850463600000000L,
-                                               1378850463770000000L,
-                                               1378850463868753000L };
-
-    /**
-     * Class setup
-     */
-    @BeforeClass
-    public static void setUpClass() {
-        assumeTrue(CtfTmfTestTrace.CYG_PROFILE.exists());
-    }
-
-    @Override
-    protected CtfTmfTestTrace getTestTrace() {
-        return CtfTmfTestTrace.CYG_PROFILE;
-    }
-
-    @Override
-    protected String getProcName() {
-        return "glxgears-16073";
-    }
-
-    @Override
-    protected long getTestTimestamp(int index) {
-        return timestamps[index];
-    }
-
-}
index aa767400a353140528aa2ac25a5e4523eed08598..abc60e790d0ab65fe676c0de65a1d31ca3ca2962 100644 (file)
@@ -9,8 +9,8 @@ Bundle-Activator: org.eclipse.tracecompass.internal.lttng2.ust.core.Activator
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Export-Package: org.eclipse.tracecompass.internal.lttng2.ust.core;x-friends:="org.eclipse.tracecompass.lttng2.ust.core.tests,org.eclipse.tracecompass.lttng2.ust.ui",
- org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
- org.eclipse.tracecompass.internal.lttng2.ust.core.trace.callstack;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
+ org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
+ org.eclipse.tracecompass.internal.lttng2.ust.core.callstack;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
  org.eclipse.tracecompass.lttng2.ust.core.analysis.memory,
  org.eclipse.tracecompass.lttng2.ust.core.trace
 Require-Bundle: org.eclipse.core.runtime,
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java
new file mode 100644 (file)
index 0000000..3175711
--- /dev/null
@@ -0,0 +1,204 @@
+/**********************************************************************
+ * Copyright (c) 2014, 2015 Ericsson, É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:
+ *   Matthew Khouzam - Initial API and implementation
+ *   Geneviève Bastien - Memory is per thread and only total is kept
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
+import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+
+/**
+ * State provider to track the memory of the threads using the UST libc wrapper
+ * memory events.
+ *
+ * @author Matthew Khouzam
+ * @author Geneviève Bastien
+ */
+public class UstMemoryStateProvider extends AbstractTmfStateProvider {
+
+    /* Version of this state provider */
+    private static final int VERSION = 1;
+
+    /* Maps a pointer to a memory zone to the size of the memory */
+    private final Map<Long, Long> fMemory = new HashMap<>();
+
+    private static final Long MINUS_ONE = Long.valueOf(-1);
+    private static final Long ZERO = Long.valueOf(0);
+    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+    /**
+     * Constructor
+     *
+     * @param trace
+     *            trace
+     */
+    public UstMemoryStateProvider(@NonNull LttngUstTrace trace) {
+        super(trace, "Ust:Memory"); //$NON-NLS-1$
+    }
+
+    @Override
+    protected void eventHandle(ITmfEvent event) {
+        String name = event.getName();
+        switch (name) {
+        case UstMemoryStrings.MALLOC: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            setMem(event, ptr, size);
+        }
+            break;
+        case UstMemoryStrings.FREE: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            setMem(event, ptr, ZERO);
+        }
+            break;
+        case UstMemoryStrings.CALLOC: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            Long nmemb = (Long) event.getContent().getField(UstMemoryStrings.FIELD_NMEMB).getValue();
+            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            setMem(event, ptr, size * nmemb);
+        }
+            break;
+        case UstMemoryStrings.REALLOC: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            Long newPtr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_INPTR).getValue();
+            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            setMem(event, ptr, ZERO);
+            setMem(event, newPtr, size);
+        }
+            break;
+        case UstMemoryStrings.MEMALIGN: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            setMem(event, ptr, size);
+        }
+            break;
+        case UstMemoryStrings.POSIX_MEMALIGN: {
+            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_OUTPTR).getValue();
+            if (ZERO.equals(ptr)) {
+                return;
+            }
+            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
+            setMem(event, ptr, size);
+        }
+            break;
+        default:
+            break;
+        }
+
+    }
+
+    @Override
+    public ITmfStateProvider getNewInstance() {
+        return new UstMemoryStateProvider(getTrace());
+    }
+
+    @Override
+    public LttngUstTrace getTrace() {
+        return (LttngUstTrace) super.getTrace();
+    }
+
+    @Override
+    public int getVersion() {
+        return VERSION;
+    }
+
+    private static Long getVtid(ITmfEvent event) {
+        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_VTID);
+        if (field == null) {
+            return MINUS_ONE;
+        }
+        return (Long) field.getValue();
+    }
+
+    private static String getProcname(ITmfEvent event) {
+        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_PROCNAME);
+        if (field == null) {
+            return EMPTY_STRING;
+        }
+        return (String) field.getValue();
+    }
+
+    private void setMem(ITmfEvent event, Long ptr, Long size) {
+        ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
+        long ts = event.getTimestamp().getValue();
+        Long tid = getVtid(event);
+
+        Long memoryDiff = size;
+        /* Size is 0, it means it was deleted */
+        if (ZERO.equals(size)) {
+            Long memSize = fMemory.remove(ptr);
+            if (memSize == null) {
+                return;
+            }
+            memoryDiff = -memSize;
+        } else {
+            fMemory.put(ptr, size);
+        }
+        try {
+            int tidQuark = ss.getQuarkAbsoluteAndAdd(tid.toString());
+            int tidMemQuark = ss.getQuarkRelativeAndAdd(tidQuark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE);
+
+            ITmfStateValue prevMem = ss.queryOngoingState(tidMemQuark);
+            /* First time we set this value */
+            if (prevMem.isNull()) {
+                int procNameQuark = ss.getQuarkRelativeAndAdd(tidQuark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
+                String procName = getProcname(event);
+                /*
+                 * No tid/procname for the event for the event, added to a
+                 * 'others' thread
+                 */
+                if (tid.equals(MINUS_ONE)) {
+                    procName = UstMemoryStrings.OTHERS;
+                }
+                ss.modifyAttribute(ts, TmfStateValue.newValueString(procName), procNameQuark);
+                prevMem = TmfStateValue.newValueLong(0);
+            }
+
+            long prevMemValue = prevMem.unboxLong();
+            prevMemValue += memoryDiff.longValue();
+            ss.modifyAttribute(ts, TmfStateValue.newValueLong(prevMemValue), tidMemQuark);
+        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStrings.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStrings.java
new file mode 100644 (file)
index 0000000..b573a3f
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson, É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:
+ *   Matthew Khouzam, Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;
+
+/**
+ * Strings for the memory usage state system using the LTTng UST libc
+ * instrumentation
+ *
+ * @author Matthew Khouzam
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings({ "nls", "javadoc" })
+public interface UstMemoryStrings {
+
+    /** Memory state system attribute name */
+    static final String UST_MEMORY_MEMORY_ATTRIBUTE = "Memory"; //$NON-NLS-1$
+    /** Procname state system attribute name */
+    static final String UST_MEMORY_PROCNAME_ATTRIBUTE = "Procname"; //$NON-NLS-1$
+    /** Name of the attribute to store memory usage of events with no context */
+    static final String OTHERS = "Others";
+
+    /* UST_libc event names */
+    static final String MALLOC = "ust_libc:malloc";
+    static final String CALLOC = "ust_libc:calloc";
+    static final String REALLOC = "ust_libc:realloc";
+    static final String FREE = "ust_libc:free";
+    static final String MEMALIGN = "ust_libc:memalign";
+    static final String POSIX_MEMALIGN = "ust_libc:posix_memalign";
+
+    /* Possible contexts */
+    static final String CONTEXT_VTID = "context._vtid";
+    static final String CONTEXT_PROCNAME = "context._procname";
+
+    /* Event fields */
+    static final String FIELD_PTR = "ptr";
+    static final String FIELD_NMEMB = "nmemb";
+    static final String FIELD_SIZE = "size";
+    static final String FIELD_OUTPTR = "out_ptr";
+    static final String FIELD_INPTR = "in_ptr";
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/callstack/LttngUstCallStackProvider.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/callstack/LttngUstCallStackProvider.java
new file mode 100644 (file)
index 0000000..6d14911
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2015 Ericsson
+ *
+ * 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:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *   Patrick Tasse - Add support for thread id
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.ust.core.callstack;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.callstack.CallStackStateProvider;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+
+/**
+ * Callstack provider for LTTng-UST traces.
+ *
+ * If the traces contains 'func_entry' and 'func_exit' event (see the
+ * lttng-ust-cyg-profile manpage), AND contains vtid and procname contexts, we
+ * can use this information to populate the TMF Callstack View.
+ *
+ * Granted, most UST traces will not contain this information. In this case,
+ * this will simply build an empty state system, and the view will remain
+ * unavailable.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class LttngUstCallStackProvider extends CallStackStateProvider {
+
+    // ------------------------------------------------------------------------
+    // Event strings
+    // ------------------------------------------------------------------------
+
+    /** Name of the fake field for the vtid contexts */
+    private static final String CONTEXT_VTID = "context._vtid"; //$NON-NLS-1$
+
+    /** Name of the fake field for the procname context */
+    private static final String CONTEXT_PROCNAME = "context._procname"; //$NON-NLS-1$
+
+    /** Field name for the target function address */
+    private static final String FIELD_ADDR = "addr"; //$NON-NLS-1$
+
+    /** Event names indicating function entry */
+    private static final Set<String> FUNC_ENTRY_EVENTS = new HashSet<>();
+
+    /** Event names indicating function exit */
+    private static final Set<String> FUNC_EXIT_EVENTS = new HashSet<>();
+
+    static {
+        /* This seems overkill, but it will be checked every event. Gotta go FAST! */
+        FUNC_ENTRY_EVENTS.add("lttng_ust_cyg_profile:func_entry"); //$NON-NLS-1$
+        FUNC_ENTRY_EVENTS.add("lttng_ust_cyg_profile_fast:func_entry"); //$NON-NLS-1$
+
+        FUNC_EXIT_EVENTS.add("lttng_ust_cyg_profile:func_exit"); //$NON-NLS-1$
+        FUNC_EXIT_EVENTS.add("lttng_ust_cyg_profile_fast:func_exit"); //$NON-NLS-1$
+    }
+
+    /**
+     * Version number of this state provider. Please bump this if you modify
+     * the contents of the generated state history in some way.
+     */
+    private static final int VERSION = 2;
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructor
+     *
+     * @param trace
+     *            The UST trace
+     */
+    public LttngUstCallStackProvider(@NonNull ITmfTrace trace) {
+        super(trace);
+    }
+
+    // ------------------------------------------------------------------------
+    // Methods from AbstractTmfStateProvider
+    // ------------------------------------------------------------------------
+
+    @Override
+    public LttngUstCallStackProvider getNewInstance() {
+        return new LttngUstCallStackProvider(getTrace());
+    }
+
+    @Override
+    public int getVersion() {
+        return VERSION;
+    }
+
+    // ------------------------------------------------------------------------
+    // Methods from CallStackStateProvider
+    // ------------------------------------------------------------------------
+
+    /**
+     * Check that this event contains the required information we need to be
+     * used in the call stack view. We need at least the "procname" and "vtid"
+     * contexts.
+     */
+    @Override
+    protected boolean considerEvent(ITmfEvent event) {
+        if (!(event instanceof CtfTmfEvent)) {
+            return false;
+        }
+        ITmfEventField content = ((CtfTmfEvent) event).getContent();
+        if (content.getField(CONTEXT_VTID) == null ||
+                content.getField(CONTEXT_PROCNAME) == null) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String functionEntry(ITmfEvent event) {
+        String eventName = event.getName();
+        if (!FUNC_ENTRY_EVENTS.contains(eventName)) {
+            return null;
+        }
+        Long address = (Long) event.getContent().getField(FIELD_ADDR).getValue();
+        return Long.toHexString(address);
+    }
+
+    @Override
+    public String functionExit(ITmfEvent event) {
+        String eventName = event.getName();
+        if (!FUNC_EXIT_EVENTS.contains(eventName)) {
+            return null;
+        }
+        /*
+         * The 'addr' field may or may not be present in func_exit events,
+         * depending on if cyg-profile.so or cyg-profile-fast.so was used.
+         */
+        ITmfEventField field = event.getContent().getField(FIELD_ADDR);
+        if (field == null) {
+            return CallStackStateProvider.UNDEFINED;
+        }
+        Long address = (Long) field.getValue();
+        return Long.toHexString(address);
+    }
+
+    @Override
+    public String getThreadName(ITmfEvent event) {
+        /* Class type and content was already checked if we get called here */
+        ITmfEventField content = ((CtfTmfEvent) event).getContent();
+        String procName = (String) content.getField(CONTEXT_PROCNAME).getValue();
+        Long vtid = (Long) content.getField(CONTEXT_VTID).getValue();
+
+        if (procName == null || vtid == null) {
+            throw new IllegalStateException();
+        }
+
+        return new String(procName + '-' + vtid.toString());
+    }
+
+    @Override
+    protected Long getThreadId(ITmfEvent event) {
+        ITmfEventField content = ((CtfTmfEvent) event).getContent();
+        return (Long) content.getField(CONTEXT_VTID).getValue();
+    }
+}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/MemoryUsageStateProvider.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/MemoryUsageStateProvider.java
deleted file mode 100644 (file)
index b83d9ec..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2014, 2015 Ericsson, É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:
- *   Matthew Khouzam - Initial API and implementation
- *   Geneviève Bastien - Memory is per thread and only total is kept
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-
-/**
- * State provider to track the memory of the threads using the UST libc wrapper
- * memory events.
- *
- * @author Matthew Khouzam
- * @author Geneviève Bastien
- */
-public class MemoryUsageStateProvider extends AbstractTmfStateProvider {
-
-    /* Version of this state provider */
-    private static final int VERSION = 1;
-
-    /* Maps a pointer to a memory zone to the size of the memory */
-    private final Map<Long, Long> fMemory = new HashMap<>();
-
-    private static final Long MINUS_ONE = Long.valueOf(-1);
-    private static final Long ZERO = Long.valueOf(0);
-    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
-    /**
-     * Constructor
-     *
-     * @param trace
-     *            trace
-     */
-    public MemoryUsageStateProvider(@NonNull LttngUstTrace trace) {
-        super(trace, "Ust:Memory"); //$NON-NLS-1$
-    }
-
-    @Override
-    protected void eventHandle(ITmfEvent event) {
-        String name = event.getName();
-        switch (name) {
-        case UstMemoryStrings.MALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
-            setMem(event, ptr, size);
-        }
-            break;
-        case UstMemoryStrings.FREE: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            setMem(event, ptr, ZERO);
-        }
-            break;
-        case UstMemoryStrings.CALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            Long nmemb = (Long) event.getContent().getField(UstMemoryStrings.FIELD_NMEMB).getValue();
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
-            setMem(event, ptr, size * nmemb);
-        }
-            break;
-        case UstMemoryStrings.REALLOC: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            Long newPtr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_INPTR).getValue();
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
-            setMem(event, ptr, ZERO);
-            setMem(event, newPtr, size);
-        }
-            break;
-        case UstMemoryStrings.MEMALIGN: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_PTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
-            setMem(event, ptr, size);
-        }
-            break;
-        case UstMemoryStrings.POSIX_MEMALIGN: {
-            Long ptr = (Long) event.getContent().getField(UstMemoryStrings.FIELD_OUTPTR).getValue();
-            if (ZERO.equals(ptr)) {
-                return;
-            }
-            Long size = (Long) event.getContent().getField(UstMemoryStrings.FIELD_SIZE).getValue();
-            setMem(event, ptr, size);
-        }
-            break;
-        default:
-            break;
-        }
-
-    }
-
-    @Override
-    public ITmfStateProvider getNewInstance() {
-        return new MemoryUsageStateProvider(getTrace());
-    }
-
-    @Override
-    public LttngUstTrace getTrace() {
-        return (LttngUstTrace) super.getTrace();
-    }
-
-    @Override
-    public int getVersion() {
-        return VERSION;
-    }
-
-    private static Long getVtid(ITmfEvent event) {
-        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_VTID);
-        if (field == null) {
-            return MINUS_ONE;
-        }
-        return (Long) field.getValue();
-    }
-
-    private static String getProcname(ITmfEvent event) {
-        ITmfEventField field = event.getContent().getField(UstMemoryStrings.CONTEXT_PROCNAME);
-        if (field == null) {
-            return EMPTY_STRING;
-        }
-        return (String) field.getValue();
-    }
-
-    private void setMem(ITmfEvent event, Long ptr, Long size) {
-        ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
-        long ts = event.getTimestamp().getValue();
-        Long tid = getVtid(event);
-
-        Long memoryDiff = size;
-        /* Size is 0, it means it was deleted */
-        if (ZERO.equals(size)) {
-            Long memSize = fMemory.remove(ptr);
-            if (memSize == null) {
-                return;
-            }
-            memoryDiff = -memSize;
-        } else {
-            fMemory.put(ptr, size);
-        }
-        try {
-            int tidQuark = ss.getQuarkAbsoluteAndAdd(tid.toString());
-            int tidMemQuark = ss.getQuarkRelativeAndAdd(tidQuark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE);
-
-            ITmfStateValue prevMem = ss.queryOngoingState(tidMemQuark);
-            /* First time we set this value */
-            if (prevMem.isNull()) {
-                int procNameQuark = ss.getQuarkRelativeAndAdd(tidQuark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
-                String procName = getProcname(event);
-                /*
-                 * No tid/procname for the event for the event, added to a
-                 * 'others' thread
-                 */
-                if (tid.equals(MINUS_ONE)) {
-                    procName = UstMemoryStrings.OTHERS;
-                }
-                ss.modifyAttribute(ts, TmfStateValue.newValueString(procName), procNameQuark);
-                prevMem = TmfStateValue.newValueLong(0);
-            }
-
-            long prevMemValue = prevMem.unboxLong();
-            prevMemValue += memoryDiff.longValue();
-            ss.modifyAttribute(ts, TmfStateValue.newValueLong(prevMemValue), tidMemQuark);
-        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/UstMemoryStrings.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/memoryusage/UstMemoryStrings.java
deleted file mode 100644 (file)
index 519e797..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Ericsson, É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:
- *   Matthew Khouzam, Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage;
-
-/**
- * Strings for the memory usage state system using the LTTng UST libc
- * instrumentation
- *
- * @author Matthew Khouzam
- * @author Geneviève Bastien
- */
-@SuppressWarnings({ "nls", "javadoc" })
-public interface UstMemoryStrings {
-
-    /** Memory state system attribute name */
-    static final String UST_MEMORY_MEMORY_ATTRIBUTE = "Memory"; //$NON-NLS-1$
-    /** Procname state system attribute name */
-    static final String UST_MEMORY_PROCNAME_ATTRIBUTE = "Procname"; //$NON-NLS-1$
-    /** Name of the attribute to store memory usage of events with no context */
-    static final String OTHERS = "Others";
-
-    /* UST_libc event names */
-    static final String MALLOC = "ust_libc:malloc";
-    static final String CALLOC = "ust_libc:calloc";
-    static final String REALLOC = "ust_libc:realloc";
-    static final String FREE = "ust_libc:free";
-    static final String MEMALIGN = "ust_libc:memalign";
-    static final String POSIX_MEMALIGN = "ust_libc:posix_memalign";
-
-    /* Possible contexts */
-    static final String CONTEXT_VTID = "context._vtid";
-    static final String CONTEXT_PROCNAME = "context._procname";
-
-    /* Event fields */
-    static final String FIELD_PTR = "ptr";
-    static final String FIELD_NMEMB = "nmemb";
-    static final String FIELD_SIZE = "size";
-    static final String FIELD_OUTPTR = "out_ptr";
-    static final String FIELD_INPTR = "in_ptr";
-
-}
diff --git a/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java b/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java
deleted file mode 100644 (file)
index 345cd00..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2015 Ericsson
- *
- * 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:
- *   Alexandre Montplaisir - Initial API and implementation
- *   Patrick Tasse - Add support for thread id
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.ust.core.trace.callstack;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.callstack.CallStackStateProvider;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-
-/**
- * Callstack provider for LTTng-UST traces.
- *
- * If the traces contains 'func_entry' and 'func_exit' event (see the
- * lttng-ust-cyg-profile manpage), AND contains vtid and procname contexts, we
- * can use this information to populate the TMF Callstack View.
- *
- * Granted, most UST traces will not contain this information. In this case,
- * this will simply build an empty state system, and the view will remain
- * unavailable.
- *
- * @author Alexandre Montplaisir
- */
-public class LttngUstCallStackProvider extends CallStackStateProvider {
-
-    // ------------------------------------------------------------------------
-    // Event strings
-    // ------------------------------------------------------------------------
-
-    /** Name of the fake field for the vtid contexts */
-    private static final String CONTEXT_VTID = "context._vtid"; //$NON-NLS-1$
-
-    /** Name of the fake field for the procname context */
-    private static final String CONTEXT_PROCNAME = "context._procname"; //$NON-NLS-1$
-
-    /** Field name for the target function address */
-    private static final String FIELD_ADDR = "addr"; //$NON-NLS-1$
-
-    /** Event names indicating function entry */
-    private static final Set<String> FUNC_ENTRY_EVENTS = new HashSet<>();
-
-    /** Event names indicating function exit */
-    private static final Set<String> FUNC_EXIT_EVENTS = new HashSet<>();
-
-    static {
-        /* This seems overkill, but it will be checked every event. Gotta go FAST! */
-        FUNC_ENTRY_EVENTS.add("lttng_ust_cyg_profile:func_entry"); //$NON-NLS-1$
-        FUNC_ENTRY_EVENTS.add("lttng_ust_cyg_profile_fast:func_entry"); //$NON-NLS-1$
-
-        FUNC_EXIT_EVENTS.add("lttng_ust_cyg_profile:func_exit"); //$NON-NLS-1$
-        FUNC_EXIT_EVENTS.add("lttng_ust_cyg_profile_fast:func_exit"); //$NON-NLS-1$
-    }
-
-    /**
-     * Version number of this state provider. Please bump this if you modify
-     * the contents of the generated state history in some way.
-     */
-    private static final int VERSION = 2;
-
-    // ------------------------------------------------------------------------
-    // Constructor
-    // ------------------------------------------------------------------------
-
-    /**
-     * Constructor
-     *
-     * @param trace
-     *            The UST trace
-     */
-    public LttngUstCallStackProvider(@NonNull ITmfTrace trace) {
-        super(trace);
-    }
-
-    // ------------------------------------------------------------------------
-    // Methods from AbstractTmfStateProvider
-    // ------------------------------------------------------------------------
-
-    @Override
-    public LttngUstCallStackProvider getNewInstance() {
-        return new LttngUstCallStackProvider(getTrace());
-    }
-
-    @Override
-    public int getVersion() {
-        return VERSION;
-    }
-
-    // ------------------------------------------------------------------------
-    // Methods from CallStackStateProvider
-    // ------------------------------------------------------------------------
-
-    /**
-     * Check that this event contains the required information we need to be
-     * used in the call stack view. We need at least the "procname" and "vtid"
-     * contexts.
-     */
-    @Override
-    protected boolean considerEvent(ITmfEvent event) {
-        if (!(event instanceof CtfTmfEvent)) {
-            return false;
-        }
-        ITmfEventField content = ((CtfTmfEvent) event).getContent();
-        if (content.getField(CONTEXT_VTID) == null ||
-                content.getField(CONTEXT_PROCNAME) == null) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String functionEntry(ITmfEvent event) {
-        String eventName = event.getName();
-        if (!FUNC_ENTRY_EVENTS.contains(eventName)) {
-            return null;
-        }
-        Long address = (Long) event.getContent().getField(FIELD_ADDR).getValue();
-        return Long.toHexString(address);
-    }
-
-    @Override
-    public String functionExit(ITmfEvent event) {
-        String eventName = event.getName();
-        if (!FUNC_EXIT_EVENTS.contains(eventName)) {
-            return null;
-        }
-        /*
-         * The 'addr' field may or may not be present in func_exit events,
-         * depending on if cyg-profile.so or cyg-profile-fast.so was used.
-         */
-        ITmfEventField field = event.getContent().getField(FIELD_ADDR);
-        if (field == null) {
-            return CallStackStateProvider.UNDEFINED;
-        }
-        Long address = (Long) field.getValue();
-        return Long.toHexString(address);
-    }
-
-    @Override
-    public String getThreadName(ITmfEvent event) {
-        /* Class type and content was already checked if we get called here */
-        ITmfEventField content = ((CtfTmfEvent) event).getContent();
-        String procName = (String) content.getField(CONTEXT_PROCNAME).getValue();
-        Long vtid = (Long) content.getField(CONTEXT_VTID).getValue();
-
-        if (procName == null || vtid == null) {
-            throw new IllegalStateException();
-        }
-
-        return new String(procName + '-' + vtid.toString());
-    }
-
-    @Override
-    protected Long getThreadId(ITmfEvent event) {
-        ITmfEventField content = ((CtfTmfEvent) event).getContent();
-        return (Long) content.getField(CONTEXT_VTID).getValue();
-    }
-}
index c8130075e82ab4341b43be7ef50447e041e1ca95..43bea1371303037c4a0792b01d762552e9bbea2a 100644 (file)
@@ -18,8 +18,8 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.MemoryUsageStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStateProvider;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
@@ -75,7 +75,7 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
 
     @Override
     protected ITmfStateProvider createStateProvider() {
-        return new MemoryUsageStateProvider(checkNotNull(getTrace()));
+        return new UstMemoryStateProvider(checkNotNull(getTrace()));
     }
 
     /**
index a6167e3c8fe29c35dabfd319a33062c3f9900608..a30d3ef8c87983d3cd0181b6057557932238511e 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Map;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.memory.UstMemoryAnalysisModule;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
index e8335031dd8690e0acfacdf0b7c1fd88a9a6e053..6078caaa2d81ba9ec3775da28356bb901dd73098 100644 (file)
@@ -14,7 +14,7 @@ package org.eclipse.tracecompass.lttng2.ust.ui.analysis.callstack;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
-import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackProvider;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
This page took 0.048602 seconds and 5 git commands to generate.