Summary: | Web Inspector: Expose function scope / closure data | ||
---|---|---|---|
Product: | WebKit | Reporter: | Peter Rybin <prybin> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | UNCONFIRMED --- | ||
Severity: | Normal | CC: | ggaren, joepeck, mark.lam, ngockhanhlam87, oliver, prybin, yurys |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Description
Peter Rybin
2012-05-22 18:24:43 PDT
Note that WebKit Remote Debugging protocol is about to include this feature as an optional one. This bug might be no-op and only a formal one since there is JSC::JSFunction::scope in public API. function->scope()->object will give you the scope in which a function was defined. Do you expect all functions to create closures all the time? That isn't usually the case. (In reply to comment #4) > function->scope()->object will give you the scope in which a function was defined. > > Do you expect all functions to create closures all the time? That isn't usually the case. This si for the debugger. If the debugger is on everything gets a full and beautiful scope chain > If the debugger is on everything gets a full and beautiful scope chain
What happens to functions that were created before the debugger was attached?
they're kind of screwed. /me thinks... (In reply to comment #5) > (In reply to comment #4) > > function->scope()->object will give you the scope in which a function was defined. > > > > Do you expect all functions to create closures all the time? That isn't usually the case. > > This si for the debugger. If the debugger is on everything gets a full and beautiful scope chain That's exactly what I need. But how end user can see this scope chain? I plan on showing the scope chain from WebInspector (Safari and Chrome) and from Java-based http://code.google.com/p/chromedevtools/ for every function value. So I'm working on adding scope chain to Remote Debugging protocol (with V8 engine right now). (In reply to comment #7) > they're kind of screwed. > > /me thinks... Yeah they're screwed as their parent scope will be the first scope that was actually necessary. Presumably we could reify the entire scope chain when the debugger is enabled, but then you may get issues going backwards. Also in the absence pre-debugger functions won't have all the variables that were not captured initially. (In reply to comment #5) > (In reply to comment #4) > > function->scope()->object will give you the scope in which a function was defined. > > > > Do you expect all functions to create closures all the time? That isn't usually the case. > > This si for the debugger. If the debugger is on everything gets a full and beautiful scope chain That's exactly what I need. But how end user can see this scope chain? I plan on showing the scope chain from WebInspector (Safari and Chrome) and from Java-based http://code.google.com/p/chromedevtools/ for every function value. So I'm working on adding scope chain to Remote Debugging protocol (with V8 engine right now). We recompile all the functions when the debugger attaches/detaches using Debugger::recompileAllJSFunctions. Dosen't that help here? > We recompile all the functions when the debugger attaches/detaches using Debugger::recompileAllJSFunctions. Dosen't that help here?
It helps, but there's an edge case: closures created before the recompile will capture only a subset of their variables (possibly 0).
|