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

Method setLibrariesDebuggable

src/debug/threads.ts:106–143  ·  view source on GitHub ↗
(isolateRef: VMIsolateRef)

Source from the content-addressed store, hash-verified

104 }
105
106 private async setLibrariesDebuggable(isolateRef: VMIsolateRef): Promise<void> {
107 if (this.debugSession.noDebug || !this.debugSession.vmService)
108 return;
109
110 // Helpers to categories libraries as SDK/ExternalLibrary/not.
111 // Set whether libraries should be debuggable based on user settings.
112 const response = await this.debugSession.vmService.getIsolate(isolateRef.id);
113 const isolate: VMIsolate = response.result as VMIsolate;
114 const validDebugLibraries = isolate.libraries || [];
115 if (validDebugLibraries.length === 0)
116 return;
117
118 const debugSession = this.debugSession;
119 function setLibrary(library: VMLibraryRef): Promise<any> {
120 if (!debugSession.vmService)
121 return Promise.resolve(true);
122 // Note: Condition is negated.
123 const shouldDebug = !(
124 // Inside here is shouldNotDebug!
125 (debugSession.isSdkLibrary(library.uri) && !debugSession.debugSdkLibraries)
126 || (debugSession.isExternalLibrary(library.uri) && !debugSession.debugExternalPackageLibraries));
127 return debugSession.vmService.setLibraryDebuggable(isolate.id, library.id, shouldDebug);
128 }
129
130 // We usually send these requests all concurrently, however on web this is not currently
131 // supported (https://github.com/dart-lang/webdev/issues/606) which results in a lot of
132 // bloat in the logs. Instead, send the first one, and if it works successfully, then
133 // do the whole lot.
134 const firstLib = validDebugLibraries[0];
135 try {
136 await setLibrary(firstLib);
137 } catch (e) {
138 this.logger.info(errorString(e));
139 return;
140 }
141 // Do all.
142 await Promise.all(validDebugLibraries.map(setLibrary)).catch((e) => this.logger.info(errorString(e)));
143 }
144
145 // Just resends existing breakpoints for a single thread.
146 public async resendThreadBreakpoints(thread: ThreadInfo): Promise<void> {

Callers 2

registerThreadMethod · 0.95

Calls 3

errorStringFunction · 0.90
getIsolateMethod · 0.80
infoMethod · 0.65

Tested by

no test coverage detected