Confirmed users
497
edits
(Let frame actors live as long as the frames to which they refer. Notify the client of each frame actor's demise.) |
(Simplify pause types, and make them more like the usual debugger 'next', 'step', 'continue', and 'finish'.) |
||
| Line 405: | Line 405: | ||
To attach to a thread, the client sends a packet of the form: | To attach to a thread, the client sends a packet of the form: | ||
{ "to":<i>thread</i>, "type":"attach" | { "to":<i>thread</i>, "type":"attach" } | ||
Here, <i>thread</i> is the actor representing the thread, perhaps a browsing context from a "list-contexts" reply. This | Here, <i>thread</i> is the actor representing the thread, perhaps a browsing context from a "list-contexts" reply. This packet causes the thread to pause its execution, if it does not exit of its own accord first. The thread responds in one of two ways: | ||
{ "from":<i>thread</i>, "type":"paused", "why":{ "type":"attached" }, ... } | |||
The thread is now in the <b>Paused</b> state, because the client has attached to it. The actor name <i>thread</i> remains valid until the client detaches from the thread or acknowledges a thread exit. This is an ordinary <code>"paused"</code> packet, whose form and additional properties are as described in [#Thread_Pauses|Thread Pauses], below. | |||
{ "from":<i>thread</i>, "type":"exited" } | { "from":<i>thread</i>, "type":"exited" } | ||
This indicates that the thread exited before receiving the | This indicates that the thread exited on its own before receiving the "attach" packet. The thread is now in the <b>Exited</b> state. The client should follow by sending a "release" packet; see [[#Exiting_Threads|Exiting Threads]], below. | ||
== Detaching From a Thread == | == Detaching From a Thread == | ||
| Line 480: | Line 478: | ||
<i>TODO: This should provide more details about the watchpoint in the packet, instead of incurring another round-trip before we can display anything helpful.</i> | <i>TODO: This should provide more details about the watchpoint in the packet, instead of incurring another round-trip before we can display anything helpful.</i> | ||
{ "type":" | { "type":"pause-for" } | ||
The client had asked the thread to | The client had asked the thread to resume, and the thread paused because the <i>pause-condition</i> given in the "resume" request was met. | ||
{ "type":"client-evaluated", "value":<i>grip</i> } | { "type":"client-evaluated", "value":<i>grip</i> } | ||
| Line 516: | Line 490: | ||
The client's prior <tt>client-evaluate</tt> command has completed abruptly; <i>grip</i> is the uncaught exception value. See [[#Evaluating_Source-Language_Expressions|Evaluating Source-Language Expressions]] for details. | The client's prior <tt>client-evaluate</tt> command has completed abruptly; <i>grip</i> is the uncaught exception value. See [[#Evaluating_Source-Language_Expressions|Evaluating Source-Language Expressions]] for details. | ||
{ "type":"attached" } | |||
The | The thread paused because the client attached to it. | ||
== Resuming a Thread == | |||
If a thread is in the <b>Paused</b> state, the client can resume it by sending a packet of the following form: | |||
{ "to":<i>thread</i>, "type":"resume", "pause-for":<i>pause-condition</i> } | |||
This puts the thread in the <b>Running</b> state. The thread will pause again for breakpoint hits, watchpoint hits, throw watches, frame pop watches, and other standing pause requests. | |||
In addition, if the optional <tt>pause-for</tt> property is present, then the thread should also pause if <i>pause-condition</i> is satisfied. <i>Pause-condition</i> must have one of the following forms: | |||
{ "type":"next" } | |||
The thread should pause: | |||
<ul> | |||
<li>just before the current frame is popped, whether by throwing an exception or returning a value; or | |||
<li>when control in the current frame reaches a different statement than the one it is currently at. | |||
</ul> | |||
Note that execution in frames younger than the current frame never meets this condition; a <tt>"next"</tt> steps over calls, generator-iterator invocations, and so on. | |||
{ "type":"step" } | |||
The thread should pause: | |||
<ul> | |||
<li>just before the current frame is popped, whether by throwing an exception or returning a value; or | |||
<li>just after a new frame is pushed; or | |||
<li>when control in the current frame reaches a different statement than the one it is currently | |||
at. | |||
</ul> | |||
This is the same as <tt>"next"</tt>, except that it steps into calls. | |||
{ "type":"finish" } | |||
The thread should pause just before the current frame is popped, whether by throwing an exception or returning a value. | |||
When a thread pauses because a <i>pause-condition</i> was met, the "paused" packet's <i>reason</i> will have a type of <tt>"pause-for"</tt>. | |||
A pause condition applies only to the current resumption; once the thread pauses, whether because the condition was met or some other event occurred—a breakpoint hit, for example—the pause condition is no longer in effect. | |||
If no <tt>"pause-for"</tt> property appears in the "resume" packet, then the thread should run until a standing pause request's conditions are satisfied (breakpoint, watchpoint, or the like). | |||
A "resume" packet closes the pause actor the client provided in the "paused" or "interrupted" packet that began the pause. | A "resume" packet closes the pause actor the client provided in the "paused" or "interrupted" packet that began the pause. | ||
| Line 701: | Line 680: | ||
To evaluate a source-language expression in a thread, the client sends a specialized <tt>resume</tt> packet of the form: | To evaluate a source-language expression in a thread, the client sends a specialized <tt>resume</tt> packet of the form: | ||
{ "to":<i>thread</i>, "type":"client-evaluate", "expression":<i>expr</i>, "frame":<i>frame | { "to":<i>thread</i>, "type":"client-evaluate", "expression":<i>expr</i>, "frame":<i>frame</i> } | ||
This resumes the thread just as an ordinary <tt>resume</tt> packet does, but rather than continuing execution where the pause took place, has the thread begin evaluation of the source-language expression given by <i>expr</i>, a string. The evaluation takes place in a new [[#Client_Evaluation_Frames|Client Evaluation Frame]], pushed on the stack. When evaluation of <i>expr</i> completes, the client will report a <tt>client-evaluate</tt> pause containing the expression's value. | This resumes the thread just as an ordinary <tt>resume</tt> packet does, but rather than continuing execution where the pause took place, has the thread begin evaluation of the source-language expression given by <i>expr</i>, a string. The evaluation takes place in a new [[#Client_Evaluation_Frames|Client Evaluation Frame]], pushed on the stack. When evaluation of <i>expr</i> completes, the client will report a <tt>client-evaluate</tt> pause containing the expression's value. | ||