Skip to content

Commit

Permalink
callstack: Add incubated FunctionDensityView &co.
Browse files Browse the repository at this point in the history
[Added] o.e.t.i.a.callstack.ui.functiondensity.FunctionDensityView

Change-Id: I8b79d2c5313f0796a621fae441366c2b53989d6b
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/199894
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 6281c6f commit bcb4b5e
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Automatic-Module-Name: org.eclipse.tracecompass.analysis.callstack.ui
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.swtchart,
org.eclipse.tracecompass.analysis.callstack.core,
org.eclipse.tracecompass.analysis.os.linux.core,
org.eclipse.tracecompass.analysis.os.linux.ui,
org.eclipse.tracecompass.analysis.profiling.ui,
org.eclipse.tracecompass.analysis.timing.core,
org.eclipse.tracecompass.analysis.timing.ui,
org.eclipse.tracecompass.common.core,
org.eclipse.tracecompass.tmf.core,
org.eclipse.tracecompass.tmf.ui,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Bundle-Name = Trace Compass Analysis Callstack UI Plug-in
view.flameChart = Flame Chart (new Callstack)
view.flameGraph = Flame Graph (new Callstack)
view.flameGraphSel = Flame Graph Selection (new Callstack)
view.functionDensity = Function Durations Distribution (new Callstack)
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@
name="%view.flameGraphSel"
restorable="true">
</view>
<view
allowMultiple="false"
category="org.eclipse.linuxtools.tmf.ui.views.category"
class="org.eclipse.tracecompass.internal.analysis.callstack.ui.functiondensity.FunctionDensityView"
icon="icons/elcl16/funcdensity.png"
id="org.eclipse.tracecompass.analysis.callstack.ui.functiondensity"
name="%view.functionDensity"
restorable="true">
</view>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.tracecompass.internal.analysis.callstack.core.tree.IWeightedTreeProvider;
import org.eclipse.tracecompass.internal.analysis.callstack.ui.flamegraph.FlameGraphSelView;
import org.eclipse.tracecompass.internal.analysis.callstack.ui.flamegraph.FlameGraphView;
import org.eclipse.tracecompass.internal.analysis.callstack.ui.functiondensity.FunctionDensityView;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.analysis.ITmfNewAnalysisModuleListener;
import org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput;
Expand All @@ -33,6 +34,7 @@ public class CallStackAnalysisListener implements ITmfNewAnalysisModuleListener
public void moduleCreated(@Nullable IAnalysisModule module) {
if (module instanceof IFlameChartProvider) {
module.registerOutput(new TmfAnalysisViewOutput(FlameChartView.ID, module.getId()));
module.registerOutput(new TmfAnalysisViewOutput(FunctionDensityView.ID, module.getId()));
}
if (module instanceof IWeightedTreeProvider) {
module.registerOutput(new TmfAnalysisViewOutput(FlameGraphView.ID, module.getId()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/******************************************************************************
* 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.ui.functiondensity;

import java.util.Objects;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density2.AbstractSegmentStoreDensityView;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density2.AbstractSegmentStoreDensityViewer;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
import org.eclipse.tracecompass.tmf.core.segment.SegmentDurationAspect;
import org.eclipse.tracecompass.tmf.core.segment.SegmentEndTimeAspect;
import org.eclipse.tracecompass.tmf.core.segment.SegmentStartTimeAspect;

/**
* Call stack Density view displaying the call stack segments tree.
*
* @author Sonia Farrah
*/
public class FunctionDensityView extends AbstractSegmentStoreDensityView {

/** The view's ID */
public static final String ID = "org.eclipse.tracecompass.analysis.callstack.ui.functiondensity"; //$NON-NLS-1$

/**
* Constructs a new density view.
*/
public FunctionDensityView() {
super(ID);
}

@SuppressWarnings("null")
@Override
protected AbstractSegmentStoreTableViewer createSegmentStoreTableViewer(Composite parent) {
return new FunctionTableViewer(new TableViewer(parent, SWT.FULL_SELECTION | SWT.VIRTUAL), getViewSite().getSecondaryId()) {
@Override
protected void createProviderColumns() {
super.createProviderColumns();
Table t = (Table) getControl();

moveColumnTo(t, SegmentDurationAspect.SEGMENT_DURATION_ASPECT.getName(), 0);
moveColumnTo(t, SegmentStartTimeAspect.SEGMENT_START_TIME_ASPECT.getName(), 1);
moveColumnTo(t, SegmentEndTimeAspect.SEGMENT_END_TIME_ASPECT.getName(), 2);
}

private void moveColumnTo(Table t, String aspectName, int desiredIndex) {
int[] order = t.getColumnOrder();
int foundIndex = -1;
for (int i = 0; i < t.getColumnCount(); i++) {
TableColumn col = t.getColumn(i);
if (col.getText().equals(aspectName)) {
foundIndex = i;
}
}
if (foundIndex == -1) {
// At least we tried
return;
}
int tmp = order[desiredIndex];
order[desiredIndex] = order[foundIndex];
order[foundIndex] = tmp;
t.setColumnOrder(order);
}
};
}

@SuppressWarnings("null")
@Override
protected AbstractSegmentStoreDensityViewer createSegmentStoreDensityViewer(Composite parent) {
return new FunctionDensityViewer(Objects.requireNonNull(parent), getViewSite().getSecondaryId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/******************************************************************************
* 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.ui.functiondensity;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density2.AbstractSegmentStoreDensityViewer;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;

/**
* Call stack segments density viewer
*
* @author Sonia Farrah
*/
public class FunctionDensityViewer extends AbstractSegmentStoreDensityViewer {
private final String fAnalysisId;

/**
* Constructs a new density viewer.
*
* @param parent
* the parent of the viewer
* @param analysisId
* The ID of the analysis for this view
*/
public FunctionDensityViewer(Composite parent, String analysisId) {
super(parent);
fAnalysisId = analysisId;
}

@Override
protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) {
IAnalysisModule modules = trace.getAnalysisModule(fAnalysisId);
if (!(modules instanceof ISegmentStoreProvider)) {
return null;
}
return (ISegmentStoreProvider) modules;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*******************************************************************************
* 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.ui.functiondensity;

import java.util.Objects;
import java.util.Optional;
import java.util.stream.StreamSupport;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;

/**
* Displays the Call Stack data in a column table
*
* @author Sonia Farrah
*/
public class FunctionTableViewer extends AbstractSegmentStoreTableViewer {
private final String fAnalysisId;

/**
* Constructor
*
* @param tableViewer
* The table viewer
* @param analysisId
* The ID of the analysis for this view
*/
public FunctionTableViewer(TableViewer tableViewer, String analysisId) {
super(tableViewer);
fAnalysisId = analysisId;
}

@Override
protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) {
IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
if (!(module instanceof ISegmentStoreProvider)) {
Iterable<@NonNull ISegmentStoreProvider> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, ISegmentStoreProvider.class);
Optional<@NonNull ISegmentStoreProvider> providers = StreamSupport.stream(modules.spliterator(), false)
.filter(mod -> (mod instanceof IAnalysisModule && Objects.equals(fAnalysisId, ((IAnalysisModule) mod).getId())))
.findFirst();
if (providers.isPresent()) {
return providers.get();
}
return null;
}
return (ISegmentStoreProvider) module;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*******************************************************************************
* Copyright (c) 2023 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
*******************************************************************************/

@org.eclipse.jdt.annotation.NonNullByDefault
package org.eclipse.tracecompass.internal.analysis.callstack.ui.functiondensity;

0 comments on commit bcb4b5e

Please sign in to comment.