MCPcopy
hub / github.com/microsoft/vscode-js-debug / setThread

Method setThread

src/adapter/breakpoints.ts:413–461  ·  view source on GitHub ↗

* Updates the thread the breakpoint manager is attached to.

(thread: Thread)

Source from the content-addressed store, hash-verified

411 * Updates the thread the breakpoint manager is attached to.
412 */
413 public setThread(thread: Thread) {
414 this._thread = thread;
415 this._thread.cdp().Debugger.on('breakpointResolved', async event => {
416 // Sometimes V8 says a breakpoint is unverified and then _immediately_ verifies
417 // it which, due to event ordering, can happen before before the reply to 'set'
418 // is processed. Try to find the breakpoint on the next microtask if that
419 // might have happened.
420 const breakpoint = this._resolvedBreakpoints.get(event.breakpointId)
421 || await delay(0).then(() => this._resolvedBreakpoints.get(event.breakpointId));
422 if (breakpoint) {
423 breakpoint.updateUiLocations(thread, event.breakpointId, [event.location]);
424 }
425 });
426
427 this._thread.setSourceMapDisabler(breakpointIds => {
428 const sources: ISourceWithMap[] = [];
429 for (const id of breakpointIds) {
430 const breakpoint = this._resolvedBreakpoints.get(id);
431 if (breakpoint) {
432 const source = this._sourceContainer.source(breakpoint.source);
433 if (isSourceWithMap(source)) sources.push(source);
434 }
435 }
436 return sources;
437 });
438
439 for (const breakpoints of this._byPath.values()) {
440 breakpoints.forEach(b => this._setBreakpoint(b, thread));
441 this.ensureModuleEntryBreakpoint(thread, breakpoints[0]?.source);
442 }
443
444 for (const breakpoints of this._byRef.values()) {
445 breakpoints.forEach(b => this._setBreakpoint(b, thread));
446 }
447
448 if (
449 'runtimeSourcemapPausePatterns' in this.launchConfig
450 && this.launchConfig.runtimeSourcemapPausePatterns.length
451 ) {
452 this.setRuntimeSourcemapPausePatterns(
453 thread,
454 this.launchConfig.runtimeSourcemapPausePatterns,
455 ); // will update the launchblocker
456 }
457
458 if (this._byDapId.size > 0) {
459 this._installSourceMapHandler(this._thread);
460 }
461 }
462
463 /**
464 * Returns a promise that resolves when all breakpoints that can be set,

Callers 1

createThreadMethod · 0.80

Calls 14

_setBreakpointMethod · 0.95
delayFunction · 0.90
isSourceWithMapFunction · 0.90
setSourceMapDisablerMethod · 0.80
valuesMethod · 0.80
onMethod · 0.65
getMethod · 0.65
sourceMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected