Debugger: Difference between revisions

Jump to navigation Jump to search
174 bytes added ,  7 April 2011
Use inherited accessors on instances instead of own properties.
(Split out scope chain objects into their own reflection type, Debug.Environment. Other changes.)
(Use inherited accessors on instances instead of own properties.)
Line 19: Line 19:
=== Properties ===
=== Properties ===


The objects comprising the <code>Debug</code> interface and the objects that interface creates to present the debuggee's state to the debugger follow some conventions:
Properties of objects the <code>Debug</code> interface creates, and those of the interface objects themselves, follow some general conventions:
<ul>
<ul>
<li>Properties described here are configurable. This applies to both "own" and prototype properties, and to both methods and data properties. (Leaving these properties open to redefinition will hopefully make it easier for JavaScript debugger code to cope with bugs, bug fixes, and changes in the interface over time.)
<li>Instances and prototypes are extensible; you can add your own properties and methods to them.
<li>Data properties are non-writable, unless stated otherwise. Since they are configurable, they can be made writable, but assigning to them has no effect on the debuggee unless stated otherwise.
<li>Properties are configurable. This applies to both "own" and prototype properties, and to both methods and data properties. (Leaving these properties open to redefinition will hopefully make it easier for JavaScript debugger code to cope with bugs, bug fixes, and changes in the interface over time.)
<li>Method properties are writable.
<li>Method properties are writable.
<li>Instances and prototypes are extensible; you can add your own properties and methods to them.
<li>We prefer inherited accessor properties to own data properties. Both are read using the same syntax, but inherited accessors seem like a more accurate reflection of what's going on. Unless otherwise noted, these properties have getters but no setters, as they cannot meaningfully be assigned to.
</ul>
</ul>


Line 61: Line 61:
</dl>
</dl>


== Beginning to Debug ==
== The Debug Object ==


To begin debugging another compartment's code, create a Debug object for the debuggee compartment. You can use this object to install hook functions, set breakpoints, and so on.
To begin debugging another compartment's code, create a Debug object for the debuggee compartment. You can use this object to install hook functions, set breakpoints, and so on.
Line 72: Line 72:
</dl>
</dl>


=== Properties of Debug instances ===
=== Accessor Properties of the Debug Prototype Object ===
 
A <code>Debug</code> instance inherits the following accessor properties from its prototype:


<dl>
<dl>
Line 81: Line 83:
</dl>
</dl>


=== Properties of the Debug Prototype Object ===
=== Function Properties of the Debug Prototype Object ===


The functions described below may only be called with a <code>this</code> value referring to a <code>Debug</code> instance; they may not be used as methods of other kinds of objects.
The functions described below may only be called with a <code>this</code> value referring to a <code>Debug</code> instance; they may not be used as methods of other kinds of objects.
Line 228: Line 230:
A <code>Debug.Frame</code> instance is a weak reference to the frame; once the debuggee destroys the frame (by returning from the function, completing the <code>eval</code> call, freeing the generator-iterator object, or taking some similar action), the <code>Debug.Frame</code> instance becomes inactive: its <code>live</code> property becomes <code>false</code>, its properties become undefined, and calls to its methods throw exceptions. (Note that this means that debugger code can be affected by the garbage collector, since debugger code can notice when <code>Debug.Frame</code> instances die.)
A <code>Debug.Frame</code> instance is a weak reference to the frame; once the debuggee destroys the frame (by returning from the function, completing the <code>eval</code> call, freeing the generator-iterator object, or taking some similar action), the <code>Debug.Frame</code> instance becomes inactive: its <code>live</code> property becomes <code>false</code>, its properties become undefined, and calls to its methods throw exceptions. (Note that this means that debugger code can be affected by the garbage collector, since debugger code can notice when <code>Debug.Frame</code> instances die.)


=== Properties of Debug.Frame instances ===
=== Accessor Properties of the Debug.Frame Prototype Object ===


A <code>Debug.Frame</code> instance has the following properties:
A <code>Debug.Frame</code> instance inherits the following accessor properties from its prototype:


<dl>
<dl>
Line 277: Line 279:
</dl>
</dl>


=== Properties of the Debug.Frame Prototype Object ===
=== Function Properties of the Debug.Frame Prototype Object ===


The functions described below may only be called with a <code>this</code> value referring to a <code>Debug.Frame</code> instance; they may not be used as methods of other kinds of objects.
The functions described below may only be called with a <code>this</code> value referring to a <code>Debug.Frame</code> instance; they may not be used as methods of other kinds of objects.
Line 334: Line 336:
The lifetime of a script depends on its origin. A function script is shared by all closures produced for that function, and lives as long as there are live closures referring to it. An <code>eval</code> script lives until the call to <code>eval</code> completes. Debuggers should avoid depending on scripts' lifetimes after the stack frames, functions, and so on that own them have been destroyed.
The lifetime of a script depends on its origin. A function script is shared by all closures produced for that function, and lives as long as there are live closures referring to it. An <code>eval</code> script lives until the call to <code>eval</code> completes. Debuggers should avoid depending on scripts' lifetimes after the stack frames, functions, and so on that own them have been destroyed.


=== Properties of Debug.Script instances ===
=== Accessor Properties of the Debug.Script Prototype Object ===


<dl>
<dl>
Line 353: Line 355:
</dl>
</dl>


=== Properties of the Debug.Script Prototype Object ===
=== Function Properties of the Debug.Script Prototype Object ===


The functions described below may only be called with a <code>this</code> value referring to a <code>Debug.Script</code> instance; they may not be used as methods of other kinds of objects.
The functions described below may only be called with a <code>this</code> value referring to a <code>Debug.Script</code> instance; they may not be used as methods of other kinds of objects.
Line 515: Line 517:
<code>Debug.Environment</code> instances protect their referents from the garbage collector; as long as the <code>Debug.Environment</code> instance is live, the referent remains live. Garbage collection has no debugger-visible effect on <code>Debug.Environment</code> instances.
<code>Debug.Environment</code> instances protect their referents from the garbage collector; as long as the <code>Debug.Environment</code> instance is live, the referent remains live. Garbage collection has no debugger-visible effect on <code>Debug.Environment</code> instances.


=== Accessors for Debug.Environment Instances ===  
=== Accessor Properties of the Debug.Environment Prototype Object ===  


The following are accessor properties on the <code>Debug.Environment</code> prototype object, and thus are visible on each <code>Debug.Environment</code> instance. Except where noted otherwise, each property has a getter, but no setter.
A <code>Debug.Environment</code> instance inherits the following accessor properties from its prototype:


<dl>
<dl>
Line 534: Line 536:
</dl>
</dl>


=== Properties of the Debug.Environment Prototype Object ===
=== Function Properties of the Debug.Environment Prototype Object ===


The methods described below may only be called with a <code>this</code> value referring to a <code>Debug.Environment</code> instance; they may not be used as methods of other kinds of objects.
The methods described below may only be called with a <code>this</code> value referring to a <code>Debug.Environment</code> instance; they may not be used as methods of other kinds of objects.
Confirmed users
497

edits

Navigation menu