Skip to content

Commit 1da7c20

Browse files
Fix the child process logging #1287 (#1318)
1 parent 5cc9800 commit 1da7c20

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ object UtSettings : AbstractSettings(
282282
*/
283283
var logConcreteExecutionErrors by getBooleanProperty(false)
284284

285+
286+
/**
287+
* Property useful only for idea
288+
* If true - runs engine process with the ability to attach a debugger
289+
* @see runChildProcessWithDebug
290+
* @see org.utbot.intellij.plugin.process.EngineProcess
291+
*/
292+
var runIdeaProcessWithDebug by getBooleanProperty(false)
293+
285294
/**
286295
* Number of branch instructions using for clustering executions in the test minimization phase.
287296
*/

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,5 @@ object Settings {
3030
*/
3131
const val runChildProcessWithDebug = false
3232

33-
/**
34-
* Property useful only for idea
35-
* If true - runs engine process with the ability to attach a debugger
36-
* @see runChildProcessWithDebug
37-
* @see org.utbot.intellij.plugin.process.EngineProcess
38-
*/
39-
const val runIdeaProcessWithDebug = false
40-
4133
var defaultConcreteExecutorPoolSize = 10
4234
}

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,22 @@ private fun ChildProcessModel.setup(kryoHelper: KryoHelper, synchronizer: CallsS
121121
synchronizer.measureExecutionForTermination(invokeMethodCommand) { params ->
122122
logger.debug { "received invokeMethod request: ${params.classname}, ${params.signature}" }
123123
val clazz = HandlerClassesLoader.loadClass(params.classname)
124-
val res = instrumentation.invoke(
125-
clazz,
126-
params.signature,
127-
kryoHelper.readObject(params.arguments),
128-
kryoHelper.readObject(params.parameters)
129-
)
130-
131-
logger.debug { "invokeMethod result: $res" }
132-
InvokeMethodCommandResult(kryoHelper.writeObject(res))
124+
val res = kotlin.runCatching {
125+
instrumentation.invoke(
126+
clazz,
127+
params.signature,
128+
kryoHelper.readObject(params.arguments),
129+
kryoHelper.readObject(params.parameters)
130+
)
131+
}
132+
res.fold({
133+
logger.debug { "invokeMethod success" }
134+
InvokeMethodCommandResult(kryoHelper.writeObject(it))
135+
}) {
136+
logger.debug { "invokeMethod failure" }
137+
logger.error(it)
138+
throw it
139+
}
133140
}
134141
synchronizer.measureExecutionForTermination(setInstrumentation) { params ->
135142
logger.debug { "setInstrumentation request" }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import kotlinx.coroutines.sync.withLock
1717
import mu.KotlinLogging
1818
import org.utbot.common.*
1919
import org.utbot.framework.UtSettings
20+
import org.utbot.framework.UtSettings.runIdeaProcessWithDebug
2021
import org.utbot.framework.codegen.*
2122
import org.utbot.framework.codegen.model.UtilClassKind
2223
import org.utbot.framework.plugin.api.*
@@ -29,7 +30,6 @@ import org.utbot.framework.process.generated.*
2930
import org.utbot.framework.process.generated.Signature
3031
import org.utbot.framework.util.Conflict
3132
import org.utbot.framework.util.ConflictTriggers
32-
import org.utbot.instrumentation.Settings
3333
import org.utbot.instrumentation.util.KryoHelper
3434
import org.utbot.intellij.plugin.models.GenerateTestsModel
3535
import org.utbot.intellij.plugin.ui.TestReportUrlOpeningListener
@@ -96,7 +96,7 @@ class EngineProcess(parent: Lifetime, val project: Project) {
9696
}
9797

9898
private fun debugArgument(): String {
99-
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf { Settings.runIdeaProcessWithDebug }
99+
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf { runIdeaProcessWithDebug }
100100
?: ""
101101
}
102102

0 commit comments

Comments
 (0)