lttng: Add configuration files to call LTTng-Analyses scripts
authorPhilippe Proulx <pproulx@efficios.com>
Fri, 29 Apr 2016 02:57:53 +0000 (22:57 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 17 May 2016 18:49:19 +0000 (14:49 -0400)
This patch implements configuration files to offer calling
LTTng-Analyses scripts [1] from Trace Compass.

The `index.properties` file contains a single property, `analyses`,
which is a whitespace-separated list of names of configuration files,
without the extension, to load in order to create as many LAMI
analyses.

Each configuration file contains two properties:

  * `name`: Display name of the analysis.
  * `command`: Full command to run. This string supports
    double-quoted arguments to allow arguments with whitespaces,
    or empty arguments. The `\` and `"` characters must be
    escaped with `\`.

Both properties are mandatory.

LTTng-Analyses 0.4 is supported, however 0.5 and up are recommended
since these will offer a proper progress bar and cancellation
mechanism.

[1] https://github.com/lttng/lttng-analyses

Change-Id: I3e3f7c0e8b29f1714df1f2e3acd685fc23b51e7d
Signed-off-by: Philippe Proulx <pproulx@efficios.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/72101
Reviewed-by: Hudson CI
27 files changed:
analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/LamiConfigFileStrings.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/ShellUtils.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/module/ConfigFileLamiAnalysisFactory.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.core/build.properties
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/cputop.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/index.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencyfreq.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencystats.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencytop.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolog.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iousagetop.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqfreq.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqlog.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqstats.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/memtop.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedfreq.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedlog.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedstats.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedtop.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/syscallstats.properties [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/Activator.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/LttngAnalysesLoader.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel/feature.xml
rcp/org.eclipse.tracecompass.rcp/feature.xml
rcp/org.eclipse.tracecompass.rcp/pom.xml
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/ondemand/OnDemandAnalysisManager.java

diff --git a/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/LamiConfigFileStrings.java b/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/LamiConfigFileStrings.java
new file mode 100644 (file)
index 0000000..bd4fa61
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.provisional.analysis.lami.core;
+
+/**
+ * Strings used in the config files describing LAMI analyses.
+ *
+ * @author Philippe Proulx
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+@SuppressWarnings({ "javadoc", "nls" })
+public interface LamiConfigFileStrings {
+
+    String PROP_NAME = "name";
+    String PROP_COMMAND = "command";
+
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/ShellUtils.java b/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/ShellUtils.java
new file mode 100644 (file)
index 0000000..937c994
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.provisional.analysis.lami.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Static methods to convert from a shell-like command string to individual
+ * arguments and vice versa. Not all shell parsing features are implemented.
+ *
+ * @author Philippe Proulx
+ */
+public class ShellUtils {
+
+    /**
+     * Converts the string {@code command} to a list of individual arguments.
+     * {@code command} is split on one or more spaces, but double-quoted
+     * arguments are supported, as well as escaped backslashes ({@code \\})
+     * and double quotes ({@code \"}).
+     *
+     * @param command Command string
+     * @return List of arguments extracted from {@code command}
+     */
+    public static List<String> commandStringToArgs(String command) {
+        int index = 0;
+        boolean inQuotes = false;
+        List<String> args = new ArrayList<>();
+        StringBuilder sb = new StringBuilder();
+
+        while (index < command.length()) {
+            char ch = command.charAt(index);
+
+            if (ch == '\\' && index < command.length() - 1) {
+                char escaped = command.charAt(index + 1);
+
+                if (escaped == '\\' || escaped == '"') {
+                    // Valid escaped character
+                    sb.append(escaped);
+                    index += 2;
+                    continue;
+                }
+            }
+
+            if (ch == '"') {
+                if (inQuotes) {
+                    // Quoted string ends: keep the quoted string, even if empty
+                    args.add(sb.toString());
+                    sb.setLength(0);
+                } else {
+                    // Quoted string begins
+                    if (sb.length() > 0) {
+                        args.add(sb.toString());
+                        sb.setLength(0);
+                    }
+                }
+
+                inQuotes = !inQuotes;
+                index++;
+                continue;
+            }
+
+            if (!inQuotes && ch == ' ') {
+                // Argument delimiter
+                if (sb.length() > 0) {
+                    args.add(sb.toString());
+                    sb.setLength(0);
+                }
+
+                index++;
+                continue;
+            }
+
+            sb.append(ch);
+            index++;
+        }
+
+        // Last argument, if any
+        if (sb.length() > 0) {
+            args.add(sb.toString());
+        }
+
+        return args;
+    }
+
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/module/ConfigFileLamiAnalysisFactory.java b/analysis/org.eclipse.tracecompass.analysis.lami.core/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/core/module/ConfigFileLamiAnalysisFactory.java
new file mode 100644 (file)
index 0000000..eb9c683
--- /dev/null
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.function.Predicate;
+
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.LamiConfigFileStrings;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.ShellUtils;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Factory which builds {@link LamiAnalysis} objects out of configuration
+ * files.
+ *
+ * @author Philippe Proulx
+ */
+public final class ConfigFileLamiAnalysisFactory {
+
+    /**
+     * Class-specific exception, for when things go wrong with the
+     * {@link ConfigFileLamiAnalysisFactory}.
+     */
+    public static class ConfigFileLamiAnalysisFactoryException extends Exception {
+
+        private static final long serialVersionUID = 1349804105078874111L;
+
+        /**
+         * Default constructor
+         */
+        public ConfigFileLamiAnalysisFactoryException() {
+            super();
+        }
+
+        /**
+         * Constructor specifying a message
+         *
+         * @param message
+         *            The exception message
+         */
+        public ConfigFileLamiAnalysisFactoryException(String message) {
+            super(message);
+        }
+
+        /**
+         * Constructor specifying both a cause and a message
+         *
+         * @param message
+         *            The exception message
+         * @param cause
+         *            The exception that caused this one
+         */
+        public ConfigFileLamiAnalysisFactoryException(String message, Throwable cause) {
+            super(message, cause);
+        }
+
+        /**
+         * Constructor specifying a cause
+         *
+         * @param cause
+         *            The exception that caused this one
+         */
+        public ConfigFileLamiAnalysisFactoryException(Throwable cause) {
+            super(cause);
+        }
+
+    }
+
+    private ConfigFileLamiAnalysisFactory() {
+    }
+
+    private static String getProperty(Properties props, String propName) throws ConfigFileLamiAnalysisFactoryException {
+        String prop = props.getProperty(propName);
+
+        if (prop == null) {
+            throw new ConfigFileLamiAnalysisFactoryException(String.format("Cannot find \"%s\" property", propName)); //$NON-NLS-1$
+        }
+
+        prop = prop.trim();
+
+        if (prop.isEmpty()) {
+            throw new ConfigFileLamiAnalysisFactoryException(String.format("\"%s\" property cannot be empty", propName)); //$NON-NLS-1$
+        }
+
+        return prop;
+    }
+
+    /**
+     * Builds a {@link LamiAnalysis} object from an input stream providing the
+     * content of a configuration file.
+     * <p>
+     * The caller is responsible for opening and closing {@code inputStream}.
+     *
+     * @param inputStream
+     *            Input stream for reading the configuration file; the stream is
+     *            not closed by this method
+     * @param isUserDefined
+     *            {@code true} if the analysis to build is user-defined
+     * @param appliesTo
+     *            Predicate to use to check whether or not this analysis applies
+     *            to a given trace
+     * @return Built {@link LamiAnalysis} object
+     * @throws ConfigFileLamiAnalysisFactoryException
+     *             If something go wrong
+     */
+    public static LamiAnalysis buildFromInputStream(InputStream inputStream, boolean isUserDefined,
+            Predicate<ITmfTrace> appliesTo) throws ConfigFileLamiAnalysisFactoryException {
+        Properties props = new Properties();
+
+        // Load properties
+        try {
+            props.load(inputStream);
+        } catch (IOException e) {
+            throw new ConfigFileLamiAnalysisFactoryException(e);
+        }
+
+        // Get analysis' name and command
+        String name = getProperty(props, LamiConfigFileStrings.PROP_NAME);
+        String command = getProperty(props, LamiConfigFileStrings.PROP_COMMAND);
+
+        // Get individual arguments from command string
+        List<String> args = ShellUtils.commandStringToArgs(command);
+
+        return new LamiAnalysis(name, isUserDefined, appliesTo, args);
+    }
+
+    /**
+     * Builds a {@link LamiAnalysis} object from a configuration file.
+     *
+     * @param configFilePath
+     *            Configuration file path
+     * @param isUserDefined
+     *            {@code true} if the analysis to build is user-defined
+     * @param appliesTo
+     *            Predicate to use to check whether or not this analysis applies
+     *            to a given trace
+     * @return Built {@link LamiAnalysis} object
+     * @throws ConfigFileLamiAnalysisFactoryException
+     *             If something go wrong
+     */
+    public static LamiAnalysis buildFromConfigFile(Path configFilePath, boolean isUserDefined,
+            Predicate<ITmfTrace> appliesTo) throws ConfigFileLamiAnalysisFactoryException {
+        try (FileInputStream propsStream = new FileInputStream(configFilePath.toFile())) {
+            return buildFromInputStream(propsStream, isUserDefined, appliesTo);
+        } catch (IOException e) {
+            throw new ConfigFileLamiAnalysisFactoryException(e);
+        }
+    }
+
+    /**
+     * Builds a list of {@link LamiAnalysis} objects from a directory containing
+     * configuration files.
+     *
+     * @param configDir
+     *            Configuration directory containing the configuration files to
+     *            load
+     * @param isUserDefined
+     *            {@code true} if the analyses to build are user-defined
+     * @param appliesTo
+     *            Predicate to use to check whether or not those analyses apply
+     *            to a given trace
+     * @return List of built {@link LamiAnalysis} objects
+     * @throws ConfigFileLamiAnalysisFactoryException
+     *             If something go wrong
+     */
+    public static List<LamiAnalysis> buildFromConfigDir(Path configDir, boolean isUserDefined,
+            Predicate<ITmfTrace> appliesTo) throws ConfigFileLamiAnalysisFactoryException {
+        List<LamiAnalysis> analyses = new ArrayList<>();
+
+        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(configDir)) {
+            for (Path path : directoryStream) {
+                analyses.add(buildFromConfigFile(path, isUserDefined, appliesTo));
+            }
+        } catch (IOException e) {
+            throw new ConfigFileLamiAnalysisFactoryException(e);
+        }
+
+        return analyses;
+    }
+
+}
index c44d9507fd15e532de80a3de4283f9d683a0d9d4..5d1b03fb3fa4f373b8466e09721b39b8b92ba88d 100644 (file)
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.tmf.core,
  org.eclipse.tracecompass.tmf.ctf.core,
  org.eclipse.tracecompass.analysis.os.linux.core,
- org.eclipse.tracecompass.analysis.graph.core
+ org.eclipse.tracecompass.analysis.graph.core,
+ org.eclipse.tracecompass.analysis.lami.core
 Export-Package: org.eclipse.tracecompass.internal.lttng2.kernel.core;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
  org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
  org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
index 244c9d8e3efa2e54a79c05c3358966706de484a5..21b81595a9c67e801fc6501d8753cc9aa8397417 100644 (file)
@@ -16,7 +16,8 @@ bin.includes = META-INF/,\
                .,\
                about.html,\
                plugin.properties,\
-               plugin.xml
+               plugin.xml,\
+               lttng-analyses-configs/
 src.includes = about.html
 additional.bundles = org.eclipse.jdt.annotation
 jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/cputop.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/cputop.properties
new file mode 100644 (file)
index 0000000..3b94221
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: CPU Usage Top
+command = lttng-cputop-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/index.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/index.properties
new file mode 100644 (file)
index 0000000..9176768
--- /dev/null
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+analyses = cputop \
+           iolatencyfreq \
+           iolatencystats \
+           iolatencytop \
+           iolog \
+           iousagetop \
+           irqfreq \
+           irqlog \
+           irqstats \
+           memtop \
+           schedfreq \
+           schedlog \
+           schedstats \
+           schedtop \
+           syscallstats
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencyfreq.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencyfreq.properties
new file mode 100644 (file)
index 0000000..ebaa88a
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: I/O Latency Frequency Distribution
+command = lttng-iolatencyfreq-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencystats.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencystats.properties
new file mode 100644 (file)
index 0000000..36c6431
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: I/O Latency Statistics
+command = lttng-iolatencystats-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencytop.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolatencytop.properties
new file mode 100644 (file)
index 0000000..e030726
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: I/O Latency Top
+command = lttng-iolatencytop-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolog.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iolog.properties
new file mode 100644 (file)
index 0000000..6a282df
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: I/O Usage Log
+command = lttng-iolog-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iousagetop.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/iousagetop.properties
new file mode 100644 (file)
index 0000000..1f1f4f1
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: I/O Usage Top
+command = lttng-iousagetop-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqfreq.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqfreq.properties
new file mode 100644 (file)
index 0000000..74efda3
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Interrupt Frequency Distribution
+command = lttng-irqfreq-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqlog.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqlog.properties
new file mode 100644 (file)
index 0000000..6eeccd6
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Interrupt Log
+command = lttng-irqlog-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqstats.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/irqstats.properties
new file mode 100644 (file)
index 0000000..0bdb506
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Interrupt Statistics
+command = lttng-irqstats-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/memtop.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/memtop.properties
new file mode 100644 (file)
index 0000000..5a8af73
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Memory Usage Top
+command = lttng-memtop-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedfreq.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedfreq.properties
new file mode 100644 (file)
index 0000000..e1508d1
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Scheduling Latency Frequency Distribution
+command = lttng-schedfreq-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedlog.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedlog.properties
new file mode 100644 (file)
index 0000000..d10a7d7
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Scheduling Latency Log
+command = lttng-schedlog-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedstats.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedstats.properties
new file mode 100644 (file)
index 0000000..ef72a83
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Scheduling Latency Statistics
+command = lttng-schedstats-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedtop.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/schedtop.properties
new file mode 100644 (file)
index 0000000..703e27d
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: Scheduling Latency Top
+command = lttng-schedtop-mi
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/syscallstats.properties b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/lttng-analyses-configs/syscallstats.properties
new file mode 100644 (file)
index 0000000..e8d66b0
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2016 EfficiOS Inc. and others
+#
+# 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
+###############################################################################
+
+name = LTTng-Analyses: System Call Statistics
+command = lttng-syscallstats-mi
index eea384b965ef33d53d5619cae6b5e2fec32ea552..a270bb839f4e44870da20aab9061c0fab3dfcd7b 100644 (file)
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core;
 
+import java.io.IOException;
+
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Plugin;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.ConfigFileLamiAnalysisFactory.ConfigFileLamiAnalysisFactoryException;
 import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatching;
 import org.osgi.framework.BundleContext;
 
@@ -76,6 +79,13 @@ public class Activator extends Plugin {
         plugin = this;
         TmfEventMatching.registerMatchObject(new TcpEventMatching());
         TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
+
+        try {
+            LttngAnalysesLoader.load();
+        } catch (ConfigFileLamiAnalysisFactoryException | IOException e) {
+            // Not the end of the world if the analyses are not available
+            logWarning("Cannot find LTTng analyses configuration files: " + e.getMessage()); //$NON-NLS-1$
+        }
     }
 
     @Override
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/LttngAnalysesLoader.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/LttngAnalysesLoader.java
new file mode 100644 (file)
index 0000000..af301f1
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.kernel.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.Lttng27EventLayout;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.ConfigFileLamiAnalysisFactory;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.ConfigFileLamiAnalysisFactory.ConfigFileLamiAnalysisFactoryException;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysis;
+import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.tmf.core.analysis.ondemand.OnDemandAnalysisManager;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Loader of LTTng analyses.
+ *
+ * @author Philippe Proulx
+ */
+final class LttngAnalysesLoader {
+
+    private static final String CONFIG_DIR_NAME = "lttng-analyses-configs"; //$NON-NLS-1$
+
+    private LttngAnalysesLoader() {
+    }
+
+    private static boolean appliesTo(ITmfTrace trace) {
+        /* LTTng-Analysis is supported only on LTTng >= 2.7 kernel traces */
+        if (trace instanceof LttngKernelTrace) {
+            LttngKernelTrace kernelTrace = (LttngKernelTrace) trace;
+            IKernelAnalysisEventLayout layout = kernelTrace.getKernelEventLayout();
+
+            if (layout instanceof Lttng27EventLayout) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private static String[] getAnalysisNames() throws IOException {
+        ClassLoader loader = LttngAnalysesLoader.class.getClassLoader();
+        String path = "/" + CONFIG_DIR_NAME + "/index.properties"; //$NON-NLS-1$ //$NON-NLS-2$
+        String[] names = new String[0];
+        Properties indexProps = new Properties();
+
+        try (InputStream in = loader.getResourceAsStream(path)) {
+            if (in == null) {
+                return names;
+            }
+
+            indexProps.load(in);
+        }
+
+        String analyses = indexProps.getProperty("analyses"); //$NON-NLS-1$
+
+        if (analyses == null) {
+            return names;
+        }
+
+        analyses = analyses.trim();
+        String[] splitNames = analyses.split("\\s+"); //$NON-NLS-1$
+
+        return splitNames;
+    }
+
+    public static void load() throws ConfigFileLamiAnalysisFactoryException, IOException {
+        String[] names = getAnalysisNames();
+        ClassLoader loader = LttngAnalysesLoader.class.getClassLoader();
+
+        for (String name : names) {
+            String path = String.format("/%s/%s.properties", CONFIG_DIR_NAME, name); //$NON-NLS-1$
+
+            try (InputStream in = loader.getResourceAsStream(path)) {
+                if (in == null) {
+                    continue;
+                }
+
+                LamiAnalysis analysis = ConfigFileLamiAnalysisFactory.buildFromInputStream(in, false, LttngAnalysesLoader::appliesTo);
+                OnDemandAnalysisManager.getInstance().registerAnalysis(analysis);
+            }
+        }
+    }
+
+}
index ffd3e5f32307186688b6f18efd2f05c7cf14968a..9eb242c251528fcfcb0620f7dbb48e1c32f53353 100644 (file)
       <import plugin="org.eclipse.help"/>
    </requires>
 
+   <plugin
+         id="org.eclipse.tracecompass.analysis.lami.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.tracecompass.analysis.lami.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
    <plugin
          id="org.eclipse.tracecompass.analysis.os.linux.core"
          download-size="0"
index 39550e8b2200aecfd04f81245dfe72f188065eab..e4349b3c501b2f6d07b35ae26a4bb2d7a19bd887 100644 (file)
       <import feature="org.eclipse.platform" version="0.0.0" match="greaterOrEqual"/>
    </requires>
 
+   <plugin
+         id="org.json"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
    <plugin
          id="org.antlr.runtime"
          download-size="0"
index bb6e73ece36740b07bf195d6412fa88d6e992aad..de6754b30f93d54e7edfe7542344f289696a802c 100644 (file)
@@ -69,6 +69,7 @@
                 <plugin id="org.eclipse.core.net.linux.x86"/>
                 <plugin id="org.eclipse.linuxtools.dataviewers.piechart"/>
                 <plugin id="org.eclipse.tracecompass.tracing.rcp.help"/>
+                <plugin id="org.json"/>
                 <plugin id="org.sat4j.core"/>
                 <plugin id="org.sat4j.pb"/>
                 <plugin id="org.swtchart"/>
index 0bdf08a9dcc54df0c29738e8d05e2c3d70054bef..3f93bb7526b1786ed387f3bea96aa62b8215b1f1 100644 (file)
@@ -11,8 +11,7 @@ package org.eclipse.tracecompass.tmf.core.analysis.ondemand;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -60,7 +59,7 @@ public final class OnDemandAnalysisManager {
                     }
             }));
 
-    private final List<OndemandAnalysisWrapper> fAnalysisWrappers;
+    private final Set<OndemandAnalysisWrapper> fAnalysisWrappers;
 
     /**
      * Internal class used to store extension point information
@@ -92,7 +91,7 @@ public final class OnDemandAnalysisManager {
      * Private constructor, should only be called via {@link #getInstance()}.
      */
     private OnDemandAnalysisManager() {
-        fAnalysisWrappers = new ArrayList<>();
+        fAnalysisWrappers = new HashSet<>();
         IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
 
         for (IConfigurationElement element : configElements) {
@@ -120,4 +119,14 @@ public final class OnDemandAnalysisManager {
     public Set<IOnDemandAnalysis> getOndemandAnalyses(ITmfTrace trace) {
         return checkNotNull(analysisCache.getUnchecked(trace));
     }
+
+    /**
+     * Registers an on-demand analysis to this manager.
+     *
+     * @param analysis
+     *            On-demand analysis to register
+     */
+    public void registerAnalysis(IOnDemandAnalysis analysis) {
+        fAnalysisWrappers.add(new OndemandAnalysisWrapper(analysis));
+    }
 }
This page took 0.038808 seconds and 5 git commands to generate.