| 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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 const char* event_type, | 907 const char* event_type, |
| 908 uint8_t* bytes, | 908 uint8_t* bytes, |
| 909 intptr_t bytes_length) { | 909 intptr_t bytes_length) { |
| 910 Thread* thread = Thread::Current(); | 910 Thread* thread = Thread::Current(); |
| 911 Isolate* isolate = thread->isolate(); | 911 Isolate* isolate = thread->isolate(); |
| 912 ASSERT(isolate != NULL); | 912 ASSERT(isolate != NULL); |
| 913 ASSERT(!ServiceIsolate::IsServiceIsolateDescendant(isolate)); | 913 ASSERT(!ServiceIsolate::IsServiceIsolateDescendant(isolate)); |
| 914 | 914 |
| 915 if (FLAG_trace_service) { | 915 if (FLAG_trace_service) { |
| 916 OS::PrintErr( | 916 OS::PrintErr( |
| 917 "vm-service: Pushing ServiceEvent(isolate='%s', kind='%s'," | 917 "vm-service: Pushing ServiceEvent(isolate='%s', " |
| 918 "isolateId='" ISOLATE_SERVICE_ID_FORMAT_STRING |
| 919 "', kind='%s'," |
| 918 " len=%" Pd ") to stream %s\n", | 920 " len=%" Pd ") to stream %s\n", |
| 919 isolate->name(), event_type, bytes_length, stream_id); | 921 isolate->name(), static_cast<int64_t>(isolate->main_port()), event_type, |
| 922 bytes_length, stream_id); |
| 920 } | 923 } |
| 921 | 924 |
| 922 bool result; | 925 bool result; |
| 923 { | 926 { |
| 924 TransitionVMToNative transition(thread); | 927 TransitionVMToNative transition(thread); |
| 925 Dart_CObject cbytes; | 928 Dart_CObject cbytes; |
| 926 cbytes.type = Dart_CObject_kExternalTypedData; | 929 cbytes.type = Dart_CObject_kExternalTypedData; |
| 927 cbytes.value.as_external_typed_data.type = Dart_TypedData_kUint8; | 930 cbytes.value.as_external_typed_data.type = Dart_TypedData_kUint8; |
| 928 cbytes.value.as_external_typed_data.length = bytes_length; | 931 cbytes.value.as_external_typed_data.length = bytes_length; |
| 929 cbytes.value.as_external_typed_data.data = bytes; | 932 cbytes.value.as_external_typed_data.data = bytes; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 978 |
| 976 // Data. | 979 // Data. |
| 977 memmove(&message[offset], data, data_size); | 980 memmove(&message[offset], data, data_size); |
| 978 offset += data_size; | 981 offset += data_size; |
| 979 | 982 |
| 980 ASSERT(offset == total_bytes); | 983 ASSERT(offset == total_bytes); |
| 981 SendEvent(stream_id, event_type, message, total_bytes); | 984 SendEvent(stream_id, event_type, message, total_bytes); |
| 982 } | 985 } |
| 983 | 986 |
| 984 static void ReportPauseOnConsole(ServiceEvent* event) { | 987 static void ReportPauseOnConsole(ServiceEvent* event) { |
| 985 const char* name = event->isolate()->debugger_name(); | 988 const char* name = event->isolate()->name(); |
| 989 const int64_t main_port = static_cast<int64_t>(event->isolate()->main_port()); |
| 986 switch (event->kind()) { | 990 switch (event->kind()) { |
| 987 case ServiceEvent::kPauseStart: | 991 case ServiceEvent::kPauseStart: |
| 988 OS::PrintErr( | 992 OS::PrintErr("vm-service: isolate(%" Pd64 |
| 989 "vm-service: isolate '%s' has no debugger attached and is paused at " | 993 ") '%s' has no debugger attached and is paused at start.", |
| 990 "start.", | 994 main_port, name); |
| 991 name); | |
| 992 break; | 995 break; |
| 993 case ServiceEvent::kPauseExit: | 996 case ServiceEvent::kPauseExit: |
| 994 OS::PrintErr( | 997 OS::PrintErr("vm-service: isolate(%" Pd64 |
| 995 "vm-service: isolate '%s' has no debugger attached and is paused at " | 998 ") '%s' has no debugger attached and is paused at exit.", |
| 996 "exit.", | 999 main_port, name); |
| 997 name); | |
| 998 break; | 1000 break; |
| 999 case ServiceEvent::kPauseException: | 1001 case ServiceEvent::kPauseException: |
| 1000 OS::PrintErr( | 1002 OS::PrintErr( |
| 1001 "vm-service: isolate '%s' has no debugger attached and is paused due " | 1003 "vm-service: isolate (%" Pd64 |
| 1002 "to exception.", | 1004 ") '%s' has no debugger attached and is paused due to exception.", |
| 1003 name); | 1005 main_port, name); |
| 1004 break; | 1006 break; |
| 1005 case ServiceEvent::kPauseInterrupted: | 1007 case ServiceEvent::kPauseInterrupted: |
| 1006 OS::PrintErr( | 1008 OS::PrintErr( |
| 1007 "vm-service: isolate '%s' has no debugger attached and is paused due " | 1009 "vm-service: isolate (%" Pd64 |
| 1008 "to interrupt.", | 1010 ") '%s' has no debugger attached and is paused due to interrupt.", |
| 1009 name); | 1011 main_port, name); |
| 1010 break; | 1012 break; |
| 1011 case ServiceEvent::kPauseBreakpoint: | 1013 case ServiceEvent::kPauseBreakpoint: |
| 1012 OS::PrintErr( | 1014 OS::PrintErr("vm-service: isolate (%" Pd64 |
| 1013 "vm-service: isolate '%s' has no debugger attached and is paused.", | 1015 ") '%s' has no debugger attached and is paused.", |
| 1014 name); | 1016 main_port, name); |
| 1015 break; | 1017 break; |
| 1016 case ServiceEvent::kPausePostRequest: | 1018 case ServiceEvent::kPausePostRequest: |
| 1017 OS::PrintErr( | 1019 OS::PrintErr("vm-service: isolate (%" Pd64 |
| 1018 "vm-service: isolate '%s' has no debugger attached and is paused " | 1020 ") '%s' has no debugger attached and is paused post reload.", |
| 1019 "post reload.", | 1021 main_port, name); |
| 1020 name); | |
| 1021 break; | 1022 break; |
| 1022 default: | 1023 default: |
| 1023 UNREACHABLE(); | 1024 UNREACHABLE(); |
| 1024 break; | 1025 break; |
| 1025 } | 1026 } |
| 1026 if (!ServiceIsolate::IsRunning()) { | 1027 if (!ServiceIsolate::IsRunning()) { |
| 1027 OS::PrintErr(" Start the vm-service to debug.\n"); | 1028 OS::PrintErr(" Start the vm-service to debug.\n"); |
| 1028 } else if (ServiceIsolate::server_address() == NULL) { | 1029 } else if (ServiceIsolate::server_address() == NULL) { |
| 1029 OS::PrintErr(" Connect to Observatory to debug.\n"); | 1030 OS::PrintErr(" Connect to Observatory to debug.\n"); |
| 1030 } else { | 1031 } else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 stream_id_cobj.type = Dart_CObject_kString; | 1088 stream_id_cobj.type = Dart_CObject_kString; |
| 1088 stream_id_cobj.value.as_string = const_cast<char*>(stream_id); | 1089 stream_id_cobj.value.as_string = const_cast<char*>(stream_id); |
| 1089 list_values[0] = &stream_id_cobj; | 1090 list_values[0] = &stream_id_cobj; |
| 1090 | 1091 |
| 1091 Dart_CObject json_cobj; | 1092 Dart_CObject json_cobj; |
| 1092 json_cobj.type = Dart_CObject_kString; | 1093 json_cobj.type = Dart_CObject_kString; |
| 1093 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); | 1094 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); |
| 1094 list_values[1] = &json_cobj; | 1095 list_values[1] = &json_cobj; |
| 1095 | 1096 |
| 1096 if (FLAG_trace_service) { | 1097 if (FLAG_trace_service) { |
| 1097 const char* isolate_name = "<no current isolate>"; | |
| 1098 if (isolate != NULL) { | 1098 if (isolate != NULL) { |
| 1099 isolate_name = isolate->name(); | 1099 OS::PrintErr( |
| 1100 "vm-service: Pushing ServiceEvent(isolate='%s', " |
| 1101 "isolateId='" ISOLATE_SERVICE_ID_FORMAT_STRING |
| 1102 "', kind='%s') to stream %s\n", |
| 1103 isolate->name(), static_cast<int64_t>(isolate->main_port()), kind, |
| 1104 stream_id); |
| 1105 } else { |
| 1106 OS::PrintErr( |
| 1107 "vm-service: Pushing ServiceEvent(isolate='<no current isolate>', " |
| 1108 "kind='%s') to stream %s\n", |
| 1109 kind, stream_id); |
| 1100 } | 1110 } |
| 1101 OS::PrintErr( | |
| 1102 "vm-service: Pushing ServiceEvent(isolate='%s', kind='%s') " | |
| 1103 "to stream %s\n", | |
| 1104 isolate_name, kind, stream_id); | |
| 1105 } | 1111 } |
| 1106 | 1112 |
| 1107 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); | 1113 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); |
| 1108 } | 1114 } |
| 1109 | 1115 |
| 1110 class EmbedderServiceHandler { | 1116 class EmbedderServiceHandler { |
| 1111 public: | 1117 public: |
| 1112 explicit EmbedderServiceHandler(const char* name) | 1118 explicit EmbedderServiceHandler(const char* name) |
| 1113 : name_(NULL), callback_(NULL), user_data_(NULL), next_(NULL) { | 1119 : name_(NULL), callback_(NULL), user_data_(NULL), next_(NULL) { |
| 1114 ASSERT(name != NULL); | 1120 ASSERT(name != NULL); |
| (...skipping 2896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4011 PrintInvalidParamError(js, "libraryId"); | 4017 PrintInvalidParamError(js, "libraryId"); |
| 4012 return true; | 4018 return true; |
| 4013 } | 4019 } |
| 4014 | 4020 |
| 4015 static const MethodParameter* set_name_params[] = { | 4021 static const MethodParameter* set_name_params[] = { |
| 4016 ISOLATE_PARAMETER, new MethodParameter("name", true), NULL, | 4022 ISOLATE_PARAMETER, new MethodParameter("name", true), NULL, |
| 4017 }; | 4023 }; |
| 4018 | 4024 |
| 4019 static bool SetName(Thread* thread, JSONStream* js) { | 4025 static bool SetName(Thread* thread, JSONStream* js) { |
| 4020 Isolate* isolate = thread->isolate(); | 4026 Isolate* isolate = thread->isolate(); |
| 4021 isolate->set_debugger_name(js->LookupParam("name")); | 4027 isolate->set_name(js->LookupParam("name")); |
| 4022 if (Service::isolate_stream.enabled()) { | 4028 if (Service::isolate_stream.enabled()) { |
| 4023 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); | 4029 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); |
| 4024 Service::HandleEvent(&event); | 4030 Service::HandleEvent(&event); |
| 4025 } | 4031 } |
| 4026 PrintSuccess(js); | 4032 PrintSuccess(js); |
| 4027 return true; | 4033 return true; |
| 4028 } | 4034 } |
| 4029 | 4035 |
| 4030 static const MethodParameter* set_vm_name_params[] = { | 4036 static const MethodParameter* set_vm_name_params[] = { |
| 4031 NO_ISOLATE_PARAMETER, new MethodParameter("name", true), NULL, | 4037 NO_ISOLATE_PARAMETER, new MethodParameter("name", true), NULL, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4200 if (strcmp(method_name, method.name) == 0) { | 4206 if (strcmp(method_name, method.name) == 0) { |
| 4201 return &method; | 4207 return &method; |
| 4202 } | 4208 } |
| 4203 } | 4209 } |
| 4204 return NULL; | 4210 return NULL; |
| 4205 } | 4211 } |
| 4206 | 4212 |
| 4207 #endif // !PRODUCT | 4213 #endif // !PRODUCT |
| 4208 | 4214 |
| 4209 } // namespace dart | 4215 } // namespace dart |
| OLD | NEW |