| OLD | NEW |
| 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 /// An implementation of the vm service-protocol in terms of a DartinoVmContext. | 5 /// An implementation of the vm service-protocol in terms of a DartinoVmContext. |
| 6 /// Processes are mapped to isolates. | 6 /// Processes are mapped to isolates. |
| 7 // TODO(sigurdm): Handle processes better. | 7 // TODO(sigurdm): Handle processes better. |
| 8 // TODO(sigurdm): Find a way to represent fibers. | 8 // TODO(sigurdm): Find a way to represent fibers. |
| 9 // TODO(sigurdm): Represent remote values. | |
| 10 // TODO(sigurdm): Use https://pub.dartlang.org/packages/json_rpc_2 for serving. | 9 // TODO(sigurdm): Use https://pub.dartlang.org/packages/json_rpc_2 for serving. |
| 11 | 10 |
| 12 import "dart:async" show Future; | 11 import "dart:async" show Future; |
| 13 | 12 |
| 14 import 'dart:convert' show JSON; | 13 import 'dart:convert' show JSON; |
| 15 | 14 |
| 16 import 'dart:io' show File, HttpServer, WebSocket, WebSocketTransformer; | 15 import 'dart:io' show File, HttpServer, WebSocket, WebSocketTransformer; |
| 17 | 16 |
| 18 import 'hub/session_manager.dart' show SessionState; | 17 import 'hub/session_manager.dart' show SessionState; |
| 19 | 18 |
| 20 import 'guess_configuration.dart' show dartinoVersion; | 19 import 'guess_configuration.dart' show dartinoVersion; |
| 21 | 20 |
| 22 import '../debug_state.dart' | 21 import '../debug_state.dart' |
| 23 show BackTrace, BackTraceFrame, Breakpoint, RemoteObject; | 22 show |
| 23 BackTrace, |
| 24 BackTraceFrame, |
| 25 Breakpoint, |
| 26 RemoteArray, |
| 27 RemoteErrorObject, |
| 28 RemoteInstance, |
| 29 RemoteObject, |
| 30 RemoteValue; |
| 24 | 31 |
| 25 import '../vm_context.dart' show DartinoVmContext, DebugListener; | 32 import '../vm_context.dart' show DartinoVmContext, DebugListener; |
| 26 | 33 |
| 27 import '../dartino_system.dart' | 34 import '../dartino_system.dart' |
| 28 show DartinoFunction, DartinoFunctionKind, DartinoSystem; | 35 show DartinoFunction, DartinoFunctionKind, DartinoSystem; |
| 29 | 36 |
| 30 import 'debug_info.dart' show DebugInfo, ScopeInfo, SourceLocation; | 37 import 'debug_info.dart' show DebugInfo, ScopeInfo, SourceLocation; |
| 31 | 38 |
| 32 import 'dartino_compiler_implementation.dart' | 39 import 'dartino_compiler_implementation.dart' |
| 33 show DartinoCompilerImplementation; | 40 show DartinoCompilerImplementation; |
| 34 | 41 import 'element_utils.dart'; |
| 35 import 'codegen_visitor.dart' show LocalValue; | |
| 36 | 42 |
| 37 import '../program_info.dart' show Configuration; | 43 import '../program_info.dart' show Configuration; |
| 44 import '../vm_commands.dart' |
| 45 show |
| 46 Array, |
| 47 Boolean, |
| 48 ClassValue, |
| 49 DartValue, |
| 50 Double, |
| 51 Instance, |
| 52 Integer, |
| 53 NullValue, |
| 54 StringValue; |
| 38 | 55 |
| 39 import 'package:collection/collection.dart' show binarySearch; | 56 import 'package:collection/collection.dart' show binarySearch; |
| 40 | 57 |
| 41 import 'package:compiler/src/scanner/scanner.dart' show Scanner; | 58 import 'package:compiler/src/scanner/scanner.dart' show Scanner; |
| 42 import 'package:compiler/src/tokens/token.dart' show Token; | 59 import 'package:compiler/src/tokens/token.dart' show Token; |
| 43 import 'package:compiler/src/io/source_file.dart' show SourceFile; | 60 import 'package:compiler/src/io/source_file.dart' show SourceFile; |
| 44 import 'package:compiler/src/elements/visitor.dart' show BaseElementVisitor; | 61 import 'package:compiler/src/elements/visitor.dart' show BaseElementVisitor; |
| 45 import 'package:compiler/src/elements/elements.dart' | 62 import 'package:compiler/src/elements/elements.dart' |
| 46 show | 63 show |
| 64 ClassElement, |
| 47 CompilationUnitElement, | 65 CompilationUnitElement, |
| 48 Element, | 66 Element, |
| 67 FieldElement, |
| 49 FunctionElement, | 68 FunctionElement, |
| 50 LibraryElement, | 69 LibraryElement, |
| 51 MemberElement, | 70 MemberElement, |
| 52 ScopeContainerElement; | 71 ScopeContainerElement; |
| 53 | 72 |
| 54 const bool logging = const bool.fromEnvironment("dartino-log-debug-server"); | 73 const bool logging = const bool.fromEnvironment("dartino-log-debug-server"); |
| 55 | 74 |
| 56 //TODO(danrubel): Verify const map values | |
| 57 const Map<String, dynamic> dartCoreLibRefDesc = const <String, dynamic>{ | |
| 58 "type": "@Library", | |
| 59 "id": "libraries/dart:core", | |
| 60 "fixedId": true, | |
| 61 "name": "dart:core", | |
| 62 "uri": "dart:core", | |
| 63 }; | |
| 64 | |
| 65 //TODO(danrubel): Verify correct id | |
| 66 const String nullId = "objects/Null"; | |
| 67 | |
| 68 //TODO(danrubel): Verify const map values | |
| 69 const Map<String, dynamic> nullClassRefDesc = const <String, dynamic>{ | |
| 70 "type": "@Class", | |
| 71 "id": "classes/NullClass", | |
| 72 "name": "NullClass", | |
| 73 }; | |
| 74 | |
| 75 //TODO(danrubel): Verify const map values | |
| 76 const Map<String, dynamic> nullRefDesc = const <String, dynamic>{ | |
| 77 "type": "@Null", | |
| 78 "id": nullId, | |
| 79 "kind": "Null", | |
| 80 "class": nullClassRefDesc, | |
| 81 "valueAsString": "null", | |
| 82 }; | |
| 83 | |
| 84 //TODO(danrubel): Verify const map values | |
| 85 const Map<String, dynamic> nullDesc = const <String, dynamic>{ | |
| 86 "type": "Null", | |
| 87 "id": nullId, | |
| 88 "kind": "Null", | |
| 89 "class": nullClassRefDesc, | |
| 90 "valueAsString": "null", | |
| 91 }; | |
| 92 | |
| 93 class DebugServer { | 75 class DebugServer { |
| 94 Future<int> serveSingleShot(SessionState state, | 76 Future<int> serveSingleShot(SessionState state, |
| 95 {int port: 0, Uri snapshotLocation}) async { | 77 {int port: 0, Uri snapshotLocation}) async { |
| 96 HttpServer server = await HttpServer.bind("127.0.0.1", port); | 78 HttpServer server = await HttpServer.bind("127.0.0.1", port); |
| 97 // The Atom Dartino plugin waits for "localhost:<port-number>" | 79 // The Atom Dartino plugin waits for "localhost:<port-number>" |
| 98 // to determine the observatory port for debugging. | 80 // to determine the observatory port for debugging. |
| 99 print("localhost:${server.port}"); | 81 print("localhost:${server.port}"); |
| 100 WebSocket socket = await server.transform(new WebSocketTransformer()).first; | 82 WebSocket socket = await server.transform(new WebSocketTransformer()).first; |
| 101 await new DebugConnection(state, socket, snapshotLocation: snapshotLocation) | 83 await new DebugConnection(state, socket, snapshotLocation: snapshotLocation) |
| 102 .serve(); | 84 .serve(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 socket.add(JSON.encode(message)); | 120 socket.add(JSON.encode(message)); |
| 139 } | 121 } |
| 140 | 122 |
| 141 void setStream(String streamId, bool value) { | 123 void setStream(String streamId, bool value) { |
| 142 streams[streamId] = value; | 124 streams[streamId] = value; |
| 143 } | 125 } |
| 144 | 126 |
| 145 Map<String, CompilationUnitElement> scripts = | 127 Map<String, CompilationUnitElement> scripts = |
| 146 new Map<String, CompilationUnitElement>(); | 128 new Map<String, CompilationUnitElement>(); |
| 147 | 129 |
| 148 Map frameDesc(BackTraceFrame frame, int index) { | 130 Future<Map> frameDesc(BackTraceFrame frame, int index) async { |
| 149 List<Map> vars = new List<Map>(); | 131 List<Map> vars = new List<Map>(); |
| 150 for (ScopeInfo current = frame.scopeInfo(); | 132 for (ScopeInfo current = frame.scopeInfo(); |
| 151 current != ScopeInfo.sentinel; | 133 current != ScopeInfo.sentinel; |
| 152 current = current.previous) { | 134 current = current.previous) { |
| 135 RemoteValue remoteValue = |
| 136 await vmContext.processLocal(index, current.local.slot); |
| 153 vars.add({ | 137 vars.add({ |
| 154 "type": "BoundVariable", | 138 "type": "BoundVariable", |
| 155 "name": current.name, | 139 "name": current.name, |
| 156 "value": valueDesc(current.lookup(current.name)) | 140 "value": instanceRef( |
| 141 remoteValue.value, "objects/$index.${current.local.slot}"), |
| 157 }); | 142 }); |
| 158 } | 143 } |
| 159 return { | 144 return { |
| 160 "type": "Frame", | 145 "type": "Frame", |
| 161 "index": index, | 146 "index": index, |
| 162 "function": functionRef(frame.function), | 147 "function": functionRef(frame.function), |
| 163 "code": { | 148 "code": { |
| 164 "id": "code-id", //TODO(danrubel): what is the unique id here? | 149 "id": "code-id", //TODO(danrubel): what is the unique id here? |
| 165 "type": "@Code", | 150 "type": "@Code", |
| 166 "name": "code-name", // TODO(sigurdm): How to create a name here? | 151 "name": "code-name", // TODO(sigurdm): How to create a name here? |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 "type": "Function", | 316 "type": "Function", |
| 332 "id": "functions/${function.functionId}", | 317 "id": "functions/${function.functionId}", |
| 333 // TODO(sigurdm): All kinds of owner. | 318 // TODO(sigurdm): All kinds of owner. |
| 334 "owner": libraryRef(element.library), | 319 "owner": libraryRef(element.library), |
| 335 "static": element.isStatic, | 320 "static": element.isStatic, |
| 336 "const": element.isConst, | 321 "const": element.isConst, |
| 337 "_kind": functionKind(function.kind), | 322 "_kind": functionKind(function.kind), |
| 338 }; | 323 }; |
| 339 } | 324 } |
| 340 | 325 |
| 341 Map valueDesc(LocalValue lookup) { | 326 Map classRef(ClassElement classElement) { |
| 342 //TODO(danrubel): Translate local value into description? | 327 if (classElement == null) { |
| 343 // Need to return an @InstanceRef or Sentinel | 328 return {"type": "@Class", "id": "unknown", "name": "unknown class"}; |
| 344 return nullRefDesc; | 329 } |
| 330 String symbolicName = |
| 331 "${classElement.library.canonicalUri}.${classElement.name}"; |
| 332 return { |
| 333 "type": "@Class", |
| 334 "id": "classes/$symbolicName", |
| 335 "name": "${classElement.name}", |
| 336 }; |
| 337 } |
| 338 |
| 339 Map instanceRef(DartValue value, String id) { |
| 340 int classId; |
| 341 Element classElement; |
| 342 String stringValue; |
| 343 String kind; |
| 344 int length; |
| 345 String name; |
| 346 if (value is Instance) { |
| 347 kind = "PlainInstance"; |
| 348 classId = value.classId; |
| 349 } else if (value is Integer) { |
| 350 kind = "Int"; |
| 351 classElement = vmContext.compiler.compiler.backend.intImplementation; |
| 352 stringValue = "${value.value}"; |
| 353 } else if (value is StringValue) { |
| 354 kind = "String"; |
| 355 classElement = vmContext.compiler.compiler.backend.stringImplementation; |
| 356 stringValue = value.value; |
| 357 } else if (value is Boolean) { |
| 358 kind = "Bool"; |
| 359 classElement = vmContext.compiler.compiler.backend.boolImplementation; |
| 360 stringValue = "${value.value}"; |
| 361 } else if (value is Double) { |
| 362 kind = "Double"; |
| 363 classElement = vmContext.compiler.compiler.backend.doubleImplementation; |
| 364 stringValue = "${value.value}"; |
| 365 } else if (value is ClassValue) { |
| 366 kind = "Type"; |
| 367 Element element = |
| 368 vmContext.dartinoSystem.classesById[value.classId].element; |
| 369 classElement = vmContext.compiler.compiler.backend.typeImplementation; |
| 370 name = "${element}"; |
| 371 } else if (value is NullValue) { |
| 372 kind = "Null"; |
| 373 classElement = vmContext.compiler.compiler.backend.nullImplementation; |
| 374 stringValue = "null"; |
| 375 } else if (value is Array) { |
| 376 kind = "List"; |
| 377 classElement = vmContext.compiler.compiler.backend.listImplementation; |
| 378 length = value.length; |
| 379 } else { |
| 380 throw "Unexpected remote value $value"; |
| 381 } |
| 382 Map classReference = classRef( |
| 383 classElement ?? vmContext.dartinoSystem.classesById[classId]?.element); |
| 384 Map result = { |
| 385 "type": "@Instance", |
| 386 "id": id, |
| 387 "kind": kind, |
| 388 "class": classReference, |
| 389 }; |
| 390 if (stringValue != null) { |
| 391 result["valueAsString"] = stringValue; |
| 392 } |
| 393 if (length != null) { |
| 394 result["length"] = length; |
| 395 } |
| 396 if (name != null) { |
| 397 result["name"] = name; |
| 398 } |
| 399 return result; |
| 400 } |
| 401 |
| 402 Map instanceDesc(RemoteObject remoteObject, String id) { |
| 403 // TODO(sigurdm): Allow inspecting any frame. |
| 404 assert(remoteObject is! RemoteErrorObject); |
| 405 if (remoteObject is RemoteInstance) { |
| 406 int classId = remoteObject.instance.classId; |
| 407 Element classElement = |
| 408 vmContext.dartinoSystem.classesById[classId].element; |
| 409 List<FieldElement> fieldElements = computeFields(classElement); |
| 410 assert(fieldElements.length == remoteObject.fields.length); |
| 411 List fields = new List(); |
| 412 for (int i = 0; i < fieldElements.length; i++) { |
| 413 FieldElement fieldElement = fieldElements[i]; |
| 414 fields.add({ |
| 415 "type": "BoundField", |
| 416 "decl": { |
| 417 "type": "@Field", |
| 418 "name": fieldElement.name, |
| 419 "owner": classRef(fieldElement.contextClass), |
| 420 "declaredType": null, // TODO(sigurdm): fill this in. |
| 421 "const": fieldElement.isConst, |
| 422 "final": fieldElement.isFinal, |
| 423 "static": fieldElement.isStatic, |
| 424 }, |
| 425 "value": instanceRef(remoteObject.fields[i], "$id.$i"), |
| 426 }); |
| 427 } |
| 428 return <String, dynamic>{ |
| 429 "type": "Instance", |
| 430 "id": id, |
| 431 "kind": "PlainInstance", |
| 432 "class": classRef(classElement), |
| 433 "fields": fields, |
| 434 }; |
| 435 } else if (remoteObject is RemoteArray) { |
| 436 // TODO(sigurdm): Handle large arrays. (Issue #536). |
| 437 List elements = new List(); |
| 438 for (int i = 0; i < remoteObject.array.length; i++) { |
| 439 elements.add(instanceRef(remoteObject.values[i], "$id.$i")); |
| 440 } |
| 441 return <String, dynamic>{ |
| 442 "type": "Instance", |
| 443 "id": id, |
| 444 "kind": "List", |
| 445 "class": |
| 446 classRef(vmContext.compiler.compiler.backend.listImplementation), |
| 447 "elements": elements, |
| 448 }; |
| 449 } else if (remoteObject is RemoteValue) { |
| 450 Map instance = instanceRef(remoteObject.value, id); |
| 451 instance["type"] = "Instance"; |
| 452 return instance; |
| 453 } else { |
| 454 throw "Unexpected remote object kind"; |
| 455 } |
| 345 } | 456 } |
| 346 | 457 |
| 347 initialize(DartinoCompilerImplementation compiler) { | 458 initialize(DartinoCompilerImplementation compiler) { |
| 348 for (LibraryElement library in compiler.libraryLoader.libraries) { | 459 for (LibraryElement library in compiler.libraryLoader.libraries) { |
| 349 cacheScripts(LibraryElement library) { | 460 cacheScripts(LibraryElement library) { |
| 350 for (CompilationUnitElement compilationUnit | 461 for (CompilationUnitElement compilationUnit |
| 351 in library.compilationUnits) { | 462 in library.compilationUnits) { |
| 352 Uri uri = compilationUnit.script.file.uri; | 463 Uri uri = compilationUnit.script.file.uri; |
| 353 scripts["scripts/$uri"] = compilationUnit; | 464 scripts["scripts/$uri"] = compilationUnit; |
| 354 tokenTables[uri] = makeTokenTable(compilationUnit); | 465 tokenTables[uri] = makeTokenTable(compilationUnit); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 .lookupLibrary(Uri.parse(uri)))); | 608 .lookupLibrary(Uri.parse(uri)))); |
| 498 break; | 609 break; |
| 499 case "scripts": | 610 case "scripts": |
| 500 sendResult(scriptDesc(scripts[id])); | 611 sendResult(scriptDesc(scripts[id])); |
| 501 break; | 612 break; |
| 502 case "functions": | 613 case "functions": |
| 503 sendResult(functionDesc(vmContext.dartinoSystem.functionsById[ | 614 sendResult(functionDesc(vmContext.dartinoSystem.functionsById[ |
| 504 int.parse(id.substring(slashIndex + 1))])); | 615 int.parse(id.substring(slashIndex + 1))])); |
| 505 break; | 616 break; |
| 506 case "objects": | 617 case "objects": |
| 507 if (id == nullId) { | 618 String path = id.substring(slashIndex + 1); |
| 508 sendResult(nullDesc); | 619 List<int> dotted = path.split(".").map(int.parse).toList(); |
| 509 } else { | 620 int localFrame = dotted.first; |
| 510 //TODO(danrubel): Need to return an Instance description | 621 int localSlot = dotted[1]; |
| 511 // or Sentinel for the given @InstanceRef | 622 List<int> fieldAccesses = dotted.skip(2).toList(); |
| 512 throw 'Unknown object: $id'; | 623 RemoteObject remoteObject = await vmContext.processLocalStructure( |
| 513 } | 624 localFrame, localSlot, |
| 625 fieldAccesses: fieldAccesses); |
| 626 sendResult(instanceDesc(remoteObject, id)); |
| 514 break; | 627 break; |
| 515 default: | 628 default: |
| 516 throw "Unsupported object type $id"; | 629 throw "Unsupported object type $id"; |
| 517 } | 630 } |
| 518 break; | 631 break; |
| 519 case "getStack": | 632 case "getStack": |
| 520 String isolateIdString = decodedMessage["params"]["isolateId"]; | 633 String isolateIdString = decodedMessage["params"]["isolateId"]; |
| 521 int isolateId = int.parse( | 634 int isolateId = int.parse( |
| 522 isolateIdString.substring(isolateIdString.indexOf("/") + 1)); | 635 isolateIdString.substring(isolateIdString.indexOf("/") + 1)); |
| 523 BackTrace backTrace = | 636 BackTrace backTrace = |
| 524 await state.vmContext.backTrace(processId: isolateId); | 637 await state.vmContext.backTrace(processId: isolateId); |
| 525 List frames = []; | 638 List frames = []; |
| 526 int index = 0; | 639 int index = 0; |
| 527 for (BackTraceFrame frame in backTrace.frames) { | 640 for (BackTraceFrame frame in backTrace.frames) { |
| 528 frames.add(frameDesc(frame, index)); | 641 frames.add(await frameDesc(frame, index)); |
| 529 index++; | 642 index++; |
| 530 } | 643 } |
| 531 | 644 |
| 532 sendResult({"type": "Stack", "frames": frames, "messages": [],}); | 645 sendResult({"type": "Stack", "frames": frames, "messages": [],}); |
| 533 break; | 646 break; |
| 534 case "getSourceReport": | 647 case "getSourceReport": |
| 535 String scriptId = decodedMessage["params"]["scriptId"]; | 648 String scriptId = decodedMessage["params"]["scriptId"]; |
| 536 CompilationUnitElement compilationUnit = scripts[scriptId]; | 649 CompilationUnitElement compilationUnit = scripts[scriptId]; |
| 537 Uri scriptUri = compilationUnit.script.file.uri; | 650 Uri scriptUri = compilationUnit.script.file.uri; |
| 538 List<int> tokenTable = tokenTables[scriptUri]; | 651 List<int> tokenTable = tokenTables[scriptUri]; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 // TODO(sigurdm): Implement gc notification. | 816 // TODO(sigurdm): Implement gc notification. |
| 704 } | 817 } |
| 705 | 818 |
| 706 @override | 819 @override |
| 707 lostConnection() { | 820 lostConnection() { |
| 708 socket.close(); | 821 socket.close(); |
| 709 } | 822 } |
| 710 | 823 |
| 711 @override | 824 @override |
| 712 pauseBreakpoint( | 825 pauseBreakpoint( |
| 713 int processId, BackTraceFrame topFrame, Breakpoint breakpoint) { | 826 int processId, BackTraceFrame topFrame, Breakpoint breakpoint) async { |
| 714 //TODO(danrubel): are there any other breakpoints | 827 //TODO(danrubel): are there any other breakpoints |
| 715 // at which we are currently paused for a PauseBreakpoint event? | 828 // at which we are currently paused for a PauseBreakpoint event? |
| 716 List<Breakpoint> pauseBreakpoints = <Breakpoint>[]; | 829 List<Breakpoint> pauseBreakpoints = <Breakpoint>[]; |
| 717 pauseBreakpoints.add(breakpoint); | 830 pauseBreakpoints.add(breakpoint); |
| 718 Map event = { | 831 Map event = { |
| 719 "type": "Event", | 832 "type": "Event", |
| 720 "kind": "PauseBreakpoint", | 833 "kind": "PauseBreakpoint", |
| 721 "isolate": isolateRef(processId), | 834 "isolate": isolateRef(processId), |
| 722 "timestamp": new DateTime.now().millisecondsSinceEpoch, | 835 "timestamp": new DateTime.now().millisecondsSinceEpoch, |
| 723 "topFrame": frameDesc(topFrame, 0), | 836 "topFrame": await frameDesc(topFrame, 0), |
| 724 "atAsyncSuspension": false, | 837 "atAsyncSuspension": false, |
| 725 "breakpoint": breakpointDesc(breakpoint), | 838 "breakpoint": breakpointDesc(breakpoint), |
| 726 "pauseBreakpoints": | 839 "pauseBreakpoints": |
| 727 new List.from(pauseBreakpoints.map((bp) => breakpointDesc(bp))), | 840 new List.from(pauseBreakpoints.map((bp) => breakpointDesc(bp))), |
| 728 }; | 841 }; |
| 729 lastPauseEvent = event; | 842 lastPauseEvent = event; |
| 730 streamNotify("Debug", event); | 843 streamNotify("Debug", event); |
| 731 } | 844 } |
| 732 | 845 |
| 733 @override | 846 @override |
| 734 pauseException(int processId, BackTraceFrame topFrame, RemoteObject thrown) { | 847 pauseException( |
| 848 int processId, BackTraceFrame topFrame, RemoteObject thrown) async { |
| 735 Map event = { | 849 Map event = { |
| 736 "type": "Event", | 850 "type": "Event", |
| 737 "kind": "PauseException", | 851 "kind": "PauseException", |
| 738 "isolate": isolateRef(processId), | 852 "isolate": isolateRef(processId), |
| 739 "timestamp": new DateTime.now().millisecondsSinceEpoch, | 853 "timestamp": new DateTime.now().millisecondsSinceEpoch, |
| 740 "topFrame": frameDesc(topFrame, 0), | 854 "topFrame": await frameDesc(topFrame, 0), |
| 741 "atAsyncSuspension": false, | 855 "atAsyncSuspension": false, |
| 742 // TODO(sigurdm): pass thrown as an instance. | 856 // TODO(sigurdm): pass thrown as an instance. |
| 743 }; | 857 }; |
| 744 streamNotify("Debug", event); | 858 streamNotify("Debug", event); |
| 745 } | 859 } |
| 746 | 860 |
| 747 @override | 861 @override |
| 748 pauseExit(int processId, BackTraceFrame topFrame) { | 862 pauseExit(int processId, BackTraceFrame topFrame) { |
| 749 // TODO(sigurdm): implement pauseExit | 863 // TODO(sigurdm): implement pauseExit |
| 750 } | 864 } |
| 751 | 865 |
| 752 @override | 866 @override |
| 753 pauseInterrupted(int processId, BackTraceFrame topFrame) { | 867 pauseInterrupted(int processId, BackTraceFrame topFrame) async { |
| 754 Map event = { | 868 Map event = { |
| 755 "type": "Event", | 869 "type": "Event", |
| 756 "kind": "PauseInterrupted", | 870 "kind": "PauseInterrupted", |
| 757 "isolate": isolateRef(processId), | 871 "isolate": isolateRef(processId), |
| 758 "timestamp": new DateTime.now().millisecondsSinceEpoch, | 872 "timestamp": new DateTime.now().millisecondsSinceEpoch, |
| 759 "topFrame": frameDesc(topFrame, 0), | 873 "topFrame": await frameDesc(topFrame, 0), |
| 760 "atAsyncSuspension": false, | 874 "atAsyncSuspension": false, |
| 761 }; | 875 }; |
| 762 lastPauseEvent = event; | 876 lastPauseEvent = event; |
| 763 streamNotify("Debug", event); | 877 streamNotify("Debug", event); |
| 764 } | 878 } |
| 765 | 879 |
| 766 @override | 880 @override |
| 767 pauseStart(int processId) { | 881 pauseStart(int processId) { |
| 768 Map event = { | 882 Map event = { |
| 769 "type": "Event", | 883 "type": "Event", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 processStart(int processId) { | 915 processStart(int processId) { |
| 802 streamNotify("Isolate", { | 916 streamNotify("Isolate", { |
| 803 "type": "Event", | 917 "type": "Event", |
| 804 "kind": "IsolateStart", | 918 "kind": "IsolateStart", |
| 805 "isolate": isolateRef(processId), | 919 "isolate": isolateRef(processId), |
| 806 "timestamp": new DateTime.now().millisecondsSinceEpoch, | 920 "timestamp": new DateTime.now().millisecondsSinceEpoch, |
| 807 }); | 921 }); |
| 808 } | 922 } |
| 809 | 923 |
| 810 @override | 924 @override |
| 811 resume(int processId) { | 925 resume(int processId) async { |
| 812 Map event = { | 926 Map event = { |
| 813 "type": "Event", | 927 "type": "Event", |
| 814 "kind": "Resume", | 928 "kind": "Resume", |
| 815 "isolate": isolateRef(processId), | 929 "isolate": isolateRef(processId), |
| 816 "timestamp": new DateTime.now().millisecondsSinceEpoch, | 930 "timestamp": new DateTime.now().millisecondsSinceEpoch, |
| 817 }; | 931 }; |
| 818 BackTraceFrame topFrame = vmContext.debugState.topFrame; | 932 BackTraceFrame topFrame = vmContext.debugState.topFrame; |
| 819 if (topFrame != null) { | 933 if (topFrame != null) { |
| 820 event["topFrame"] = frameDesc(vmContext.debugState.topFrame, 0); | 934 event["topFrame"] = await frameDesc(vmContext.debugState.topFrame, 0); |
| 821 } | 935 } |
| 822 lastPauseEvent = event; | 936 lastPauseEvent = event; |
| 823 streamNotify("Debug", event); | 937 streamNotify("Debug", event); |
| 824 } | 938 } |
| 825 | 939 |
| 826 @override | 940 @override |
| 827 writeStdErr(int processId, List<int> data) { | 941 writeStdErr(int processId, List<int> data) { |
| 828 Map event = { | 942 Map event = { |
| 829 "type": "Event", | 943 "type": "Event", |
| 830 "kind": "WriteEvent", | 944 "kind": "WriteEvent", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 } | 986 } |
| 873 | 987 |
| 874 visitScopeContainerElement(ScopeContainerElement e, _) { | 988 visitScopeContainerElement(ScopeContainerElement e, _) { |
| 875 e.forEachLocalMember(visit); | 989 e.forEachLocalMember(visit); |
| 876 } | 990 } |
| 877 | 991 |
| 878 visitCompilationUnitElement(CompilationUnitElement e, _) { | 992 visitCompilationUnitElement(CompilationUnitElement e, _) { |
| 879 e.forEachLocalMember(visit); | 993 e.forEachLocalMember(visit); |
| 880 } | 994 } |
| 881 } | 995 } |
| OLD | NEW |