From 4bc539296f35c03451988aff23e4d8e37ce10180 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Thu, 14 Nov 2013 11:47:11 -0500 Subject: [PATCH] Tmf: Port the LTTng Kernel state system to an analysis module MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit And update the views accordingly. Change-Id: I90975b5772db24a784d99d2d0232f6f76a8e5e03 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/19432 Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- .../META-INF/MANIFEST.MF | 6 +- .../kernel/core/trace/LttngKernelTrace.java | 41 +-------- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 2 + .../plugin.properties | 2 + .../plugin.xml | 12 +++ .../internal/lttng2/kernel/ui/Messages.java | 2 + .../lttng2/kernel/ui/messages.properties | 2 + .../ControlFlowPresentationProvider.java | 35 ++++---- .../ui/views/controlflow/ControlFlowView.java | 38 ++++++-- .../ResourcesPresentationProvider.java | 61 ++++++------- .../ui/views/resources/ResourcesView.java | 25 ++++-- .../analysis/LttngKernelAnalysisModule.java | 90 +++++++++++++++++++ .../TmfAnalysisModuleHelperConfigElement.java | 6 +- .../ui/project/model/TmfAnalysisElement.java | 11 +++ 15 files changed, 226 insertions(+), 110 deletions(-) create mode 100644 org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/lttng2/kernel/ui/analysis/LttngKernelAnalysisModule.java diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng2.kernel.core/META-INF/MANIFEST.MF index 10ca723cbe..7effe4d465 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng2.kernel.core/META-INF/MANIFEST.MF @@ -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 diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java index 6ea09e1cbb..f71697c199 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java @@ -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; - } - } diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF index 4811b27833..3271f9c8c4 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF @@ -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 diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/build.properties b/org.eclipse.linuxtools.lttng2.kernel.ui/build.properties index cb21f79b76..0536a02f8d 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/build.properties +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/build.properties @@ -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 diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.properties b/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.properties index 9172f4976e..bb75d70b7f 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.properties +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.properties @@ -20,3 +20,5 @@ controlflow.view.name = Control Flow resources.view.name = Resources tracetype.type.kernel = LTTng Kernel Trace + +analysis.lttngkernel = LTTng Kernel Analysis diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.xml b/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.xml index 98b081bfac..0e66b752ef 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/plugin.xml @@ -61,4 +61,16 @@ + + + + + + diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java index 7200352850..f851aa73e4 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java @@ -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); diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties index 29e75b8991..cfa70d2424 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties @@ -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 diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java index 94bd6beaf3..cdb01ecb46 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java @@ -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 */ } diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java index e0fb7a0c29..adf51cce29 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java @@ -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 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 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 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()); diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java index a713db513e..162ba4a2cb 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java @@ -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 */ } diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java index 4746386c18..7bf37217a8 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java @@ -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 index 0000000000..090f931ea1 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/lttng2/kernel/ui/analysis/LttngKernelAnalysisModule.java @@ -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; + } + +} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java index bc56fe229b..6bd1892b21 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java @@ -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 diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java index ae7399f5f3..0493aa1c20 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java @@ -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(); -- 2.34.1