(response: DebugProtocol.LaunchResponse, attach: boolean)
| 497 | } |
| 498 | |
| 499 | private processLaunchAttachRequest(response: DebugProtocol.LaunchResponse, attach: boolean): Promise<void> { |
| 500 | return new Promise<void>((resolve) => { |
| 501 | const doResolve = () => { |
| 502 | if (resolve) { |
| 503 | resolve(); |
| 504 | resolve = null; |
| 505 | } |
| 506 | }; |
| 507 | const haveSymFiles = this.args.symbolFiles && (this.args.symbolFiles.length > 0); |
| 508 | if (!fs.existsSync(this.args.executable) && !haveSymFiles) { |
| 509 | this.sendErrorResponse(response, 103, `Unable to find executable file at ${this.args.executable}.`); |
| 510 | return doResolve(); |
| 511 | } |
| 512 | |
| 513 | const ControllerClass = SERVER_TYPE_MAP[this.args.servertype]; |
| 514 | this.serverController = new ControllerClass(); |
| 515 | this.serverController.setArguments(this.args); |
| 516 | this.serverController.on('event', this.serverControllerEvent.bind(this)); |
| 517 | |
| 518 | this.quit = false; |
| 519 | this.attached = false; |
| 520 | this.started = false; |
| 521 | this.debugReady = false; |
| 522 | this.stopped = false; |
| 523 | this.continuing = false; |
| 524 | this.activeThreadIds.clear(); |
| 525 | this.disassember = new GdbDisassembler(this, this.args); |
| 526 | // dbgResumeStopCounter = 0; |
| 527 | |
| 528 | this.serverConsoleLog(`******* Starting new session request type="${this.args.request}"`); |
| 529 | |
| 530 | if (!this.getGdbPath(response)) { |
| 531 | return doResolve(); |
| 532 | } |
| 533 | const symbolsPromise = this.loadSymbols(); // This is totally async and in most cases, done while gdb is starting |
| 534 | const gdbPromise = this.startGdb(response); |
| 535 | // const gdbInfoVariables = this.symbolTable.loadSymbolsFromGdb(gdbPromise); |
| 536 | this.usingParentServer = this.args.pvtMyConfigFromParent && !this.args.pvtMyConfigFromParent.detached; |
| 537 | this.getTCPPorts(this.usingParentServer).then(async () => { |
| 538 | await this.serverController.allocateRTTPorts(); // Must be done before serverArguments() |
| 539 | const executable = this.usingParentServer ? null : this.serverController.serverExecutable(); |
| 540 | const args = this.usingParentServer ? [] : this.serverController.serverArguments(); |
| 541 | this.sendEvent(new GenericCustomEvent('ports-done', undefined)); // Should be no more TCP ports allocation |
| 542 | |
| 543 | const serverCwd = this.getServerCwd(executable); |
| 544 | |
| 545 | if (executable) { |
| 546 | this.handleMsg('log', 'Launching gdb-server: ' + quoteShellCmdLine([executable, ...args]) + '\n'); |
| 547 | this.handleMsg('stdout', ` Please check TERMINAL tab (gdb-server) for output from ${executable}` + '\n'); |
| 548 | } |
| 549 | |
| 550 | const consolePort = (this.args as any).gdbServerConsolePort; |
| 551 | const gdbPort = this.ports[createPortName(this.args.targetProcessor)]; |
| 552 | let initMatch = null; |
| 553 | if (!this.usingParentServer) { |
| 554 | initMatch = this.serverController.initMatch(); |
| 555 | if (this.args.overrideGDBServerStartedRegex) { |
| 556 | initMatch = new RegExp(this.args.overrideGDBServerStartedRegex, 'i'); |
no test coverage detected