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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; | 106 Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; |
107 | 107 |
108 // These are the set of streams known to the core VM. | 108 // These are the set of streams known to the core VM. |
109 StreamInfo Service::vm_stream("VM"); | 109 StreamInfo Service::vm_stream("VM"); |
110 StreamInfo Service::isolate_stream("Isolate"); | 110 StreamInfo Service::isolate_stream("Isolate"); |
111 StreamInfo Service::debug_stream("Debug"); | 111 StreamInfo Service::debug_stream("Debug"); |
112 StreamInfo Service::gc_stream("GC"); | 112 StreamInfo Service::gc_stream("GC"); |
113 StreamInfo Service::echo_stream("_Echo"); | 113 StreamInfo Service::echo_stream("_Echo"); |
114 StreamInfo Service::graph_stream("_Graph"); | 114 StreamInfo Service::graph_stream("_Graph"); |
115 StreamInfo Service::logging_stream("_Logging"); | 115 StreamInfo Service::logging_stream("_Logging"); |
| 116 StreamInfo Service::extension_stream("Extension"); |
116 | 117 |
117 static StreamInfo* streams_[] = { | 118 static StreamInfo* streams_[] = { |
118 &Service::vm_stream, | 119 &Service::vm_stream, |
119 &Service::isolate_stream, | 120 &Service::isolate_stream, |
120 &Service::debug_stream, | 121 &Service::debug_stream, |
121 &Service::gc_stream, | 122 &Service::gc_stream, |
122 &Service::echo_stream, | 123 &Service::echo_stream, |
123 &Service::graph_stream, | 124 &Service::graph_stream, |
124 &Service::logging_stream, | 125 &Service::logging_stream, |
| 126 &Service::extension_stream, |
125 }; | 127 }; |
126 | 128 |
127 | 129 |
128 bool Service::ListenStream(const char* stream_id) { | 130 bool Service::ListenStream(const char* stream_id) { |
129 if (FLAG_trace_service) { | 131 if (FLAG_trace_service) { |
130 OS::Print("vm-service: starting stream '%s'\n", | 132 OS::Print("vm-service: starting stream '%s'\n", |
131 stream_id); | 133 stream_id); |
132 } | 134 } |
133 intptr_t num_streams = sizeof(streams_) / | 135 intptr_t num_streams = sizeof(streams_) / |
134 sizeof(streams_[0]); | 136 sizeof(streams_[0]); |
(...skipping 2810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2945 | 2947 |
2946 void Service::SendLogEvent(Isolate* isolate, | 2948 void Service::SendLogEvent(Isolate* isolate, |
2947 int64_t sequence_number, | 2949 int64_t sequence_number, |
2948 int64_t timestamp, | 2950 int64_t timestamp, |
2949 intptr_t level, | 2951 intptr_t level, |
2950 const String& name, | 2952 const String& name, |
2951 const String& message, | 2953 const String& message, |
2952 const Instance& zone, | 2954 const Instance& zone, |
2953 const Object& error, | 2955 const Object& error, |
2954 const Instance& stack_trace) { | 2956 const Instance& stack_trace) { |
| 2957 if (!Service::logging_stream.enabled()) { |
| 2958 return; |
| 2959 } |
2955 ServiceEvent::LogRecord log_record; | 2960 ServiceEvent::LogRecord log_record; |
2956 log_record.sequence_number = sequence_number; | 2961 log_record.sequence_number = sequence_number; |
2957 log_record.timestamp = timestamp; | 2962 log_record.timestamp = timestamp; |
2958 log_record.level = level; | 2963 log_record.level = level; |
2959 log_record.name = &name; | 2964 log_record.name = &name; |
2960 log_record.message = &message; | 2965 log_record.message = &message; |
2961 log_record.zone = &zone; | 2966 log_record.zone = &zone; |
2962 log_record.error = &error; | 2967 log_record.error = &error; |
2963 log_record.stack_trace = &stack_trace; | 2968 log_record.stack_trace = &stack_trace; |
2964 ServiceEvent event(isolate, ServiceEvent::kLogging); | 2969 ServiceEvent event(isolate, ServiceEvent::kLogging); |
2965 event.set_log_record(log_record); | 2970 event.set_log_record(log_record); |
2966 Service::HandleEvent(&event); | 2971 Service::HandleEvent(&event); |
2967 } | 2972 } |
2968 | 2973 |
2969 | 2974 |
| 2975 void Service::SendExtensionEvent(Isolate* isolate, |
| 2976 const String& event_kind, |
| 2977 const String& event_data) { |
| 2978 if (!Service::extension_stream.enabled()) { |
| 2979 return; |
| 2980 } |
| 2981 ServiceEvent::ExtensionEvent extension_event; |
| 2982 extension_event.event_kind = &event_kind; |
| 2983 extension_event.event_data = &event_data; |
| 2984 ServiceEvent event(isolate, ServiceEvent::kExtension); |
| 2985 event.set_extension_event(extension_event); |
| 2986 Service::HandleEvent(&event); |
| 2987 } |
| 2988 |
| 2989 |
2970 class ContainsAddressVisitor : public FindObjectVisitor { | 2990 class ContainsAddressVisitor : public FindObjectVisitor { |
2971 public: | 2991 public: |
2972 ContainsAddressVisitor(Isolate* isolate, uword addr) | 2992 ContainsAddressVisitor(Isolate* isolate, uword addr) |
2973 : FindObjectVisitor(isolate), addr_(addr) { } | 2993 : FindObjectVisitor(isolate), addr_(addr) { } |
2974 virtual ~ContainsAddressVisitor() { } | 2994 virtual ~ContainsAddressVisitor() { } |
2975 | 2995 |
2976 virtual uword filter_addr() const { return addr_; } | 2996 virtual uword filter_addr() const { return addr_; } |
2977 | 2997 |
2978 virtual bool FindObject(RawObject* obj) const { | 2998 virtual bool FindObject(RawObject* obj) const { |
2979 // Free list elements are not real objects, so skip them. | 2999 // Free list elements are not real objects, so skip them. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3575 const ServiceMethodDescriptor& method = service_methods_[i]; | 3595 const ServiceMethodDescriptor& method = service_methods_[i]; |
3576 if (strcmp(method_name, method.name) == 0) { | 3596 if (strcmp(method_name, method.name) == 0) { |
3577 return &method; | 3597 return &method; |
3578 } | 3598 } |
3579 } | 3599 } |
3580 return NULL; | 3600 return NULL; |
3581 } | 3601 } |
3582 | 3602 |
3583 | 3603 |
3584 } // namespace dart | 3604 } // namespace dart |
OLD | NEW |