import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.AggregatedCalledFunction;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.AggregatedCalledFunctionStatistics;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.CallGraphAnalysis;
+import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.ThreadNode;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.StateSystemFactory;
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
@NonNull
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
Object[] children = threads.get(0).getChildren().toArray();
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
assertNotNull(threads);
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
Object[] children = threads.get(0).getChildren().toArray();
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
// Test the threads generated by the analysis
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.AggregatedCalledFunction;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.CallGraphAnalysis;
+import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.ThreadNode;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.StateSystemFactory;
fixture.closeHistory(1002);
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
assertNotNull(threads);
assertEquals("Number of threads found", 0, threads.size());
}
// Build the state system
long start = 1;
long end = 1001;
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueLong(100), threadQuark);
for (int i = 1; i <= SMALL_AMOUNT_OF_SEGMENT; i++) {
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, Integer.toString(i));
TmfStateValue statev = TmfStateValue.newValueLong(i);
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
@NonNull
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
+ assertEquals("Thread id", 100, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
public void treeTest() {
ITmfStateSystemBuilder fixture = createFixture();
// Build the state system
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
TmfStateValue statev = TmfStateValue.newValueLong(0);
fixture.modifyAttribute(0, statev, quark);
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
@NonNull
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
public void mergeFirstLevelCalleesTest() {
ITmfStateSystemBuilder fixture = createFixture();
// Build the state system
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, "123");
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
TmfStateValue statev = TmfStateValue.newValueLong(0);
fixture.modifyAttribute(0, statev, quark);
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
- assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ String @NonNull [] tp = { "123" };
+ assertTrue(cga.iterateOverStateSystem(fixture, tp, PP, CSP, new NullProgressMonitor()));
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", 123, threads.get(0).getId());
+ assertEquals("Thread name", "123", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction main = (AggregatedCalledFunction) children[0];
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction parent = (AggregatedCalledFunction) children[0];
for (int i = 1; i < LARGE_AMOUNT_OF_SEGMENTS; i++) {
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 2, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
import org.eclipse.tracecompass.tmf.core.callstack.CallStackAnalysis;
* The List of thread nodes. Each thread has a virtual node having the root
* function as children
*/
- private List<AggregatedCalledFunction> fThreadNodes = new ArrayList<>();
+ private List<ThreadNode> fThreadNodes = new ArrayList<>();
/**
* Default constructor
*/
private boolean iterateOverQuark(ITmfStateSystem stateSystem, int quark, String[] subAttributePath, IProgressMonitor monitor) {
String threadName = stateSystem.getAttributeName(quark);
- AggregatedCalledFunction init = null;
+ long threadId = -1;
+ ITmfStateInterval interval = null;
+ try {
+ interval = stateSystem.querySingleState(stateSystem.getStartTime(), quark);
+ ITmfStateValue threadStateValue = interval.getStateValue();
+ if (threadStateValue.getType() == Type.LONG || threadStateValue.getType() == Type.INTEGER) {
+ threadId = threadStateValue.unboxLong();
+ } else {
+ try {
+ threadId = Long.parseLong(threadName);
+ } catch (NumberFormatException e) {
+ /* use default threadId */
+ }
+ }
+ } catch (StateSystemDisposedException error) {
+ Activator.getInstance().logError(Messages.QueringStateSystemError, error);
+ }
try {
long curTime = stateSystem.getStartTime();
long limit = stateSystem.getCurrentEndTime();
AbstractCalledFunction initSegment = CalledFunctionFactory.create(0, 0, 0, threadName, null);
- init = new AggregatedCalledFunction(initSegment, 0);
+ ThreadNode init = new ThreadNode(initSegment, 0, threadId);
while (curTime < limit) {
if (monitor.isCanceled()) {
return false;
}
final int depth = 0;
int quarkParent = fCurrentQuarks.get(depth);
- ITmfStateInterval interval = stateSystem.querySingleState(curTime, quarkParent);
+ interval = stateSystem.querySingleState(curTime, quarkParent);
ITmfStateValue stateValue = interval.getStateValue();
if (!stateValue.isNull()) {
curTime = interval.getEndTime() + 1;
}
-
+ fThreadNodes.add(init);
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
Activator.getInstance().logError(Messages.QueringStateSystemError, e);
return false;
}
- fThreadNodes.add(init);
return true;
}
*
* @return The thread nodes
*/
- public List<AggregatedCalledFunction> getThreadNodes() {
+ public List<ThreadNode> getThreadNodes() {
return ImmutableList.copyOf(fThreadNodes);
}