Closed Bug 1436151 Opened 7 years ago Closed 7 years ago

Breakpoints at the beginning of a line are missed

Categories

(DevTools :: Debugger, enhancement)

enhancement
Not set
normal

Tracking

(firefox60 fixed)

RESOLVED FIXED
Firefox 60
Tracking Status
firefox60 --- fixed

People

(Reporter: jlast, Assigned: jlast)

References

Details

Attachments

(1 file, 4 obsolete files)

When applications have source maps, it's possible for an original line to map to a generated column. We ran into this case in this bug: https://github.com/devtools-html/debugger.html/issues/5280 Here, line 18, column undefined mapped to line 21205 column 4. As a result the client tried to set a breakpoint at (21205, 4). The problem is that 4 comes before the first bytecode offset so the breakpoint is never set. > class ComponentsSidebar { > onComponentChange() { > var searchBug = this.props.searchBug > } > } We can fix this by defaulting to adding a breakpoint at the first offset if no entrypoints are found.
Comment on attachment 8948792 [details] Bug 1436151 - Breakpoints at the beginning of a line are missed. https://reviewboard.mozilla.org/r/218156/#review223992 Code analysis found 2 defects in this patch: - 2 defects found by mozlint You can run this analysis locally with: - `./mach lint path/to/file` (JS/Python) If you see a problem in this automated review, please report it here: http://bit.ly/2y9N9Vx ::: devtools/server/actors/source.js:919 (Diff revision 2) > + return true; > + } > + > + return false; > + } > + Error: More than 1 blank line not allowed. [eslint: no-multiple-empty-lines] ::: devtools/server/actors/source.js:934 (Diff revision 2) > - entryPoints.push({ script, offsets: [offset] }); > + entryPoints.push({ script, offsets: [offset] }); > - } > + } > - } > + } > - } > + } > - } > Error: More than 1 blank line not allowed. [eslint: no-multiple-empty-lines]
Comment on attachment 8948792 [details] Bug 1436151 - Breakpoints at the beginning of a line are missed. https://reviewboard.mozilla.org/r/218156/#review223994 Code analysis found 4 defects in this patch: - 4 defects found by mozlint You can run this analysis locally with: - `./mach lint path/to/file` (JS/Python) If you see a problem in this automated review, please report it here: http://bit.ly/2y9N9Vx ::: devtools/server/actors/source.js:914 (Diff revision 1) > } > } > - } else { > + > + if (entryPoints.length > 0) { > + setBreakpointAtEntryPoints(actor, entryPoints); > + return true; Error: Trailing spaces not allowed. [eslint: no-trailing-spaces] ::: devtools/server/actors/source.js:919 (Diff revision 1) > + return true; > + } > + > + return false; > + } > + Error: More than 1 blank line not allowed. [eslint: no-multiple-empty-lines] ::: devtools/server/actors/source.js:934 (Diff revision 1) > - entryPoints.push({ script, offsets: [offset] }); > + entryPoints.push({ script, offsets: [offset] }); > - } > + } > - } > + } > - } > + } > - } > Error: More than 1 blank line not allowed. [eslint: no-multiple-empty-lines] ::: devtools/server/actors/source.js:949 (Diff revision 1) > + }); > + > + if (columnToOffsetMap.length > 0) { > + let { columnNumber: column, offset } = columnToOffsetMap[0]; > + if (generatedColumn < column) { > + entryPoints.push({ script, offsets: [offset] }); Error: Trailing spaces not allowed. [eslint: no-trailing-spaces]
Comment on attachment 8948792 [details] Bug 1436151 - Breakpoints at the beginning of a line are missed. https://reviewboard.mozilla.org/r/218154/#review224990 Looks good, but there are some changes I'd like to see. ::: devtools/server/actors/source.js:918 (Diff revision 3) > + setBreakpointAtEntryPoints(actor, entryPoints); > + return true; > + } > + > + return false; > + } Could we write it this way? if (generatedColumn === undefined) { ... handle whole-line breakpoints ... } else { ... look for columns within range ... if (entryPoints.length === 0) { ... look for first column on line ... } } if (entryPoints.length === 0) { return false; } setBreakpointAtEntryPoints(actor, entryPoints); return true; I think it's clearer that these are three different strategies for producing `entryPoints`, but we always return `false` if there was nothing there (the patched version misses this in the column case, I think), and call `setBreakpointAtEntryPoints` if we did find something. ::: devtools/server/actors/source.js:942 (Diff revision 3) > - return false; > + for (let script of scripts) { > + let columnToOffsetMap = script > + .getAllColumnOffsets() > + .filter(({ lineNumber }) => { > + return lineNumber === generatedLine; > + }); `getAllColumnOffsets` returns a potentially very large data set. Let's not recompute the scripts' `columnToOffsetMap`s again; maybe we can save them in an array after we compute them the first time? (I'm not happy with `Debugger.Script` not offering a better API for just looking up the offsets we need; I have a bad feeling about just how much allocation `getAllColumnOffsets` is doing...)
Attachment #8948792 - Flags: review?(jimb)
Comment on attachment 8948792 [details] Bug 1436151 - Breakpoints at the beginning of a line are missed. https://reviewboard.mozilla.org/r/218156/#review225694 Looks great - thanks!
Attachment #8948792 - Flags: review?(jimb) → review+
The linter had some comments, too. Were those addressed?
Attached patch col-bp-2.patch (obsolete) (deleted) — Splinter Review
Attachment #8948792 - Attachment is obsolete: true
Keywords: checkin-needed
Blocks: js-devtools
Assignee: nobody → jlaster
Keywords: checkin-needed
Attached patch col-bp-3.patch (obsolete) (deleted) — Splinter Review
carrying over the r+
Attachment #8950761 - Attachment is obsolete: true
Attachment #8951041 - Flags: review+
Keywords: checkin-needed
Whiteboard: checkin-needed
Pushed by apavel@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/a8aa7e2af130 Breakpoints at the beginning of a line are missed. r=jimb
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Flags: needinfo?(jlaster)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: Firefox 60 → ---
There were also test-verify failures on /test_setBreakpoint-at-the-beginning-of-a-line.js Log: https://treeherder.mozilla.org/logviewer.html#?job_id=162612059&repo=mozilla-central&lineNumber=9986
These XPCshell failures showed up after the merges. Conflict with bug 1437828.
Attached patch col-bp-4.patch (obsolete) (deleted) — Splinter Review
carrying over the r+
Attachment #8951041 - Attachment is obsolete: true
Flags: needinfo?(jlaster)
Attachment #8951756 - Flags: review+
Attached patch col-bp-5.patch (deleted) — Splinter Review
carry over
Attachment #8951756 - Attachment is obsolete: true
Attachment #8951760 - Flags: review+
Pushed by jlaster@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/29223aed98f3 Breakpoints at the beginning of a line are missed. r=jimb
Status: REOPENED → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: