From dedf6868e8602b8393ed1ed09a3ffde832e6a53e Mon Sep 17 00:00:00 2001 From: Arnaud Fiorini Date: Tue, 16 Apr 2024 09:19:02 -0400 Subject: [PATCH] callstack: remove xml analysis Signed-off-by: Arnaud Fiorini --- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 1 - .../FlameChartDataProviderTest.java | 7 +- .../tests/xml/module/XmlCallstackTest.java | 96 ---- .../test_xml_files/test_callstack.xml | 69 --- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 1 - .../plugin.xml | 6 - .../xml/callstack/CallstackXmlAnalysis.java | 435 ------------------ .../callstack/CallstackXmlModuleHelper.java | 156 ------- .../callstack/CallstackXmlSchemaParser.java | 47 -- .../xml/callstack/CallstackXmlStrings.java | 36 -- .../core/xml/callstack/package-info.java | 13 - .../xsd_files/xmlCallstack.xsd | 159 ------- 14 files changed, 3 insertions(+), 1029 deletions(-) delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/xml/module/XmlCallstackTest.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/test_xml_files/test_callstack.xml delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlAnalysis.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlModuleHelper.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlSchemaParser.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlStrings.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/package-info.java delete mode 100644 callstack/org.eclipse.tracecompass.incubator.callstack.core/xsd_files/xmlCallstack.xsd diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/META-INF/MANIFEST.MF b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/META-INF/MANIFEST.MF index 33088b6e0..b5482941d 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/META-INF/MANIFEST.MF +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/META-INF/MANIFEST.MF @@ -41,7 +41,6 @@ Export-Package: org.eclipse.tracecompass.incubator.callstack.core.tests, org.eclipse.tracecompass.incubator.callstack.core.tests.lttng2.ust.callstack, org.eclipse.tracecompass.incubator.callstack.core.tests.perf.analysis, org.eclipse.tracecompass.incubator.callstack.core.tests.sampled, - org.eclipse.tracecompass.incubator.callstack.core.tests.stubs, - org.eclipse.tracecompass.incubator.callstack.core.tests.xml.module + org.eclipse.tracecompass.incubator.callstack.core.tests.stubs Import-Package: com.google.common.collect Automatic-Module-Name: org.eclipse.tracecompass.incubator.callstack.core.tests diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/build.properties b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/build.properties index f1ad88eb3..968671172 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/build.properties +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/build.properties @@ -18,5 +18,4 @@ bin.includes = META-INF/,\ about.html,\ plugin.properties,\ plugin.xml,\ - test_xml_files/,\ testfiles/ diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/flamechart/FlameChartDataProviderTest.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/flamechart/FlameChartDataProviderTest.java index e7ce4c1b0..b837be21a 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/flamechart/FlameChartDataProviderTest.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/flamechart/FlameChartDataProviderTest.java @@ -77,7 +77,7 @@ private FlameChartDataProvider getDataProvider() { public void testGetDescriptors() { FlameChartDataProviderFactory dataProviderFactory = new FlameChartDataProviderFactory(); Collection descriptors = dataProviderFactory.getDescriptors(getTrace()); - assertEquals(descriptors.size(), 2); + assertEquals(1, descriptors.size()); for (IDataProviderDescriptor descriptor : descriptors) { switch(descriptor.getId()) { @@ -86,11 +86,6 @@ public void testGetDescriptors() { assertEquals(IDataProviderDescriptor.ProviderType.TIME_GRAPH, descriptor.getType()); assertEquals("Show FlameChart provided by Analysis module: Test Callstack", descriptor.getDescription()); break; - case "org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.provider.flamechart:callstack.analysis": - assertEquals("FlameChart Test XML callstack", descriptor.getName()); - assertEquals(IDataProviderDescriptor.ProviderType.TIME_GRAPH, descriptor.getType()); - assertEquals("Show FlameChart provided by Analysis module: Test XML callstack", descriptor.getDescription()); - break; default: fail("Unknown Entry" + descriptor.getId()); break; diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/xml/module/XmlCallstackTest.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/xml/module/XmlCallstackTest.java deleted file mode 100644 index e90db3eef..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/xml/module/XmlCallstackTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.eclipse.tracecompass.incubator.callstack.core.tests.xml.module; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.IDataPalette; -import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.IWeightedTreeProvider.DataType; -import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.IWeightedTreeProvider.MetricType; -import org.eclipse.tracecompass.incubator.callstack.core.tests.Activator; -import org.eclipse.tracecompass.incubator.callstack.core.tests.flamechart.CallStackTestBase; -import org.eclipse.tracecompass.incubator.internal.callstack.core.palette.FlameWithKernelPalette; -import org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack.CallstackXmlAnalysis; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils; -import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; -import org.junit.Test; - -/** - * Test the XML callstack analysis - * - * @author Geneviève Bastien - */ -@SuppressWarnings("restriction") -public class XmlCallstackTest extends CallStackTestBase { - - private static final String XML_FILE_NAME = "test_callstack.xml"; - private static final @NonNull String XML_MODULE_ID = "callstack.analysis"; - private static final String XML_FILE = "test_xml_files/" + XML_FILE_NAME; - - private CallstackXmlAnalysis fXmlModule; - - @Override - public void setUp() { - // Add the XML file - IPath absoluteFilePath = Activator.getAbsoluteFilePath(XML_FILE); - File file = absoluteFilePath.toFile(); - IStatus xmlFile = XmlUtils.addXmlFile(file); - assertTrue(xmlFile.isOK()); - super.setUp(); - - ITmfTrace trace = getTrace(); - CallstackXmlAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, CallstackXmlAnalysis.class, XML_MODULE_ID); - assertNotNull(module); - - module.schedule(); - assertTrue(module.waitForCompletion()); - fXmlModule = module; - } - - @Override - public void tearDown() { - super.tearDown(); - // Remote the XML file - XmlUtils.deleteFiles(Collections.singleton(XML_FILE_NAME)); - - } - - /** - * Test the weighted tree configuration of the XML callstack - */ - @Test - public void testCallstackWeightedTree() { - CallstackXmlAnalysis xmlModule = fXmlModule; - assertNotNull(xmlModule); - - MetricType weightType = xmlModule.getWeightType(); - assertEquals(DataType.NANOSECONDS, weightType.getDataType()); - - List<@NonNull MetricType> additionalMetrics = xmlModule.getAdditionalMetrics(); - assertFalse(additionalMetrics.isEmpty()); - - IDataPalette palette = xmlModule.getPalette(); - assertEquals(FlameWithKernelPalette.getInstance(), palette); - } - -} diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/test_xml_files/test_callstack.xml b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/test_xml_files/test_callstack.xml deleted file mode 100644 index 1bf8a9424..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/test_xml_files/test_callstack.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/META-INF/MANIFEST.MF b/callstack/org.eclipse.tracecompass.incubator.callstack.core/META-INF/MANIFEST.MF index 2755a6a6a..39bbb9d2d 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/META-INF/MANIFEST.MF +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/META-INF/MANIFEST.MF @@ -39,8 +39,7 @@ Export-Package: org.eclipse.tracecompass.incubator.callstack.core.base, org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.callgraph;x-friends:="org.eclipse.tracecompass.incubator.callstack.core.tests,org.eclipse.tracecompass.incubator.callstack.ui", org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.provider, org.eclipse.tracecompass.incubator.internal.callstack.core.palette, - org.eclipse.tracecompass.incubator.internal.callstack.core.symbol;x-internal:=true, - org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack;x-friends:="org.eclipse.tracecompass.incubator.callstack.core.tests,org.eclipse.tracecompass.incubator.callstack.ui" + org.eclipse.tracecompass.incubator.internal.callstack.core.symbol;x-internal:=true Import-Package: com.google.common.annotations, com.google.common.base, com.google.common.cache, diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/build.properties b/callstack/org.eclipse.tracecompass.incubator.callstack.core/build.properties index 2fc32c78a..9e23af68b 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/build.properties +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/build.properties @@ -14,6 +14,5 @@ output.. = bin/ bin.includes = META-INF/,\ about.html,\ plugin.properties,\ - xsd_files/,\ .,\ plugin.xml diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/plugin.xml b/callstack/org.eclipse.tracecompass.incubator.callstack.core/plugin.xml index 12e721238..d4289ee74 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/plugin.xml +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/plugin.xml @@ -3,12 +3,6 @@ - - - - diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlAnalysis.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlAnalysis.java deleted file mode 100644 index ce01f63f6..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlAnalysis.java +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener; -import org.eclipse.tracecompass.incubator.analysis.core.concepts.AggregatedCallSite; -import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.IDataPalette; -import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.IWeightedTreeGroupDescriptor; -import org.eclipse.tracecompass.incubator.callstack.core.callgraph.CallGraph; -import org.eclipse.tracecompass.incubator.callstack.core.callgraph.ICallGraphProvider; -import org.eclipse.tracecompass.incubator.callstack.core.callgraph.SymbolAspect; -import org.eclipse.tracecompass.incubator.callstack.core.instrumented.IFlameChartProvider; -import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.CallStackHostUtils; -import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.CallStackHostUtils.IHostIdResolver; -import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.CallStackSeries; -import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.CallStackSeries.IThreadIdResolver; -import org.eclipse.tracecompass.incubator.internal.callstack.core.Activator; -import org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.FunctionTidAspect; -import org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.callgraph.CallGraphAnalysis; -import org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack.CallstackXmlModuleHelper.ISubModuleHelper; -import org.eclipse.tracecompass.segmentstore.core.ISegment; -import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; -import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; -import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; -import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule; -import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; -import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; -import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.w3c.dom.Element; - -import com.google.common.collect.ImmutableList; - -/** - * - * - * @author Geneviève Bastien - */ -public class CallstackXmlAnalysis extends TmfAbstractAnalysisModule implements IFlameChartProvider, ITmfAnalysisModuleWithStateSystems, ICallGraphProvider { - - private final Path fSourceFile; - private final ISubModuleHelper fHelper; - private @Nullable IAnalysisModule fModule = null; - private @Nullable CallStackSeries fCallStacks = null; - private final CallGraphAnalysis fCallGraph; - private boolean fHasTid = false; - - private final ListenerList fListeners = new ListenerList(ListenerList.IDENTITY); - - /** - * Constructor - * - * @param sourceFile - * The source file containing this callstack analysis - * @param helper - * The helper for the dependent module - */ - public CallstackXmlAnalysis(Path sourceFile, ISubModuleHelper helper) { - super(); - fSourceFile = sourceFile; - fHelper = helper; - fCallGraph = new CallGraphAnalysis(this); - } - - @Override - public @Nullable CallStackSeries getCallStackSeries() { - CallStackSeries series = fCallStacks; - if (series == null) { - IAnalysisModule module = getAnalysisModule(); - if (!(module instanceof ITmfAnalysisModuleWithStateSystems)) { - return null; - } - Iterator<@NonNull ITmfStateSystem> stateSystems = ((ITmfAnalysisModuleWithStateSystems) module).getStateSystems().iterator(); - if (!stateSystems.hasNext()) { - return null; - } - ITmfStateSystem ss = stateSystems.next(); - Path xmlFile = fSourceFile; - final String pathString = xmlFile.toString(); - Element doc = TmfXmlUtils.getElementInFile(pathString, CallstackXmlStrings.CALLSTACK, getId()); - if (doc == null) { - fCallStacks = null; - return null; - } - - /* parser for defined Fields */ - List callStackElements = TmfXmlUtils.getChildElements(doc, CallstackXmlStrings.CALLSTACK_GROUP); - if (callStackElements.size() > 1) { - Activator.getInstance().logWarning("More than one callstack series defined. Only the first one will be displayed"); //$NON-NLS-1$ - } else if (callStackElements.isEmpty()) { - fCallStacks = null; - return null; - } - Element callStackElement = callStackElements.get(0); - - List patterns = new ArrayList<>(); - for (Element child : TmfXmlUtils.getChildElements(callStackElement, CallstackXmlStrings.CALLSTACK_LEVEL)) { - String attribute = child.getAttribute(CallstackXmlStrings.CALLSTACK_PATH); - patterns.add(attribute.split("/")); //$NON-NLS-1$ - } - - // Build the thread resolver - List childElements = TmfXmlUtils.getChildElements(callStackElement, CallstackXmlStrings.CALLSTACK_THREAD); - IThreadIdResolver resolver = null; - if (childElements.size() > 0) { - Element threadElement = childElements.get(0); - String attribute = threadElement.getAttribute(CallstackXmlStrings.CALLSTACK_THREADCPU); - if (!attribute.isEmpty()) { - resolver = new CallStackSeries.CpuResolver(attribute.split("/")); //$NON-NLS-1$ - } else { - attribute = threadElement.getAttribute(CallstackXmlStrings.CALLSTACK_THREADLEVEL); - if (!attribute.isEmpty()) { - String type = threadElement.getAttribute(CallstackXmlStrings.CALLSTACK_THREADLEVEL_TYPE); - if (type.equals(CallstackXmlStrings.CALLSTACK_THREADLEVEL_VALUE)) { - resolver = new CallStackSeries.AttributeValueThreadResolver(Integer.valueOf(attribute)); - } else { - resolver = new CallStackSeries.AttributeNameThreadResolver(Integer.valueOf(attribute)); - } - } - } - } - fHasTid = (resolver != null); - - // Build the host resolver - childElements = TmfXmlUtils.getChildElements(callStackElement, CallstackXmlStrings.CALLSTACK_HOST); - IHostIdResolver hostResolver = null; - if (childElements.size() > 0) { - Element hostElement = childElements.get(0); - String attribute = hostElement.getAttribute(CallstackXmlStrings.CALLSTACK_THREADLEVEL); - if (!attribute.isEmpty()) { - String type = hostElement.getAttribute(CallstackXmlStrings.CALLSTACK_THREADLEVEL_TYPE); - if (type.equals(CallstackXmlStrings.CALLSTACK_THREADLEVEL_VALUE)) { - hostResolver = new CallStackHostUtils.AttributeValueHostResolver(Integer.valueOf(attribute)); - } else { - hostResolver = new CallStackHostUtils.AttributeNameHostResolver(Integer.valueOf(attribute)); - } - } - } - hostResolver = hostResolver == null ? new CallStackHostUtils.TraceHostIdResolver(Objects.requireNonNull(getTrace())) : hostResolver; - fHasTid = resolver != null; - series = new CallStackSeries(ss, patterns, 0, callStackElement.getAttribute(TmfXmlStrings.NAME), hostResolver, resolver); - fCallStacks = series; - } - return series; - } - - @Override - public String getHostId() { - ITmfTrace trace = getTrace(); - if (trace == null) { - return ""; //$NON-NLS-1$ - } - return trace.getHostId(); - } - - @Override - protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException { - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule == null) { - return false; - } - boolean ret = analysisModule.waitForCompletion(monitor); - if (!ret) { - return ret; - } - ISegmentStore segmentStore = getSegmentStore(); - if (segmentStore != null) { - sendUpdate(segmentStore); - } - fCallGraph.schedule(); - return true; - } - - @Override - protected void canceling() { - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule != null) { - analysisModule.cancel(); - } - fCallGraph.cancel(); - } - - @Override - public void dispose() { - /* - * The sub-analyses are not registered to the trace directly, so we need - * to tell them when the trace is disposed. - */ - super.dispose(); - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule != null) { - analysisModule.dispose(); - } - fCallGraph.dispose(); - } - - @Override - public boolean setTrace(@NonNull ITmfTrace trace) throws TmfAnalysisException { - if (!super.setTrace(trace)) { - return false; - } - return fCallGraph.setTrace(trace); - } - - @Override - public void setName(String name) { - super.setName(name); - fCallGraph.setName(name); - } - - @Override - protected Iterable getDependentAnalyses() { - ITmfTrace trace = getTrace(); - if (trace == null) { - throw new NullPointerException("Trace should not be null at this point"); //$NON-NLS-1$ - } - IAnalysisModule module = getAnalysisModule(); - - if (module == null) { - return Collections.emptyList(); - } - return Collections.singleton(module); - - } - - private synchronized @Nullable IAnalysisModule getAnalysisModule() { - IAnalysisModule module = fModule; - if (module == null) { - ITmfTrace trace = getTrace(); - if (trace == null) { - return null; - } - module = fHelper.getAnalysis(trace); - if (module != null) { - fModule = module; - } - } - return module; - } - - @Override - public @Nullable ITmfStateSystem getStateSystem(String id) { - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule instanceof ITmfAnalysisModuleWithStateSystems) { - return ((ITmfAnalysisModuleWithStateSystems) analysisModule).getStateSystem(id); - } - return null; - } - - @Override - public Iterable getStateSystems() { - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule instanceof ITmfAnalysisModuleWithStateSystems) { - return ((ITmfAnalysisModuleWithStateSystems) analysisModule).getStateSystems(); - } - return Collections.emptyList(); - } - - @Override - public boolean waitForInitialization() { - IAnalysisModule analysisModule = getAnalysisModule(); - if (analysisModule instanceof ITmfAnalysisModuleWithStateSystems) { - return ((ITmfAnalysisModuleWithStateSystems) analysisModule).waitForInitialization(); - } - return false; - } - - @Override - public Collection getGroupDescriptors() { - fCallGraph.schedule(); - fCallGraph.waitForCompletion(); - return fCallGraph.getGroupDescriptors(); - } - - @Override - public CallGraph getCallGraph(ITmfTimestamp start, ITmfTimestamp end) { - fCallGraph.schedule(); - fCallGraph.waitForCompletion(); - return fCallGraph.getCallGraph(start, end); - } - - @Override - public CallGraph getCallGraph() { - fCallGraph.schedule(); - fCallGraph.waitForCompletion(); - return fCallGraph.getCallGraph(); - } - - @Override - public AggregatedCallSite createCallSite(Object symbol) { - return fCallGraph.createCallSite(symbol); - } - - @Override - public String getTitle() { - return fCallGraph.getTitle(); - } - - @Override - public void addListener(@NonNull IAnalysisProgressListener listener) { - fListeners.add(listener); - } - - @Override - public void removeListener(@NonNull IAnalysisProgressListener listener) { - fListeners.remove(listener); - } - - @Override - public Iterable getSegmentAspects() { - if (fHasTid) { - return ImmutableList.of(FunctionTidAspect.TID_ASPECT, SymbolAspect.SYMBOL_ASPECT); - } - return Collections.singletonList(SymbolAspect.SYMBOL_ASPECT); - } - - @Override - public @Nullable ISegmentStore getSegmentStore() { - CallStackSeries series = getCallStackSeries(); - if (series == null) { - return null; - } - return series; - } - - /** - * Returns all the listeners - * - * @return latency listeners - */ - protected Iterable getListeners() { - List listeners = new ArrayList<>(); - for (Object listener : fListeners.getListeners()) { - if (listener != null) { - listeners.add((IAnalysisProgressListener) listener); - } - } - return listeners; - } - - /** - * Send the segment store to all its listener - * - * @param store - * The segment store to broadcast - */ - protected void sendUpdate(final ISegmentStore store) { - for (IAnalysisProgressListener listener : getListeners()) { - listener.onComplete(this, store); - } - } - - @Override - public boolean isComplete() { - // Initialization error, but the analysis is completed - if (!waitForInitialization()) { - return true; - } - Iterator iterator = getStateSystems().iterator(); - if (!iterator.hasNext()) { - throw new IllegalStateException("The initialization is complete, so the state system must not be null"); //$NON-NLS-1$ - } - return iterator.next().waitUntilBuilt(0); - } - - @Override - public long getEnd() { - // Initialization error, but the analysis is completed - if (!waitForInitialization()) { - return Integer.MIN_VALUE; - } - Iterator iterator = getStateSystems().iterator(); - if (!iterator.hasNext()) { - throw new IllegalStateException("The initialization is complete, so the state system must not be null"); //$NON-NLS-1$ - } - return iterator.next().getCurrentEndTime(); - } - - @Override - public List getExtraDataSets() { - return fCallGraph.getExtraDataSets(); - } - - @Override - public MetricType getWeightType() { - return fCallGraph.getWeightType(); - } - - @Override - public List getAdditionalMetrics() { - return fCallGraph.getAdditionalMetrics(); - } - - @Override - public String toDisplayString(AggregatedCallSite object) { - return fCallGraph.toDisplayString(object); - } - - @Override - public Object getAdditionalMetric(AggregatedCallSite object, int metricIndex) { - return fCallGraph.getAdditionalMetric(object, metricIndex); - } - - @Override - public IDataPalette getPalette() { - fCallGraph.schedule(); - fCallGraph.waitForCompletion(); - return fCallGraph.getPalette(); - } - -} diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlModuleHelper.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlModuleHelper.java deleted file mode 100644 index d1081ddb4..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlModuleHelper.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.incubator.internal.callstack.core.Activator; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfAnalysisModuleHelperXml; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; -import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; -import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper; -import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager; -import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; -import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.w3c.dom.Element; - -import com.google.common.collect.Multimap; - -/** - * An XML module helper for the callstack modules. It overrides some methods to - * use the trace type that applies as well as labels from the module that - * creates the state system. - * - * @author Geneviève Bastien - */ -public class CallstackXmlModuleHelper extends TmfAnalysisModuleHelperXml { - - static interface ISubModuleHelper { - public Collection getHelpers(); - - public @Nullable IAnalysisModule getAnalysis(ITmfTrace trace); - } - - static class HiddenModuleHelper implements ISubModuleHelper { - private final IAnalysisModuleHelper fHelper; - - public HiddenModuleHelper(IAnalysisModuleHelper helper) { - fHelper = helper; - } - - @Override - public Collection getHelpers() { - return Collections.singleton(fHelper); - } - - @Override - public @Nullable IAnalysisModule getAnalysis(@NonNull ITmfTrace trace) { - try { - return fHelper.newModule(trace); - } catch (TmfAnalysisException e) { - Activator.getInstance().logError(e.getMessage()); - } - return null; - } - } - - static class RefModuleHelper implements ISubModuleHelper { - private final String fAnalysisId; - - public RefModuleHelper(String id) { - fAnalysisId = id; - } - - @Override - public @NonNull Collection getHelpers() { - Multimap analysisModules = TmfAnalysisManager.getAnalysisModules(); - Collection collection = analysisModules.get(fAnalysisId); - if (collection.isEmpty()) { - Activator.getInstance().logWarning("Callstack XML analysis: no analysis called " + fAnalysisId); //$NON-NLS-1$ - } - return collection; - } - - @Override - public @Nullable IAnalysisModule getAnalysis(@NonNull ITmfTrace trace) { - return trace.getAnalysisModule(fAnalysisId); - } - } - - private final ISubModuleHelper fHelper; - - /** - * Constructor - * - * @param xmlFile - * The XML file this element comes from - * @param node - * The XML element for this callstack - */ - public CallstackXmlModuleHelper(File xmlFile, Element node) { - super(xmlFile, node, XmlAnalysisModuleType.OTHER); - /* Create the helper for the underlying module or set its analysis ID */ - List<@NonNull Element> childElements = TmfXmlUtils.getChildElements(node, TmfXmlStrings.PATTERN); - if (!childElements.isEmpty()) { - // Create a helper for this module - fHelper = new HiddenModuleHelper(new TmfAnalysisModuleHelperXml(xmlFile, childElements.get(0), XmlAnalysisModuleType.PATTERN)); - return; - } - childElements = TmfXmlUtils.getChildElements(node, TmfXmlStrings.STATE_PROVIDER); - if (!childElements.isEmpty()) { - // Create a helper for this module - fHelper = new HiddenModuleHelper(new TmfAnalysisModuleHelperXml(xmlFile, childElements.get(0), XmlAnalysisModuleType.STATE_SYSTEM)); - return; - } - childElements = TmfXmlUtils.getChildElements(node, TmfXmlStrings.ANALYSIS); - if (childElements.isEmpty()) { - throw new IllegalStateException("XML callstack element: there should be one of {pattern, stateProvider, analysis}. none found"); //$NON-NLS-1$ - } - // Create a helper for this module - fHelper = new RefModuleHelper(String.valueOf(childElements.get(0).getAttribute(TmfXmlStrings.ID))); - return; - } - - @Override - protected IAnalysisModule createOtherModule(@NonNull String analysisid, @NonNull String name) { - IAnalysisModule module = new CallstackXmlAnalysis(getSourceFile(), fHelper); - module.setId(analysisid); - module.setName(name); - return module; - } - - @Override - public String getName() { - return fHelper.getHelpers().stream() - .map(h -> h.getName()) - .findFirst() - .get(); - } - - @Override - @NonNullByDefault({}) - public boolean appliesToTraceType(Class traceClass) { - List collect = fHelper.getHelpers().stream() - .filter(h -> h.appliesToTraceType(traceClass)) - .collect(Collectors.toList()); - return !collect.isEmpty(); - } - -} diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlSchemaParser.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlSchemaParser.java deleted file mode 100644 index 1cfb9fd04..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlSchemaParser.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.ITmfXmlSchemaParser; -import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** - * Class that will parse the XML schema and extract the helpers for data-driven - * callstack analyses - * - * @author Geneviève Bastien - */ -public class CallstackXmlSchemaParser implements ITmfXmlSchemaParser { - - @Override - public Collection getModuleHelpers(File xmlFile, Document doc) { - List list = new ArrayList<>(); - NodeList callstackNodes = doc.getElementsByTagName(CallstackXmlStrings.CALLSTACK); - for (int i = 0; i < callstackNodes.getLength(); i++) { - Element node = Objects.requireNonNull((Element) callstackNodes.item(i)); - - IAnalysisModuleHelper helper = new CallstackXmlModuleHelper(xmlFile, node); - list.add(helper); - } - return list; - } - -} diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlStrings.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlStrings.java deleted file mode 100644 index efe94a16b..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/CallstackXmlStrings.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack; - -/** - * This file defines all name in the XML Structure for the State Provider - * - * @author Geneviève Bastien - * @noimplement This interface only contains static defines - */ -@SuppressWarnings({ "javadoc"}) -public interface CallstackXmlStrings { - - /** The callstack base element string */ - String CALLSTACK = "callstack"; //$NON-NLS-1$ - String CALLSTACK_LEVEL = "level"; //$NON-NLS-1$ - String CALLSTACK_PATH = "path"; //$NON-NLS-1$ - String CALLSTACK_HOST = "host"; //$NON-NLS-1$ - String CALLSTACK_THREAD = "thread"; //$NON-NLS-1$ - String CALLSTACK_THREADCPU = "cpu"; //$NON-NLS-1$ - String CALLSTACK_THREADLEVEL = "level"; //$NON-NLS-1$ - String CALLSTACK_THREADLEVEL_NAME = "name"; //$NON-NLS-1$ - String CALLSTACK_THREADLEVEL_TYPE = "type"; //$NON-NLS-1$ - String CALLSTACK_THREADLEVEL_VALUE = "value"; //$NON-NLS-1$ - String CALLSTACK_GROUP = "callstackGroup"; //$NON-NLS-1$ - -} diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/package-info.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/package-info.java deleted file mode 100644 index f733f8844..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/xml/callstack/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 É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 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -@org.eclipse.jdt.annotation.NonNullByDefault -package org.eclipse.tracecompass.incubator.internal.callstack.core.xml.callstack; diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/xsd_files/xmlCallstack.xsd b/callstack/org.eclipse.tracecompass.incubator.callstack.core/xsd_files/xmlCallstack.xsd deleted file mode 100644 index 0904c5f39..000000000 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/xsd_files/xmlCallstack.xsd +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - Declares a callstack path in the state system. If part of the state system describes a callstack, defining a callstack element will allow the analysis to have access to all callstack analysis information. - - - - - Defines a value that maps a string used in the pattern state provider to a numbered value. - - - - - - The ID of the analysis whose state system is to be used as base for the state system. Both the callstack and the analysis it links to will appear for a given trace. The trace type it applies to are the same as the base analysis. - - - - - The ID of the analysis whose state system is to be used as base for the state system. Both the callstack and the analysis it links to will appear for a given trace. The trace type it applies to are the same as the base analysis. - - - - - - - Defines an internal pattern analysis that will be used to populate the callstack. This analysis will not appear under the trace, only the callstack one, but its label and trace type will be used for the callstack analysis - - - - - Defines an internal state system analysis that will be used to populate the callstack. This analysis will not appear under the trace, only the callstack one, but its label and trace type will be used for the callstack analysis - - - - - - - The unique ID of this callstack. It will be used to identify the analysis that will be built from this pattern provider. - - - - - - - - - Declares a callstack path in the state system. If part of the state system describes a callstack, defining a callstack element will allow the analysis to have access to all callstack analysis information. - - - - - Defines the path in the state system that describes a level of the callstack. - - - - - Defines how to get the thread ID of the thread doing the callstack. - - - - - Defines how to get the host ID for a callstack. - - - - - - A name to identify this callstack group - - - - - - - Defines a level in the callstack - - - - The path from the root of the state system where the callstack process pattern starts. It can be empty. - - - - - - - Defines the way to get the thread ID for the callstack. - - - - The path relative to the last element of the callstack where to find the CPU that will be used to get the Thread ID. - - - - - The level whose value contains the thread ID. - - - - - Describe where at this level the thread ID value is. - - - - - - The thread ID is the name of the level - - - The thread ID is the value at this level - - - - - - - - Defines the way to get the host ID for the callstack. - - - - The level whose data to use to get the host ID. - - - - - Describe where at this level the host ID is. - - - - - - The host ID is the name of the level - - - The host ID is the value at this level - - - - - - \ No newline at end of file