MCPcopy Create free account
hub / github.com/Marus/cortex-debug / processLaunchAttachRequest

Method processLaunchAttachRequest

src/gdb.ts:499–726  ·  view source on GitHub ↗
(response: DebugProtocol.LaunchResponse, attach: boolean)

Source from the content-addressed store, hash-verified

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');

Callers 2

launchRequestMethod · 0.95
attachRequestMethod · 0.95

Calls 15

serverConsoleLogMethod · 0.95
getGdbPathMethod · 0.95
loadSymbolsMethod · 0.95
startGdbMethod · 0.95
getTCPPortsMethod · 0.95
sendEventMethod · 0.95
getServerCwdMethod · 0.95
handleMsgMethod · 0.95
launchErrorResponseMethod · 0.95
serverQuitEventMethod · 0.95
startGdbForLiveWatchMethod · 0.95
startCompleteMethod · 0.95

Tested by

no test coverage detected