Confirmed users
497
edits
(Add link to discussion bug.) |
(→Debug.Object: Work in progress.) |
||
| Line 195: | Line 195: | ||
When you use the <code>Debug</code> object to inspect a program that is running a generator frame, that frame appears on the stack like any other call frame, except that its <code>generator</code> property is <code>true</code>. Such a frame will disappear from the stack when it is suspended, and reappear (possibly with a different <code>older</code> frame and <code>depth</code> value) each time it is resumed. | When you use the <code>Debug</code> object to inspect a program that is running a generator frame, that frame appears on the stack like any other call frame, except that its <code>generator</code> property is <code>true</code>. Such a frame will disappear from the stack when it is suspended, and reappear (possibly with a different <code>older</code> frame and <code>depth</code> value) each time it is resumed. | ||
==Debug. | == Debug.Object== | ||
A <code>Debug.Object</code> instance represents an object in the debuggee. Debugger code never accesses debuggee objects directly; instead, it works with <code>Debug.Object</code> instances that refer to the debuggee objects. SpiderMonkey's compartment system ensures that this separation is respected. | |||
A <code>Debug.Object</code> instance has reflection-oriented methods to inspect and modify its referent. The referent's properties do not appear directly as properties of the <code>Debug.Object</code> instance; the debugger can access them only through methods like <code>Debug.Object.prototype.getOwnPropertyDescriptor</code> and <code>Debug.Object.prototype.defineProperty</code>, ensuring that the debugger will not inadvertently invoke the referent's getters and setters. | |||
SpiderMonkey creates exactly one <code>Debug.Object</code> instance for each debuggee object it presents to the debugger: if the debugger encounters the same object through two different routes (perhaps two functions are called on the same object), SpiderMonkey presents the same <code>Debug.Object</code> instance to the debugger each time. This means that the debugger can use the <code>==</code> operator to recognize when two <code>Debug.Object</code> instances refer to the same debuggee object, and place its own properties on <code>Debug.Object</code> instances and find them later reliably. | |||
<code>Debug.Object</code> instances protect their referents from the garbage collector; as long as the <code>Debug.Object</code> instance is live, the referent remains live. Garbage collection has no debugger-visible effect. | |||
While most <code>Debug.Object</code> instances are created by SpiderMonkey in the process of exposing debuggee's behavior and state to the debugger, the debugger can apply the <code>Debug.Object</code> constructor to its own objects, to copy them into the debuggee; see the description of the <code>Debug.Object</code> constructor below. | |||
=== The <code>Debug.Object</code> constructor === | |||
When called via a <code>new</code> expression, the <code>Debug.Object</code> constructor takes one argument, an object in the debugger's compartment, and applies the HTML5 "structured cloning" algorithm to copy the object into the debuggee's compartment. It then returns a <code>Debug.Object</code> instance referring to the copy. It is an error to apply <code>Debug.Object</code> to a primitive value via a <code>new</code> expression. | |||
When applied as a function, <code>Debug.Object</code> behaves as above, except that primitive values are returned unchanged (although possibly wrapped, in an ordinary cross-compartment wrapper). (This allows the debugger to use <code>Debug.Object</code> as a generic "debugger value to debuggee value" conversion function.) | |||
=== Properties of the <code>Debug.Object</code> constructor === | |||
<i>create(O, [,Properties])</i> | |||
=== Properties of the <code>Debug.Object</code> prototype === | |||
<i>getPrototype</i> | |||
<i>getOwnPropertyDescriptor</i> | |||
<i>getOwnPropertyNames</i> | |||
<i>defineProperty</i> | |||
<i>defineProperties</i> | |||
<i>seal</i> | |||
<i>freeze</i> | |||
<i>preventExtensions</i> | |||
<i>isSealed</i> | |||
<i>isFrozen</i> | |||
<i>isExtensible</i> | |||
<i>safeToString</i> | |||
== Debug.Object== | == Debug.Object== | ||
strong reference | strong reference | ||