Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Fix break-on-load breakpoint not hitting on the first line for Chrome #285

Merged
merged 4 commits into from
Feb 14, 2018

Conversation

digeff
Copy link
Contributor

@digeff digeff commented Feb 14, 2018

The previous userBreakpointOnLine1Col1 logic depended on parts of the ScriptParsed method executing synchronically to set that instance variable before ScriptPaused started executing. In recent changes, I added some new awaits to ScriptParsed which make it not execute synchronical any more, so the existing logic doesn't work any more.

const pausedScriptUrl = this.getPausedScriptUrlFromId(pausedLocation.scriptId);
// Important: We need to get the commited breakpoints only after all the pending breakpoints for this file have been resolved. If not this logic won't work
const commitedBps = this._chromeDebugAdapter.committedBreakpointsByUrl.get(pausedScriptUrl);
const anyBreakpointsAtPausedLocation = commitedBps.filter(bp =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We populate the committedBreakpointsByUrl on breakpointResolved right? Can there be a situation where we hit the stopOnEntry breakpoint and a user breakpoint on (1,1) hasn't been resolved yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We block on resolvePendingBreakpointsOfPausedScript which should set all the pending breakpoints before returning. My understanding is that that will guarantee all the breakpoints are set before we continue. @roblourens: You know a lot more about the code than us, do you think that is a correct assumption?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think that's correct.


const pausedScriptUrl = this.getPausedScriptUrlFromId(pausedLocation.scriptId);
// Important: We need to get the commited breakpoints only after all the pending breakpoints for this file have been resolved. If not this logic won't work
const commitedBps = this._chromeDebugAdapter.committedBreakpointsByUrl.get(pausedScriptUrl);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: *committed

@roblourens
Copy link
Member

Could you add a test for this?

Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments, otherwise looks great

@@ -67,12 +66,16 @@ export class BreakOnLoadHelper {
}
}

private getPausedScriptUrlFromId(scriptId: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just a "paused" script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Renaming to getScriptUrlFromId

@@ -945,8 +945,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
}

const committedBps = this._committedBreakpointsByUrl.get(script.url) || [];
if (committedBps.indexOf(params.breakpointId) === -1) {
committedBps.push(params.breakpointId);
if (committedBps.findIndex(committedBp => committedBp.breakpointId === params.breakpointId) === -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer if (!committedBps.find(... instead of checking index -1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@roblourens roblourens merged commit d92e64e into microsoft:master Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants