Remote Debugging Protocol: Difference between revisions

Jump to navigation Jump to search
Use property descriptors to describe bindings in environments. Separate arguments and variables. https://github.com/jimblandy/DebuggerDocs/commit/d72b346731108616ecb1453eb4c2dcffab8d0a00
(Revisions based on Panos's implementation notes. https://github.com/jimblandy/DebuggerDocs/commit/f2344f17e4f3aa2a99b6ab0702d782e09398e45d)
(Use property descriptors to describe bindings in environments. Separate arguments and variables. https://github.com/jimblandy/DebuggerDocs/commit/d72b346731108616ecb1453eb4c2dcffab8d0a00)
Line 825: Line 825:
<i>Actor</i> is the name of an actor representing this lexical environment. The requests it can answer are described below.
<i>Actor</i> is the name of an actor representing this lexical environment. The requests it can answer are described below.


<i>ParentEnvironment</i> describes the next enclosing lexical environment; the <tt>parent</tt> property is omitted on the outermost environment.
<i>ParentEnvironment</i> is a lexical environment describing the next enclosing environment; the <tt>parent</tt> property is omitted on the outermost environment.


   { "type":"function", "actor":<i>actor</i>, "function":<i>function</i>, "functionName":<i>functionName</i>,
   { "type":"function", "actor":<i>actor</i>, "function":<i>function</i>, "functionName":<i>functionName</i>,
Line 834: Line 834:
   { "type":"with", "actor":<i>actor</i>, "object":<i>object</i>, "parent":<i>parentEnvironment</i> }
   { "type":"with", "actor":<i>actor</i>, "object":<i>object</i>, "parent":<i>parentEnvironment</i> }


This represents bindings introduced by a <tt>with</tt> statement whose operand is <i>object</i> (a grip). The other properties are as described above.
This represents an environment introduced by a <tt>with</tt> statement whose operand is <i>object</i> (a grip). The other properties are as described above.


   { "type":"block", "actor":<i>actor</i>, "bindings":<i>bindings</i>, "parent":<i>parentEnvironment</i> }
   { "type":"block", "actor":<i>actor</i>, "bindings":<i>bindings</i>, "parent":<i>parentEnvironment</i> }


This represents bindings introduced by a <tt>let</tt> block, <tt>for-in</tt> statement, <tt>catch</tt> block, or the like. The properties are as described above.
This represents an environment introduced by a <tt>let</tt> block, <tt>for-in</tt> statement, <tt>catch</tt> block, or the like. The properties are as described above.


A <i>bindings</i> value has the form:
A <i>bindings</i> value has the form:


   { "mutable":{ <i>name</i>:<i>value</i>, ... },
   { "arguments":[ { <i>name</i>:<i>descriptor</i> }, ... ],
     "immutable":{ <i>name</i>:<i>value</i>, ... } }
     "variables":{ <i>name</i>:<i>descriptor</i>, ... } }


where each <i>name</i> is the name of a bound identifier, and each <i>value</i> is a grip on that identifier's value. Mutable bindings appear in the <tt>mutable</tt> object, and immutable bindings appear in the <tt>immutable</tt> object. If either category has no bindings, the property may be omitted entirely.
Each <i>name</i> is the name of a bound identifier, as a string. Each <i>descriptor</i> is a [[#Property_Descriptors|property descriptor]] for the variable, presenting the variable's value as the descriptor's <tt>"value"</tt> property, and the variable's mutability as the descriptor's <tt>"writable"</tt> property. The descriptor's <tt>"configurable"</tt> property reflects whether the environment supports deleting and adding variables. Each descriptor's <tt>"enumerable"</tt> property is <tt>true</tt>.


<i>TODO: Should we segregate function arguments in bindings values, in case clients want to display them separately? They should appear in order...</i>
The <tt>"arguments"</tt> list appears only in bindings for <tt>"function"</tt> environments. It lists the arguments in the order they appear in the function's definition. (The same name may appear several times in the list, as permitted by JavaScript; the name's last appearance is the one in scope in the function.)


Note that language implementations may omit some environment records from a function's scope if it can determine that the function would not use them. This means that it may be impossible for a debugger to find all the variables that ought to be in scope.
Note that language implementations may omit some environment records from a function's scope if it can determine that the function would not use them. This means that it may be impossible for a debugger to find all the variables that ought to be in scope.
Line 877: Line 877:
   function f(x) {
   function f(x) {
     function g(y) {
     function g(y) {
      var z = "value of z";
       alert(x + y);
       alert(x + y);
     }
     }
Line 894: Line 895:
                               "function":{ "type":"object", "class":"Function", "actor":<i>gActor</i> },
                               "function":{ "type":"object", "class":"Function", "actor":<i>gActor</i> },
                               "functionName":"g",
                               "functionName":"g",
                               "bindings":{ "mutable":{ "y":"argument to g" } },
                               "bindings":{ arguments: [ { "y": { "value":"argument to g", "configurable":"false",
                                                                "writable":true, "enumerable":true } } ] },
                               "parent":{ "type":"function", "actor":<i>fFrameActor</i>,
                               "parent":{ "type":"function", "actor":<i>fFrameActor</i>,
                                         "function":{ "type":"object", "class":"Function", "actor":<i>fActor</i> },
                                         "function":{ "type":"object", "class":"Function", "actor":<i>fActor</i> },
                                         "functionName":"f",
                                         "functionName":"f",
                                         "bindings":{ "mutable":{ "x":"argument to f" } },
                                         "bindings": { arguments: [ { "x": { "value":"argument to f", "configurable":"false",
                                                                      "writable":true, "enumerable":true } } ],
                                                      variables: { "z": { "value":"value of z", "configurable":"false",
                                                                          "writable":true, "enumerable":true } } },
                                         "parent":{ "type":"object", "actor":<i>globalCodeActor</i>,
                                         "parent":{ "type":"object", "actor":<i>globalCodeActor</i>,
                                                     "object":{ "type":"object", "class":"Global",
                                                     "object":{ "type":"object", "class":"Global",
Confirmed users
496

edits

Navigation menu