From d2494267b74b9d6fd746e8619410273742522bba Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Thu, 23 May 2024 09:23:05 -0400 Subject: [PATCH] Fix compilation error after Trace Compass API clean-up See https://github.com/eclipse-tracecompass/org.eclipse.tracecompass/issues/87 Note: XAF was broken before due incompatible changes in mainline TC. This commit, just makes it compile again, but it's still broken. Signed-off-by: Bernd Hufmann --- .../IOQueueStatisticsAnalysis.java | 2 +- .../core/pthread/PThreadLockGraphHandler.java | 45 +++++++++++-------- .../StateMachineVariableAnalysis.java | 25 +++++++---- .../variable/utils/CriticalPathState.java | 2 +- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/analyses/org.eclipse.tracecompass.incubator.kernel.core/src/org/eclipse/tracecompass/incubator/internal/kernel/core/inputoutput/IOQueueStatisticsAnalysis.java b/analyses/org.eclipse.tracecompass.incubator.kernel.core/src/org/eclipse/tracecompass/incubator/internal/kernel/core/inputoutput/IOQueueStatisticsAnalysis.java index ea4547c1e..ab4058b79 100644 --- a/analyses/org.eclipse.tracecompass.incubator.kernel.core/src/org/eclipse/tracecompass/incubator/internal/kernel/core/inputoutput/IOQueueStatisticsAnalysis.java +++ b/analyses/org.eclipse.tracecompass.incubator.kernel.core/src/org/eclipse/tracecompass/incubator/internal/kernel/core/inputoutput/IOQueueStatisticsAnalysis.java @@ -52,7 +52,7 @@ protected boolean executeAnalysis(@NonNull IProgressMonitor monitor) throws TmfA } @Override - protected @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(@NonNull ITmfTrace trace) { + protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) { return fSegmentStoreProvider; } diff --git a/analyses/org.eclipse.tracecompass.incubator.lttng2.ust.extras.core/src/org/eclipse/tracecompass/incubator/internal/lttng2/ust/extras/core/pthread/PThreadLockGraphHandler.java b/analyses/org.eclipse.tracecompass.incubator.lttng2.ust.extras.core/src/org/eclipse/tracecompass/incubator/internal/lttng2/ust/extras/core/pthread/PThreadLockGraphHandler.java index 3ff2cea22..32d84fc1c 100644 --- a/analyses/org.eclipse.tracecompass.incubator.lttng2.ust.extras.core/src/org/eclipse/tracecompass/incubator/internal/lttng2/ust/extras/core/pthread/PThreadLockGraphHandler.java +++ b/analyses/org.eclipse.tracecompass.incubator.lttng2.ust.extras.core/src/org/eclipse/tracecompass/incubator/internal/lttng2/ust/extras/core/pthread/PThreadLockGraphHandler.java @@ -17,17 +17,18 @@ import java.util.regex.Pattern; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge.EdgeType; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex; import org.eclipse.tracecompass.analysis.graph.core.building.AbstractTraceEventHandler; import org.eclipse.tracecompass.analysis.graph.core.building.ITraceEventHandler; +import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfGraph; +import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfVertex; import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.IOsExecutionGraphHandlerBuilder; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsExecutionGraphProvider; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker; import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread; import org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus; +import org.eclipse.tracecompass.internal.analysis.graph.core.graph.legacy.OSEdgeContextState; +import org.eclipse.tracecompass.internal.analysis.graph.core.graph.legacy.OSEdgeContextState.OSEdgeContextEnum; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; @@ -49,7 +50,7 @@ public class PThreadLockGraphHandler extends AbstractTraceEventHandler { private static class LastLockOwner { public final Integer fTid; - public final TmfVertex fVertex; + public final ITmfVertex fVertex; /** * @param tid @@ -57,7 +58,7 @@ private static class LastLockOwner { * @param vertex * The vertex at which the lock was removed by the worker */ - public LastLockOwner(Integer tid, TmfVertex vertex) { + public LastLockOwner(Integer tid, ITmfVertex vertex) { fTid = tid; fVertex = vertex; } @@ -65,7 +66,7 @@ public LastLockOwner(Integer tid, TmfVertex vertex) { private final OsExecutionGraphProvider fProvider; /** tid, mutex ID, vertex of the last lock request */ - private final Table fLastRequest; + private final Table fLastRequest; /** mutex ID, last lock owner */ private final Map fLastLockOwner = new HashMap<>(); @@ -97,13 +98,13 @@ public ITraceEventHandler createHandler(@NonNull OsExecutionGraphProvider provid private OsWorker getOrCreateKernelWorker(ITmfEvent event, Integer tid) { HostThread ht = new HostThread(event.getTrace().getHostId(), tid); - OsWorker worker = fProvider.getSystem().findWorker(ht); + OsWorker worker = fProvider.getSystem().findWorker(ht, null); if (worker != null) { return worker; } worker = new OsWorker(ht, "kernel/" + tid, event.getTimestamp().getValue()); //$NON-NLS-1$ worker.setStatus(ProcessStatus.RUN); - fProvider.getSystem().addWorker(worker); + fProvider.getSystem().addWorker(worker, null); return worker; } @@ -131,23 +132,26 @@ private void handleAcquireLockEvent(ITmfEvent event) { OsWorker worker = getOrCreateKernelWorker(event, tid); // Get the vertex for the last request - TmfVertex lastReqVertex = fLastRequest.get(tid, fieldValue); + ITmfVertex lastReqVertex = fLastRequest.get(tid, fieldValue); if (lastReqVertex == null) { return; } // Get the last lock owner LastLockOwner lastOwner = fLastLockOwner.get(fieldValue); - if (lastOwner != null && lastOwner.fTid != tid && lastOwner.fVertex.getTs() > lastReqVertex.getTs()) { + if (lastOwner != null && lastOwner.fTid != tid && lastOwner.fVertex.getTimestamp() > lastReqVertex.getTimestamp()) { // This thread has been blocked, add the proper vertices and links - TmfGraph graph = Objects.requireNonNull(fProvider.getAssignedGraph()); + ITmfGraph graph = Objects.requireNonNull(fProvider.getGraph()); + // First add a vertex at the time of lock request - graph.append(worker, lastReqVertex, EdgeType.RUNNING); + graph.append(lastReqVertex, new OSEdgeContextState(OSEdgeContextEnum.RUNNING)); // Then add the blocked transition for the current worker - TmfVertex unblockVertex = new TmfVertex(event.getTimestamp().toNanos()); - graph.append(worker, unblockVertex, EdgeType.BLOCKED); + ITmfVertex unblockVertex = graph.createVertex(worker, event.getTimestamp().toNanos()); + graph.append(unblockVertex, new OSEdgeContextState(OSEdgeContextEnum.BLOCKED)); // And add the vertical link between the unlock and the acquisition - lastOwner.fVertex.linkVertical(unblockVertex); + // TODO: check if it's the correct replacement +// lastOwner.fVertex.linkVertical(unblockVertex); + graph.edgeVertical(lastOwner.fVertex, unblockVertex, new OSEdgeContextState(OSEdgeContextEnum.DEFAULT), MUTEX_FIELD); } } @@ -161,8 +165,11 @@ private void handleRequestLockEvent(ITmfEvent event) { return; } + ITmfGraph graph = Objects.requireNonNull(fProvider.getGraph()); + OsWorker worker = getOrCreateKernelWorker(event, tid); + // Don't add a state change to the worker just yet, let's keep the previous state until we know it's being blocked - TmfVertex vertex = new TmfVertex(event.getTimestamp().toNanos()); + ITmfVertex vertex = graph.createVertex(worker, event.getTimestamp().toNanos()); //TmfVertex stateChange = stateChange(worker, event.getTimestamp().toNanos(), EdgeType.RUNNING); fLastRequest.put(tid, fieldValue, vertex); } @@ -179,9 +186,9 @@ private void handleUnlockEvent(ITmfEvent event) { OsWorker worker = getOrCreateKernelWorker(event, tid); // Set the previous state to running for the worker and add a vertex at this // event, so it can be used by any thread that was blocked - TmfGraph graph = Objects.requireNonNull(fProvider.getAssignedGraph()); - TmfVertex vertex = new TmfVertex(event.getTimestamp().toNanos()); - graph.append(worker, vertex, EdgeType.RUNNING); + ITmfGraph graph = Objects.requireNonNull(fProvider.getGraph()); + ITmfVertex vertex = graph.createVertex(worker, event.getTimestamp().toNanos()); + graph.append(vertex, new OSEdgeContextState(OSEdgeContextEnum.RUNNING)); fLastLockOwner.put(fieldValue, new LastLockOwner(tid, vertex)); } diff --git a/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/StateMachineVariableAnalysis.java b/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/StateMachineVariableAnalysis.java index 9243b1422..f3899899b 100644 --- a/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/StateMachineVariableAnalysis.java +++ b/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/StateMachineVariableAnalysis.java @@ -31,10 +31,10 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex; import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathAlgorithmException; +import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfGraph; +import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfGraphVisitor; +import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfVertex; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsExecutionGraph; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker; import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule; @@ -69,8 +69,9 @@ import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineReport; import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineSegment; import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineUtils.TimestampInterval; +import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfEdge; import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraphVisitor; -import org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath.CriticalPathAlgorithmBounded; +import org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath.OSCriticalPathAlgorithm; import org.eclipse.tracecompass.internal.segmentstore.core.treemap.TreeMapStore; import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; @@ -1284,7 +1285,7 @@ private List getCriticalPathSteps(InstanceStepInformation g.waitForCompletion(); // Get the general graph for the trace - TmfGraph graph = g.getGraph(); + ITmfGraph graph = g.getCriticalPathGraph(); if (graph == null) { Activator.getInstance().logWarning("graph == null"); //$NON-NLS-1$ continue; @@ -1310,12 +1311,18 @@ private List getCriticalPathSteps(InstanceStepInformation workerFound = true; // Compute the path for the period we're interested into - TmfVertex vstart = graph.getVertexAt(Objects.requireNonNull(ti.getStartTime()), lw); - TmfVertex vend = graph.getVertexAt(Objects.requireNonNull(ti.getEndTime()), lw); - TmfGraph path = new CriticalPathAlgorithmBounded(graph).compute(Objects.requireNonNull(vstart), Objects.requireNonNull(vend)); + ITmfVertex vstart = graph.getVertexAt(Objects.requireNonNull(ti.getStartTime()), lw); + ITmfVertex vend = graph.getVertexAt(Objects.requireNonNull(ti.getEndTime()), lw); + + // Note: compute() method was removed because it was deprecated. More over when it was deprecated the method implementation + // was changed to throw an UnsupportedOperationException(). + // See https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/182723 + // So, the implementation was broken and this change just makes it compile + + ITmfGraph path = new OSCriticalPathAlgorithm(graph).computeCriticalPath(graph, Objects.requireNonNull(vstart), Objects.requireNonNull(vend)); // Then traverse that path to get the data for what happened in there - path.scanLineTraverse(path.getHead(lw), new TmfGraphVisitor() { + path.scanLineTraverse(path.getHead(lw), (ITmfGraphVisitor) new TmfGraphVisitor() { @Override public void visit(TmfEdge link, boolean horizontal) { if (!horizontal) { diff --git a/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/utils/CriticalPathState.java b/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/utils/CriticalPathState.java index fa3b6f0a8..aebe6315f 100644 --- a/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/utils/CriticalPathState.java +++ b/analyses/org.eclipse.tracecompass.incubator.xaf.ui/src/org/eclipse/tracecompass/incubator/internal/xaf/core/statemachine/variable/utils/CriticalPathState.java @@ -13,8 +13,8 @@ import java.util.Objects; -import org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge; import org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker; +import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfEdge; /** * Element representing a Critical Path state