Tmf: Port the LTTng Kernel state system to an analysis module
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 14 Nov 2013 16:47:11 +0000 (11:47 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 17 Jan 2014 22:06:02 +0000 (17:06 -0500)
And update the views accordingly.

Change-Id: I90975b5772db24a784d99d2d0232f6f76a8e5e03
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/19432
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
15 files changed:
org.eclipse.linuxtools.lttng2.kernel.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java
org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng2.kernel.ui/build.properties
org.eclipse.linuxtools.lttng2.kernel.ui/plugin.properties
org.eclipse.linuxtools.lttng2.kernel.ui/plugin.xml
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/lttng2/kernel/ui/analysis/LttngKernelAnalysisModule.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java

index 10ca723cbe86902a853a90712737b8de8860113c..7effe4d465fac1143f9065f7dffafbe9e3fb5dca 100644 (file)
@@ -13,6 +13,6 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0",
  org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0"
 Export-Package: org.eclipse.linuxtools.internal.lttng2.kernel.core;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui,org.eclipse.linuxtools.lttng2.kernel.core.tests",
- org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider;x-friends:="org.eclipse.linuxtools.lttng2.kernel.core.tests",
- org.eclipse.linuxtools.lttng2.kernel.core.trace,
- org.eclipse.linuxtools.lttng2.kernel.core.event.matching
+ org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui,org.eclipse.linuxtools.lttng2.kernel.core.tests",
+ org.eclipse.linuxtools.lttng2.kernel.core.event.matching,
+ org.eclipse.linuxtools.lttng2.kernel.core.trace
index 6ea09e1cbb6e376b56fb531cdd05394f769aec15..f71697c199b7bc1cc5948fe0e570ebd6c2d38900 100644 (file)
@@ -13,7 +13,6 @@
 
 package org.eclipse.linuxtools.lttng2.kernel.core.trace;
 
-import java.io.File;
 import java.nio.BufferOverflowException;
 
 import org.eclipse.core.resources.IProject;
@@ -22,34 +21,17 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
 
 /**
  * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
- * traces. It uses the CtfKernelStateInput to generate the state history.
+ * traces.
  *
  * @author Alexandre Montplaisir
  * @since 2.0
  */
 public class LttngKernelTrace extends CtfTmfTrace {
 
-    /**
-     * The file name of the History Tree
-     */
-    public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
-
-    /**
-     * ID of the state system we will build
-     * @since 2.0
-     * */
-    public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
-
     /**
      * Default constructor
      */
@@ -91,25 +73,4 @@ public class LttngKernelTrace extends CtfTmfTrace {
         return validStatus;
     }
 
-    /**
-     * @since 3.0
-     */
-    @Override
-    protected IStatus buildStateSystem() {
-        super.buildStateSystem();
-
-        /* Build the state system specific to LTTng kernel traces */
-        String directory = TmfTraceManager.getSupplementaryFileDir(this);
-        final File htFile = new File(directory + HISTORY_TREE_FILE_NAME);
-        final ITmfStateProvider htInput = new LttngKernelStateProvider(this);
-
-        try {
-            ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
-            fStateSystems.put(STATE_ID, ss);
-        } catch (TmfTraceException e) {
-            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
-        }
-        return Status.OK_STATUS;
-    }
-
 }
index 4811b27833dd36aaf521796fbb221abe8e24abc9..3271f9c8c4df796ce92bf03bac8af44943485e6a 100644 (file)
@@ -21,4 +21,5 @@ Export-Package: org.eclipse.linuxtools.internal.lttng2.kernel.ui;x-friends:="org
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.views;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui.swtbot.tests",
- org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui.swtbot.tests"
+ org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui.swtbot.tests",
+ org.eclipse.linuxtools.lttng2.kernel.ui.analysis
index cb21f79b7684ee02df0966710c1f7ef6f2edf5d5..0536a02f8dd018fac4fe8ceb218d301baeb213dc 100644 (file)
@@ -19,3 +19,5 @@ bin.includes = META-INF/,\
                about.html,\
                plugin.properties
 src.includes = about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
\ No newline at end of file
index 9172f4976ed16a59c977b55f969e6402d1a9c212..bb75d70b7f3b881920e92ffa670f171012e01cc2 100644 (file)
@@ -20,3 +20,5 @@ controlflow.view.name = Control Flow
 resources.view.name = Resources
 
 tracetype.type.kernel = LTTng Kernel Trace
+
+analysis.lttngkernel = LTTng Kernel Analysis
index 98b081bfacbf795d91efe800778eb18e7cba54c8..0e66b752efce0fecb5d40a1e180d8db156c046b4 100644 (file)
          </enablement>
       </commonWizard>
    </extension>
+   <extension
+         point="org.eclipse.linuxtools.tmf.core.analysis">
+      <module
+            analysis_module="org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule"
+            automatic="true"
+            id="org.eclipse.linuxtools.lttng2.kernel.analysis"
+            name="%analysis.lttngkernel">
+         <tracetype
+               class="org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace">
+         </tracetype>
+      </module>
+   </extension>
 </plugin>
index 7200352850e6b9b6f37570416d091d0920cd3514..f851aa73e491cd0972dd9628d9826b4a20eedfae 100644 (file)
@@ -49,6 +49,8 @@ public class Messages extends NLS {
     public static String ResourcesView_attributeProcessName;
     public static String ResourcesView_attributeSyscallName;
 
+    public static String LttngKernelAnalysis_Help;
+
     static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index 29e75b8991ee09f2551cee556c1b7837484b8694..cfa70d242422f982f9d7e2ba6a0d0aabbaca4651 100644 (file)
@@ -41,3 +41,5 @@ ResourcesView_attributeHoverTime=> Hover Time
 ResourcesView_attributeTidName=> TID
 ResourcesView_attributeProcessName=> Process
 ResourcesView_attributeSyscallName=> System Call
+
+LttngKernelAnalysis_Help=Builds the LTTng2 kernel state system to populate the Control Flow view and the Resources View
index 94bd6beaf3bb0a637dd898ec0ca147a6dc713a49..cdb01ecb46fb17a44c0cc514bc97191c3a5f5922 100644 (file)
@@ -19,8 +19,9 @@ import java.util.Map;
 
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule;
 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
@@ -126,7 +127,11 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
             return retMap;
         }
         ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
-        ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
+        LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ssq = module.getStateSystem();
+        if (ssq == null) {
+            return retMap;
+        }
         int tid = entry.getThreadId();
 
         try {
@@ -146,12 +151,8 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
                 }
             }
 
-        } catch (AttributeNotFoundException e) {
-            e.printStackTrace();
-        } catch (TimeRangeException e) {
-            e.printStackTrace();
-        } catch (StateValueTypeException e) {
-            e.printStackTrace();
+        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+            Activator.getDefault().logError("Error in ControlFlowPresentationProvider", e); //$NON-NLS-1$
         } catch (StateSystemDisposedException e) {
             /* Ignored */
         }
@@ -165,10 +166,8 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
                     retMap.put(Messages.ControlFlowView_attributeSyscallName, state.toString());
                 }
 
-            } catch (AttributeNotFoundException e) {
-                e.printStackTrace();
-            } catch (TimeRangeException e) {
-                e.printStackTrace();
+            } catch (AttributeNotFoundException | TimeRangeException e) {
+                Activator.getDefault().logError("Error in ControlFlowPresentationProvider", e); //$NON-NLS-1$
             } catch (StateSystemDisposedException e) {
                 /* Ignored */
             }
@@ -186,7 +185,11 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
             return;
         }
         ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
-        ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
+        LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ss = module.getStateSystem();
+        if (ss == null) {
+            return;
+        }
         int status = ((TimeEvent) event).getValue();
 
         if (status != StateValues.PROCESS_STATUS_RUN_SYSCALL) {
@@ -200,10 +203,8 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
                 gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
                 Utils.drawText(gc, state.toString().substring(4), bounds.x, bounds.y - 2, bounds.width, true, true);
             }
-        } catch (AttributeNotFoundException e) {
-            e.printStackTrace();
-        } catch (TimeRangeException e) {
-            e.printStackTrace();
+        } catch (AttributeNotFoundException | TimeRangeException e) {
+            Activator.getDefault().logError("Error in ControlFlowPresentationProvider", e); //$NON-NLS-1$
         } catch (StateSystemDisposedException e) {
             /* Ignored */
         }
index e0fb7a0c29bf6dd74b751af59110e1ec50081a88..adf51cce29bda5a721373c054e153cd722ce1fd0 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.dialogs.IDialogSettings;
@@ -26,6 +27,7 @@ import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
 import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule;
 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
@@ -210,13 +212,18 @@ public class ControlFlowView extends AbstractTimeGraphView {
             if (aTrace instanceof LttngKernelTrace) {
                 ArrayList<ControlFlowEntry> entryList = new ArrayList<>();
                 LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) aTrace;
-                ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+                LttngKernelAnalysisModule module = ctfKernelTrace.getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+                module.schedule();
+                if (!module.waitForCompletion(new NullProgressMonitor())) {
+                    continue;
+                }
+                ITmfStateSystem ssq = module.getStateSystem();
                 if (ssq == null) {
-                    return;
+                    continue;
                 }
                 ssq.waitUntilBuilt();
                 if (ssq.isCancelled()) {
-                    return;
+                    continue;
                 }
                 long start = ssq.getStartTime();
                 long end = ssq.getCurrentEndTime() + 1;
@@ -327,8 +334,11 @@ public class ControlFlowView extends AbstractTimeGraphView {
     }
 
     private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor) {
-        ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
-
+        LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ssq = module.getStateSystem();
+        if (ssq == null) {
+            return;
+        }
         long start = ssq.getStartTime();
         long end = ssq.getCurrentEndTime() + 1;
         long resolution = Math.max(1, (end - start) / getDisplayWidth());
@@ -360,7 +370,11 @@ public class ControlFlowView extends AbstractTimeGraphView {
         if (realEnd <= realStart) {
             return null;
         }
-        ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
+        LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ssq = module.getStateSystem();
+        if (ssq == null) {
+            return null;
+        }
         try {
             int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
             List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, realStart, realEnd - 1, resolution, monitor);
@@ -412,7 +426,11 @@ public class ControlFlowView extends AbstractTimeGraphView {
             }
             if (trace instanceof LttngKernelTrace) {
                 LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) trace;
-                ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+                LttngKernelAnalysisModule module = ctfKernelTrace.getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+                ITmfStateSystem ssq = module.getStateSystem();
+                if (ssq == null) {
+                    continue;
+                }
                 if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
                     List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
                     for (int currentThreadQuark : currentThreadQuarks) {
@@ -469,7 +487,11 @@ public class ControlFlowView extends AbstractTimeGraphView {
         }
         for (ITmfTrace trace : traces) {
             if (trace instanceof LttngKernelTrace) {
-                ITmfStateSystem ssq = trace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+                LttngKernelAnalysisModule module = trace.getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+                ITmfStateSystem ssq = module.getStateSystem();
+                if (ssq == null) {
+                    continue;
+                }
                 try {
                     long start = Math.max(startTime, ssq.getStartTime());
                     long end = Math.min(endTime, ssq.getCurrentEndTime());
index a713db513ea90b662977914c13180750eafa208f..162ba4a2cb0385df046bcc941bba849fc1ea2657 100644 (file)
@@ -19,9 +19,10 @@ import java.util.Map;
 
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule;
 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
@@ -156,6 +157,11 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
             ResourcesEntry entry = (ResourcesEntry) event.getEntry();
 
             if (tcEvent.hasValue()) {
+                LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+                ITmfStateSystem ss = module.getStateSystem();
+                if (ss == null) {
+                    return retMap;
+                }
                 // Check for IRQ or Soft_IRQ type
                 if (entry.getType().equals(Type.IRQ) || entry.getType().equals(Type.SOFT_IRQ)) {
 
@@ -172,7 +178,6 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
 
                     if (status == StateValues.CPU_STATUS_IRQ) {
                         // In IRQ state get the IRQ that caused the interruption
-                        ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
                         int cpu = entry.getId();
 
                         try {
@@ -189,18 +194,13 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                                     break;
                                 }
                             }
-                        } catch (AttributeNotFoundException e) {
-                            e.printStackTrace();
-                        } catch (TimeRangeException e) {
-                            e.printStackTrace();
-                        } catch (StateValueTypeException e) {
-                            e.printStackTrace();
+                        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+                            Activator.getDefault().logError("Error in ResourcesPresentationProvider", e); //$NON-NLS-1$
                         } catch (StateSystemDisposedException e) {
                             /* Ignored */
                         }
                     } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
                         // In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
-                        ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
                         int cpu = entry.getId();
 
                         try {
@@ -217,49 +217,40 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                                     break;
                                 }
                             }
-                        } catch (AttributeNotFoundException e) {
-                            e.printStackTrace();
-                        } catch (TimeRangeException e) {
-                            e.printStackTrace();
-                        } catch (StateValueTypeException e) {
-                            e.printStackTrace();
+                        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+                            Activator.getDefault().logError("Error in ResourcesPresentationProvider", e); //$NON-NLS-1$
                         } catch (StateSystemDisposedException e) {
                             /* Ignored */
                         }
                     } else if (status == StateValues.CPU_STATUS_RUN_USERMODE || status == StateValues.CPU_STATUS_RUN_SYSCALL) {
                         // In running state get the current tid
-                        ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
 
                         try {
                             retMap.put(Messages.ResourcesView_attributeHoverTime, Utils.formatTime(hoverTime, TimeFormat.CALENDAR, Resolution.NANOSEC));
                             int cpuQuark = entry.getQuark();
-                            int currentThreadQuark = ssq.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);
-                            ITmfStateInterval interval = ssq.querySingleState(hoverTime, currentThreadQuark);
+                            int currentThreadQuark = ss.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);
+                            ITmfStateInterval interval = ss.querySingleState(hoverTime, currentThreadQuark);
                             if (!interval.getStateValue().isNull()) {
                                 ITmfStateValue value = interval.getStateValue();
                                 int currentThreadId = value.unboxInt();
                                 retMap.put(Messages.ResourcesView_attributeTidName, Integer.toString(currentThreadId));
-                                int execNameQuark = ssq.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThreadId), Attributes.EXEC_NAME);
-                                interval = ssq.querySingleState(hoverTime, execNameQuark);
+                                int execNameQuark = ss.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThreadId), Attributes.EXEC_NAME);
+                                interval = ss.querySingleState(hoverTime, execNameQuark);
                                 if (!interval.getStateValue().isNull()) {
                                     value = interval.getStateValue();
                                     retMap.put(Messages.ResourcesView_attributeProcessName, value.unboxStr());
                                 }
                                 if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {
-                                    int syscallQuark = ssq.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThreadId), Attributes.SYSTEM_CALL);
-                                    interval = ssq.querySingleState(hoverTime, syscallQuark);
+                                    int syscallQuark = ss.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThreadId), Attributes.SYSTEM_CALL);
+                                    interval = ss.querySingleState(hoverTime, syscallQuark);
                                     if (!interval.getStateValue().isNull()) {
                                         value = interval.getStateValue();
                                         retMap.put(Messages.ResourcesView_attributeSyscallName, value.unboxStr());
                                     }
                                 }
                             }
-                        } catch (AttributeNotFoundException e) {
-                            e.printStackTrace();
-                        } catch (TimeRangeException e) {
-                            e.printStackTrace();
-                        } catch (StateValueTypeException e) {
-                            e.printStackTrace();
+                        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+                            Activator.getDefault().logError("Error in ResourcesPresentationProvider", e); //$NON-NLS-1$
                         } catch (StateSystemDisposedException e) {
                             /* Ignored */
                         }
@@ -296,7 +287,11 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
             return;
         }
 
-        ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
+        LttngKernelAnalysisModule module = entry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ss = module.getStateSystem();
+        if (ss == null) {
+            return;
+        }
         long time = event.getTime();
         try {
             while (time < event.getTime() + event.getDuration()) {
@@ -348,12 +343,8 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                     }
                 }
             }
-        } catch (AttributeNotFoundException e) {
-            e.printStackTrace();
-        } catch (TimeRangeException e) {
-            e.printStackTrace();
-        } catch (StateValueTypeException e) {
-            e.printStackTrace();
+        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+            Activator.getDefault().logError("Error in ResourcesPresentationProvider", e); //$NON-NLS-1$
         } catch (StateSystemDisposedException e) {
             /* Ignored */
         }
index 4746386c1810e6bef9b62988ae48115dbe315f8d..7bf37217a8e79589b7079f63482e5e3e7185cc1f 100644 (file)
@@ -17,10 +17,12 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
 import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
 import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.ui.analysis.LttngKernelAnalysisModule;
 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
@@ -97,13 +99,18 @@ public class ResourcesView extends AbstractTimeGraphView {
             }
             if (aTrace instanceof LttngKernelTrace) {
                 LttngKernelTrace lttngKernelTrace = (LttngKernelTrace) aTrace;
-                ITmfStateSystem ssq = lttngKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+                LttngKernelAnalysisModule module = lttngKernelTrace.getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+                module.schedule();
+                if (!module.waitForCompletion(new NullProgressMonitor())) {
+                    continue;
+                }
+                ITmfStateSystem ssq = module.getStateSystem();
                 if (ssq == null) {
-                    return;
+                    continue;
                 }
                 ssq.waitUntilBuilt();
                 if (ssq.isCancelled()) {
-                    return;
+                    continue;
                 }
                 long startTime = ssq.getStartTime();
                 long endTime = ssq.getCurrentEndTime() + 1;
@@ -150,7 +157,11 @@ public class ResourcesView extends AbstractTimeGraphView {
                 return;
             }
             LttngKernelTrace lttngKernelTrace = traceEntry.getTrace();
-            ITmfStateSystem ssq = lttngKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+            LttngKernelAnalysisModule module = lttngKernelTrace.getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+            ITmfStateSystem ssq = module.getStateSystem();
+            if (ssq == null) {
+                continue;
+            }
             long startTime = ssq.getStartTime();
             long endTime = ssq.getCurrentEndTime() + 1;
             long resolution = (endTime - startTime) / getDisplayWidth();
@@ -167,7 +178,11 @@ public class ResourcesView extends AbstractTimeGraphView {
             long startTime, long endTime, long resolution,
             IProgressMonitor monitor) {
         ResourcesEntry resourcesEntry = (ResourcesEntry) entry;
-        ITmfStateSystem ssq = resourcesEntry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
+        LttngKernelAnalysisModule module = resourcesEntry.getTrace().getAnalysisModules(LttngKernelAnalysisModule.class).get(LttngKernelAnalysisModule.ID);
+        ITmfStateSystem ssq = module.getStateSystem();
+        if (ssq == null) {
+            return null;
+        }
         final long realStart = Math.max(startTime, ssq.getStartTime());
         final long realEnd = Math.min(endTime, ssq.getCurrentEndTime() + 1);
         if (realEnd <= realStart) {
diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/lttng2/kernel/ui/analysis/LttngKernelAnalysisModule.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/lttng2/kernel/ui/analysis/LttngKernelAnalysisModule.java
new file mode 100644 (file)
index 0000000..090f931
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2013 É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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.ui.analysis;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow.ControlFlowView;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesView;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.analysis.TmfAnalysisViewOutput;
+
+/**
+ * State System Module for lttng kernel traces
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class LttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+
+    /**
+     * The file name of the History Tree
+     */
+    @NonNull
+    public static final String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
+
+    /** The ID of this analysis module */
+    public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.analysis"; //$NON-NLS-1$
+
+    /**
+     * Constructor adding the views to the analysis
+     */
+    public LttngKernelAnalysisModule() {
+        super();
+        this.registerOutput(new TmfAnalysisViewOutput(ControlFlowView.ID));
+        this.registerOutput(new TmfAnalysisViewOutput(ResourcesView.ID));
+    }
+
+    @Override
+    public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
+        if (!(trace instanceof LttngKernelTrace)) {
+            throw new IllegalArgumentException("LttngKernelStateSystemModule: trace should be of type LttngKernelTrace"); //$NON-NLS-1$
+        }
+        super.setTrace(trace);
+    }
+
+    @Override
+    protected LttngKernelTrace getTrace() {
+        /* Cast should be safe because we check the type at the setTrace() */
+        return (LttngKernelTrace) super.getTrace();
+    }
+
+    @Override
+    @NonNull
+    protected ITmfStateProvider createStateProvider() {
+        return new LttngKernelStateProvider(getTrace());
+    }
+
+    @Override
+    @NonNull
+    protected StateSystemBackendType getBackendType() {
+        return StateSystemBackendType.FULL;
+    }
+
+    @Override
+    @NonNull
+    protected String getSsFileName() {
+        return HISTORY_TREE_FILE_NAME;
+    }
+
+    @Override
+    protected String getFullHelpText() {
+        return Messages.LttngKernelAnalysis_Help;
+    }
+
+}
index bc56fe229bd0ef5846d6dd41d3a9d3397be98090..6bd1892b21ac9ab0bbce9a846f6c64495baeb01f 100644 (file)
@@ -65,7 +65,11 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp
 
     @Override
     public String getHelpText() {
-        return new String();
+        /*
+         * FIXME: No need to externalize this. A better solution will be found
+         * soon and this string is just temporary
+         */
+        return new String("The trace must be opened to get the help message"); //$NON-NLS-1$
     }
 
     @Override
index ae7399f5f38622d370ccd2e36d98e725b218045c..0493aa1c20afa6c11696246cbd4a782836ea892a 100644 (file)
@@ -153,6 +153,17 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
      * @return The help message
      */
     public String getHelpMessage() {
+        ITmfProjectModelElement parent = getParent();
+
+        if (parent instanceof TmfTraceElement) {
+            TmfTraceElement traceElement = (TmfTraceElement) parent;
+            ITmfTrace trace = traceElement.getTrace();
+            if (trace != null) {
+                IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
+                return module.getHelpText();
+            }
+        }
+
         IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(fAnalysisId);
         if (helper == null) {
             return new String();
This page took 0.03769 seconds and 5 git commands to generate.