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

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.

Occasionally responses will have the vmName property. This represents the internal names used to refer to an object inside the VM itself. The vmName of an object is only provided when it differs from the name property; when vmName is not present, the client may assume the name and vmName are the same.

Events

TODO

Catalog of Types

@AbstractType

AbstractType

Breakpoint

TODO: Get rid of Location or else use it more generally.

keysvaluescomments
type“Breakpoint”
idString
breakpointNumberint
enabledbool
resolvedbool
locationLocation

@Class

keysvaluescomments
type“@Class”
idString
nameString
vmName?String

Class

keysvaluescomments
type“@Class”
idString
nameString
vmName?String
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

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 | 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

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

Code

keysvaluescomments
type“@Code”
idString
nameString
vmName?String
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 | 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

DebuggerEvent

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

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

Error

TODO: Drop id from Error.

keysvaluescomments
type“Error”
idStringalways empty
kindString
messageString

@Field

keysvaluescomments
type“@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

Field

keysvaluescomments
type“Field”
idString
nameString
vmName?String
value?Instancevalue associated with static field
owner@LibraryOwning library <-- handling of owner is inconsistent with Function
owner@ClassOwning class <-- handling of owner is inconsistent with Function
declared_type@AbstractType
staticbool
finalbool
constbool
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?

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

FrameVar

keysvaluescomments
nameString
value@Instance

@Function

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

Function

keysvaluescomments
type“@Function”
idString
nameString
vmName?String
owningLibrary@LibrarySet for non-top level functions
owningClass@ClassSet for non-top level functions
parent?@FunctionParent function
kindString
staticbool
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

keysvaluescomments
type“@Isolate”
idString
mainPortStringkill?
nameString

Isolate

keysvaluescomments
type“Isolate”
idString
mainPortStringkill?
nameString
entry?@Function
heaps???
topFrame?Frame
livePortsint
pauseOnExitbool
pauseEvent?DebuggerEvent
rootLib@Library
timers???
tagCounters???
error?Error
canonicalTypeArgumentskill?
libsList of @Library
featuresList of String

@Library

keysvaluescomments
type“@Library”
idString
nameString
vmName?StringInternal vm name. Provided only when different from ‘name’.
urlString

Library

keysvaluescomments
type“Library”
idString
nameString
vmName?StringInternal vm name. Provided only when different from ‘name’.
classesList of @Class
importsList of @Library
variablesList of ...
functionsList of @Function
scriptsList of @Script

Location

keysvaluescomments
type“Location”
script@Script
tokenPosint

@Null

TODO: Split Null from the other Sentinel types.

keysvaluescomments
type“@Null”
idString
valueAsStringString

PcDescriptor

@Script

| keys | values | comments | example | | --- | --- | --- | type | “@Script” | | id | String | name | String | vmName? | String | Internal vm name. Provided only when different from ‘name’. | kind | String

Script

keysvaluescomments
type“@Script”
idString
nameString
vmName?StringInternal vm name. Provided only when different from ‘name’.
kindString
owningLibrary@Library
sourceString
tokenPosTableList of list of int. See note below about token line format.

Token line format | index | value | comments | --- | --- | --- | 0 | int | line number | 1 | int | first token position | 2 | int | first column number | ... | ... | ... | 1 + (2 * k) | int | kth token position | 2 + (2 * k) | int | kth column number

VM

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