Closed Bug 978019 Opened 11 years ago Closed 11 years ago

Breakpoint doesn't get hit on self-executing function

Categories

(DevTools :: Debugger, defect, P2)

x86_64
Windows 7
defect

Tracking

(Not tracked)

VERIFIED FIXED
Firefox 30

People

(Reporter: Honza, Assigned: fitzgen)

References

Details

Attachments

(1 file, 3 obsolete files)

Debugger doesn't pause at a breakpoint. STR: 1. Load https://getfirebug.com/tests/manual/issues/7217/test.html 2. Open the debugger 4. Create a breakpoint at line 2 in test.html 5. Reload the page, breakpoint doesn't hit -> BUG Originally reported in Firebug issue list: http://code.google.com/p/fbug/issues/detail?id=7217 (it's works in JSD1) Honza
Line 2 of test.js, right? I can reproduce. :(
Hmmm, the script is added via onNewScript -> _addScript, but the breakpoint doesn't get set because endLine is reported as 1, and our breakpoint is on line 2. I think we might just have an off by one error on this line, where the decrement is unnecessary: let endLine = aScript.startLine + aScript.lineCount - 1;
Assignee: nobody → nfitzgerald
Status: NEW → ASSIGNED
Priority: -- → P2
Comment on attachment 8383858 [details] [diff] [review] bug-978019-iife-breakpoint.patch Review of attachment 8383858 [details] [diff] [review]: ----------------------------------------------------------------- Nice catch! I started playing a little more with the test case and I found that slightly modifying the script indicates there are more problems. Try changing the one-liner to 3 lines like this: var b = 9; console.log("x", b); return b; In this case only a breakpoint in the first line will pause execution. Breakpoints in the other two lines are ignored. Can you investigate why? ::: browser/devtools/debugger/test/head.js @@ +15,5 @@ > let { Task } = Cu.import("resource://gre/modules/Task.jsm", {}); > let { Promise: promise } = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}); > let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); > let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); > +let { require } = devtools; This seems unused, is it a leftover from debugging?
Attachment #8383858 - Flags: review?(past)
(In reply to Nick Fitzgerald [:fitzgen] from comment #1) > Line 2 of test.js, right? Sorry, yes, it should have been test.js, but you already figured that out :-) Honza
Attached patch bug-978019-iife-breakpoint.patch (obsolete) — Splinter Review
Hmmmm... In my debugging, when we call |findScripts| from |_restoreBreakpoints|, we only get the global level Debugger.Script (aka its staticLevel is 0) and *not* the Debugger.Script for the Immediately Invoked Function Expression (IIFE). Furthermore, |onNewScript| is never called for the IIFE's Debugger.Script. Because neither of those two things happen, the breakpoints are never reset on the Debugger.Script and will never be hit. Very troubling that the IIFE's Debugger.Script doesn't show up via either |findScripts| or |onNewScript|... Would think that maybe the fact that |findScripts| is GC sensitive or that we lazily compile functions would account for the IIFE not showing up in |findScripts|, but I have no idea why it wouldn't show up via |onNewScript|. needinfo?ing Jim for help.
Attachment #8383858 - Attachment is obsolete: true
Flags: needinfo?(jimb)
Wait, I kind of remember the debugger API only calling |onNewScript| for new global level scripts (aka static level is 0). This combined with the lazy function compilation could possibly account for this bug. If this is the case (I'm about to dig), I'd think that we would want to have onNewScript called for every new Debugger.Script instance.
See Also: → 979065
Attached patch bug-978019-iife-breakpoint.patch (obsolete) — Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=ed07b6abde04 So yeah, child scripts weren't getting found by our |findScripts| call nor by |onNewScript| so we have to find it ourselves by calling |getChildScripts| on every script found by |findScripts| in our |_restoreBreakpoints| method.
Attachment #8384963 - Attachment is obsolete: true
Attachment #8384998 - Flags: review?(past)
Flags: needinfo?(jimb)
https://tbpl.mozilla.org/?tree=Try&rev=a78f86bfb9e3 Actually we just need to call |getChildScripts| on the scripts we get from |onNewScript| because that only gives us top level scripts.
Attachment #8384998 - Attachment is obsolete: true
Attachment #8384998 - Flags: review?(past)
Attachment #8385025 - Flags: review?(past)
See also, the reason this bug was kind of tricky to track down: https://bugzilla.mozilla.org/show_bug.cgi?id=979094
Comment on attachment 8385025 [details] [diff] [review] bug-978019-iife-breakpoint.patch Review of attachment 8385025 [details] [diff] [review]: ----------------------------------------------------------------- It looks like the new test is broken, so I'm clearing the review until it's fixed.
Attachment #8385025 - Flags: review?(past)
(In reply to Panos Astithas [:past] from comment #11) > Comment on attachment 8385025 [details] [diff] [review] > bug-978019-iife-breakpoint.patch > > Review of attachment 8385025 [details] [diff] [review]: > ----------------------------------------------------------------- > > It looks like the new test is broken, so I'm clearing the review until it's > fixed. Huh. I was getting this error locally, but then I rebased and it was fixed. Maybe I need to update my hg repo too...
Attachment #8385025 - Flags: review?(past)
Comment on attachment 8385025 [details] [diff] [review] bug-978019-iife-breakpoint.patch Review of attachment 8385025 [details] [diff] [review]: ----------------------------------------------------------------- Very nice patch for a very sad bug. *sigh* ::: browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js @@ +23,5 @@ > + Task.spawn(function* () { > + yield waitForSourceShown(gPanel, CODE_URL); > + > + // Pause and set our breakpoints. > + yield doInterrupt(); This shouldn't be necessary right? No need to take it out if doing that would make the test more flaky though. ::: toolkit/devtools/server/actors/script.js @@ +2195,5 @@ > onNewScript: function (aScript, aGlobal) { > this._addScript(aScript); > + for (let s of aScript.getChildScripts()) { > + this._addScript(s); > + } Could you add a brief comment about why we have to do this?
Attachment #8385025 - Flags: review?(past) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 30
Justed tested with Firebug and it's working fine for me now. Thanks for the quick fix! Sebastian
Keywords: verifyme
No longer blocks: 998908
Depends on: 998908
Reproduced on Developer Tools / Debugger on Nightly 2014-02-28. Verified as fixed on latest Aurora 30.0a2 2014-04-23.
Status: RESOLVED → VERIFIED
Keywords: verifyme
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: