jetbrains-rider/src-203-212/software/aws/toolkits/jetbrains/services/clouddebug/DotNetDebuggerSupport.kt [259:397]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - enableHeuristicPathResolve.set(true) remoteDebug.set(true) } workerModel.activeSession.set(sessionModel) val console = TextConsoleBuilderFactory.getInstance().createBuilder(environment.project).console val processHandler = object : ProcessHandler() { override fun detachProcessImpl() { destroyProcessImpl() } override fun detachIsDefault(): Boolean = false override fun getProcessInput(): OutputStream? = null override fun destroyProcessImpl() { notifyProcessTerminated(0) } fun notifyProcessDestroyed(exitCode: Int) { notifyProcessTerminated(exitCode) } } processHandler.addProcessListener( object : ProcessAdapter() { override fun processTerminated(event: ProcessEvent) { logger.trace { "Process exited. Terminating debugger lifetime" } runInEdt { debuggerLifetimeDefinition.terminate() } } } ) workerModel.targetExited.advise(debuggerLifetime) { logger.trace { "Target exited" } // We should try to kill deployment there because it's already stopped, // just notify debugger session about termination via its process handler. processHandler.notifyProcessDestroyed(it.exitCode ?: 0) } promise.setResult( DotNetDebuggerUtils.createAndStartSession( executionConsole = console, env = environment, sessionLifetime = debuggerLifetime, processHandler = processHandler, protocol = protocol, sessionModel = sessionModel, outputEventsListener = object : IDebuggerOutputListener {} ) ) return@initialized true } } catch (t: Throwable) { debuggerLifetimeDefinition.terminate() promise.setError(t) } return@connected true } val checkDebuggerTask = Timer("Debugger Worker launch timer", true).schedule(60_000L) { if (debuggerLifetimeDefinition.isAlive && !protocol.wire.connected.value) { debuggerLifetimeDefinition.terminate() promise.setError(message("lambda.debug.process.start.timeout")) } } debuggerLifetime.onTermination { checkDebuggerTask.cancel() } return promise } private fun prepareDebuggerArtifacts(targetPath: File, assemblyNames: Array) { val assemblyFileErrors = mutableListOf() for (assemblyName in assemblyNames) { val assemblyFile = try { // Look through DLL file val dllFileName = "$assemblyName.dll" RiderEnvironment.getBundledFile(dllFileName) } catch (e: FileNotFoundException) { // Look through EXE file val exeFileName = "$assemblyName.exe" try { RiderEnvironment.getBundledFile(exeFileName) } catch (e: FileNotFoundException) { null } } if (assemblyFile == null) { assemblyFileErrors.add(assemblyName) logger.trace { "Cannot find assembly with name: '$assemblyName'" } continue } FileUtil.copy(assemblyFile, File(targetPath, assemblyFile.name)) logger.trace { "Copy '${assemblyFile.canonicalPath}'" } // Check runtimeconfig.json val runtimeFileName = "$assemblyName.runtimeconfig.json" try { val runtimeFile = RiderEnvironment.getBundledFile(runtimeFileName) // overwrite runtimeconfig of Rider assemblies with own ones which target netcoreapp2.1 instead of 3.0 FileUtil.writeToFile(File(targetPath, runtimeFile.name), DotNetRuntimeUtils.RUNTIME_CONFIG_JSON_21, false) logger.trace { "Write '${runtimeFile.canonicalPath}'" } } catch (e: FileNotFoundException) { logger.trace { "Cannot find '$runtimeFileName'" } } // Check deps.json files val depsFileName = "$assemblyName.deps.json" try { val depsFile = RiderEnvironment.getBundledFile(depsFileName) FileUtil.copy(depsFile, File(targetPath, depsFile.name)) logger.trace { "Copy '${depsFile.canonicalPath}'" } } catch (e: FileNotFoundException) { logger.trace { "Cannot find '$depsFileName'" } } } if (assemblyFileErrors.isNotEmpty()) { throw IllegalStateException("Unable to find necessary assembly with names: '${assemblyFileErrors.joinToString(", ")}'") } val linuxSubdirectoryName = "linux-x64" val linuxMonoSubdirectory = File(targetPath, linuxSubdirectoryName) if (linuxMonoSubdirectory.isDirectory) { try { // remove existing linux Mono distribution since we run debugger on container .net core linuxMonoSubdirectory.deleteRecursively() } catch (e: Throwable) { logger.trace(e) { "Error while trying to delete unused linux Mono directory ${linuxMonoSubdirectory.absolutePath}" } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jetbrains-rider/src-213+/software/aws/toolkits/jetbrains/services/clouddebug/DotNetDebuggerSupport.kt [259:397]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - enableHeuristicPathResolve.set(true) remoteDebug.set(true) } workerModel.activeSession.set(sessionModel) val console = TextConsoleBuilderFactory.getInstance().createBuilder(environment.project).console val processHandler = object : ProcessHandler() { override fun detachProcessImpl() { destroyProcessImpl() } override fun detachIsDefault(): Boolean = false override fun getProcessInput(): OutputStream? = null override fun destroyProcessImpl() { notifyProcessTerminated(0) } fun notifyProcessDestroyed(exitCode: Int) { notifyProcessTerminated(exitCode) } } processHandler.addProcessListener( object : ProcessAdapter() { override fun processTerminated(event: ProcessEvent) { logger.trace { "Process exited. Terminating debugger lifetime" } runInEdt { debuggerLifetimeDefinition.terminate() } } } ) workerModel.targetExited.advise(debuggerLifetime) { logger.trace { "Target exited" } // We should try to kill deployment there because it's already stopped, // just notify debugger session about termination via its process handler. processHandler.notifyProcessDestroyed(it.exitCode ?: 0) } promise.setResult( DotNetDebuggerUtils.createAndStartSession( executionConsole = console, env = environment, sessionLifetime = debuggerLifetime, processHandler = processHandler, protocol = protocol, sessionModel = sessionModel, outputEventsListener = object : IDebuggerOutputListener {} ) ) return@initialized true } } catch (t: Throwable) { debuggerLifetimeDefinition.terminate() promise.setError(t) } return@connected true } val checkDebuggerTask = Timer("Debugger Worker launch timer", true).schedule(60_000L) { if (debuggerLifetimeDefinition.isAlive && !protocol.wire.connected.value) { debuggerLifetimeDefinition.terminate() promise.setError(message("lambda.debug.process.start.timeout")) } } debuggerLifetime.onTermination { checkDebuggerTask.cancel() } return promise } private fun prepareDebuggerArtifacts(targetPath: File, assemblyNames: Array) { val assemblyFileErrors = mutableListOf() for (assemblyName in assemblyNames) { val assemblyFile = try { // Look through DLL file val dllFileName = "$assemblyName.dll" RiderEnvironment.getBundledFile(dllFileName) } catch (e: FileNotFoundException) { // Look through EXE file val exeFileName = "$assemblyName.exe" try { RiderEnvironment.getBundledFile(exeFileName) } catch (e: FileNotFoundException) { null } } if (assemblyFile == null) { assemblyFileErrors.add(assemblyName) logger.trace { "Cannot find assembly with name: '$assemblyName'" } continue } FileUtil.copy(assemblyFile, File(targetPath, assemblyFile.name)) logger.trace { "Copy '${assemblyFile.canonicalPath}'" } // Check runtimeconfig.json val runtimeFileName = "$assemblyName.runtimeconfig.json" try { val runtimeFile = RiderEnvironment.getBundledFile(runtimeFileName) // overwrite runtimeconfig of Rider assemblies with own ones which target netcoreapp2.1 instead of 3.0 FileUtil.writeToFile(File(targetPath, runtimeFile.name), DotNetRuntimeUtils.RUNTIME_CONFIG_JSON_21, false) logger.trace { "Write '${runtimeFile.canonicalPath}'" } } catch (e: FileNotFoundException) { logger.trace { "Cannot find '$runtimeFileName'" } } // Check deps.json files val depsFileName = "$assemblyName.deps.json" try { val depsFile = RiderEnvironment.getBundledFile(depsFileName) FileUtil.copy(depsFile, File(targetPath, depsFile.name)) logger.trace { "Copy '${depsFile.canonicalPath}'" } } catch (e: FileNotFoundException) { logger.trace { "Cannot find '$depsFileName'" } } } if (assemblyFileErrors.isNotEmpty()) { throw IllegalStateException("Unable to find necessary assembly with names: '${assemblyFileErrors.joinToString(", ")}'") } val linuxSubdirectoryName = "linux-x64" val linuxMonoSubdirectory = File(targetPath, linuxSubdirectoryName) if (linuxMonoSubdirectory.isDirectory) { try { // remove existing linux Mono distribution since we run debugger on container .net core linuxMonoSubdirectory.deleteRecursively() } catch (e: Throwable) { logger.trace(e) { "Error while trying to delete unused linux Mono directory ${linuxMonoSubdirectory.absolutePath}" } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -