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 "include/dart_native_api.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 | 10 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 const String& stream_id_str = String::Handle(String::New(stream_id)); | 665 const String& stream_id_str = String::Handle(String::New(stream_id)); |
666 list.SetAt(0, stream_id_str); | 666 list.SetAt(0, stream_id_str); |
667 list.SetAt(1, event_message); | 667 list.SetAt(1, event_message); |
668 | 668 |
669 // Push the event to port_. | 669 // Push the event to port_. |
670 uint8_t* data = NULL; | 670 uint8_t* data = NULL; |
671 MessageWriter writer(&data, &allocator, false); | 671 MessageWriter writer(&data, &allocator, false); |
672 writer.WriteMessage(list); | 672 writer.WriteMessage(list); |
673 intptr_t len = writer.BytesWritten(); | 673 intptr_t len = writer.BytesWritten(); |
674 if (FLAG_trace_service) { | 674 if (FLAG_trace_service) { |
675 OS::Print( | 675 OS::Print("vm-service: Pushing ServiceEvent(isolate='%s', kind='%s'," |
676 "vm-service: Pushing event of type %s to stream %s (%s), len %" Pd "\n", | 676 " len=%" Pd ") to stream %s\n", |
677 event_type, stream_id, isolate->name(), len); | 677 isolate->name(), event_type, len, stream_id); |
678 } | 678 } |
679 // TODO(turnidge): For now we ignore failure to send an event. Revisit? | 679 // TODO(turnidge): For now we ignore failure to send an event. Revisit? |
680 PortMap::PostMessage( | 680 PortMap::PostMessage( |
681 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); | 681 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 // TODO(turnidge): Rewrite this method to use Post_CObject instead. | 685 // TODO(turnidge): Rewrite this method to use Post_CObject instead. |
686 void Service::SendEventWithData(const char* stream_id, | 686 void Service::SendEventWithData(const char* stream_id, |
687 const char* event_type, | 687 const char* event_type, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 json_cobj.type = Dart_CObject_kString; | 763 json_cobj.type = Dart_CObject_kString; |
764 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); | 764 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); |
765 list_values[1] = &json_cobj; | 765 list_values[1] = &json_cobj; |
766 | 766 |
767 if (FLAG_trace_service) { | 767 if (FLAG_trace_service) { |
768 Isolate* isolate = Isolate::Current(); | 768 Isolate* isolate = Isolate::Current(); |
769 const char* isolate_name = "<no current isolate>"; | 769 const char* isolate_name = "<no current isolate>"; |
770 if (isolate != NULL) { | 770 if (isolate != NULL) { |
771 isolate_name = isolate->name(); | 771 isolate_name = isolate->name(); |
772 } | 772 } |
773 OS::Print( | 773 OS::Print("vm-service: Pushing ServiceEvent(isolate='%s', kind='%s') " |
774 "vm-service: Pushing event of type %s to stream %s (%s)\n", | 774 "to stream %s\n", |
775 kind, stream_id, isolate_name); | 775 isolate_name, kind, stream_id); |
776 } | 776 } |
777 | 777 |
778 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); | 778 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 class EmbedderServiceHandler { | 782 class EmbedderServiceHandler { |
783 public: | 783 public: |
784 explicit EmbedderServiceHandler(const char* name) : name_(NULL), | 784 explicit EmbedderServiceHandler(const char* name) : name_(NULL), |
785 callback_(NULL), | 785 callback_(NULL), |
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2961 // Construct the isolate list. | 2961 // Construct the isolate list. |
2962 { | 2962 { |
2963 JSONArray jsarr(&jsobj, "isolates"); | 2963 JSONArray jsarr(&jsobj, "isolates"); |
2964 ServiceIsolateVisitor visitor(&jsarr); | 2964 ServiceIsolateVisitor visitor(&jsarr); |
2965 Isolate::VisitIsolates(&visitor); | 2965 Isolate::VisitIsolates(&visitor); |
2966 } | 2966 } |
2967 return true; | 2967 return true; |
2968 } | 2968 } |
2969 | 2969 |
2970 | 2970 |
| 2971 static const MethodParameter* restart_vm_params[] = { |
| 2972 NO_ISOLATE_PARAMETER, |
| 2973 NULL, |
| 2974 }; |
| 2975 |
| 2976 |
| 2977 static bool RestartVM(Isolate* isolate, JSONStream* js) { |
| 2978 Isolate::KillAllIsolates(Isolate::kVMRestartMsg); |
| 2979 PrintSuccess(js); |
| 2980 return true; |
| 2981 } |
| 2982 |
| 2983 |
2971 static const MethodParameter* set_exception_pause_info_params[] = { | 2984 static const MethodParameter* set_exception_pause_info_params[] = { |
2972 ISOLATE_PARAMETER, | 2985 ISOLATE_PARAMETER, |
2973 NULL, | 2986 NULL, |
2974 }; | 2987 }; |
2975 | 2988 |
2976 | 2989 |
2977 static bool SetExceptionPauseInfo(Isolate* isolate, JSONStream* js) { | 2990 static bool SetExceptionPauseInfo(Isolate* isolate, JSONStream* js) { |
2978 const char* exceptions = js->LookupParam("exceptions"); | 2991 const char* exceptions = js->LookupParam("exceptions"); |
2979 if (exceptions == NULL) { | 2992 if (exceptions == NULL) { |
2980 PrintMissingParamError(js, "exceptions"); | 2993 PrintMissingParamError(js, "exceptions"); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3187 { "getVM", GetVM, | 3200 { "getVM", GetVM, |
3188 get_vm_params }, | 3201 get_vm_params }, |
3189 { "_getVMMetric", GetVMMetric, | 3202 { "_getVMMetric", GetVMMetric, |
3190 get_vm_metric_params }, | 3203 get_vm_metric_params }, |
3191 { "_getVMMetricList", GetVMMetricList, | 3204 { "_getVMMetricList", GetVMMetricList, |
3192 get_vm_metric_list_params }, | 3205 get_vm_metric_list_params }, |
3193 { "pause", Pause, | 3206 { "pause", Pause, |
3194 pause_params }, | 3207 pause_params }, |
3195 { "removeBreakpoint", RemoveBreakpoint, | 3208 { "removeBreakpoint", RemoveBreakpoint, |
3196 remove_breakpoint_params }, | 3209 remove_breakpoint_params }, |
| 3210 { "_restartVM", RestartVM, |
| 3211 restart_vm_params }, |
3197 { "resume", Resume, | 3212 { "resume", Resume, |
3198 resume_params }, | 3213 resume_params }, |
3199 { "_requestHeapSnapshot", RequestHeapSnapshot, | 3214 { "_requestHeapSnapshot", RequestHeapSnapshot, |
3200 request_heap_snapshot_params }, | 3215 request_heap_snapshot_params }, |
3201 { "_setExceptionPauseInfo", SetExceptionPauseInfo, | 3216 { "_setExceptionPauseInfo", SetExceptionPauseInfo, |
3202 set_exception_pause_info_params }, | 3217 set_exception_pause_info_params }, |
3203 { "_setFlag", SetFlag, | 3218 { "_setFlag", SetFlag, |
3204 set_flags_params }, | 3219 set_flags_params }, |
3205 { "setLibraryDebuggable", SetLibraryDebuggable, | 3220 { "setLibraryDebuggable", SetLibraryDebuggable, |
3206 set_library_debuggable_params }, | 3221 set_library_debuggable_params }, |
(...skipping 11 matching lines...) Expand all Loading... |
3218 ServiceMethodDescriptor& method = service_methods_[i]; | 3233 ServiceMethodDescriptor& method = service_methods_[i]; |
3219 if (strcmp(method_name, method.name) == 0) { | 3234 if (strcmp(method_name, method.name) == 0) { |
3220 return &method; | 3235 return &method; |
3221 } | 3236 } |
3222 } | 3237 } |
3223 return NULL; | 3238 return NULL; |
3224 } | 3239 } |
3225 | 3240 |
3226 | 3241 |
3227 } // namespace dart | 3242 } // namespace dart |
OLD | NEW |