Skip to content

Commit b79d242

Browse files
committed
[rd-factoring]
review fix
1 parent 407a1ff commit b79d242

File tree

11 files changed

+30
-25
lines changed

11 files changed

+30
-25
lines changed

docs/contributing/InterProcessDebugging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For engine and instrumented processes you need to enable some options:
3232
4. Additionally, you can set additional options for JDWP agent if debug is enabled:
3333
* `engineProcessDebugPort` and `instrumentedProcessDebugPort` - port for debugging.
3434
Default values - 5005 for Engine and 5006 for Instrumented processes.
35-
* `engineProcessDebugSuspendPolicy` and `instrumentedProcessSuspendPolicy` - whether JDWP agent should
35+
* `suspendEngineProcessExecutionInDebugMode` and `suspendInstrumentedProcessExecutionInDebugMode` - whether JDWP agent should
3636
suspend process until debugger is connected.
3737

3838
More formally, if debug is enabled following switch is added to engine process JVM at start by default:
@@ -44,7 +44,7 @@ For engine and instrumented processes you need to enable some options:
4444
```
4545
runEngineProcessWithDebug=true
4646
engineProcessDebugPort=12345
47-
engineProcessDebugSuspendPolicy=false
47+
suspendEngineProcessExecutionInDebugMode=false
4848
```
4949
result switch will be:
5050
```

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,35 +274,39 @@ object UtSettings : AbstractSettings(
274274
var engineProcessLogConfigFile by getStringProperty("")
275275

276276
/**
277-
* Property useful only for idea
278-
* If true - runs engine process with the ability to attach a debugger
277+
* The property is useful only for the IntelliJ IDEs.
278+
* If the property is set in true the engine process opens a debug port.
279279
* @see runInstrumentedProcessWithDebug
280280
* @see org.utbot.intellij.plugin.process.EngineProcess
281281
*/
282282
var runEngineProcessWithDebug by getBooleanProperty(false)
283283

284284
/**
285-
* Port which will be used for debugging engine process
285+
* The engine process JDWP agent's port of the instrumented process.
286+
* A debugger attaches to the port in order to debug the process.
286287
*/
287288
var engineProcessDebugPort by getIntProperty(5005)
288289

289290
/**
290-
* Whether engine process should suspend until debugger attached
291+
* Value of the suspend mode for the JDWP agent of the engine process.
292+
* If the value is true, the engine process will suspend until a debugger attaches to it.
291293
*/
292-
var engineProcessDebugSuspendPolicy by getBooleanProperty(true)
294+
var suspendEngineProcessExecutionInDebugMode by getBooleanProperty(true)
293295

294296
// endregion
295297

296298
// region instrumented process debug
297299
/**
298-
* Port which will be used for debugging instrumented process
300+
* The instrumented process JDWP agent's port of the instrumented process.
301+
* A debugger attaches to the port in order to debug the process.
299302
*/
300303
var instrumentedProcessDebugPort by getIntProperty(5006)
301304

302305
/**
303-
* Whether instrumented process should suspend until debugger attached
306+
* Value of the suspend mode for the JDWP agent of the instrumented process.
307+
* If the value is true, the instrumented process will suspend until a debugger attaches to it.
304308
*/
305-
var instrumentedProcessSuspendPolicy by getBooleanProperty(true)
309+
var suspendInstrumentedProcessExecutionInDebugMode by getBooleanProperty(true)
306310

307311
/**
308312
* If true, runs the instrumented process with the ability to attach a debugger.

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/ConcreteExecutor.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class ConcreteExecutor<TIResult, TInstrumentation : Instrumentation<TIResult>> p
242242
val parametersByteArray = kryoHelper.writeObject(parameters)
243243
val params = InvokeMethodCommandParams(className, signature, argumentsByteArray, parametersByteArray)
244244

245-
val ba = chidlProcessModel.invokeMethodCommand.startSuspending(lifetime, params).result
245+
val ba = instrumentedProcessModel.invokeMethodCommand.startSuspending(lifetime, params).result
246246
kryoHelper.readObject(ba)
247247
}
248248
} catch (e: Throwable) {
@@ -282,7 +282,7 @@ class ConcreteExecutor<TIResult, TInstrumentation : Instrumentation<TIResult>> p
282282
if (alive) {
283283
try {
284284
processInstance?.run {
285-
chidlProcessModel.stopProcess.start(lifetime, Unit)
285+
instrumentedProcessModel.stopProcess.start(lifetime, Unit)
286286
}
287287
} catch (_: Exception) {}
288288
processInstance = null
@@ -296,7 +296,7 @@ class ConcreteExecutor<TIResult, TInstrumentation : Instrumentation<TIResult>> p
296296

297297
fun ConcreteExecutor<*,*>.warmup() = runBlocking {
298298
withProcess {
299-
chidlProcessModel.warmup.start(lifetime, Unit)
299+
instrumentedProcessModel.warmup.start(lifetime, Unit)
300300
}
301301
}
302302

@@ -308,7 +308,7 @@ fun <T> ConcreteExecutor<*, *>.computeStaticField(fieldId: FieldId): Result<T> =
308308
val fieldIdSerialized = kryoHelper.writeObject(fieldId)
309309
val params = ComputeStaticFieldParams(fieldIdSerialized)
310310

311-
val result = chidlProcessModel.computeStaticField.startSuspending(lifetime, params)
311+
val result = instrumentedProcessModel.computeStaticField.startSuspending(lifetime, params)
312312

313313
kryoHelper.readObject(result.result)
314314
}

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/coverage/CoverageInstrumentation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ fun ConcreteExecutor<Result<*>, CoverageInstrumentation>.collectCoverage(clazz:
103103
withProcess {
104104
val clazzByteArray = kryoHelper.writeObject(clazz)
105105

106-
kryoHelper.readObject(chidlProcessModel.collectCoverage.startSuspending(lifetime, CollectCoverageParams(clazzByteArray)).coverageInfo)
106+
kryoHelper.readObject(instrumentedProcessModel.collectCoverage.startSuspending(lifetime, CollectCoverageParams(clazzByteArray)).coverageInfo)
107107
}
108108
}

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/InstrumentedProcessRunner.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class InstrumentedProcessRunner {
5959
}
6060

6161
companion object {
62-
private fun suspendValue(): String = if (UtSettings.engineProcessDebugSuspendPolicy) "y" else "n"
62+
private fun suspendValue(): String = if (UtSettings.suspendInstrumentedProcessExecutionInDebugMode) "y" else "n"
6363

6464
private const val UTBOT_INSTRUMENTATION = "utbot-instrumentation"
6565
private const val ERRORS_FILE_PREFIX = "utbot-instrumentedprocess-errors"

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/rd/InstrumentedProcess.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class InstrumentedProcess private constructor(
3232
val kryoHelper = KryoHelper(lifetime.createNested()).apply {
3333
classLoader?.let { setKryoClassLoader(it) }
3434
}
35-
val chidlProcessModel: InstrumentedProcessModel = onSchedulerBlocking { protocol.instrumentedProcessModel }
35+
val instrumentedProcessModel: InstrumentedProcessModel = onSchedulerBlocking { protocol.instrumentedProcessModel }
3636

3737
companion object {
3838
suspend operator fun <TIResult, TInstrumentation : Instrumentation<TIResult>> invoke(
@@ -65,15 +65,15 @@ class InstrumentedProcess private constructor(
6565
}
6666

6767
logger.trace("sending add paths")
68-
proc.chidlProcessModel.addPaths.startSuspending(
68+
proc.instrumentedProcessModel.addPaths.startSuspending(
6969
proc.lifetime, AddPathsParams(
7070
pathsToUserClasses,
7171
pathsToDependencyClasses
7272
)
7373
)
7474

7575
logger.trace("sending instrumentation")
76-
proc.chidlProcessModel.setInstrumentation.startSuspending(
76+
proc.instrumentedProcessModel.setInstrumentation.startSuspending(
7777
proc.lifetime, SetInstrumentationParams(
7878
proc.kryoHelper.writeObject(instrumentation)
7979
)

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class EngineProcess private constructor(val project: Project, rdProcess: Process
9090

9191
private val log4j2ConfigSwitch = "-Dlog4j2.configurationFile=${log4j2ConfigFile.canonicalPath}"
9292

93-
private fun suspendValue(): String = if (UtSettings.engineProcessDebugSuspendPolicy) "y" else "n"
93+
private fun suspendValue(): String = if (UtSettings.suspendEngineProcessExecutionInDebugMode) "y" else "n"
9494

9595
private val debugArgument: String?
9696
get() = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspendValue()},quiet=y,address=${UtSettings.engineProcessDebugPort}"

utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal fun childCreatedFileName(port: Int): String {
3030
return "$port.created"
3131
}
3232

33-
internal fun signalInstrumentedReady(port: Int) {
33+
internal fun signalProcessReady(port: Int) {
3434
processSyncDirectory.mkdirs()
3535

3636
val signalFile = File(processSyncDirectory, childCreatedFileName(port))
@@ -161,7 +161,7 @@ class ClientProtocolBuilder {
161161
clientProtocol.block(synchronizer)
162162
}
163163

164-
signalInstrumentedReady(port)
164+
signalProcessReady(port)
165165
logger.info { "signalled" }
166166
clientProtocol.synchronizationModel.synchronizationSignal.let { sync ->
167167
val answerFromMainProcess = sync.adviseForConditionAsync(ldef) {

utbot-rd/src/main/kotlin/org/utbot/rd/LifetimedProcess.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.jetbrains.rd.util.lifetime.Lifetime
44
import com.jetbrains.rd.util.lifetime.LifetimeDefinition
55
import com.jetbrains.rd.util.lifetime.throwIfNotAlive
66
import kotlinx.coroutines.delay
7+
import java.util.concurrent.ConcurrentSkipListSet
78
import java.util.concurrent.TimeUnit
89
import kotlin.concurrent.thread
910

@@ -90,7 +91,7 @@ class LifetimedProcessIml(override val process: Process, lifetime: Lifetime? = n
9091
}
9192

9293
companion object {
93-
private val allProcessList = mutableListOf<LifetimedProcess>()
94+
private val allProcessList = ConcurrentSkipListSet<LifetimedProcess>()
9495

9596
init {
9697
Runtime.getRuntime().addShutdownHook(thread(start = false) {

utbot-rd/src/main/kotlin/org/utbot/rd/RdSettingsContainer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class RdSettingsContainer(val logger: KLogger, val key: String, val settingsMode
3535
}
3636

3737
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
38-
throw NotImplementedError("Setting properties allowed only from plugin process")
38+
throw IllegalStateException("Setting properties allowed only from plugin process")
3939
}
4040
}
4141
}

utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class UtRdCoroutineScope(lifetime: Lifetime) : RdCoroutineScope(lifetime) {
1111
companion object {
1212
val current = UtRdCoroutineScope(Lifetime.Eternal)
1313
fun initialize() {
14-
// only to initialize load and initialize class
14+
// only to load and initialize class
1515
}
1616
}
1717

0 commit comments

Comments
 (0)