-
Notifications
You must be signed in to change notification settings - Fork 9
/
Otf2CallstackAnalysis.java
89 lines (78 loc) · 3.34 KB
/
Otf2CallstackAnalysis.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**********************************************************************
* Copyright (c) 2021 É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.otf2.core.analysis.callstack;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackStateProvider;
import org.eclipse.tracecompass.analysis.profiling.core.callstack2.CallStackSeries;
import org.eclipse.tracecompass.analysis.profiling.core.callstack2.CallStackSeries.IThreadIdResolver;
import org.eclipse.tracecompass.analysis.profiling.core.instrumented.InstrumentedCallStackAnalysis;
import org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.AbstractOtf2Analysis;
import org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2Constants;
import org.eclipse.tracecompass.incubator.otf2.core.trace.Otf2Trace;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import com.google.common.collect.ImmutableList;
/**
* OTF2 callstack analysis
*
* @author Yoann Heitz
*
*/
public class Otf2CallstackAnalysis extends InstrumentedCallStackAnalysis {
private static final String ID_SUFFIX = ".callstack"; //$NON-NLS-1$
private static final int THREAD_DEPTH = 3;
@Override
public String getId() {
return AbstractOtf2Analysis.getAnalysisIdFromSuffix(ID_SUFFIX);
}
@Override
protected @NonNull IThreadIdResolver getCallStackTidResolver() {
return new CallStackSeries.AttributeValueThreadResolver(THREAD_DEPTH);
}
@Override
protected ITmfStateProvider createStateProvider() {
ITmfTrace trace = Objects.requireNonNull(getTrace());
if (trace instanceof Otf2Trace) {
return new Otf2CallStackStateProvider(trace);
}
throw new IllegalStateException("Trace is not an OTF2 trace"); //$NON-NLS-1$
}
@Override
protected Collection<Integer> getEdgeQuarks() {
ITmfStateSystem ss = getStateSystem();
if (ss == null) {
return Collections.emptyList();
}
int edgeQuark = ss.optQuarkAbsolute(IOtf2Constants.EDGES);
if (edgeQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
return Collections.emptyList();
}
return ss.getSubAttributes(edgeQuark, false);
}
/**
* Get the patterns for the clusters, nodes, processes and threads
*
* @return The patterns for the different levels in the state system
*/
@Override
protected List<String[]> getPatterns() {
return ImmutableList.of(
new String[] { CallStackStateProvider.PROCESSES, "*" }, //$NON-NLS-1$
new String[] { "*" }, //$NON-NLS-1$
new String[] { "*" }, //$NON-NLS-1$
new String[] { "*" }); //$NON-NLS-1$
}
}