Closed
Bug 786711
Opened 12 years ago
Closed 12 years ago
Stack frame listed as anonymous rather than the expected name
Categories
(DevTools :: Debugger, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 18
People
(Reporter: dangoor, Assigned: past)
References
()
Details
Attachments
(2 files)
3.76 KB,
patch
|
msucan
:
review+
vporof
:
review+
|
Details | Diff | Splinter Review |
1.06 KB,
patch
|
jimb
:
review+
|
Details | Diff | Splinter Review |
STR: 1. go to http://todomvc.com/architecture-examples/backbone/ 2. set a breakpoint in todo.js around line 21 (this.save in the toggle function) 3. add a todo item 4. click the checkbox to toggle it 5. note that the stack frames are all "anonymous" when what you really want is for the frames to have useful names expected result: the top frame should be called "toggle".
Comment 1•12 years ago
|
||
(In reply to Kevin Dangoor from comment #0) > STR: > > 1. go to http://todomvc.com/architecture-examples/backbone/ > 2. set a breakpoint in todo.js around line 21 (this.save in the toggle > function) > 3. add a todo item > 4. click the checkbox to toggle it > 5. note that the stack frames are all "anonymous" when what you really want > is for the frames to have useful names > > expected result: > the top frame should be called "toggle". The function is actually anonymous. "toggle" is the property name in the container object (app.Todo, or the thing that results via calling Backbone.Model.extend), which has the value of an anonymous function expression (not a named expression, and not a declaration). This is less than optimal, for sure, but that's how js works. So { foo: function(){} } would create the anonymous function, via an anonymous function expression and { foo: function bar(){} } would create the function foo, via a named function expression
Comment 2•12 years ago
|
||
("the function bar", not "foo" in my last example)
Reporter | ||
Comment 3•12 years ago
|
||
Sure, I agree that the function is anonymous as far as JavaScript is concerned. As far as the user is concerned, however, it is not anonymous... it's "toggle". And, according to the other browser tools it's "toggle".
Assignee | ||
Comment 4•12 years ago
|
||
Alex, Jason: where are the statically-inferred names from bug 433529 surfacing in JS? Isn't fn.name updated with that information? Does that work cover the case in this bug?
Comment 5•12 years ago
|
||
fn.displayName is what you want. Jim says it's not in the protocol yet.
If you're using the C++ api, you can also use JS_GetFunctionDisplayId instead of JS_GetFunctionId
Assignee | ||
Comment 7•12 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #5) > fn.displayName is what you want. Jim says it's not in the protocol yet. I wonder why this doesn't work then: http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/debugger/server/dbg-script-actors.js#1688 Is displayName set on the prototype, when it's set by the engine?
Assignee | ||
Comment 8•12 years ago
|
||
Duh, probably because I'm using the Debugger API there...
Assignee | ||
Comment 9•12 years ago
|
||
Thanks to Alex's work this was too easy. Try: https://tbpl.mozilla.org/?tree=Try&rev=836b3125544e
Assignee | ||
Comment 10•12 years ago
|
||
Comment on attachment 657798 [details] [diff] [review] Simple fix Since Rob is on PTO, maybe you guys can take a look at this. It's pretty simple actually.
Attachment #657798 -
Flags: review?(vporof)
Attachment #657798 -
Flags: review?(rcampbell)
Attachment #657798 -
Flags: review?(mihai.sucan)
Comment 11•12 years ago
|
||
Comment on attachment 657798 [details] [diff] [review] Simple fix Review of attachment 657798 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me. ::: browser/devtools/debugger/test/browser_dbg_displayName.js @@ +58,5 @@ > + is(frames.querySelectorAll(".dbg-stackframe").length, 3, > + "Should have three frames."); > + > + is(frames.querySelector("#stackframe-0 .dbg-stackframe-name").getAttribute("value"), > + "a/<", "Frame name should be a/<"); I love the way these inferred names show up.
Attachment #657798 -
Flags: review?(vporof) → review+
Comment 12•12 years ago
|
||
Comment on attachment 657798 [details] [diff] [review] Simple fix Looks good!
Attachment #657798 -
Flags: review?(mihai.sucan) → review+
Assignee | ||
Updated•12 years ago
|
Whiteboard: [land-in-fx-team]
Assignee | ||
Comment 13•12 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/20bb14ce0b55
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
Comment 14•12 years ago
|
||
Comment on attachment 657798 [details] [diff] [review] Simple fix Review of attachment 657798 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/devtools/debugger/server/dbg-script-actors.js @@ +1690,4 @@ > let desc = aFunction.getOwnPropertyDescriptor("displayName"); > if (desc && desc.value && typeof desc.value == "string") { > name = desc.value; > + } else if ("displayName" in aFunction) { Every Debugger.Object instance should have a "displayName" property --- its value will be undefined, if we couldn't infer any name for it at all, but it will be present. So this 'in' test will always return true.
Assignee | ||
Comment 15•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/20bb14ce0b55
Target Milestone: --- → Firefox 18
Assignee | ||
Comment 16•12 years ago
|
||
(In reply to Jim Blandy :jimb from comment #14) > ::: toolkit/devtools/debugger/server/dbg-script-actors.js > @@ +1690,4 @@ > > let desc = aFunction.getOwnPropertyDescriptor("displayName"); > > if (desc && desc.value && typeof desc.value == "string") { > > name = desc.value; > > + } else if ("displayName" in aFunction) { > > Every Debugger.Object instance should have a "displayName" property --- its > value will be undefined, if we couldn't infer any name for it at all, but it > will be present. So this 'in' test will always return true. OK, I just converted the "else if" to an "else" then.
Attachment #659984 -
Flags: review?(jimb)
Comment 17•12 years ago
|
||
Comment on attachment 659984 [details] [diff] [review] Remove redundant check Review of attachment 659984 [details] [diff] [review]: ----------------------------------------------------------------- displayName will still return null if the function is anonymous and SpiderMonkey couldn't infer a name for it. Is that all right?
Attachment #659984 -
Flags: review?(jimb) → review+
Assignee | ||
Comment 18•12 years ago
|
||
(In reply to Jim Blandy :jimb from comment #17) > Comment on attachment 659984 [details] [diff] [review] > Remove redundant check > > Review of attachment 659984 [details] [diff] [review]: > ----------------------------------------------------------------- > > displayName will still return null if the function is anonymous and > SpiderMonkey couldn't infer a name for it. Is that all right? Yes, in that case the frontend will just display <anonymous> as before.
Assignee | ||
Comment 19•12 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/93e7a6cb66ff
Comment 20•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/93e7a6cb66ff
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•