Consolidate function scopes
Categories
(DevTools :: Debugger, defect, P1)
Tracking
(firefox70 fixed)
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: jlast, Assigned: bhackett1024)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed, Whiteboard: [debugger-mvp])
Attachments
(4 files, 1 obsolete file)
Reporter | ||
Comment 1•7 years ago
|
||
Reporter | ||
Updated•7 years ago
|
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Comment 2•6 years ago
|
||
The consolidation of the function and function body scopes makes perfect sense. Debugger is just exposing what the engine and spec say ought to be there; we should absolutely feel free to merge/omit/re-interpret things however we please.
The only concern is to make sure you've handled all the cases, so that we don't omit necessary information. For example, there can be a definition in the function body with the same name as the function itself. Simply listing them both in a single block would be unclear; the display should reflect the fact that only the body's definition is visible. Etc.
Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 3•6 years ago
|
||
This patch works but I'm not very happy with it. The main problem is that there currently isn't a way to distinguish between the top level function lexical scope and inner lexical scopes. The top level function lexical scope isn't created if it's empty, so there isn't a way to tell apart this case:
function foo(a) {
let x = a;
}
from this one:
function foo(a) {
if (a) {
let x = a;
}
}
This patch deals with this by modifying spidermonkey to give a different scope kind to the top level function lexical scope, which the debugger conveys to the devtools server/client. There are already some special scope kinds like this for try/catch lexical scopes and so forth, but adding more is painful and error prone and it seems best to avoid. This same thing would have to be done for other lexical scopes we want to collapse, like the following:
for (let x in a) {
let y = x;
}
As an alternative, would it make sense to just collapse all the lexical scopes in a script into a single entry in the scopes pane? The UI would need to distinguish between variables that are shadowed vs. those that aren't, but that seems like it would be a good thing in general, e.g. when stopped in 'bar' below it would be nice to indicate that the 'a' in foo is shadowed.
function foo(a) {
bar(a);
function bar(a) {
}
}
This would be easier to do with the information provided by spidermonkey and seems like it would provide a better UX: users wouldn't have to expand all the various identically-named block scopes in a script to find the variable they are interested in.
Reporter | ||
Comment 4•6 years ago
•
|
||
As an alternative, would it make sense to just collapse all the lexical scopes in a script into a single entry in the scopes pane? The UI would need to distinguish between variables that are shadowed vs. those that aren't, but that seems like it would be a good thing in general, e.g. when stopped in 'bar' below it would be nice to indicate that the 'a' in foo is shadowed.
I think it makes sense to try and collapse the scopes in the UI or server. It's more presentational this way and we can still support shadowing.
Assignee | ||
Comment 6•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Comment 7•6 years ago
•
|
||
Actually, after looking into it a bit more, I think I'm a fan of what chrome is doing.
Here is a small test case dbg-shadow.
In general, I think it is helpful in this UI to visualize the scopes because they could be meaningful to the users. In this case, top-level const are just not helpful and should be a separate case.
I think your initial patch was good in that it differentiates function lexicals and lets the UI do the merging.
--
We're currently working on inline variable preview bug, doc, which i hope will do a better job of helping users see the most relevant values. But either way, I think the scopes pane should show most block scopes, while somewhere else we help users see the most relevant local values
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Comment 8•6 years ago
|
||
Brian, if you're fine with direction, would you mind if I ran with your C++ patch? I think it would be a good opportunity to learn more about the engine.
Reporter | ||
Comment 9•6 years ago
•
|
||
try run:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=982d2043dc5f7c4be4ae2f77b470e17524d8d5fa
one failing debugger mochitest
devtools/client/debugger/test/mochitest/browser_dbg-scopes-mutations.js
but that is likely because we're looking in the wrong scope now
Assignee | ||
Comment 10•6 years ago
|
||
Sure, that's fine.
Reporter | ||
Comment 11•6 years ago
|
||
and some jit-test failures
basic/bug688939.js
basic/bug832203.js
basic/inflate-oom.js
coverage/bug1214548.js
gc/bug-1143706.js
gc/bug-1303015.js
gc/bug-1462337.js
gc/bug-1543589.js
gc/oomInFindPath.js
gc/oomInGetJumpLabelForBranch.js
gc/weak-marking-varying.js
Reporter | ||
Comment 12•6 years ago
|
||
It looks like the jit failures were only local and not on try.
Here is a quick fix for the scopes-mutations failure.
It looks like the try run is green, so there isn't much for me to do here :) I'll hand it back to you so you can get a proper phab review.
Updated•5 years ago
|
Assignee | ||
Comment 13•5 years ago
|
||
Assignee | ||
Comment 14•5 years ago
|
||
Depends on D35043
Assignee | ||
Comment 15•5 years ago
|
||
Depends on D35044
Updated•5 years ago
|
Comment 16•5 years ago
|
||
Comment 17•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a1059c1d9019
https://hg.mozilla.org/mozilla-central/rev/f43145570ca5
https://hg.mozilla.org/mozilla-central/rev/2b69083f7aba
Updated•5 years ago
|
Description
•