@@ -5,7 +5,9 @@ package software.aws.toolkits.jetbrains.services.lambda.dotnet
5
5
6
6
import com.intellij.execution.configurations.GeneralCommandLine
7
7
import com.intellij.execution.filters.TextConsoleBuilderFactory
8
+ import com.intellij.execution.process.CapturingProcessAdapter
8
9
import com.intellij.execution.process.OSProcessHandler
10
+ import com.intellij.execution.process.ProcessEvent
9
11
import com.intellij.execution.process.ProcessHandlerFactory
10
12
import com.intellij.execution.runners.ExecutionEnvironment
11
13
import com.intellij.openapi.rd.defineNestedLifetime
@@ -31,6 +33,7 @@ import kotlinx.coroutines.launch
31
33
import kotlinx.coroutines.runBlocking
32
34
import kotlinx.coroutines.withContext
33
35
import org.jetbrains.concurrency.AsyncPromise
36
+ import software.aws.toolkits.core.utils.debug
34
37
import software.aws.toolkits.core.utils.getLogger
35
38
import software.aws.toolkits.core.utils.warn
36
39
import software.aws.toolkits.jetbrains.core.coroutines.disposableCoroutineScope
@@ -52,6 +55,7 @@ object DotnetDebugUtils {
52
55
private const val DEBUGGER_MODE = " server"
53
56
54
57
private const val REMOTE_DEBUGGER_DIR = " /tmp/lambci_debug_files"
58
+ private const val REMOTE_NETCORE_CLI_PATH = " /var/lang/bin/dotnet"
55
59
const val NUMBER_OF_DEBUG_PORTS = 2
56
60
57
61
fun createDebugProcess (
@@ -93,6 +97,22 @@ object DotnetDebugUtils {
93
97
val dockerContainer = context.getRequiredAttribute(DOCKER_CONTAINER )
94
98
val pid = context.getRequiredAttribute(DOTNET_PID )
95
99
val riderDebuggerProcessHandler = startDebugWorker(dockerContainer, backendPort, frontendPort)
100
+ riderDebuggerProcessHandler.addProcessListener(object : CapturingProcessAdapter () {
101
+ override fun processTerminated (event : ProcessEvent ) {
102
+ super .processTerminated(event)
103
+ // if we don't get this message, we can assume the debugger terminated prematurely
104
+ // TODO: can we detect this without waiting for the timeout task to kick in?
105
+ LOG .debug {
106
+ """
107
+ Rider debugger worker exited with code: ${output.exitCode}
108
+ stdout: ${output.stdout}
109
+ stderr: ${output.stderr}
110
+ """ .trimIndent()
111
+ }
112
+ }
113
+ })
114
+
115
+ LOG .debug { " Waiting for debug process worker to be available" }
96
116
97
117
withContext(edtContext) {
98
118
protocol.wire.connected.adviseUntil(debuggerLifetime) connected@{ isConnected ->
@@ -176,12 +196,12 @@ object DotnetDebugUtils {
176
196
val runDebuggerCommand = GeneralCommandLine (
177
197
" docker" ,
178
198
" exec" ,
199
+ " --env" ,
200
+ " RIDER_DEBUGGER_LOG_DIR=/tmp/log" ,
179
201
" -i" ,
180
202
dockerContainer,
181
- // use dotnet binary bundled with worker since Lambda netcore2.1 image seems to be missing:
182
- // System.Runtime.CompilerServices.TupleElementNamesAttribute' from assembly 'mscorlib, Version=4.0.0.0
183
- // and therefore cannot debug netcore2.1 under Rider 2021.2+
184
- " $REMOTE_DEBUGGER_DIR /linux-x64/dotnet/dotnet" ,
203
+ // ideally we'd use the dotnet binary bundled with Rider, but linux-x64/dotnet is no longer guaranteed to exist in 2022.1.1+
204
+ REMOTE_NETCORE_CLI_PATH ,
185
205
" $REMOTE_DEBUGGER_DIR /${DotNetDebuggerUtils .debuggerAssemblyFile.name} " ,
186
206
" --mode=$DEBUGGER_MODE " ,
187
207
" --frontend-port=$frontendPort " ,
0 commit comments