# Dart VM Service Protocol
NOTE: The service api is still changing rapidly. If you use the
service api, expect to encounter non-compatible changes.
Description
How to start
JSON
Websocket
## Types
Every response returned by the VM Service has the type
property. This allows the client distinguish between different kinds
of responses. For example, global information about the VM is encoded
in an response of type [VM](#VM) and information about an isolate is
encoded in an response of type [Isolate](#Isolate).
If the type name of a response begins with an @ character
then that response is a _reference_. If the type name of a response
does not begin with an @ character then that response is
an _object_ (or sometimes _full object_). A reference is meant to be
a subset of a full object with just enough information for the client
to generate a reasonable-looking link.
For example, an isolate reference may look like this...
{
type: "@Isolate",
id: "isolates/123",
name: "worker"
}
... and a full isolate object would have additional properties:
{
type: "Isolate",
id: "isolates/123",
name: "worker"
entry: ...
heaps: ...
topFrame: ...
...
}
## Type Hierarchy
The types returned by the VM Service fit into a type hierarchy, with a
subtyping relationship as indicated by the following indented list:
Object
ClassHeapStats
Class
Code
Context
Counter
Error
Field
FrameVar
Frame
Function
Gauge
Instance
AbstractType
BoundedType
TypeParameter
TypeRef
Type
List
Sentinel // TODO - subtype of Instance or not?
String
bool
double
int
null
Isolate
Library
Location
Script
ServiceError
ServiceEvent
Socket
TypeArguments // TODO - expose?
VM
TODO: How to put links in a pre in markdown?
A subtype is guaranteed to provide all of the properties of its
parent type. For example, an [int](#int) can be used as an
[Instance](#Instance).
The subtyping relationship also holds for reference types. For
example, [@int](#int) can be used as an [@Instance](#Instance).
## IDs
Most responses returned by the VM Service have an id
property. An id is used to request an object from the VM. Each id is
unique; that is to say, If two responses have the same id, they refer
to the same object. The converse is not true: the same object may
occasionally be returned with two different ids.
An id is either _global_ or _relative_. Global ids can be requested
from the VM directly by requesting the uri /{global id}.
The following is a list of known, fixed global ids:
| id | uri | type
| --- | --- | ---
| vm | /vm | [VM](#VM)
| flags | /flags | [FlagList](#FlagList)
In addition, all isolates have global ids, but these ids are
dynamically generated. An isolate with an id like
isolates/123 would be available at the uri
/isolates/123.
Relative ids are used to refer to objects that are owned by an
isolate. Relative ids can be requested from the VM directly by
requesting the uri /{isolate id}/{relative id}.
For example, we can get information about a class with id
classes/Foo from isolate isolates/123 by
requesting the uri /isolates/123/classes/Foo from the VM.
The client must not parse ids -- they must be treated as opaque
strings. We reserve the right to change the ids of objects.
## Names
Many responses have the name property. Names are
provided so that objects can be displayed in a way that a Dart
language programmer would find sensible.
Note that names are not in any way unique. Many objects will have the
same name.
## Private Properties
Some properties returned by the VM Service begin with an underscore
(_) character. These properties are called _private
properties_. Private properties provide private information about the
VM's implementation. Private properties may be added, removed, or
changed at any time with any release of the VM. They are provided for
those tools that need this level of internal access, such as the
Observatory.
For example, some responses will have the _vmType
property. This provides the VM-internal type name of an object, and
is provided only when this type name differs from the
type property.
## Events
TODO
## Catalog of Types
### AbstractType
### Breakpoint
TODO: Get rid of Location or else use it more generally.
Object properties:
| keys | values | comments
| --- | --- | ---
| type | "Breakpoint" |
| id | String |
| breakpointNumber | int |
| enabled | bool |
| resolved | bool |
| location | [Location](#Location) |
### Class
Reference properties:
| keys | values | comments
| --- | --- | ---
| type | "@Class", "Class" |
| id | String |
| name | String |
| _vmName? | String |
Object properties:
| keys | values | comments
| --- | --- | ---
| error? | [Error](#Error) | Error encountered during class finalization
| implemented | bool |
| abstract | bool |
| patch | bool |
| finalized | bool |
| const | bool |
| super? | [@Class](#Class) | Super class
| library | [@Library](#Library) | Owning library
| script? | [@Script](#Script) | Script containing class source
| tokenPos? | int | starting token position of class source in script
| endTokenPos? | int | end token position of class source in script
| interfaces | List of [@Class](#Class) | interfaces this class has implemented
| fields | List of [@Field](#Field) |
| functions | List of [@Function](#Function) |
| subclasses | List of [@Class](#Class) | classes which extend this class.
| canonicalTypes | [@TypeList] | kill?
| allocationStats | ClassHeapStats |
### ClassHeapStats
Object properties:
| keys | values | comments
| --- | --- | ---
| type | "ClassHeapStats" |
| id | String |
| class | [@Class](#Class) |
| new | List of int | Allocation statistics for new space. See note below on allocation statistics list format.
| old | List of int | Allocation statistics for old space. See note below on allocation statistics list format.
| promotedInstances | int | number of instances promoted at last new-space GC.
| promotedBytes | int | number of bytes promoted at last new-space GC.
*Allocation statistics list format*
| index | value | description
| --- | --- | --- |
| 0 | int | Instances allocated before last GC |
| 1 | int | Bytes allocated before last GC |
| 2 | int | Instances alive after last GC |
| 3 | int | Bytes alive after last GC |
| 4 | int | Instances allocated since last GC |
| 5 | int | Bytes allocated since last GC |
| 6 | int | Instances allocated since last accumulator reset |
| 7 | int | Bytes allocated since last accumulator reset |
### Code
Reference properties:
| keys | values | comments
| --- | --- | ---
| type | "@Code", "Code"|
| id | String |
| name | String |
| _vmName? | String |
| start | String | starting address of code
| end | String | ending address of code
| isOptimized | bool |
| isAlive | bool |
| kind | String
| function | [@Function](#Function) |
Object properties:
| keys | values | comments
| --- | --- | ---
| start | String | starting address of code
| end | String | ending address of code
| isOptimized | bool |
| isAlive | bool |
| kind | String
| function | [@Function](#Function) |
| object_pool | List of [@Object](#Object) |
| disassembly | List of String | See note below on disassembly list format
*Disassembly list format*
| index | value | description
| --- | --- | --- |
| 0 | String | Address of instruction
| 1 | String | Hex encoding of instruction
| 2 | String | Human encoding of instruction
| 0 + (3 * K) | String | Address of Kth instruction
| 1 + (3 * K) | String | Hex encoding of instruction of Kth instruction
| 2 + (3 * K) | String | Human encoding of instruction of Kth instruction
### Error
TODO: Drop id from Error.