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 and information about an isolate is encoded in an response of type 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:

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 can be used as an Instance.

The subtyping relationship also holds for reference types. For example, @int can be used as an @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:

iduritype
vm/vmVM
flags/flagsFlagList

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 nnnproperty. 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:

keysvaluescomments
type“Breakpoint”
idString
breakpointNumberint
enabledbool
resolvedbool
locationLocation

Class

Reference properties:

keysvaluescomments
type“@Class”, “Class”
idString
nameString
_vmName?String

Object properties:

keysvaluescomments
error?ErrorError encountered during class finalization
implementedbool
abstractbool
patchbool
finalizedbool
constbool
super?@ClassSuper class
library@LibraryOwning library
script?@ScriptScript containing class source
tokenPos?intstarting token position of class source in script
endTokenPos?intend token position of class source in script
interfacesList of @Classinterfaces this class has implemented
fieldsList of @Field
functionsList of @Function
subclassesList of @Classclasses which extend this class.
canonicalTypes[@TypeList]kill?
allocationStatsClassHeapStats

ClassHeapStats

Object properties:

keysvaluescomments
type“ClassHeapStats”
idString
class@Class
newList of intAllocation statistics for new space. See note below on allocation statistics list format.
oldList of intAllocation statistics for old space. See note below on allocation statistics list format.
promotedInstancesintnumber of instances promoted at last new-space GC.
promotedBytesintnumber of bytes promoted at last new-space GC.

Allocation statistics list format

indexvaluedescription
0intInstances allocated before last GC
1intBytes allocated before last GC
2intInstances alive after last GC
3intBytes alive after last GC
4intInstances allocated since last GC
5intBytes allocated since last GC
6intInstances allocated since last accumulator reset
7intBytes allocated since last accumulator reset

Code

Reference properties:

keysvaluescomments
type“@Code”, “Code”
idString
nameString
_vmName?String
startStringstarting address of code
endStringending address of code
isOptimizedbool
isAlivebool
kindString
function@Function

Object properties:

keysvaluescomments
startStringstarting address of code
endStringending address of code
isOptimizedbool
isAlivebool
kindString
function@Function
object_poolList of @Object
disassemblyList of StringSee note below on disassembly list format

Disassembly list format

indexvaluedescription
0StringAddress of instruction
1StringHex encoding of instruction
2StringHuman encoding of instruction
0 + (3 * K)StringAddress of Kth instruction
1 + (3 * K)StringHex encoding of instruction of Kth instruction
2 + (3 * K)StringHuman encoding of instruction of Kth instruction

Error

TODO: Drop id from Error.

Object properties:

keysvaluescomments
type“Error”
_vmType?StringVM internal name for this type. Provided only when different from ‘type’
idStringalways empty
kindString
messageString

Field

Reference properties:

keysvaluescomments
type“@Field”, “Field”
idString
nameString
_vmName?String
value?Instancevalue associated with static field <-- do we want to include this in a field reference?
owner@Library,@ClassOwning library or class <-- handling of owner is inconsistent with Function
declared_type@AbstractType
staticbool
finalbool
constbool

Object properties:

keysvaluescomments
guard_nullableboolcan this field hold a null?
guard_classString OR @Class“unknown”, “dynamic”, or a class
guard_lengthString OR int“unknown”, “variable”, or length of array
script?@ScriptScript containing field source
tokenPos?intstarting token position of field source in script

Frame

TODO: Add type and id?

Object properties:

keysvaluescomments
script@Script
tokenPosint
function@Function
code@Code
varsList of FrameVar

FrameVar

Object properties:

keysvaluescomments
nameString
value@Instance

Function

Reference properties:

keysvaluescomments
type“@Function”, “Function”
idString
nameString
_vmName?String
owningLibrary?@LibrarySet for non-top level functions
owningClass?@ClassSet for non-top level functions
parent?@FunctionParent function
kindString

Object properties:

keysvaluescomments
staticboolTODO: not consistent with Field
constbool
optimizablebool
inlinablebool
usage_counterint
optimized_call_site_countint
deoptimizationsint
script?@ScriptScript containing function source
tokenPos?intstarting token position of function source in script
endTokenPos?intend token position of function source in script
unoptimized_code@Code
code@CodeCurrent code

Isolate

Reference properties:

keysvaluescomments
type“@Isolate”, “Isolate”
idString
mainPortStringkill?
nameString

Object properties:

keysvaluescomments
entry?@Function
heaps???
topFrame?Frame
livePortsint
pauseOnExitbool
pauseEvent?DebuggerEvent
rootLib@Library
timers???
tagCounters???
error?Error
canonicalTypeArgumentskill?
libsList of @Library
featuresList of String

Library

Reference properties:

keysvaluescomments
type“@Library”, “Library”
idString
nameString
_vmName?StringVM-internal name. Provided only when different from ‘name’.
urlString

Object properties:

keysvaluescomments
classesList of @Class
importsList of @Library
variablesList of ...
functionsList of @Function
scriptsList of @Script

Location

Object properties:

keysvaluescomments
type“Location”
script@Script
tokenPosint

null

Reference properties:

keysvaluescomments
type“@null”, “null”
idString
valueAsStringString

Object properties:

TODO.

Object

Object is the supertype of all responses returned by the VM Service. It does not necessarily refer to an Object at the Dart language level (see Instance).

Reference properties:

keysvaluescomments
type“@Object”, “Object” or subtype
_vmType?StringVM internal name for this type. Provided only when different from ‘type’
idString

Object properties: none

PcDescriptor

Script

Reference properties:

| keys | values | comments | example | | --- | --- | --- | type | “@Script”, “Script” | | id | String | name | String | _vmName? | String | VM-internal name. Provided only when different from ‘name’. | kind | String

Object properties:

keysvaluescomments
owningLibrary@Library
sourceString
tokenPosTableList of list of int. See note below about token line format.

Token line format

indexvaluecomments
0intline number
1intfirst token position
2intfirst column number
.........
1 + (2 * k)intkth token position
2 + (2 * k)intkth column number

Sentinel

TODO: Enumerate known Sentinels
TODO: Should this even have an id? Maybe a kind instead.

Object properties:

keysvaluescomments
type“Sentinel”
idString
valueAsStringString

ServiceEvent

Object properties:

keysvaluescomments
type“ServiceEvent”
idStringTODO: Remove
eventTypeString“BreakpointReached”, “BreakpointResolved”, “ExceptionThrown”, “IsolateCreated”, “IsolateShutdown”, “IsolateInterrupted”
isolate@Isolate
breakpoint?Breakpointfor eventTypes “BreakpointResolved” and "BreakpointReached

TODO: Maybe make this @Breakpoint?
exception?@Instancefor eventType “ExceptionThrown”

VM

Object properties:

keysvaluescomments
type“VM”
idString
targetCPUString
hostCPUString
dateStringkill?
versionString
pidint
assertsEnabledboolTODO: move to features?
typeChecksEnabledboolTODO: move to features?
uptimedoubleseconds since vm started
“isolates”List of @Isolate