lttng: Add the link between the control flow view and the critical path
authorFrancis Giraldeau <francis.giraldeau@gmail.com>
Mon, 9 Feb 2015 03:52:06 +0000 (22:52 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 22 Oct 2015 18:55:48 +0000 (14:55 -0400)
A parameter provider listens to the selection of the Control Flow View
and passes that selection as a parameter to the critical path analysis

Change-Id: I2866ffe27d715d76db6d401d97273a0020f25ab4
Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/41482
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/plugin.xml
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/criticalpath/CriticalPathParameterProvider.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf/feature.xml

index dadb8012c3184fc950e7b38d25f4239ebb29acaf..ea5ffffb38fc08bdbc5dd7a01abf9062dd1a073e 100644 (file)
@@ -19,7 +19,12 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.tmf.ctf.core,
  org.eclipse.tracecompass.lttng2.control.core,
  org.eclipse.tracecompass.lttng2.control.ui,
- org.eclipse.tracecompass.lttng2.kernel.core
+ org.eclipse.tracecompass.lttng2.kernel.core,
+ org.eclipse.tracecompass.lttng2.kernel.ui,
+ org.eclipse.tracecompass.analysis.graph.ui,
+ org.eclipse.tracecompass.analysis.graph.core,
+ org.eclipse.tracecompass.analysis.os.linux.core
 Import-Package: com.google.common.collect
 Export-Package: org.eclipse.tracecompass.internal.lttng2.kernel.ui;x-internal:=true,
+ org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath;x-internal:=true,
  org.eclipse.tracecompass.internal.lttng2.kernel.ui.views;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests"
index 0bba560dec741bfc6e6c583db50f3a0c5aadae88..6890ccb287daebe99ffc481c9aea1fe067eef8fc 100644 (file)
             tracetype="org.eclipse.linuxtools.lttng2.kernel.tracetype">
       </type>
    </extension>
+   <extension
+         point="org.eclipse.linuxtools.tmf.core.analysis">
+      <parameterProvider
+            class="org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath.CriticalPathParameterProvider">
+         <analysisId
+               id="org.eclipse.tracecompass.analysis.graph.core.criticalpath">
+         </analysisId>
+      </parameterProvider>
+   </extension>
 </plugin>
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/criticalpath/CriticalPathParameterProvider.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/criticalpath/CriticalPathParameterProvider.java
new file mode 100644 (file)
index 0000000..a425ffb
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2015 É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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule;
+import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
+import org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow.ControlFlowEntry;
+import org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow.ControlFlowView;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.internal.analysis.graph.ui.criticalpath.view.CriticalPathView;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngWorker;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisParamProvider;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Class that provides parameters to the critical path analysis for lttng kernel
+ * traces
+ *
+ * @author Geneviève Bastien
+ */
+public class CriticalPathParameterProvider extends TmfAbstractAnalysisParamProvider {
+
+    private final class IPartListener2Impl implements IPartListener2 {
+
+        private final Class<?> fType;
+
+        IPartListener2Impl(Class<?> type) {
+            fType = type;
+        }
+
+        private void toggleState(IWorkbenchPartReference partRef, boolean state) {
+            if (fType.isInstance(partRef.getPart(false))) {
+                toggleActive(state);
+            }
+        }
+
+        @Override
+        public void partActivated(IWorkbenchPartReference partRef) {
+            toggleState(partRef, true);
+        }
+
+        @Override
+        public void partBroughtToTop(IWorkbenchPartReference partRef) {
+
+        }
+
+        @Override
+        public void partClosed(IWorkbenchPartReference partRef) {
+            toggleState(partRef, false);
+        }
+
+        @Override
+        public void partDeactivated(IWorkbenchPartReference partRef) {
+
+        }
+
+        @Override
+        public void partOpened(IWorkbenchPartReference partRef) {
+            toggleState(partRef, true);
+        }
+
+        @Override
+        public void partHidden(IWorkbenchPartReference partRef) {
+            toggleState(partRef, false);
+        }
+
+        @Override
+        public void partVisible(IWorkbenchPartReference partRef) {
+            toggleState(partRef, true);
+        }
+
+        @Override
+        public void partInputChanged(IWorkbenchPartReference partRef) {
+
+        }
+    }
+
+    private ISelectionListener fSelListener = new ISelectionListener() {
+        @Override
+        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+            if (selection instanceof IStructuredSelection) {
+                Object element = ((IStructuredSelection) selection).getFirstElement();
+                if (element instanceof ControlFlowEntry) {
+                    ControlFlowEntry entry = (ControlFlowEntry) element;
+                    setCurrentThreadId(entry);
+                }
+            }
+        }
+    };
+
+    private static final String NAME = "Critical Path Lttng kernel parameter provider"; //$NON-NLS-1$
+
+    private final IPartListener2 fPartListener = new IPartListener2Impl(CriticalPathView.class);
+
+    private ControlFlowEntry fCurrentEntry = null;
+
+    private boolean fActive = false;
+    private boolean fEntryChanged = false;
+
+    /**
+     * Constructor
+     */
+    public CriticalPathParameterProvider() {
+        super();
+        registerListener();
+    }
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Override
+    public Object getParameter(String name) {
+        if (fCurrentEntry == null) {
+            return null;
+        }
+        if (name.equals(CriticalPathModule.PARAM_WORKER)) {
+            /* Try to find the worker for the critical path */
+            IAnalysisModule mod = getModule();
+            if ((mod != null) && (mod instanceof CriticalPathModule)) {
+                Integer threadId = NonNullUtils.checkNotNull(fCurrentEntry.getThreadId());
+                HostThread ht = new HostThread(fCurrentEntry.getTrace().getHostId(), threadId);
+                LttngWorker worker = new LttngWorker(ht, "", 0); //$NON-NLS-1$
+                return worker;
+            }
+            return fCurrentEntry;
+        }
+        return null;
+    }
+
+    @Override
+    public boolean appliesToTrace(ITmfTrace trace) {
+        return true;
+    }
+
+    private void setCurrentThreadId(ControlFlowEntry entry) {
+        if (!entry.equals(fCurrentEntry)) {
+            fCurrentEntry = entry;
+            if (fActive) {
+                this.notifyParameterChanged(CriticalPathModule.PARAM_WORKER);
+            } else {
+                fEntryChanged = true;
+            }
+        }
+    }
+
+    private void toggleActive(boolean active) {
+        if (active != fActive) {
+            fActive = active;
+            if (fActive && fEntryChanged) {
+                this.notifyParameterChanged(CriticalPathModule.PARAM_WORKER);
+                fEntryChanged = false;
+            }
+        }
+    }
+
+    private void registerListener() {
+        final IWorkbench wb = PlatformUI.getWorkbench();
+
+        final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
+
+        /* Activate the update if critical path view visible */
+        IViewPart view = activePage.findView(CriticalPathView.ID);
+        if (view != null) {
+            if (activePage.isPartVisible(view)) {
+                toggleActive(true);
+            }
+        }
+
+        /* Add the listener to the control flow view */
+        view = activePage.findView(ControlFlowView.ID);
+        if (view != null) {
+            view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(fSelListener);
+            view.getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener);
+        }
+    }
+
+}
index d6f01f87a3e46414433ec19fdd51ae73131813f7..c0ad09e18f0d7e3e54bef04f5e8334df88f727ee 100644 (file)
          install-size="0"
          version="0.0.0"
          unpack="false"/>
+         
+   <plugin
+         id="org.eclipse.tracecompass.analysis.graph.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
 
    <plugin
          id="org.eclipse.tracecompass.analysis.timing.core"
          download-size="0"
          install-size="0"
          version="0.0.0"
-         unpack="false"/>
+         unpack="false"/>  
 
 </feature>
This page took 0.028267 seconds and 5 git commands to generate.