| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/service.h" | 5 #include "vm/service.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" |
| 8 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 9 | 10 |
| 10 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 11 #include "vm/coverage.h" | 12 #include "vm/coverage.h" |
| 12 #include "vm/cpu.h" | 13 #include "vm/cpu.h" |
| 13 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
| 14 #include "vm/dart_entry.h" | 15 #include "vm/dart_entry.h" |
| 15 #include "vm/debugger.h" | 16 #include "vm/debugger.h" |
| 16 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
| 17 #include "vm/lockers.h" | 18 #include "vm/lockers.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return zone->PrintToString("objects/%" Pd "", id); | 68 return zone->PrintToString("objects/%" Pd "", id); |
| 68 } | 69 } |
| 69 | 70 |
| 70 | 71 |
| 71 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. | 72 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. |
| 72 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; | 73 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; |
| 73 EmbedderServiceHandler* Service::root_service_handler_head_ = NULL; | 74 EmbedderServiceHandler* Service::root_service_handler_head_ = NULL; |
| 74 struct ServiceMethodDescriptor; | 75 struct ServiceMethodDescriptor; |
| 75 ServiceMethodDescriptor* FindMethod(const char* method_name); | 76 ServiceMethodDescriptor* FindMethod(const char* method_name); |
| 76 | 77 |
| 77 // TODO(turnidge): Build a general framework later. For now, we have | |
| 78 // a small set of well-known streams. | |
| 79 bool Service::needs_isolate_events_ = false; | |
| 80 bool Service::needs_debug_events_ = false; | |
| 81 bool Service::needs_gc_events_ = false; | |
| 82 bool Service::needs_echo_events_ = false; | |
| 83 bool Service::needs_graph_events_ = false; | |
| 84 | 78 |
| 85 void Service::ListenStream(const char* stream_id) { | 79 // Support for streams defined in embedders. |
| 80 Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; |
| 81 Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; |
| 82 |
| 83 |
| 84 // These are the set of streams known to the core VM. |
| 85 StreamInfo Service::isolate_stream("Isolate"); |
| 86 StreamInfo Service::debug_stream("Debug"); |
| 87 StreamInfo Service::gc_stream("GC"); |
| 88 StreamInfo Service::echo_stream("_Echo"); |
| 89 StreamInfo Service::graph_stream("_Graph"); |
| 90 |
| 91 |
| 92 static StreamInfo* streams_[] = { |
| 93 &Service::isolate_stream, |
| 94 &Service::debug_stream, |
| 95 &Service::gc_stream, |
| 96 &Service::echo_stream, |
| 97 &Service::graph_stream, |
| 98 }; |
| 99 |
| 100 |
| 101 bool Service::ListenStream(const char* stream_id) { |
| 86 if (FLAG_trace_service) { | 102 if (FLAG_trace_service) { |
| 87 OS::Print("vm-service: starting stream '%s'\n", | 103 OS::Print("vm-service: starting stream '%s'\n", |
| 88 stream_id); | 104 stream_id); |
| 89 } | 105 } |
| 90 if (strcmp(stream_id, "Isolate") == 0) { | 106 intptr_t num_streams = sizeof(streams_) / |
| 91 needs_isolate_events_ = true; | 107 sizeof(streams_[0]); |
| 92 } else if (strcmp(stream_id, "Debug") == 0) { | 108 for (intptr_t i = 0; i < num_streams; i++) { |
| 93 needs_debug_events_ = true; | 109 if (strcmp(stream_id, streams_[i]->id()) == 0) { |
| 94 } else if (strcmp(stream_id, "GC") == 0) { | 110 streams_[i]->set_enabled(true); |
| 95 needs_gc_events_ = true; | 111 return true; |
| 96 } else if (strcmp(stream_id, "_Echo") == 0) { | 112 } |
| 97 needs_echo_events_ = true; | |
| 98 } else if (strcmp(stream_id, "_Graph") == 0) { | |
| 99 needs_graph_events_ = true; | |
| 100 } else { | |
| 101 UNREACHABLE(); | |
| 102 } | 113 } |
| 114 if (stream_listen_callback_) { |
| 115 return (*stream_listen_callback_)(stream_id); |
| 116 } |
| 117 return false; |
| 103 } | 118 } |
| 104 | 119 |
| 105 void Service::CancelStream(const char* stream_id) { | 120 void Service::CancelStream(const char* stream_id) { |
| 106 if (FLAG_trace_service) { | 121 if (FLAG_trace_service) { |
| 107 OS::Print("vm-service: stopping stream '%s'\n", | 122 OS::Print("vm-service: stopping stream '%s'\n", |
| 108 stream_id); | 123 stream_id); |
| 109 } | 124 } |
| 110 if (strcmp(stream_id, "Isolate") == 0) { | 125 intptr_t num_streams = sizeof(streams_) / |
| 111 needs_isolate_events_ = false; | 126 sizeof(streams_[0]); |
| 112 } else if (strcmp(stream_id, "Debug") == 0) { | 127 for (intptr_t i = 0; i < num_streams; i++) { |
| 113 needs_debug_events_ = false; | 128 if (strcmp(stream_id, streams_[i]->id()) == 0) { |
| 114 } else if (strcmp(stream_id, "GC") == 0) { | 129 streams_[i]->set_enabled(false); |
| 115 needs_gc_events_ = false; | 130 return; |
| 116 } else if (strcmp(stream_id, "_Echo") == 0) { | 131 } |
| 117 needs_echo_events_ = false; | 132 } |
| 118 } else if (strcmp(stream_id, "_Graph") == 0) { | 133 if (stream_cancel_callback_) { |
| 119 needs_graph_events_ = false; | 134 return (*stream_cancel_callback_)(stream_id); |
| 120 } else { | |
| 121 UNREACHABLE(); | |
| 122 } | 135 } |
| 123 } | 136 } |
| 124 | 137 |
| 125 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 138 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 126 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 139 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 127 return reinterpret_cast<uint8_t*>(new_ptr); | 140 return reinterpret_cast<uint8_t*>(new_ptr); |
| 128 } | 141 } |
| 129 | 142 |
| 130 static void PrintMissingParamError(JSONStream* js, | 143 static void PrintMissingParamError(JSONStream* js, |
| 131 const char* param) { | 144 const char* param) { |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 OS::Print( | 629 OS::Print( |
| 617 "vm-service: Pushing event of type %s to stream %s, len %" Pd "\n", | 630 "vm-service: Pushing event of type %s to stream %s, len %" Pd "\n", |
| 618 event_type, stream_id, len); | 631 event_type, stream_id, len); |
| 619 } | 632 } |
| 620 // TODO(turnidge): For now we ignore failure to send an event. Revisit? | 633 // TODO(turnidge): For now we ignore failure to send an event. Revisit? |
| 621 PortMap::PostMessage( | 634 PortMap::PostMessage( |
| 622 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); | 635 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); |
| 623 } | 636 } |
| 624 | 637 |
| 625 | 638 |
| 639 // TODO(turnidge): Rewrite this method to use Post_CObject instead. |
| 626 void Service::SendEventWithData(const char* stream_id, | 640 void Service::SendEventWithData(const char* stream_id, |
| 627 const char* event_type, | 641 const char* event_type, |
| 628 const String& meta, | 642 const String& meta, |
| 629 const uint8_t* data, | 643 const uint8_t* data, |
| 630 intptr_t size) { | 644 intptr_t size) { |
| 631 // Bitstream: [meta data size (big-endian 64 bit)] [meta data (UTF-8)] [data] | 645 // Bitstream: [meta data size (big-endian 64 bit)] [meta data (UTF-8)] [data] |
| 632 const intptr_t meta_bytes = Utf8::Length(meta); | 646 const intptr_t meta_bytes = Utf8::Length(meta); |
| 633 const intptr_t total_bytes = sizeof(uint64_t) + meta_bytes + size; | 647 const intptr_t total_bytes = sizeof(uint64_t) + meta_bytes + size; |
| 634 const TypedData& message = TypedData::Handle( | 648 const TypedData& message = TypedData::Handle( |
| 635 TypedData::New(kTypedDataUint8ArrayCid, total_bytes)); | 649 TypedData::New(kTypedDataUint8ArrayCid, total_bytes)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 651 } | 665 } |
| 652 ASSERT(offset == total_bytes); | 666 ASSERT(offset == total_bytes); |
| 653 SendEvent(stream_id, event_type, message); | 667 SendEvent(stream_id, event_type, message); |
| 654 } | 668 } |
| 655 | 669 |
| 656 | 670 |
| 657 void Service::HandleEvent(ServiceEvent* event) { | 671 void Service::HandleEvent(ServiceEvent* event) { |
| 658 if (ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) { | 672 if (ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) { |
| 659 return; | 673 return; |
| 660 } | 674 } |
| 675 if (!ServiceIsolate::IsRunning()) { |
| 676 return; |
| 677 } |
| 661 JSONStream js; | 678 JSONStream js; |
| 662 const char* stream_id = event->stream_id(); | 679 const char* stream_id = event->stream_id(); |
| 663 ASSERT(stream_id != NULL); | 680 ASSERT(stream_id != NULL); |
| 664 { | 681 { |
| 665 JSONObject jsobj(&js); | 682 JSONObject jsobj(&js); |
| 666 jsobj.AddProperty("event", event); | 683 jsobj.AddProperty("event", event); |
| 667 jsobj.AddProperty("streamId", stream_id); | 684 jsobj.AddProperty("streamId", stream_id); |
| 668 } | 685 } |
| 669 const String& message = String::Handle(String::New(js.ToCString())); | 686 |
| 670 SendEvent(stream_id, ServiceEvent::EventTypeToCString(event->type()), | 687 // Message is of the format [<stream id>, <json string>]. |
| 671 message); | 688 // |
| 689 // Build the event message in the C heap to avoid dart heap |
| 690 // allocation. This method can be called while we have acquired a |
| 691 // direct pointer to typed data, so we can't allocate here. |
| 692 Dart_CObject list_cobj; |
| 693 Dart_CObject* list_values[2]; |
| 694 list_cobj.type = Dart_CObject_kArray; |
| 695 list_cobj.value.as_array.length = 2; |
| 696 list_cobj.value.as_array.values = list_values; |
| 697 |
| 698 Dart_CObject stream_id_cobj; |
| 699 stream_id_cobj.type = Dart_CObject_kString; |
| 700 stream_id_cobj.value.as_string = const_cast<char*>(stream_id); |
| 701 list_values[0] = &stream_id_cobj; |
| 702 |
| 703 Dart_CObject json_cobj; |
| 704 json_cobj.type = Dart_CObject_kString; |
| 705 json_cobj.value.as_string = const_cast<char*>(js.ToCString()); |
| 706 list_values[1] = &json_cobj; |
| 707 |
| 708 if (FLAG_trace_service) { |
| 709 OS::Print( |
| 710 "vm-service: Pushing event of type %s to stream %s\n", |
| 711 event->KindAsCString(), stream_id); |
| 712 } |
| 713 |
| 714 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); |
| 672 } | 715 } |
| 673 | 716 |
| 674 | 717 |
| 675 class EmbedderServiceHandler { | 718 class EmbedderServiceHandler { |
| 676 public: | 719 public: |
| 677 explicit EmbedderServiceHandler(const char* name) : name_(NULL), | 720 explicit EmbedderServiceHandler(const char* name) : name_(NULL), |
| 678 callback_(NULL), | 721 callback_(NULL), |
| 679 user_data_(NULL), | 722 user_data_(NULL), |
| 680 next_(NULL) { | 723 next_(NULL) { |
| 681 ASSERT(name != NULL); | 724 ASSERT(name != NULL); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 handler = new EmbedderServiceHandler(name); | 828 handler = new EmbedderServiceHandler(name); |
| 786 handler->set_callback(callback); | 829 handler->set_callback(callback); |
| 787 handler->set_user_data(user_data); | 830 handler->set_user_data(user_data); |
| 788 | 831 |
| 789 // Insert into root_service_handler_head_ list. | 832 // Insert into root_service_handler_head_ list. |
| 790 handler->set_next(root_service_handler_head_); | 833 handler->set_next(root_service_handler_head_); |
| 791 root_service_handler_head_ = handler; | 834 root_service_handler_head_ = handler; |
| 792 } | 835 } |
| 793 | 836 |
| 794 | 837 |
| 838 void Service::SetEmbedderStreamCallbacks( |
| 839 Dart_ServiceStreamListenCallback listen_callback, |
| 840 Dart_ServiceStreamCancelCallback cancel_callback) { |
| 841 stream_listen_callback_ = listen_callback; |
| 842 stream_cancel_callback_ = cancel_callback; |
| 843 } |
| 844 |
| 845 |
| 795 EmbedderServiceHandler* Service::FindRootEmbedderHandler( | 846 EmbedderServiceHandler* Service::FindRootEmbedderHandler( |
| 796 const char* name) { | 847 const char* name) { |
| 797 EmbedderServiceHandler* current = root_service_handler_head_; | 848 EmbedderServiceHandler* current = root_service_handler_head_; |
| 798 while (current != NULL) { | 849 while (current != NULL) { |
| 799 if (strcmp(name, current->name()) == 0) { | 850 if (strcmp(name, current->name()) == 0) { |
| 800 return current; | 851 return current; |
| 801 } | 852 } |
| 802 current = current->next(); | 853 current = current->next(); |
| 803 } | 854 } |
| 804 return NULL; | 855 return NULL; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 JSONObject jsobj(&js); | 919 JSONObject jsobj(&js); |
| 869 { | 920 { |
| 870 JSONObject event(&jsobj, "event"); | 921 JSONObject event(&jsobj, "event"); |
| 871 event.AddProperty("type", "Event"); | 922 event.AddProperty("type", "Event"); |
| 872 event.AddProperty("kind", "_Echo"); | 923 event.AddProperty("kind", "_Echo"); |
| 873 event.AddProperty("isolate", isolate); | 924 event.AddProperty("isolate", isolate); |
| 874 if (text != NULL) { | 925 if (text != NULL) { |
| 875 event.AddProperty("text", text); | 926 event.AddProperty("text", text); |
| 876 } | 927 } |
| 877 } | 928 } |
| 878 jsobj.AddProperty("streamId", "_Echo"); | 929 jsobj.AddProperty("streamId", echo_stream.id()); |
| 879 } | 930 } |
| 880 const String& message = String::Handle(String::New(js.ToCString())); | 931 const String& message = String::Handle(String::New(js.ToCString())); |
| 881 uint8_t data[] = {0, 128, 255}; | 932 uint8_t data[] = {0, 128, 255}; |
| 882 SendEventWithData("_Echo", "_Echo", message, data, sizeof(data)); | 933 SendEventWithData(echo_stream.id(), "_Echo", message, data, sizeof(data)); |
| 883 } | 934 } |
| 884 | 935 |
| 885 | 936 |
| 886 static bool TriggerEchoEvent(Isolate* isolate, JSONStream* js) { | 937 static bool TriggerEchoEvent(Isolate* isolate, JSONStream* js) { |
| 887 if (Service::NeedsEchoEvents()) { | 938 if (Service::echo_stream.enabled()) { |
| 888 Service::SendEchoEvent(isolate, js->LookupParam("text")); | 939 Service::SendEchoEvent(isolate, js->LookupParam("text")); |
| 889 } | 940 } |
| 890 JSONObject jsobj(js); | 941 JSONObject jsobj(js); |
| 891 return HandleCommonEcho(&jsobj, js); | 942 return HandleCommonEcho(&jsobj, js); |
| 892 } | 943 } |
| 893 | 944 |
| 894 | 945 |
| 895 static bool DumpIdZone(Isolate* isolate, JSONStream* js) { | 946 static bool DumpIdZone(Isolate* isolate, JSONStream* js) { |
| 896 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, | 947 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, |
| 897 // always send the ObjectIdRing. | 948 // always send the ObjectIdRing. |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 static const MethodParameter* resume_params[] = { | 2234 static const MethodParameter* resume_params[] = { |
| 2184 ISOLATE_PARAMETER, | 2235 ISOLATE_PARAMETER, |
| 2185 NULL, | 2236 NULL, |
| 2186 }; | 2237 }; |
| 2187 | 2238 |
| 2188 | 2239 |
| 2189 static bool Resume(Isolate* isolate, JSONStream* js) { | 2240 static bool Resume(Isolate* isolate, JSONStream* js) { |
| 2190 const char* step_param = js->LookupParam("step"); | 2241 const char* step_param = js->LookupParam("step"); |
| 2191 if (isolate->message_handler()->paused_on_start()) { | 2242 if (isolate->message_handler()->paused_on_start()) { |
| 2192 isolate->message_handler()->set_pause_on_start(false); | 2243 isolate->message_handler()->set_pause_on_start(false); |
| 2193 if (Service::NeedsDebugEvents()) { | 2244 if (Service::debug_stream.enabled()) { |
| 2194 ServiceEvent event(isolate, ServiceEvent::kResume); | 2245 ServiceEvent event(isolate, ServiceEvent::kResume); |
| 2195 Service::HandleEvent(&event); | 2246 Service::HandleEvent(&event); |
| 2196 } | 2247 } |
| 2197 PrintSuccess(js); | 2248 PrintSuccess(js); |
| 2198 return true; | 2249 return true; |
| 2199 } | 2250 } |
| 2200 if (isolate->message_handler()->paused_on_exit()) { | 2251 if (isolate->message_handler()->paused_on_exit()) { |
| 2201 isolate->message_handler()->set_pause_on_exit(false); | 2252 isolate->message_handler()->set_pause_on_exit(false); |
| 2202 // We don't send a resume event because we will be exiting. | 2253 // We don't send a resume event because we will be exiting. |
| 2203 PrintSuccess(js); | 2254 PrintSuccess(js); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 } | 2428 } |
| 2378 | 2429 |
| 2379 | 2430 |
| 2380 static const MethodParameter* request_heap_snapshot_params[] = { | 2431 static const MethodParameter* request_heap_snapshot_params[] = { |
| 2381 ISOLATE_PARAMETER, | 2432 ISOLATE_PARAMETER, |
| 2382 NULL, | 2433 NULL, |
| 2383 }; | 2434 }; |
| 2384 | 2435 |
| 2385 | 2436 |
| 2386 static bool RequestHeapSnapshot(Isolate* isolate, JSONStream* js) { | 2437 static bool RequestHeapSnapshot(Isolate* isolate, JSONStream* js) { |
| 2387 if (Service::NeedsGraphEvents()) { | 2438 if (Service::graph_stream.enabled()) { |
| 2388 Service::SendGraphEvent(isolate); | 2439 Service::SendGraphEvent(isolate); |
| 2389 } | 2440 } |
| 2390 // TODO(koda): Provide some id that ties this request to async response(s). | 2441 // TODO(koda): Provide some id that ties this request to async response(s). |
| 2391 JSONObject jsobj(js); | 2442 JSONObject jsobj(js); |
| 2392 jsobj.AddProperty("type", "OK"); | 2443 jsobj.AddProperty("type", "OK"); |
| 2393 return true; | 2444 return true; |
| 2394 } | 2445 } |
| 2395 | 2446 |
| 2396 | 2447 |
| 2397 void Service::SendGraphEvent(Isolate* isolate) { | 2448 void Service::SendGraphEvent(Isolate* isolate) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2412 { | 2463 { |
| 2413 JSONObject event(&jsobj, "event"); | 2464 JSONObject event(&jsobj, "event"); |
| 2414 event.AddProperty("type", "Event"); | 2465 event.AddProperty("type", "Event"); |
| 2415 event.AddProperty("kind", "_Graph"); | 2466 event.AddProperty("kind", "_Graph"); |
| 2416 event.AddProperty("isolate", isolate); | 2467 event.AddProperty("isolate", isolate); |
| 2417 | 2468 |
| 2418 event.AddProperty("chunkIndex", i); | 2469 event.AddProperty("chunkIndex", i); |
| 2419 event.AddProperty("chunkCount", num_chunks); | 2470 event.AddProperty("chunkCount", num_chunks); |
| 2420 event.AddProperty("nodeCount", node_count); | 2471 event.AddProperty("nodeCount", node_count); |
| 2421 } | 2472 } |
| 2422 jsobj.AddProperty("streamId", "_Graph"); | 2473 jsobj.AddProperty("streamId", graph_stream.id()); |
| 2423 } | 2474 } |
| 2424 | 2475 |
| 2425 const String& message = String::Handle(String::New(js.ToCString())); | 2476 const String& message = String::Handle(String::New(js.ToCString())); |
| 2426 | 2477 |
| 2427 uint8_t* chunk_start = buffer + (i * kChunkSize); | 2478 uint8_t* chunk_start = buffer + (i * kChunkSize); |
| 2428 intptr_t chunk_size = (i + 1 == num_chunks) | 2479 intptr_t chunk_size = (i + 1 == num_chunks) |
| 2429 ? stream.bytes_written() - (i * kChunkSize) | 2480 ? stream.bytes_written() - (i * kChunkSize) |
| 2430 : kChunkSize; | 2481 : kChunkSize; |
| 2431 | 2482 |
| 2432 SendEventWithData("_Graph", "_Graph", message, chunk_start, chunk_size); | 2483 SendEventWithData(graph_stream.id(), "_Graph", message, |
| 2484 chunk_start, chunk_size); |
| 2433 } | 2485 } |
| 2434 } | 2486 } |
| 2435 | 2487 |
| 2436 | 2488 |
| 2437 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { | 2489 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { |
| 2438 if (!Service::NeedsDebugEvents()) { | 2490 if (!Service::debug_stream.enabled()) { |
| 2439 return; | 2491 return; |
| 2440 } | 2492 } |
| 2441 ServiceEvent event(isolate, ServiceEvent::kInspect); | 2493 ServiceEvent event(isolate, ServiceEvent::kInspect); |
| 2442 event.set_inspectee(&inspectee); | 2494 event.set_inspectee(&inspectee); |
| 2443 Service::HandleEvent(&event); | 2495 Service::HandleEvent(&event); |
| 2444 } | 2496 } |
| 2445 | 2497 |
| 2446 | 2498 |
| 2499 void Service::SendEmbedderEvent(Isolate* isolate, |
| 2500 const char* stream_id, |
| 2501 const char* event_kind, |
| 2502 const uint8_t* bytes, |
| 2503 intptr_t bytes_len) { |
| 2504 if (!Service::debug_stream.enabled()) { |
| 2505 return; |
| 2506 } |
| 2507 ServiceEvent event(isolate, ServiceEvent::kEmbedder); |
| 2508 event.set_embedder_kind(event_kind); |
| 2509 event.set_embedder_stream_id(stream_id); |
| 2510 event.set_bytes(bytes, bytes_len); |
| 2511 Service::HandleEvent(&event); |
| 2512 } |
| 2513 |
| 2514 |
| 2447 class ContainsAddressVisitor : public FindObjectVisitor { | 2515 class ContainsAddressVisitor : public FindObjectVisitor { |
| 2448 public: | 2516 public: |
| 2449 ContainsAddressVisitor(Isolate* isolate, uword addr) | 2517 ContainsAddressVisitor(Isolate* isolate, uword addr) |
| 2450 : FindObjectVisitor(isolate), addr_(addr) { } | 2518 : FindObjectVisitor(isolate), addr_(addr) { } |
| 2451 virtual ~ContainsAddressVisitor() { } | 2519 virtual ~ContainsAddressVisitor() { } |
| 2452 | 2520 |
| 2453 virtual uword filter_addr() const { return addr_; } | 2521 virtual uword filter_addr() const { return addr_; } |
| 2454 | 2522 |
| 2455 virtual bool FindObject(RawObject* obj) const { | 2523 virtual bool FindObject(RawObject* obj) const { |
| 2456 // Free list elements are not real objects, so skip them. | 2524 // Free list elements are not real objects, so skip them. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2719 } else if (strcmp(exceptions, "unhandled") == 0) { | 2787 } else if (strcmp(exceptions, "unhandled") == 0) { |
| 2720 info = kPauseOnUnhandledExceptions; | 2788 info = kPauseOnUnhandledExceptions; |
| 2721 } else { | 2789 } else { |
| 2722 JSONObject jsobj(js); | 2790 JSONObject jsobj(js); |
| 2723 jsobj.AddProperty("type", "Error"); | 2791 jsobj.AddProperty("type", "Error"); |
| 2724 jsobj.AddProperty("message", "illegal value for parameter 'exceptions'"); | 2792 jsobj.AddProperty("message", "illegal value for parameter 'exceptions'"); |
| 2725 return true; | 2793 return true; |
| 2726 } | 2794 } |
| 2727 | 2795 |
| 2728 isolate->debugger()->SetExceptionPauseInfo(info); | 2796 isolate->debugger()->SetExceptionPauseInfo(info); |
| 2729 if (Service::NeedsDebugEvents()) { | 2797 if (Service::debug_stream.enabled()) { |
| 2730 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); | 2798 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); |
| 2731 Service::HandleEvent(&event); | 2799 Service::HandleEvent(&event); |
| 2732 } | 2800 } |
| 2733 PrintSuccess(js); | 2801 PrintSuccess(js); |
| 2734 return true; | 2802 return true; |
| 2735 } | 2803 } |
| 2736 | 2804 |
| 2737 | 2805 |
| 2738 static const MethodParameter* get_flag_list_params[] = { | 2806 static const MethodParameter* get_flag_list_params[] = { |
| 2739 NO_ISOLATE_PARAMETER, | 2807 NO_ISOLATE_PARAMETER, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 | 2873 |
| 2806 static const MethodParameter* set_name_params[] = { | 2874 static const MethodParameter* set_name_params[] = { |
| 2807 ISOLATE_PARAMETER, | 2875 ISOLATE_PARAMETER, |
| 2808 new MethodParameter("name", true), | 2876 new MethodParameter("name", true), |
| 2809 NULL, | 2877 NULL, |
| 2810 }; | 2878 }; |
| 2811 | 2879 |
| 2812 | 2880 |
| 2813 static bool SetName(Isolate* isolate, JSONStream* js) { | 2881 static bool SetName(Isolate* isolate, JSONStream* js) { |
| 2814 isolate->set_debugger_name(js->LookupParam("name")); | 2882 isolate->set_debugger_name(js->LookupParam("name")); |
| 2815 if (Service::NeedsIsolateEvents()) { | 2883 if (Service::isolate_stream.enabled()) { |
| 2816 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); | 2884 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); |
| 2817 Service::HandleEvent(&event); | 2885 Service::HandleEvent(&event); |
| 2818 } | 2886 } |
| 2819 PrintSuccess(js); | 2887 PrintSuccess(js); |
| 2820 return true; | 2888 return true; |
| 2821 } | 2889 } |
| 2822 | 2890 |
| 2823 | 2891 |
| 2824 static const MethodParameter* set_trace_class_allocation_params[] = { | 2892 static const MethodParameter* set_trace_class_allocation_params[] = { |
| 2825 ISOLATE_PARAMETER, | 2893 ISOLATE_PARAMETER, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2946 ServiceMethodDescriptor& method = service_methods_[i]; | 3014 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2947 if (strcmp(method_name, method.name) == 0) { | 3015 if (strcmp(method_name, method.name) == 0) { |
| 2948 return &method; | 3016 return &method; |
| 2949 } | 3017 } |
| 2950 } | 3018 } |
| 2951 return NULL; | 3019 return NULL; |
| 2952 } | 3020 } |
| 2953 | 3021 |
| 2954 | 3022 |
| 2955 } // namespace dart | 3023 } // namespace dart |
| OLD | NEW |