Skip to content

Commit f3e6f7e

Browse files
Pass whether Lincheck is in the trace debugger mode to the plugin (#562)
1 parent e9fec76 commit f3e6f7e

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/jvm/main/org/jetbrains/kotlinx/lincheck/IdeaPlugin.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import sun.nio.ch.lincheck.*
1515
import org.jetbrains.kotlinx.lincheck.runner.*
1616
import org.jetbrains.kotlinx.lincheck.strategy.*
1717
import org.jetbrains.kotlinx.lincheck.strategy.managed.*
18+
import org.jetbrains.kotlinx.lincheck.strategy.managed.ExecutionMode.GENERAL_PURPOSE_MODEL_CHECKER
1819
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
1920
import org.jetbrains.kotlinx.lincheck.execution.ExecutionResult
2021
import org.jetbrains.kotlinx.lincheck.execution.ExecutionScenario
@@ -39,7 +40,7 @@ const val MINIMAL_PLUGIN_VERSION = "0.11"
3940
* @param version current Lincheck version.
4041
* @param minimalPluginVersion minimal compatible plugin version.
4142
* @param exceptions representation of the exceptions with their stacktrace occurred during the execution.
42-
* @param isGeneralPurposeModelChecking indicates if lincheck is running in the GPMC mode
43+
* @param executionMode indicates the mode in which lincheck is running current test (see [ManagedStrategy.executionMode])
4344
*/
4445
@Suppress("UNUSED_PARAMETER")
4546
fun testFailed(
@@ -48,7 +49,7 @@ fun testFailed(
4849
version: String?,
4950
minimalPluginVersion: String,
5051
exceptions: Array<String>,
51-
isGeneralPurposeModelChecking: Boolean,
52+
executionMode: String
5253
) {}
5354

5455

@@ -159,7 +160,7 @@ internal fun ManagedStrategy.runReplayIfPluginEnabled(failure: LincheckFailure)
159160
version = lincheckVersion,
160161
minimalPluginVersion = MINIMAL_PLUGIN_VERSION,
161162
exceptions = exceptionsRepresentation,
162-
isGeneralPurposeModelChecking = isGeneralPurposeModelChecking,
163+
executionMode = executionMode.id
163164
)
164165
// Replay execution while it's needed.
165166
do {
@@ -348,7 +349,7 @@ private data class ExceptionProcessingResult(
348349
* Used to collect the data about the test instance, object numbers, threads, and continuations.
349350
*/
350351
private fun visualize(strategy: ManagedStrategy) = runCatching {
351-
if (strategy.isGeneralPurposeModelChecking) return@runCatching
352+
if (strategy.executionMode == GENERAL_PURPOSE_MODEL_CHECKER) return@runCatching
352353

353354
val runner = strategy.runner as ParallelThreadsRunner
354355
val allThreads = strategy.getRegisteredThreads()

src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/ManagedStrategy.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ abstract class ManagedStrategy(
5252
private val testCfg: ManagedCTestConfiguration,
5353
) : Strategy(scenario), EventTracker {
5454

55-
val isGeneralPurposeModelChecking = testClass == GeneralPurposeModelCheckingWrapper::class.java
55+
val executionMode: ExecutionMode =
56+
when {
57+
testClass == GeneralPurposeModelCheckingWrapper::class.java -> ExecutionMode.GENERAL_PURPOSE_MODEL_CHECKER
58+
isInTraceDebuggerMode -> ExecutionMode.TRACE_DEBUGGER
59+
else -> ExecutionMode.DATA_STRUCTURES
60+
}
5661

5762
// The flag to enable IntelliJ IDEA plugin mode
5863
var inIdeaPluginReplayMode: Boolean = false
@@ -2082,6 +2087,17 @@ private val BlockingReason.obstructionFreedomViolationMessage: String get() = wh
20822087
is BlockingReason.Suspended -> OBSTRUCTION_FREEDOM_SUSPEND_VIOLATION_MESSAGE
20832088
}
20842089

2090+
/**
2091+
* @param id specifies the string literal that will be parsed on the plugin side,
2092+
* thus, it should never be changed unconsciously. The plugin will use this values
2093+
* to determine what kind of UI to show to the user.
2094+
*/
2095+
enum class ExecutionMode(val id: String) {
2096+
DATA_STRUCTURES("DATA_STRUCTURES"),
2097+
GENERAL_PURPOSE_MODEL_CHECKER("GENERAL_PURPOSE_MODEL_CHECKER"),
2098+
TRACE_DEBUGGER("TRACE_DEBUGGER")
2099+
}
2100+
20852101
private const val OBSTRUCTION_FREEDOM_SPINLOCK_VIOLATION_MESSAGE =
20862102
"The algorithm should be non-blocking, but an active lock is detected"
20872103

0 commit comments

Comments
 (0)