OLD | NEW |
1 # Dart VM Service Protocol 2.0 | 1 # Dart VM Service Protocol 3.0 |
2 | 2 |
3 > Please post feedback to the [observatory-discuss group][discuss-list] | 3 > Please post feedback to the [observatory-discuss group][discuss-list] |
4 | 4 |
5 This document describes of _version 2.0_ of the Dart VM Service Protocol. This | 5 This document describes of _version 3.0_ of the Dart VM Service Protocol. This |
6 protocol is used to communicate with a running Dart Virtual Machine. | 6 protocol is used to communicate with a running Dart Virtual Machine. |
7 | 7 |
8 To use the Service Protocol, start the VM with the *--observe* flag. | 8 To use the Service Protocol, start the VM with the *--observe* flag. |
9 The VM will start a webserver which services protocol requests via WebSocket. | 9 The VM will start a webserver which services protocol requests via WebSocket. |
10 It is possible to make HTTP (non-WebSocket) requests, | 10 It is possible to make HTTP (non-WebSocket) requests, |
11 but this does not allow access to VM _events_ and is not documented | 11 but this does not allow access to VM _events_ and is not documented |
12 here. | 12 here. |
13 | 13 |
14 The Service Protocol uses [JSON-RPC 2.0][]. | 14 The Service Protocol uses [JSON-RPC 2.0][]. |
15 | 15 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 - [Frame](#frame) | 61 - [Frame](#frame) |
62 - [Function](#function) | 62 - [Function](#function) |
63 - [Instance](#instance) | 63 - [Instance](#instance) |
64 - [Isolate](#isolate) | 64 - [Isolate](#isolate) |
65 - [Library](#library) | 65 - [Library](#library) |
66 - [LibraryDependency](#librarydependency) | 66 - [LibraryDependency](#librarydependency) |
67 - [MapAssociation](#mapassociation) | 67 - [MapAssociation](#mapassociation) |
68 - [Message](#message) | 68 - [Message](#message) |
69 - [Null](#null) | 69 - [Null](#null) |
70 - [Object](#object) | 70 - [Object](#object) |
| 71 - [Response](#response) |
71 - [Sentinel](#sentinel) | 72 - [Sentinel](#sentinel) |
72 - [SentinelKind](#sentinelkind) | 73 - [SentinelKind](#sentinelkind) |
73 - [Script](#script) | 74 - [Script](#script) |
74 - [SourceLocation](#sourcelocation) | 75 - [SourceLocation](#sourcelocation) |
75 - [Stack](#stack) | 76 - [Stack](#stack) |
76 - [StepOption](#stepoption) | 77 - [StepOption](#stepoption) |
77 - [Success](#success) | 78 - [Success](#success) |
78 - [TypeArguments](#typearguments) | 79 - [TypeArguments](#typearguments) |
79 » - [Response](#response) | 80 » - [UresolvedSourceLocation](#unresolvedsourcelocation) |
80 - [Version](#version) | 81 - [Version](#version) |
81 - [VM](#vm) | 82 - [VM](#vm) |
82 - [Revision History](#revision-history) | 83 - [Revision History](#revision-history) |
83 | 84 |
84 ## RPCs, Requests, and Responses | 85 ## RPCs, Requests, and Responses |
85 | 86 |
86 An RPC request is a JSON object sent to the server. Here is an | 87 An RPC request is a JSON object sent to the server. Here is an |
87 example [getVersion](#getversion) request: | 88 example [getVersion](#getversion) request: |
88 | 89 |
89 ``` | 90 ``` |
(...skipping 12 matching lines...) Expand all Loading... |
102 _id_ property to pair it with the corresponding request. If the RPC | 103 _id_ property to pair it with the corresponding request. If the RPC |
103 was successful, the _result_ property provides the result. | 104 was successful, the _result_ property provides the result. |
104 | 105 |
105 Here is an example response for our [getVersion](#getversion) request above: | 106 Here is an example response for our [getVersion](#getversion) request above: |
106 | 107 |
107 ``` | 108 ``` |
108 { | 109 { |
109 "jsonrpc": "2.0", | 110 "jsonrpc": "2.0", |
110 "result": { | 111 "result": { |
111 "type": "Version", | 112 "type": "Version", |
112 "major": 2, | 113 "major": 3, |
113 "minor": 0 | 114 "minor": 0 |
114 } | 115 } |
115 "id": "1" | 116 "id": "1" |
116 } | 117 } |
117 ``` | 118 ``` |
118 | 119 |
119 Parameters for RPC requests are always provided as _named_ parameters. | 120 Parameters for RPC requests are always provided as _named_ parameters. |
120 The JSON-RPC spec provides for _positional_ parameters as well, but they | 121 The JSON-RPC spec provides for _positional_ parameters as well, but they |
121 are not supported by the Dart VM. | 122 are not supported by the Dart VM. |
122 | 123 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 293 |
293 ## Versioning | 294 ## Versioning |
294 | 295 |
295 The [getVersion](#getversion) RPC can be used to find the version of the protoco
l | 296 The [getVersion](#getversion) RPC can be used to find the version of the protoco
l |
296 returned by a VM. The _Version_ response has a major and a minor | 297 returned by a VM. The _Version_ response has a major and a minor |
297 version number: | 298 version number: |
298 | 299 |
299 ``` | 300 ``` |
300 "result": { | 301 "result": { |
301 "type": "Version", | 302 "type": "Version", |
302 "major": 2, | 303 "major": 3, |
303 "minor": 0 | 304 "minor": 0 |
304 } | 305 } |
305 ``` | 306 ``` |
306 | 307 |
307 The major version number is incremented when the protocol is changed | 308 The major version number is incremented when the protocol is changed |
308 in a potentially _incompatible_ way. An example of an incompatible | 309 in a potentially _incompatible_ way. An example of an incompatible |
309 change is removing a non-optional property from a result. | 310 change is removing a non-optional property from a result. |
310 | 311 |
311 The minor version number is incremented when the protocol is changed | 312 The minor version number is incremented when the protocol is changed |
312 in a _backwards compatible_ way. An example of a backwards compatible | 313 in a _backwards compatible_ way. An example of a backwards compatible |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ReturnType methodName(parameterType parameterName [optional) | 365 ReturnType methodName(parameterType parameterName [optional) |
365 ``` | 366 ``` |
366 | 367 |
367 A description of the return types and parameter types is provided | 368 A description of the return types and parameter types is provided |
368 in the section on [public types](#public-types). | 369 in the section on [public types](#public-types). |
369 | 370 |
370 ### addBreakpoint | 371 ### addBreakpoint |
371 | 372 |
372 ``` | 373 ``` |
373 Breakpoint addBreakpoint(string isolateId, | 374 Breakpoint addBreakpoint(string isolateId, |
374 string scriptId, | 375 string scriptId [optional], |
375 int line) | 376 string scriptUri [optional], |
| 377 int line, |
| 378 int column [optional]) |
376 ``` | 379 ``` |
377 | 380 |
378 The _addBreakpoint_ RPC is used to add a breakpoint at a specific line | 381 The _addBreakpoint_ RPC is used to add a breakpoint at a specific line |
379 of some script. | 382 of some script. |
380 | 383 |
| 384 The _scriptId_ or _scriptUri_ parameter is used to specify the target |
| 385 script. One of these two parameters must always be provided. |
| 386 |
| 387 The _line_ parameter is used to specify the target line for the |
| 388 breakpoint. If there are multiple possible breakpoints on the target |
| 389 line, then the VM will place the breakpoint at the location which |
| 390 would execute soonest. If it is not possible to set a breakpoint at |
| 391 the target line, the breakpoint will be added at the next possible |
| 392 breakpoint location within the same function. |
| 393 |
| 394 The _column_ parameter may be optionally specified. This is useful |
| 395 for targeting a specific breakpoint on a line with multiple possible |
| 396 breakpoints. |
| 397 |
381 If no breakpoint is possible at that line, the _102_ (Cannot add | 398 If no breakpoint is possible at that line, the _102_ (Cannot add |
382 breakpoint) error code is returned. | 399 breakpoint) error code is returned. |
383 | 400 |
384 Note that breakpoints are added and removed on a per-isolate basis. | 401 Note that breakpoints are added and removed on a per-isolate basis. |
385 | 402 |
386 See [Breakpoint](#breakpoint). | 403 See [Breakpoint](#breakpoint). |
387 | 404 |
388 ### addBreakpointAtEntry | 405 ### addBreakpointAtEntry |
389 | 406 |
390 ``` | 407 ``` |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 769 |
753 If the variable has been optimized out by the compiler, the _value_ | 770 If the variable has been optimized out by the compiler, the _value_ |
754 will be the _OptimizedOut_ [Sentinel](#sentinel). | 771 will be the _OptimizedOut_ [Sentinel](#sentinel). |
755 | 772 |
756 ### Breakpoint | 773 ### Breakpoint |
757 | 774 |
758 ``` | 775 ``` |
759 class Breakpoint extends Object { | 776 class Breakpoint extends Object { |
760 int breakpointNumber; | 777 int breakpointNumber; |
761 bool resolved; | 778 bool resolved; |
762 SourceLocation location; | 779 SourceLocation|UnresolvedSourceLocation location; |
763 } | 780 } |
764 ``` | 781 ``` |
765 | 782 |
766 A _Breakpoint_ describes a debugger breakpoint. | 783 A _Breakpoint_ describes a debugger breakpoint. |
767 | 784 |
768 ### Class | 785 ### Class |
769 | 786 |
770 ``` | 787 ``` |
771 class @Class extends @Object { | 788 class @Class extends @Object { |
772 // The name of this class. | 789 // The name of this class. |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 // | 1797 // |
1781 // Note that the size can be zero for some objects. In the current | 1798 // Note that the size can be zero for some objects. In the current |
1782 // VM implementation, this occurs for small integers, which are | 1799 // VM implementation, this occurs for small integers, which are |
1783 // stored entirely within their object pointers. | 1800 // stored entirely within their object pointers. |
1784 int size [optional]; | 1801 int size [optional]; |
1785 } | 1802 } |
1786 ``` | 1803 ``` |
1787 | 1804 |
1788 An _Object_ is a persistent object that is owned by some isolate. | 1805 An _Object_ is a persistent object that is owned by some isolate. |
1789 | 1806 |
| 1807 ### Response |
| 1808 |
| 1809 ``` |
| 1810 class Response { |
| 1811 // Every response returned by the VM Service has the |
| 1812 // type property. This allows the client distinguish |
| 1813 // between different kinds of responses. |
| 1814 string type; |
| 1815 } |
| 1816 ``` |
| 1817 |
| 1818 Every non-error response returned by the Service Protocol extends _Response_. |
| 1819 By using the _type_ property, the client can determine which [type](#types) |
| 1820 of response has been provided. |
| 1821 |
1790 ### Sentinel | 1822 ### Sentinel |
1791 | 1823 |
1792 ``` | 1824 ``` |
1793 class Sentinel extends Response { | 1825 class Sentinel extends Response { |
1794 // What kind of sentinel is this? | 1826 // What kind of sentinel is this? |
1795 SentinelKind kind; | 1827 SentinelKind kind; |
1796 | 1828 |
1797 // A reasonable string representation of this sentinel. | 1829 // A reasonable string representation of this sentinel. |
1798 string valueAsString; | 1830 string valueAsString; |
1799 } | 1831 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 // | 1980 // |
1949 // The value will always be one of the kinds: | 1981 // The value will always be one of the kinds: |
1950 // Type, TypeRef, TypeParameter, BoundedType. | 1982 // Type, TypeRef, TypeParameter, BoundedType. |
1951 @Instance[] types; | 1983 @Instance[] types; |
1952 } | 1984 } |
1953 ``` | 1985 ``` |
1954 | 1986 |
1955 A _TypeArguments_ object represents the type argument vector for some | 1987 A _TypeArguments_ object represents the type argument vector for some |
1956 instantiated generic type. | 1988 instantiated generic type. |
1957 | 1989 |
1958 ### Response | 1990 ### UnresolvedSourceLocation |
1959 | 1991 |
1960 ``` | 1992 ``` |
1961 class Response { | 1993 class UnresolvedSourceLocation extends Response { |
1962 // Every response returned by the VM Service has the | 1994 // The script containing the source location if the script has been loaded. |
1963 // type property. This allows the client distinguish | 1995 @Script script [optional]; |
1964 // between different kinds of responses. | 1996 |
1965 string type; | 1997 // The uri of the script containing the source location if the script |
| 1998 // has yet to be loaded. |
| 1999 string scriptUri [optional]; |
| 2000 |
| 2001 // An approximate token position for the source location. This may |
| 2002 // change when the location is resolved. |
| 2003 int tokenPos [optional]; |
| 2004 |
| 2005 // An approximate line number for the source location. This may |
| 2006 // change when the location is resolved. |
| 2007 int line [optional]; |
| 2008 |
| 2009 // An approximate column number for the source location. This may |
| 2010 // change when the location is resolved. |
| 2011 int column [optional]; |
| 2012 |
1966 } | 2013 } |
1967 ``` | 2014 ``` |
1968 | 2015 |
1969 Every non-error response returned by the Service Protocol extends _Response_. | 2016 The _UnresolvedSourceLocation_ class is used to refer to an unresolved |
1970 By using the _type_ property, the client can determine which [type](#types) | 2017 breakpoint location. As such, it is meant to approximate the final |
1971 of response has been provided. | 2018 location of the breakpoint but it is not exact. |
| 2019 |
| 2020 Either the _script_ or the _scriptUri_ field will be present. |
| 2021 |
| 2022 Either the _tokenPos_ or the _line_ field will be present. |
| 2023 |
| 2024 The _column_ field will only be present when the breakpoint was |
| 2025 specified with a specific column number. |
1972 | 2026 |
1973 ### Version | 2027 ### Version |
1974 | 2028 |
1975 ``` | 2029 ``` |
1976 class Version extends Response { | 2030 class Version extends Response { |
1977 // The major version number is incremented when the protocol is changed | 2031 // The major version number is incremented when the protocol is changed |
1978 // in a potentially incompatible way. | 2032 // in a potentially incompatible way. |
1979 int major; | 2033 int major; |
1980 | 2034 |
1981 // The minor version number is incremented when the protocol is changed | 2035 // The minor version number is incremented when the protocol is changed |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 // A list of isolates running in the VM. | 2067 // A list of isolates running in the VM. |
2014 @Isolate[] isolates; | 2068 @Isolate[] isolates; |
2015 } | 2069 } |
2016 ``` | 2070 ``` |
2017 | 2071 |
2018 ## Revision History | 2072 ## Revision History |
2019 | 2073 |
2020 version | comments | 2074 version | comments |
2021 ------- | -------- | 2075 ------- | -------- |
2022 1.0 draft 1 | initial revision | 2076 1.0 draft 1 | initial revision |
| 2077 1.1 | Describe protocol version 2.0. |
| 2078 1.2 | Describe protocol version 3.0. Added UnresolvedSourceLocation. |
2023 | 2079 |
2024 | 2080 |
2025 [discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observato
ry-discuss | 2081 [discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observato
ry-discuss |
OLD | NEW |