Skip to content

Commit

Permalink
callstack: Add incubated LttngUstCallStackAnalysis
Browse files Browse the repository at this point in the history
Bring Incubator's LTTng-UST CallStack analysis as the new mainlined one.

Add com.google.common.base to the UI dependencies, which was reported as
missing at runtime otherwise, upon exiting.

[Added] o.e.t.i.a.callstack.core.LttngUstCallStackAnalysis

Change-Id: I6e190aa1e85906e99c307bf61fc5062d9a69d9f7
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/199641
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
marco-miller committed Mar 31, 2023
1 parent 441d948 commit 93fa955
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 3 deletions.
Expand Up @@ -16,8 +16,11 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.tracecompass.analysis.timing.core,
org.eclipse.tracecompass.common.core,
org.eclipse.tracecompass.datastore.core,
org.eclipse.tracecompass.lttng2.common.core,
org.eclipse.tracecompass.lttng2.ust.core,
org.eclipse.tracecompass.segmentstore.core,
org.eclipse.tracecompass.tmf.core
org.eclipse.tracecompass.tmf.core,
org.eclipse.tracecompass.tmf.ctf.core
Export-Package: org.eclipse.tracecompass.internal.analysis.callstack.core;x-friends:="org.eclipse.tracecompass.analysis.callstack.core.tests",
org.eclipse.tracecompass.internal.analysis.callstack.core.instrumented;x-friends:="org.eclipse.tracecompass.analysis.callstack.ui"
Import-Package: com.google.common.annotations,
Expand Down
Expand Up @@ -11,3 +11,5 @@

Bundle-Vendor = Eclipse Trace Compass
Bundle-Name = Trace Compass Analysis Callstack Core Plug-in

analysis.callstack = LTTng-UST CallStack (new)
@@ -1,6 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.linuxtools.tmf.core.analysis">
<module
analysis_module="org.eclipse.tracecompass.internal.analysis.callstack.core.LttngUstCallStackAnalysis"
id="org.eclipse.tracecompass.analysis.callstack.core.analysis"
name="%analysis.callstack">
<tracetype
class="org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace">
</tracetype>
</module>
</extension>
<extension
point="org.eclipse.tracecompass.tmf.core.dataprovider">
<dataProviderFactory
Expand Down
@@ -0,0 +1,93 @@
/*******************************************************************************
* 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.internal.analysis.callstack.core;

import java.util.Collections;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.analysis.callstack.core.instrumented.InstrumentedCallStackAnalysis;
import org.eclipse.tracecompass.internal.analysis.callstack.core.model.IHostModel;
import org.eclipse.tracecompass.internal.analysis.callstack.core.model.IHostModel.ModelDataType;
import org.eclipse.tracecompass.internal.analysis.callstack.core.model.ModelManager;
import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackProvider;
import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;

import com.google.common.collect.ImmutableSet;

/**
* This is the LTTng UST analysis, ported to the new CallStack structure. It
* uses the same state provider as before
*
* @author Geneviève Bastien
*/
public class LttngUstCallStackAnalysis extends InstrumentedCallStackAnalysis {

/**
* ID of this analysis
*/
public static final String ID = "org.eclipse.tracecompass.analysis.callstack.core.analysis"; //$NON-NLS-1$

private @Nullable Set<@NonNull TmfAbstractAnalysisRequirement> fAnalysisRequirements = null;

@Override
public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException {
if (!(trace instanceof LttngUstTrace)) {
return false;
}
return super.setTrace(trace);
}

@Override
public @Nullable LttngUstTrace getTrace() {
return (LttngUstTrace) super.getTrace();
}

@Override
protected @NonNull ITmfStateProvider createStateProvider() {
return new LttngUstCallStackProvider(Objects.requireNonNull(getTrace()));
}

@Override
protected @NonNull Iterable<@NonNull IAnalysisModule> getDependentAnalyses() {
LttngUstTrace trace = getTrace();
if (trace == null) {
return Collections.emptyList();
}
IHostModel modelFor = ModelManager.getModelFor(trace.getHostId());
return modelFor.getRequiredModules(Objects.requireNonNull(EnumSet.of(ModelDataType.TID, ModelDataType.PID)));
}

@Override
public @NonNull Iterable<@NonNull TmfAbstractAnalysisRequirement> getAnalysisRequirements() {
Set<@NonNull TmfAbstractAnalysisRequirement> requirements = fAnalysisRequirements;
if (requirements == null) {
LttngUstTrace trace = getTrace();
ILttngUstEventLayout layout = ILttngUstEventLayout.DEFAULT_LAYOUT;
if (trace != null) {
layout = trace.getEventLayout();
}
requirements = ImmutableSet.of(new LttngUstCallStackAnalysisRequirement(layout));
fAnalysisRequirements = requirements;
}
return requirements;
}
}
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2016 Ericsson
*
* 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.internal.analysis.callstack.core;

import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;

import java.util.Collection;

import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.Messages;
import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfCompositeAnalysisRequirement;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

/**
* Analysis requirement implementation for LTTng Call Stack Analysis.
*
* @author Bernd Hufmann
*
*/
public class LttngUstCallStackAnalysisRequirement extends TmfCompositeAnalysisRequirement {

/**
* Constructor
*
* @param layout
* The event layout (non-null)
*/
public LttngUstCallStackAnalysisRequirement(ILttngUstEventLayout layout) {
super(getSubRequirements(layout), PriorityLevel.AT_LEAST_ONE);

addInformation(nullToEmptyString(Messages.LttnUstCallStackAnalysisModule_EventsLoadingInformation));
}

private static Collection<TmfAbstractAnalysisRequirement> getSubRequirements(ILttngUstEventLayout layout) {

// Requirement for the cyg_profile events
TmfAnalysisEventRequirement cygProfile = new TmfAnalysisEventRequirement(
ImmutableList.of(layout.eventCygProfileFuncEntry(), layout.eventCygProfileFuncExit()),
PriorityLevel.MANDATORY);

// Requirement for the cyg_profile_fast events
TmfAbstractAnalysisRequirement cygProfileFast = new TmfAnalysisEventRequirement(
ImmutableList.of(layout.eventCygProfileFastFuncEntry(), layout.eventCygProfileFastFuncExit()),
PriorityLevel.MANDATORY);

return ImmutableSet.of(cygProfile, cygProfileFast);
}
}
Expand Up @@ -20,4 +20,5 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.tracecompass.tmf.ui,
org.eclipse.ui
Export-Package: org.eclipse.tracecompass.internal.analysis.callstack.ui;x-internal:=true
Import-Package: com.google.common.collect
Import-Package: com.google.common.base,
com.google.common.collect
Expand Up @@ -12,7 +12,11 @@ Export-Package: org.eclipse.tracecompass.internal.lttng2.ust.core;x-friends:="or
org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.cpu;x-friends:="org.eclipse.tracecompass.lttng2.ust.core.tests",
org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.debuginfo;x-friends:="org.eclipse.tracecompass.lttng2.ust.core.tests,org.eclipse.tracecompass.lttng2.ust.ui",
org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
org.eclipse.tracecompass.internal.lttng2.ust.core.callstack;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests,org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests",
org.eclipse.tracecompass.internal.lttng2.ust.core.callstack;
x-friends:="org.eclipse.tracecompass.analysis.callstack.core,
org.eclipse.tracecompass.lttng2.ust.core.tests,
org.eclipse.tracecompass.lttng2.ust.ui,
org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests",
org.eclipse.tracecompass.internal.lttng2.ust.core.trace;x-internal:=true,
org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout;x-internal:=true,
org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo,
Expand Down

0 comments on commit 93fa955

Please sign in to comment.