Skip to content

Commit d1c8986

Browse files
authored
Fix debugger failure in Rider 2022.1.1 (#3156)
1 parent 2487f75 commit d1c8986

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix .NET Lambda debugging regression in 2022.1.1"
4+
}

jetbrains-rider/src-213+/software/aws/toolkits/jetbrains/services/lambda/dotnet/DotnetDebugUtils.kt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ package software.aws.toolkits.jetbrains.services.lambda.dotnet
55

66
import com.intellij.execution.configurations.GeneralCommandLine
77
import com.intellij.execution.filters.TextConsoleBuilderFactory
8+
import com.intellij.execution.process.CapturingProcessAdapter
89
import com.intellij.execution.process.OSProcessHandler
10+
import com.intellij.execution.process.ProcessEvent
911
import com.intellij.execution.process.ProcessHandlerFactory
1012
import com.intellij.execution.runners.ExecutionEnvironment
1113
import com.intellij.openapi.rd.defineNestedLifetime
@@ -31,6 +33,7 @@ import kotlinx.coroutines.launch
3133
import kotlinx.coroutines.runBlocking
3234
import kotlinx.coroutines.withContext
3335
import org.jetbrains.concurrency.AsyncPromise
36+
import software.aws.toolkits.core.utils.debug
3437
import software.aws.toolkits.core.utils.getLogger
3538
import software.aws.toolkits.core.utils.warn
3639
import software.aws.toolkits.jetbrains.core.coroutines.disposableCoroutineScope
@@ -52,6 +55,7 @@ object DotnetDebugUtils {
5255
private const val DEBUGGER_MODE = "server"
5356

5457
private const val REMOTE_DEBUGGER_DIR = "/tmp/lambci_debug_files"
58+
private const val REMOTE_NETCORE_CLI_PATH = "/var/lang/bin/dotnet"
5559
const val NUMBER_OF_DEBUG_PORTS = 2
5660

5761
fun createDebugProcess(
@@ -93,6 +97,22 @@ object DotnetDebugUtils {
9397
val dockerContainer = context.getRequiredAttribute(DOCKER_CONTAINER)
9498
val pid = context.getRequiredAttribute(DOTNET_PID)
9599
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" }
96116

97117
withContext(edtContext) {
98118
protocol.wire.connected.adviseUntil(debuggerLifetime) connected@{ isConnected ->
@@ -176,12 +196,12 @@ object DotnetDebugUtils {
176196
val runDebuggerCommand = GeneralCommandLine(
177197
"docker",
178198
"exec",
199+
"--env",
200+
"RIDER_DEBUGGER_LOG_DIR=/tmp/log",
179201
"-i",
180202
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,
185205
"$REMOTE_DEBUGGER_DIR/${DotNetDebuggerUtils.debuggerAssemblyFile.name}",
186206
"--mode=$DEBUGGER_MODE",
187207
"--frontend-port=$frontendPort",

0 commit comments

Comments
 (0)