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

Method endChainedConfigs

src/frontend/extension.ts:606–642  ·  view source on GitHub ↗
(e: vscode.DebugSessionCustomEvent)

Source from the content-addressed store, hash-verified

604 }
605
606 private endChainedConfigs(e: vscode.DebugSessionCustomEvent) {
607 const mySession = CDebugSession.FindSession(e.session);
608 if (mySession && mySession.hasChildren) {
609 // Note that we may not be the root, but we have children. Also we do not modify the tree while iterating it
610 const deathList: CDebugSession[] = [];
611 const orphanList: CDebugSession[] = [];
612 mySession.broadcastDFS((s) => {
613 if (s === mySession) { return; }
614 if (s.config.pvtMyConfigFromParent.lifecycleManagedByParent) {
615 deathList.push(s); // Qualifies to be terminated
616 } else {
617 orphanList.push(s); // This child is about to get orphaned
618 }
619 }, false);
620
621 // According to current scheme, there should not be any orphaned children.
622 while (orphanList.length > 0) {
623 const s = orphanList.pop();
624 s.moveToRoot(); // Or should we move to our parent. TODO: fix for when we are going to have grand children
625 }
626
627 while (deathList.length > 0) {
628 const s = deathList.pop();
629 // We cannot actually use the following API. We have to do this ourselves. Probably because we own
630 // the lifetime management.
631 // vscode.debug.stopDebugging(s.session);
632 ServerConsoleLog(`Sending custom-stop-debugging to ${s.session.name}`, process.pid);
633 s.session.customRequest('custom-stop-debugging', e.body.info).then(() => {
634 }, (reason) => {
635 vscode.window.showErrorMessage(`Cortex-Debug: Bug? session.customRequest('set-stop-debugging-type', ... failed ${reason}\n`);
636 });
637 }
638 // Following does not work. Apparently, a customRequest cannot be sent probably because this session is already
639 // terminating.
640 // mySession.session.customRequest('notified-children-to-terminate');
641 }
642 }
643
644 private resetOrResartChained(e: vscode.DebugSessionCustomEvent, type: 'reset' | 'restart') {
645 const mySession = CDebugSession.FindSession(e.session);

Callers 1

receivedCustomEventMethod · 0.95

Calls 5

ServerConsoleLogFunction · 0.90
FindSessionMethod · 0.80
broadcastDFSMethod · 0.80
moveToRootMethod · 0.80
customRequestMethod · 0.65

Tested by

no test coverage detected