| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 offset += metadata_size; | 972 offset += metadata_size; |
| 973 | 973 |
| 974 // Data. | 974 // Data. |
| 975 memmove(&message[offset], data, data_size); | 975 memmove(&message[offset], data, data_size); |
| 976 offset += data_size; | 976 offset += data_size; |
| 977 | 977 |
| 978 ASSERT(offset == total_bytes); | 978 ASSERT(offset == total_bytes); |
| 979 SendEvent(stream_id, event_type, message, total_bytes); | 979 SendEvent(stream_id, event_type, message, total_bytes); |
| 980 } | 980 } |
| 981 | 981 |
| 982 #if !defined(PRODUCT) |
| 982 static void ReportPauseOnConsole(ServiceEvent* event) { | 983 static void ReportPauseOnConsole(ServiceEvent* event) { |
| 983 const char* name = event->isolate()->debugger_name(); | 984 const char* name = event->isolate()->debugger_name(); |
| 984 switch (event->kind()) { | 985 switch (event->kind()) { |
| 985 case ServiceEvent::kPauseStart: | 986 case ServiceEvent::kPauseStart: |
| 986 OS::PrintErr( | 987 OS::PrintErr( |
| 987 "vm-service: isolate '%s' has no debugger attached and is paused at " | 988 "vm-service: isolate '%s' has no debugger attached and is paused at " |
| 988 "start.", | 989 "start.", |
| 989 name); | 990 name); |
| 990 break; | 991 break; |
| 991 case ServiceEvent::kPauseExit: | 992 case ServiceEvent::kPauseExit: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 OS::PrintErr(" Connect to Observatory to debug.\n"); | 1028 OS::PrintErr(" Connect to Observatory to debug.\n"); |
| 1028 } else { | 1029 } else { |
| 1029 OS::PrintErr(" Connect to Observatory at %s to debug.\n", | 1030 OS::PrintErr(" Connect to Observatory at %s to debug.\n", |
| 1030 ServiceIsolate::server_address()); | 1031 ServiceIsolate::server_address()); |
| 1031 } | 1032 } |
| 1032 const Error& err = Error::Handle(Thread::Current()->sticky_error()); | 1033 const Error& err = Error::Handle(Thread::Current()->sticky_error()); |
| 1033 if (!err.IsNull()) { | 1034 if (!err.IsNull()) { |
| 1034 OS::PrintErr("%s\n", err.ToErrorCString()); | 1035 OS::PrintErr("%s\n", err.ToErrorCString()); |
| 1035 } | 1036 } |
| 1036 } | 1037 } |
| 1038 #endif |
| 1037 | 1039 |
| 1038 void Service::HandleEvent(ServiceEvent* event) { | 1040 void Service::HandleEvent(ServiceEvent* event) { |
| 1039 if (event->stream_info() != NULL && !event->stream_info()->enabled()) { | 1041 if (event->stream_info() != NULL && !event->stream_info()->enabled()) { |
| 1042 #if !defined(PRODUCT) |
| 1040 if (FLAG_warn_on_pause_with_no_debugger && event->IsPause()) { | 1043 if (FLAG_warn_on_pause_with_no_debugger && event->IsPause()) { |
| 1041 // If we are about to pause a running program which has no | 1044 // If we are about to pause a running program which has no |
| 1042 // debugger connected, tell the user about it. | 1045 // debugger connected, tell the user about it. |
| 1043 ReportPauseOnConsole(event); | 1046 ReportPauseOnConsole(event); |
| 1044 } | 1047 } |
| 1048 #endif |
| 1045 // Ignore events when no one is listening to the event stream. | 1049 // Ignore events when no one is listening to the event stream. |
| 1046 return; | 1050 return; |
| 1047 } | 1051 } |
| 1048 if (!ServiceIsolate::IsRunning()) { | 1052 if (!ServiceIsolate::IsRunning()) { |
| 1049 return; | 1053 return; |
| 1050 } | 1054 } |
| 1051 JSONStream js; | 1055 JSONStream js; |
| 1052 const char* stream_id = event->stream_id(); | 1056 const char* stream_id = event->stream_id(); |
| 1053 ASSERT(stream_id != NULL); | 1057 ASSERT(stream_id != NULL); |
| 1054 { | 1058 { |
| (...skipping 3071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4126 if (strcmp(method_name, method.name) == 0) { | 4130 if (strcmp(method_name, method.name) == 0) { |
| 4127 return &method; | 4131 return &method; |
| 4128 } | 4132 } |
| 4129 } | 4133 } |
| 4130 return NULL; | 4134 return NULL; |
| 4131 } | 4135 } |
| 4132 | 4136 |
| 4133 #endif // !PRODUCT | 4137 #endif // !PRODUCT |
| 4134 | 4138 |
| 4135 } // namespace dart | 4139 } // namespace dart |
| OLD | NEW |