Confirmed users
496
edits
(→Interacting with Thread-Like Actors: Add incomplete text on attaching, detaching, and running threads.) |
|||
Line 110: | Line 110: | ||
Note that the rules here apply to the client's interactions with each thread agent separately. A client may send an "interrupt" to one thread agent while awaiting a reply to a request sent to a different thread agent. | Note that the rules here apply to the client's interactions with each thread agent separately. A client may send an "interrupt" to one thread agent while awaiting a reply to a request sent to a different thread agent. | ||
== Attaching To a Thread == | |||
To attach to a thread, the client sends a packet of the form: | |||
{ "to":<i>thread</i>, "type":"attach" } | |||
The thread will respond in one of two ways: | |||
{ "from":<i>thread</i>, "type":"attached" } | |||
This indicates that the thread received the <tt>attach</tt> packet, and will continue to run, reporting events of interest to the debugger. The thread is now in the "Running" state. The actor name <i>thread</i> remains valid until the client detaches from the thread or acknowledges a thread exit. | |||
{ "from":<i>thread</i>, "type":"exited" } | |||
This indicates that the thread exited before receiving the <tt>attach</tt> packet. The thread is now in the "Exited" state. The client must respond with a packet of the form: | |||
{ "to":<i>thread</i>, "type":"release" } | |||
At this point, the actor name <i>thread</i> is released and available for reuse, so the last trace of the thread's existence is gone. | |||
== Detaching From a Thread == | |||
To detach from a thread, the client sends a packet of the form: | |||
{ "to":<i>thread</i>, "type":"detach" } | |||
The thread responds in one of three ways: | |||
{ "from":<i>thread</i>, "type":"detached" } | |||
This indicates that the client has detached from the thread. The thread is now in the "Detached" state: it can run freely, and no longer reports events to the client. The actor name <i>thread</i> is released and available for reuse. | |||
{ "from":<i>thread</i>, "type":"paused", ... } | |||
{ "from":<i>thread</i>, "type":"detached" } | |||
This series of packets indicates that the thread paused of its own accord (for some reason given by the additional properties of the first packet), and only then received the "detach" packet. As above, this indicates that the thread is in the "Detached" state, and the actor name is available for reuse. | |||
{ "from":<i>thread</i>, "type":"exited" } | |||
This indicates that the thread exited on its own before receiving the "detach" packet. The client should follow by sending a "release" packet, as described above. | |||
== Running Threads == | |||
Once the client has attached to a thread, it is in the "Running" state. In this state, three things can happen: | |||
* The thread can hit a breakpoint or watchpoint, or encounter some other condition of interest to the client. | |||
* The thread could exit. | |||
* The client could interrupt the running thread. | |||
Naturally, the third is not exclusive of the first two. The protocol is designed to avoid ambiguities when both client and thread act simultaneously. | |||
== Resuming a Thread == |