MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / handlePauseEvent

Function handlePauseEvent

src/debug/dart_debug_impl.ts:1479–1583  ·  view source on GitHub ↗
(event: VMEvent)

Source from the content-addressed store, hash-verified

1477 }
1478
1479 private async handlePauseEvent(event: VMEvent) {
1480 if (!event.isolate) {
1481 this.logger.warn(`Unable to handle pause event (${event.kind}) that had no isolate`);
1482 return;
1483 }
1484
1485 const kind = event.kind;
1486 const thread = this.threadManager.getThreadInfoFromRef(event.isolate);
1487
1488 if (!thread) {
1489 this.logger.warn(`ThreadManager couldn't find thread with ref ${event.isolate.id} to handle ${kind}`);
1490 return;
1491 }
1492
1493 if (!this.vmService) {
1494 this.logger.warn("No VM service connection");
1495 return;
1496 }
1497
1498 // For PausePostRequest we need to re-send all breakpoints; this happens after a flutter restart
1499 if (kind === "PausePostRequest") {
1500 try {
1501 await this.threadManager.resendThreadBreakpoints(thread);
1502 } catch (e) {
1503 this.logger.error(e);
1504 }
1505 try {
1506 await this.vmService.resume(event.isolate.id);
1507 } catch (e: any) {
1508 // Ignore failed-to-resume errors https://github.com/flutter/flutter/issues/10934
1509 if (e.code !== 106)
1510 throw e;
1511 }
1512 } else if (kind === "PauseStart") {
1513 // "PauseStart" should auto-resume after breakpoints are set if we launched the process.
1514 if (this.childProcess)
1515 thread.receivedPauseStart();
1516 else {
1517 // Otherwise, if we were attaching, then just issue a step-into to put the debugger
1518 // right at the start of the application.
1519 thread.handlePaused(event);
1520 await thread.resume("Into");
1521 }
1522 } else {
1523 // PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException
1524 let reason = "pause";
1525 let exceptionText: string | undefined;
1526 let shouldRemainedStoppedOnBreakpoint = true;
1527
1528 if (kind === "PauseBreakpoint" && event.pauseBreakpoints && event.pauseBreakpoints.length) {
1529 reason = "breakpoint";
1530
1531 const potentialBreakpoints: Array<DebugProtocol.SourceBreakpoint | undefined> = event.pauseBreakpoints.map((bp) => thread.breakpoints[bp.id]);
1532 // When attaching to an already-stopped process, this event can be handled before the
1533 // breakpoints have been registered. If that happens, replace any unknown breakpoints with
1534 // dummy unconditional breakpoints.
1535 // TODO: Ensure that VM breakpoint state is reconciled with debugger breakpoint state before
1536 // handling thread state so that this doesn't happen, and remove this check.

Callers

nothing calls this directly

Calls 8

getThreadInfoFromRefMethod · 0.80
receivedPauseStartMethod · 0.80
handlePausedMethod · 0.80
sendEventMethod · 0.80
warnMethod · 0.65
errorMethod · 0.65
resumeMethod · 0.45

Tested by

no test coverage detected