(response: DebugProtocol.LaunchResponse, args: DartLaunchArgs & DebugProtocol.LaunchRequestArguments)
| 109 | } |
| 110 | |
| 111 | protected async launchRequest(response: DebugProtocol.LaunchResponse, args: DartLaunchArgs & DebugProtocol.LaunchRequestArguments): Promise<void> { |
| 112 | if (!args || !args.dartSdkPath || (this.requiresProgram && !args.program)) { |
| 113 | this.logToUser("Unable to restart debugging. Please try ending the debug session and starting again.\n"); |
| 114 | this.sendEvent(new TerminatedEvent()); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | // Force relative paths to absolute. |
| 119 | if (args.program && !path.isAbsolute(args.program)) { |
| 120 | if (!args.cwd) { |
| 121 | return this.errorResponse(response, "Unable to start debugging. program was specified as a relative path without cwd."); |
| 122 | } |
| 123 | args.program = path.join(args.cwd, args.program); |
| 124 | } |
| 125 | |
| 126 | this.startProgress(debugLaunchProgressId, "Launching"); |
| 127 | |
| 128 | this.cwd = args.cwd; |
| 129 | this.noDebug = args.noDebug; |
| 130 | // Set default exception mode based on noDebug. This will be sent to threads |
| 131 | // prior to VS Code sending (or, in the case of noDebug, due to not sending) |
| 132 | // the exception mode. |
| 133 | await this.threadManager.setExceptionPauseMode(this.noDebug ? "None" : "Unhandled"); |
| 134 | this.packageMap = PackageMap.load(this.logger, PackageMap.findPackagesFile(args.program || args.cwd)); |
| 135 | this.readSharedArgs(args); |
| 136 | |
| 137 | this.sendResponse(response); |
| 138 | |
| 139 | try { |
| 140 | const process = await this.spawnProcess(args); |
| 141 | |
| 142 | this.childProcess = process; |
| 143 | this.processExited = false; |
| 144 | this.processExit = new Promise((resolve) => process.on("exit", (code, signal) => resolve({ code, signal }))); |
| 145 | process.stdout.setEncoding("utf8"); |
| 146 | process.stdout.on("data", async (data: Buffer | string) => { |
| 147 | let match: RegExpExecArray | null = null; |
| 148 | if (this.shouldConnectDebugger && this.parseVmServiceUriFromStdOut && !this.vmService) { |
| 149 | match = vmServiceListeningBannerPattern.exec(data.toString()); |
| 150 | } |
| 151 | if (match) |
| 152 | await this.initDebugger(this.convertObservatoryUriToVmServiceUri(match[1])); |
| 153 | else if (this.sendStdOutToConsole) |
| 154 | this.logStdout(data.toString()); |
| 155 | }); |
| 156 | process.stderr.setEncoding("utf8"); |
| 157 | process.stderr.on("data", (data: Buffer | string) => { |
| 158 | this.logToUserBuffered(data.toString(), "stderr"); |
| 159 | }); |
| 160 | process.on("error", (error) => { |
| 161 | this.logToUser(`${error}\n`, "stderr"); |
| 162 | }); |
| 163 | void this.processExit.then(async ({ code, signal }) => { |
| 164 | this.processExited = true; |
| 165 | this.log(`Process exited (${signal ? `${signal}`.toLowerCase() : code})`); |
| 166 | if (!code && !signal) |
| 167 | this.logToUser("Exited\n"); |
| 168 | else |
nothing calls this directly
no test coverage detected