Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeneviève Bastien2018-04-06 11:48:51 -0400
committerGenevieve Bastien2018-04-18 16:13:02 -0400
commitf6ef304485943fe8e80680c2743dce4cb58ec2a1 (patch)
treeb4f3f8b21381eebddc6009766c2c3f294a600a36
parent23f6b8d429fb2ebaea6de28bc223b44a16afbcb8 (diff)
downloadorg.eclipse.tracecompass.incubator-f6ef304485943fe8e80680c2743dce4cb58ec2a1.tar.gz
org.eclipse.tracecompass.incubator-f6ef304485943fe8e80680c2743dce4cb58ec2a1.tar.xz
org.eclipse.tracecompass.incubator-f6ef304485943fe8e80680c2743dce4cb58ec2a1.zip
analysis: Have the kernel statuses return an iterable
Instead of an iterator Change-Id: Idfe6e203eca6675742f6f4d827aabcdc4edb7177 Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net> Reviewed-on: https://git.eclipse.org/r/120866 Tested-by: CI Bot Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/analysis/core/model/IHostModel.java6
-rw-r--r--callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/internal/analysis/core/model/CompositeHostModel.java35
-rw-r--r--callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java3
-rw-r--r--callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CallGraphAnalysis.java8
-rw-r--r--callstack/org.eclipse.tracecompass.incubator.callstack.ui/src/org/eclipse/tracecompass/incubator/internal/callstack/ui/views/flamechart/ProcessStatusEntry.java6
-rw-r--r--vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/overhead/VmOverheadStateProvider.java7
6 files changed, 45 insertions, 20 deletions
diff --git a/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/analysis/core/model/IHostModel.java b/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/analysis/core/model/IHostModel.java
index a4d81b2c..7fefe705 100644
--- a/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/analysis/core/model/IHostModel.java
+++ b/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/analysis/core/model/IHostModel.java
@@ -10,7 +10,7 @@
package org.eclipse.tracecompass.incubator.analysis.core.model;
import java.util.Collection;
-import java.util.Iterator;
+
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.incubator.analysis.core.concepts.AggregatedCallSite;
import org.eclipse.tracecompass.incubator.analysis.core.concepts.ProcessStatusInterval;
@@ -126,7 +126,7 @@ public interface IHostModel {
Collection<AggregatedCallSite> getSamplingData(int tid, long start, long end);
/**
- * Get an iterator over the status intervals of a thread
+ * Get an iterable over the status intervals of a thread
*
* @param tid
* The ID of the thread
@@ -139,7 +139,7 @@ public interface IHostModel {
* queries. A value lower or equal to 1 will return all intervals.
* @return An iterator over the status intervals for the thread
*/
- Iterator<ProcessStatusInterval> getThreadStatusIntervals(int tid, long start, long end, long resolution);
+ Iterable<ProcessStatusInterval> getThreadStatusIntervals(int tid, long start, long end, long resolution);
/**
* Get whether sampling data is available for this host
diff --git a/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/internal/analysis/core/model/CompositeHostModel.java b/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/internal/analysis/core/model/CompositeHostModel.java
index 34579126..757a028a 100644
--- a/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/internal/analysis/core/model/CompositeHostModel.java
+++ b/callstack/org.eclipse.tracecompass.incubator.analysis.core/src/org/eclipse/tracecompass/incubator/internal/analysis/core/model/CompositeHostModel.java
@@ -239,17 +239,44 @@ public class CompositeHostModel implements IHostModel {
}
+ /**
+ * Iterator class to allow 2-way iteration over intervals of a given attribute.
+ * Not thread-safe!
+ */
+ private static class ThreadStatusIterable implements Iterable<ProcessStatusInterval> {
+
+ private final long fStart;
+ private final long fEnd;
+ private KernelAnalysisModule fModule;
+ private int fTid;
+ private long fResolution;
+
+ public ThreadStatusIterable(long start, long end, KernelAnalysisModule module, int tid, long resolution) {
+ fStart = start;
+ fEnd = end;
+ fModule = module;
+ fTid = tid;
+ fResolution = resolution;
+ }
+
+ @Override
+ public Iterator<ProcessStatusInterval> iterator() {
+ return new ThreadStatusIterator(fStart, fEnd, KernelThreadInformationProvider.getStatusIntervalsForThread(fModule, fTid, fStart, fEnd, fResolution));
+ }
+
+ }
+
@Override
- public Iterator<ProcessStatusInterval> getThreadStatusIntervals(int tid, long start, long end, long resolution) {
+ public Iterable<ProcessStatusInterval> getThreadStatusIntervals(int tid, long start, long end, long resolution) {
if (tid == IHostModel.UNKNOWN_TID) {
- return Objects.requireNonNull(Collections.emptyListIterator());
+ return Objects.requireNonNull(Collections.emptyList());
}
Iterable<KernelAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(fHostId, KernelAnalysisModule.class);
if (modules.iterator().hasNext()) {
KernelAnalysisModule module = modules.iterator().next();
- return new ThreadStatusIterator(start, end, KernelThreadInformationProvider.getStatusIntervalsForThread(module, tid, start, end, resolution));
+ return new ThreadStatusIterable(start, end, module, tid, resolution);
}
- return Objects.requireNonNull(Collections.emptyListIterator());
+ return Objects.requireNonNull(Collections.emptyList());
}
@Override
diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java
index d76d1308..b5fb98dd 100644
--- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java
+++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java
@@ -11,7 +11,6 @@ package org.eclipse.tracecompass.incubator.callstack.core.flamechart;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
@@ -400,7 +399,7 @@ public class CallStack {
* statuses are not available or if the function is outside the range of
* the available data.
*/
- public Iterator<ProcessStatusInterval> getKernelStatuses(ICalledFunction function, long resolution) {
+ public Iterable<ProcessStatusInterval> getKernelStatuses(ICalledFunction function, long resolution) {
IHostModel model = ModelManager.getModelFor(getHostId(function.getStart()));
return model.getThreadStatusIntervals(function.getThreadId(), function.getStart(), function.getEnd(), resolution);
}
diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CallGraphAnalysis.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CallGraphAnalysis.java
index 3be1b089..8ea68176 100644
--- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CallGraphAnalysis.java
+++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CallGraphAnalysis.java
@@ -12,7 +12,6 @@ package org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -210,9 +209,10 @@ public class CallGraphAnalysis extends TmfAbstractAnalysisModule implements ICal
iterateOverCallstack(element, callStack, nextFunction, 2, aggregatedChild, model, start, end, monitor);
aggregatedChild.addFunctionCall(nextFunction);
// Add the kernel statuses if available
- Iterator<ProcessStatusInterval> kernelStatuses = callStack.getKernelStatuses(nextFunction, -1);
- kernelStatuses.forEachRemaining(aggregatedChild::addKernelStatus);
-
+ Iterable<ProcessStatusInterval> kernelStatuses = callStack.getKernelStatuses(nextFunction, -1);
+ for (ProcessStatusInterval status : kernelStatuses) {
+ aggregatedChild.addKernelStatus(status);
+ }
callgraph.addAggregatedCallSite(element, aggregatedChild);
nextFunction = (AbstractCalledFunction) callStack.getNextFunction(nextFunction.getEnd(), 1, null, model, start, end);
}
diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.ui/src/org/eclipse/tracecompass/incubator/internal/callstack/ui/views/flamechart/ProcessStatusEntry.java b/callstack/org.eclipse.tracecompass.incubator.callstack.ui/src/org/eclipse/tracecompass/incubator/internal/callstack/ui/views/flamechart/ProcessStatusEntry.java
index ae98fe3e..9b29b6ac 100644
--- a/callstack/org.eclipse.tracecompass.incubator.callstack.ui/src/org/eclipse/tracecompass/incubator/internal/callstack/ui/views/flamechart/ProcessStatusEntry.java
+++ b/callstack/org.eclipse.tracecompass.incubator.callstack.ui/src/org/eclipse/tracecompass/incubator/internal/callstack/ui/views/flamechart/ProcessStatusEntry.java
@@ -10,7 +10,6 @@
package org.eclipse.tracecompass.incubator.internal.callstack.ui.views.flamechart;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -77,9 +76,8 @@ public class ProcessStatusEntry extends TimeGraphEntry {
ICalledFunction function = fcEvent.getFunction();
// FIXME: This gets all the statuses, that can be big for large time ranges. Use
// a method with resolution when it is available
- Iterator<@NonNull ProcessStatusInterval> statuses = fCallStack.getKernelStatuses(function, resolution);
- while (statuses.hasNext()) {
- ProcessStatusInterval status = statuses.next();
+ Iterable<@NonNull ProcessStatusInterval> statuses = fCallStack.getKernelStatuses(function, resolution);
+ for (ProcessStatusInterval status : statuses) {
events.add(new TimeEvent(this, status.getStart(), status.getLength(), status.getProcessStatus().getStateValue().unboxInt()));
}
}
diff --git a/vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/overhead/VmOverheadStateProvider.java b/vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/overhead/VmOverheadStateProvider.java
index 17408372..b7de76da 100644
--- a/vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/overhead/VmOverheadStateProvider.java
+++ b/vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/overhead/VmOverheadStateProvider.java
@@ -323,9 +323,10 @@ public class VmOverheadStateProvider extends AbstractTmfStateProvider {
private void createGuestThreadStatus(ITmfStateSystemBuilder ss, HostThread ht, long start, int tidQuark) {
IHostModel model = ModelManager.getModelFor(ht.getHost());
- Iterator<ProcessStatusInterval> statuses = model.getThreadStatusIntervals(ht.getTid(), start, Long.MAX_VALUE, 1);
- if (statuses.hasNext()) {
- GuestKernelThreadStatuses threadStatus = new GuestKernelThreadStatuses(ss, start, statuses, tidQuark);
+ Iterable<ProcessStatusInterval> statuses = model.getThreadStatusIntervals(ht.getTid(), start, Long.MAX_VALUE, 1);
+ Iterator<ProcessStatusInterval> iterator = statuses.iterator();
+ if (iterator.hasNext()) {
+ GuestKernelThreadStatuses threadStatus = new GuestKernelThreadStatuses(ss, start, iterator, tidQuark);
fGuestThreads.put(ht, threadStatus);
}
}

Back to the top