in trace-recorder/src/main/org/jetbrains/lincheck/trace/recorder/TraceCollectingEventTracker.kt [765:799]
override fun onLoopIteration(
threadDescriptor: ThreadDescriptor,
codeLocation: Int,
loopId: Int
) = threadDescriptor.runInsideInjectedCode {
val threadData = threadDescriptor.eventTrackerData as? ThreadData? ?: return
// create a new loop if required
if (loopId != threadData.currentLoopTracePoint()?.loopId) {
val tracePoint = TRLoopTracePoint(
context = context,
threadId = threadData.threadId,
codeLocationId = codeLocation,
loopId = loopId,
)
strategy.tracePointCreated(threadData.currentTopTracePoint(), tracePoint)
threadData.enterLoop(tracePoint)
}
val currentLoopTracePoint = threadData.currentLoopTracePoint()!!
// complete previous iteration, if any
threadData.currentLoopIterationTracePoint()?.also { previousIteration ->
strategy.completeContainerTracePoint(Thread.currentThread(), previousIteration)
}
val tracePoint = TRLoopIterationTracePoint(
context = context,
threadId = threadData.threadId,
codeLocationId = codeLocation,
loopId = loopId,
loopIteration = currentLoopTracePoint.iterations,
)
strategy.tracePointCreated(currentLoopTracePoint, tracePoint)
threadData.addLoopIteration(tracePoint)
}