debugger_protocol.md 33.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
# Introduction

V8 has support for debugging the JavaScript code running in it. There are two API's for this a function based API using JavaScript objects and a message based API using a JSON based protocol. The function based API can be used by an in-process debugger agent, whereas the message based API can be used out of process as well.
**> The message based API is no longer maintained. Please ask in v8-users@googlegroups.com if you want to attach a debugger to the run-time.**

The debugger protocol is based on [JSON](http://www.json.org/)). Each protocol packet is defined in terms of JSON and is transmitted as a string value. All packets have two basic elements `seq` and `type`.

```
{ "seq"     : <number>,
  "type"    : <type>,
  ...
}
```

The element `seq` holds the sequence number of the packet. And element type is the type of the packet. The type is a string value with one of the following values `"request"`, `"response"` or `"event"`.

A `"request"` packet has the following structure:

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : <command>
  "arguments" : ...
}
```

A `"response"` packet has the following structure. If `success` is true `body` will contain the response data. If `success` is false `message` will contain an error message.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : <command>
  "body"        : ...
  "running"     : <is the VM running after sending this response>
  "success"     : <boolean indicating success>
  "message"     : <if command failed this property contains an error message>
}
```

An `"event"` packet has the following structure:

```
{ "seq"     : <number>,
  "type"    : "event",
  "event"   : <event name>
  body      : ...
}
```

# Request/response pairs

## Request `continue`

The request `continue` is a request from the debugger to start the VM running again. As part of the `continue` request the debugger can specify if it wants the VM to perform a single step action.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "continue",
  "arguments" : { "stepaction" : <"in", "next" or "out">,
                  "stepcount"  : <number of steps (default 1)>
                }
}
```

In the response the property `running` will always be true as the VM will be running after executing the `continue` command. If a single step action is requested the VM will respond with a `break` event after running the step.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "continue",
  "running"     : true
  "success"     : true
}
```


Here are a couple of examples.

```
{"seq":117,"type":"request","command":"continue"}
{"seq":118,"type":"request","command":"continue","arguments":{"stepaction":"out"}}
{"seq":119,"type":"request","command":"continue","arguments":{"stepaction":"next","stepcount":5}}
```

## Request `evaluate`

The request `evaluate` is used to evaluate an expression. The body of the result is as described in response object serialization below.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "evaluate",
  "arguments" : { "expression"    : <expression to evaluate>,
                  "frame"         : <number>,
                  "global"        : <boolean>,
                  "disable_break" : <boolean>,
                  "additional_context" : [
                       { "name" : <name1>, "handle" : <handle1> },
                       { "name" : <name2>, "handle" : <handle2> },
                       ... 
                  ]
                }
}
```

Optional argument `additional_context` specifies handles that will be visible from the expression under corresponding names (see example below).

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "evaluate",
  "body"        : ...
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"evaluate","arguments":{"expression":"1+2"}}
{"seq":118,"type":"request","command":"evaluate","arguments":{"expression":"a()","frame":3,"disable_break":false}}
{"seq":119,"type":"request","command":"evaluate","arguments":{"expression":"[o.a,o.b,o.c]","global":true,"disable_break":true}}
{"seq":120,"type":"request","command":"evaluate","arguments":{"expression":"obj.toString()", "additional_context": [{ "name":"obj","handle":25 }] }}
```

## Request `lookup`

The request `lookup` is used to lookup objects based on their handle. The individual array elements of the body of the result is as described in response object serialization below.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "lookup",
  "arguments" : { "handles"       : <array of handles>,
                  "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "lookup",
  "body"        : <array of serialized objects indexed using their handle>
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"lookup","arguments":{"handles":"[1]"}}
{"seq":118,"type":"request","command":"lookup","arguments":{"handles":"[7,12]"}}
```

## Request `backtrace`

The request `backtrace` returns a backtrace (or stacktrace) from the current execution state. When issuing a request a range of frames can be supplied. The top frame is frame number 0. If no frame range is supplied data for 10 frames will be returned.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "backtrace",
  "arguments" : { "fromFrame" : <number>
                  "toFrame" : <number>
                  "bottom" : <boolean, set to true if the bottom of the stack is requested>
                }
}
```

The response contains the frame data together with the actual frames returned and the toalt frame count.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "backtrace",
  "body"        : { "fromFrame" : <number>
                    "toFrame" : <number>
                    "totalFrames" : <number>
                    "frames" : <array of frames - see frame request for details>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

If there are no stack frames the result body only contains `totalFrames` with a value of `0`. When an exception event is generated due to compilation failures it is possible that there are no stack frames.

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"backtrace"}
{"seq":118,"type":"request","command":"backtrace","arguments":{"toFrame":2}}
{"seq":119,"type":"request","command":"backtrace","arguments":{"fromFrame":0,"toFrame":9}}
```

## Request `frame`

The request frame selects a new selected frame and returns information for that. If no frame number is specified the selected frame is returned.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "frame",
  "arguments" : { "number" : <frame number>
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "frame",
  "body"        : { "index"          : <frame number>,
                    "receiver"       : <frame receiver>,
                    "func"           : <function invoked>,
                    "script"         : <script for the function>,
                    "constructCall"  : <boolean indicating whether the function was called as constructor>,
                    "debuggerFrame"  : <boolean indicating whether this is an internal debugger frame>,
                    "arguments"      : [ { name: <name of the argument - missing of anonymous argument>,
                                           value: <value of the argument>
                                         },
                                         ... <the array contains all the arguments>
                                       ],
                    "locals"         : [ { name: <name of the local variable>,
                                           value: <value of the local variable>
                                         },
                                         ... <the array contains all the locals>
                                       ],
                    "position"       : <source position>,
                    "line"           : <source line>,
                    "column"         : <source column within the line>,
                    "sourceLineText" : <text for current source line>,
                    "scopes"         : [ <array of scopes, see scope request below for format> ],

                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"frame"}
{"seq":118,"type":"request","command":"frame","arguments":{"number":1}}
```

## Request `scope`

The request scope returns information on a givne scope for a givne frame. If no frame number is specified the selected frame is used.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "scope",
  "arguments" : { "number" : <scope number>
                  "frameNumber" : <frame number, optional uses selected frame if missing>
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "scope",
  "body"        : { "index"      : <index of this scope in the scope chain. Index 0 is the top scope
                                    and the global scope will always have the highest index for a
                                    frame>,
                    "frameIndex" : <index of the frame>,
                    "type"       : <type of the scope:
                                     0: Global
                                     1: Local
                                     2: With
                                     3: Closure
                                     4: Catch >,
                    "object"     : <the scope object defining the content of the scope.
                                    For local and closure scopes this is transient objects,
                                    which has a negative handle value>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"scope"}
{"seq":118,"type":"request","command":"scope","arguments":{"frameNumber":1,"number":1}}
```

## Request `scopes`

The request scopes returns all the scopes for a given frame. If no frame number is specified the selected frame is returned.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "scopes",
  "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing>
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "scopes",
  "body"        : { "fromScope" : <number of first scope in response>,
                    "toScope"   : <number of last scope in response>,
                    "totalScopes" : <total number of scopes for this frame>,
                    "scopes" : [ <array of scopes, see scope request above for format> ],
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"scopes"}
{"seq":118,"type":"request","command":"scopes","arguments":{"frameNumber":1}}
```

## Request `scripts`

The request `scripts` retrieves active scripts from the VM. An active script is source code from which there is still live objects in the VM. This request will always force a full garbage collection in the VM.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "scripts",
  "arguments" : { "types"         : <types of scripts to retrieve
                                       set bit 0 for native scripts
                                       set bit 1 for extension scripts
                                       set bit 2 for normal scripts
                                     (default is 4 for normal scripts)>
                  "ids"           : <array of id's of scripts to return. If this is not specified all scripts are requrned>
                  "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
                  "filter"        : <string or number: filter string or script id.
                                     If a number is specified, then only the script with the same number as its script id will be retrieved.
                                     If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
                }
}
```

The request contains an array of the scripts in the VM. This information includes the relative location of the script within the containing resource.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "scripts",
  "body"        : [ { "name"             : <name of the script>,
                      "id"               : <id of the script>
                      "lineOffset"       : <line offset within the containing resource>
                      "columnOffset"     : <column offset within the containing resource>
                      "lineCount"        : <number of lines in the script>
                      "data"             : <optional data object added through the API>
                      "source"           : <source of the script if includeSource was specified in the request>
                      "sourceStart"      : <first 80 characters of the script if includeSource was not specified in the request>
                      "sourceLength"     : <total length of the script in characters>
                      "scriptType"       : <script type (see request for values)>
                      "compilationType"  : < How was this script compiled:
                                               0 if script was compiled through the API
                                               1 if script was compiled through eval
                                            >
                      "evalFromScript"   : <if "compilationType" is 1 this is the script from where eval was called>
                      "evalFromLocation" : { line   : < if "compilationType" is 1 this is the line in the script from where eval was called>
                                             column : < if "compilationType" is 1 this is the column in the script from where eval was called>
                  ]
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"scripts"}
{"seq":118,"type":"request","command":"scripts","arguments":{"types":7}}
```

## Request `source`

The request `source` retrieves source code for a frame. It returns a number of source lines running from the `fromLine` to but not including the `toLine`, that is the interval is open on the "to" end. For example, requesting source from line 2 to 4 returns two lines (2 and 3). Also note that the line numbers are 0 based: the first line is line 0.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "source",
  "arguments" : { "frame"    : <frame number (default selected frame)>
                  "fromLine" : <from line within the source default is line 0>
                  "toLine"   : <to line within the source this line is not included in
                                the result default is the number of lines in the script>
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "source",
  "body"        : { "source"       : <the source code>
                    "fromLine"     : <actual from line within the script>
                    "toLine"       : <actual to line within the script this line is not included in the source>
                    "fromPosition" : <actual start position within the script>
                    "toPosition"   : <actual end position within the script>
                    "totalLines"   : <total lines in the script>
                }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"source","arguments":{"fromLine":10,"toLine":20}}
{"seq":118,"type":"request","command":"source","arguments":{"frame":2,"fromLine":10,"toLine":20}}
```

## Request `setbreakpoint`

The request `setbreakpoint` creates a new break point. This request can be used to set both function and script break points. A function break point sets a break point in an existing function whereas a script break point sets a break point in a named script. A script break point can be set even if the named script is not found.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "setbreakpoint",
  "arguments" : { "type"        : <"function" or "script" or "scriptId" or "scriptRegExp">
                  "target"      : <function expression or script identification>
                  "line"        : <line in script or function>
                  "column"      : <character position within the line>
                  "enabled"     : <initial enabled state. True or false, default is true>
                  "condition"   : <string with break point condition>
                  "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
                }
}
```

The result of the `setbreakpoint` request is a response with the number of the newly created break point. This break point number is used in the `changebreakpoint` and `clearbreakpoint` requests.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "setbreakpoint",
  "body"        : { "type"       : <"function" or "script">
                    "breakpoint" : <break point number of the new break point>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"setbreakpoint","arguments":{"type":"function,"target":"f"}}
{"seq":118,"type":"request","command":"setbreakpoint","arguments":{type:"script","target":"test.js","line":100}}
{"seq":119,"type":"request","command":"setbreakpoint","arguments":{"type":"function,"target":"f","condition":"i > 7"}}
```


## Request `changebreakpoint`

The request `changebreakpoint` changes the status of a break point.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "changebreakpoint",
  "arguments" : { "breakpoint"  : <number of the break point to clear>
                  "enabled"     : <initial enabled state. True or false, default is true>
                  "condition"   : <string with break point condition>
                  "ignoreCount" : <number specifying the number of break point hits            }
}
```

## Request `clearbreakpoint`

The request `clearbreakpoint` clears a break point.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "clearbreakpoint",
  "arguments" : { "breakpoint" : <number of the break point to clear>
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "clearbreakpoint",
  "body"        : { "type"       : <"function" or "script">
                    "breakpoint" : <number of the break point cleared>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here are a couple of examples.

```
{"seq":117,"type":"request","command":"clearbreakpoint","arguments":{"type":"function,"breakpoint":1}}
{"seq":118,"type":"request","command":"clearbreakpoint","arguments":{"type":"script","breakpoint":2}}
```

## Request `setexceptionbreak`

The request `setexceptionbreak` is a request to enable/disable breaks on all / uncaught exceptions.  If the "enabled" argument is not specify, the debuggee will toggle the state of the specified break type.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "setexceptionbreak",
  "arguments" : { "type"    : <string: "all", or "uncaught">,
                  "enabled" : <optional bool: enables the break type if true>
                }
}
```

In response, the break on exception property of the debuggee will be set accordingly, and the following response message will be dispatched to the debugger.

```
{ "seq"               : <number>,
  "type"              : "response",
  "request_seq" : <number>,
  "command"     : "setexceptionbreak",
  “body”        : { "type"    : <string: "all" or "uncaught" corresponding to the request.>,
                    "enabled" : <bool: true if the break type is currently enabled as a result of the request>
                  }
  "running"     : true
  "success"     : true
}
```

Here are a few examples.

```
{"seq":117,"type":"request","command":"setexceptionbreak","arguments":{"type":"all"}}
{"seq":118,"type":"request","command":" setexceptionbreak","arguments":{"type":"all",”enabled”:false}}
{"seq":119,"type":"request","command":" setexceptionbreak","arguments":{"type":"uncaught","enabled":true}}
```

## Request `v8flags`
The request v8flags is a request to apply the specified v8 flags (analogous to how they are specified on the command line).

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "v8flags",
  "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line>
                }
}
```

In response, the specified flags will be applied in the debuggee if they are legal flags.  Their effects vary depending on the implementation of the flag.

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "v8flags",
  "running"     : true
  "success"     : true
}
```

Here are a few examples.

```
{"seq":117,"type":"request","command":"v8flags","arguments":{"flags":"--trace_gc —always_compact"}}
{"seq":118,"type":"request","command":" v8flags","arguments":{"flags":"--notrace_gc"}}
```

## Request `version`

The request `version` reports version of the running V8.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "version",
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "type"        : "request",
  "body"        : { "V8Version":   <string, version of V8>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here is an example.

```
{"seq":1,"type":"request","command":"version"}
{"seq":134,"request_seq":1,"type":"response","command":"version","success":true,"body":{"V8Version":"1.3.19 (candidate)"},"refs":[],"running":false}
```

## Request `disconnect`

The request `disconnect` is used to detach the remote debugger from the debuggee.  This will trigger the debuggee to disable all active breakpoints and resumes execution if the debuggee was previously stopped at a break.

```
{ "seq"     : <number>,
  "type"    : "request",
  "command" : "disconnect",
}
```

The only response for the `disconnect` request is the response to a connect request if the debugger is still able to get a response before the debuggee successfully disconnects.

Here is an examples:

```
{"seq":117,"type":"request","command":"disconnect"}
```

## Request `gc`
The request `gc` is a request to run the garbage collector in the debuggee.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "gc",
  "arguments" : { "type" : <string: "all">,
                }
}
```

In response, the debuggee will run the specified GC type and send the following response message:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "gc",
  “body”        : { "before" : <int: total heap usage in bytes before the GC>,
                    "after"  : <int: total heap usage in bytes after the GC>
                  }
  "running"     : true
  "success"     : true
}
```

Here is an example.

```
{"seq":117,"type":"request","command":"gc","arguments":{"type":"all"}}
```

## Request `listbreakpoints`

The request `listbreakpoints` is used to get information on breakpoints that may have been set by the debugger.

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "listbreakpoints",
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "command"     : "listbreakpoints",
  "body"        : { "breakpoints": [ { "type"             : <string: "scriptId"  or "scriptName".>,
                                       "script_id"        : <int: script id.  Only defined if type is scriptId.>,
                                       "script_name"      : <string: script name.  Only defined if type is scriptName.>,
                                       "number"           : <int: breakpoint number.  Starts from 1.>,
                                       "line"             : <int: line number of this breakpoint.  Starts from 0.>,
                                       "column"           : <int: column number of this breakpoint.  Starts from 0.>,
                                       "groupId"          : <int: group id of this breakpoint.>,
                                       "hit_count"        : <int: number of times this breakpoint has been hit.  Starts from 0.>,
                                       "active"           : <bool: true if this breakpoint is enabled.>,
                                       "ignoreCount"      : <int: remaining number of times to ignore breakpoint.  Starts from 0.>,
                                       "actual_locations" : <actual locations of the breakpoint.>,
                                     }
                                   ],
                    "breakOnExceptions"         : <true if break on all exceptions is enabled>,
                    "breakOnUncaughtExceptions" : <true if break on uncaught exceptions is enabled>
                  }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

Here is an examples:

```
{"seq":117,"type":"request","command":"listbreakpoints"}
```


## Request `setvariablevalue`
This requests sets the value of a variable from the specified scope.

Request:

```
{ "seq"       : <number>,
  "type"      : "request",
  "command"   : "setvariablevalue",
  "arguments  : { "name"  : <string: variable name>,
                  "scope" : { "number" : <scope number>
                              "frameNumber" : <frame number, optional uses selected frame if missing>
                            }
                }
}
```

Response:

```
{ "seq"         : <number>,
  "type"        : "response",
  "request_seq" : <number>,
  "type"        : "request",
  "body"        : { "newValue":   <object: mirror object of the new value> }
  "running"     : <is the VM running after sending this response>
  "success"     : true
}
```

# Events

## Event `break`

The event `break` indicate that the execution in the VM has stopped due to a break condition. This can be caused by an unconditional break request, by a break point previously set, a stepping action have completed or by executing the `debugger` statement in JavaScript.

```
{ "seq"   : <number>,
  "type"  : "event",

  "event" : "break",
  "body"  : { "invocationText" : <text representation of the stack frame>,
              "sourceLine"     : <source line where execution is stopped>,
              "sourceColumn"   : <column within the source line where execution is stopped>,
              "sourceLineText" : <text for the source line where execution is stopped>,
              "script"         : { name         : <resource name of the origin of the script>
                                   lineOffset   : <line offset within the origin of the script>
                                   columnOffset : <column offset within the origin of the script>
                                   lineCount    : <number of lines in the script>
              "breakpoints"    : <array of break point numbers hit if any>
            }
}
```

Here are a couple of examples.

```
{"seq":117,"type":"event","event":"break","body":{"functionName":"f","sourceLine":1,"sourceColumn":14}}
{"seq":117,"type":"event","event":"break","body":{"functionName":"g","scriptData":"test.js","sourceLine":12,"sourceColumn":22,"breakpoints":[1]}}
{"seq":117,"type":"event","event":"break","body":{"functionName":"h","sourceLine":100,"sourceColumn":12,"breakpoints":[3,5,7]}}
```

## Event `exception`

The event `exception` indicate that the execution in the VM has stopped due to an exception.

```
{ "seq"   : <number>,
  "type"  : "event",
  "event" : "exception",
  "body"  : { "uncaught" : <boolean>,
              "exception" : ...
              "sourceLine"     : <source line where the exception was thrown>,
              "sourceColumn"   : <column within the source line from where the exception was thrown>,
              "sourceLineText" : <text for the source line from where the exception was thrown>,
              "script" : { "name" : <name of script>
                           "lineOffset" : <number>
                           "columnOffset" : <number>
                           "lineCount" : <number>
                         }

            }
}
```

# Response object serialization

Some responses contain objects as part of the body, e.g. the response to the evaluate request contains the result of the expression evaluated.

All objects exposed through the debugger is assigned an ID called a handle. This handle is serialized and can be used to identify objects. A handle has a certain lifetime after which it will no longer refer to the same object. Currently the lifetime of handles match the processing of a debug event. For each debug event handles are recycled.

An object can be serialized either as a reference to a given handle or as a value representation containing the object content.

An object serialized as a reference looks follows this where `<handle>` is an integer.

```
{"ref":<handle>}
```

For objects serialized as value they all contains the handle and the type of the object.

```
{ "handle" : <handle>,
  "type"   : <"undefined", "null", "boolean", "number", "string", "object", "function" or "frame">
}
```

In some situations special transient objects are created by the debugger. These objects are not really visible in from JavaScript, but are created to materialize something inside the VM as an object visible to the debugger. One example of this is the local scope object returned from the `scope` and `scopes` request. Transient objects are identified by having a negative handle. A transient object can never be retrieved using the `lookup` request, so all transient objects referenced will be in the `refs` part of the response. The lifetime of transient objects is basically the request they are involved in.

For the primitive JavaScript types `undefined` and `null` the type describes the value fully.

```
{"handle":<handle>,"type":"undefined"}
```

```
{"handle":<handle>,"type":"null"}
```

For the rest of the primitive types `boolean`, `number` and `string` the value is part of the result.

```
{ "handle":<handle>,
  "type"  : <"boolean", "number" or "string">
  "value" : <JSON encoded value>
}
```

Boolean value.

```
{"handle":7,"type":"boolean","value":true}
```

Number value.

```
{"handle":8,"type":"number","value":42}
```

String value.

```
{"handle":9,"type":"string","value":"a string"}
```

An object is encoded with additional information.

```
{ "handle"              : <handle>,
  "type"                : "object",
  "className"           : <Class name, ECMA-262 property [[Class]]>,
  "constructorFunction" : {"ref":<handle>},
  "protoObject"         : {"ref":<handle>},
  "prototypeObject"     : {"ref":<handle>},
  "properties" : [ {"name" : <name>,
                    "ref"  : <handle>
                   },
                   ...
                 ]
}
```

The difference between the `protoObject` and the `prototypeObject` is that the `protoObject` contains a reference to the actual prototype object (for which accessibility is not defined in ECMA-262, but in V8 it is accessible using the `__proto__` property) whereas the `prototypeObject` is the value of the `prototype` property.

Here is an example.

```
{"handle":3,"type":"object","className":"Object","constructorFunction":{"ref":4},"protoObject":{"ref":5},"prototypeObject":{"ref":6},"properties":[{"name":"a","ref:7},{"name":"b","ref":8}]}
```

An function is encoded as an object but with additional information in the properties `name`, `inferredName`, `source` and `script`.

```
{ "handle" : <handle>,
  "type"                : "function",
  "className"           : "Function",
  "constructorFunction" : {"ref":<handle>},
  "protoObject"         : {"ref":<handle>},
  "prototypeObject"     : {"ref":<handle>},
  "name"                : <function name>,
  "inferredName"        : <inferred function name for anonymous functions>
  "source"              : <function source>,
  "script"              : <reference to function script>,
  "scriptId"            : <id of function script>,
  "position"            : <function begin position in script>,
  "line"                : <function begin source line in script>,
  "column"              : <function begin source column in script>,
  "properties" : [ {"name" : <name>,
                    "ref"  : <handle>
                   },
                   ...
                 ]
}
```