| 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 |
| 11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 12 #include "vm/cpu.h" | 12 #include "vm/cpu.h" |
| 13 #include "vm/dart_api_impl.h" | 13 #include "vm/dart_api_impl.h" |
| 14 #include "vm/dart_api_state.h" | 14 #include "vm/dart_api_state.h" |
| 15 #include "vm/dart_entry.h" | 15 #include "vm/dart_entry.h" |
| 16 #include "vm/debugger.h" | 16 #include "vm/debugger.h" |
| 17 #include "vm/dev_fs.h" | |
| 18 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
| 19 #include "vm/lockers.h" | 18 #include "vm/lockers.h" |
| 20 #include "vm/message.h" | 19 #include "vm/message.h" |
| 21 #include "vm/message_handler.h" | 20 #include "vm/message_handler.h" |
| 22 #include "vm/native_entry.h" | 21 #include "vm/native_entry.h" |
| 23 #include "vm/native_arguments.h" | 22 #include "vm/native_arguments.h" |
| 24 #include "vm/native_symbol.h" | 23 #include "vm/native_symbol.h" |
| 25 #include "vm/object.h" | 24 #include "vm/object.h" |
| 26 #include "vm/object_graph.h" | 25 #include "vm/object_graph.h" |
| 27 #include "vm/object_id_ring.h" | 26 #include "vm/object_id_ring.h" |
| (...skipping 3973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 return true; | 4000 return true; |
| 4002 } | 4001 } |
| 4003 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); | 4002 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); |
| 4004 ASSERT(!cls.IsNull()); | 4003 ASSERT(!cls.IsNull()); |
| 4005 cls.SetTraceAllocation(enable); | 4004 cls.SetTraceAllocation(enable); |
| 4006 PrintSuccess(js); | 4005 PrintSuccess(js); |
| 4007 return true; | 4006 return true; |
| 4008 } | 4007 } |
| 4009 | 4008 |
| 4010 | 4009 |
| 4011 static const MethodParameter* create_dev_fs_params[] = { | |
| 4012 NO_ISOLATE_PARAMETER, | |
| 4013 new DartStringParameter("fsName", true), | |
| 4014 NULL, | |
| 4015 }; | |
| 4016 | |
| 4017 | |
| 4018 static bool CreateDevFS(Thread* thread, JSONStream* js) { | |
| 4019 const String& fs_name = | |
| 4020 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4021 DevFS::CreateFileSystem(js, fs_name); | |
| 4022 return true; | |
| 4023 } | |
| 4024 | |
| 4025 | |
| 4026 static const MethodParameter* delete_dev_fs_params[] = { | |
| 4027 NO_ISOLATE_PARAMETER, | |
| 4028 new DartStringParameter("fsName", true), | |
| 4029 NULL, | |
| 4030 }; | |
| 4031 | |
| 4032 | |
| 4033 static bool DeleteDevFS(Thread* thread, JSONStream* js) { | |
| 4034 const String& fs_name = | |
| 4035 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4036 DevFS::DeleteFileSystem(js, fs_name); | |
| 4037 return true; | |
| 4038 } | |
| 4039 | |
| 4040 | |
| 4041 static const MethodParameter* list_dev_fs_params[] = { | |
| 4042 NO_ISOLATE_PARAMETER, | |
| 4043 NULL, | |
| 4044 }; | |
| 4045 | |
| 4046 | |
| 4047 static bool ListDevFS(Thread* thread, JSONStream* js) { | |
| 4048 DevFS::ListFileSystems(js); | |
| 4049 return true; | |
| 4050 } | |
| 4051 | |
| 4052 | |
| 4053 static const MethodParameter* write_dev_fs_file_params[] = { | |
| 4054 NO_ISOLATE_PARAMETER, | |
| 4055 new DartStringParameter("fsName", true), | |
| 4056 new DartStringParameter("path", true), | |
| 4057 new DartStringParameter("fileContents", true), | |
| 4058 NULL, | |
| 4059 }; | |
| 4060 | |
| 4061 | |
| 4062 static bool WriteDevFSFile(Thread* thread, JSONStream* js) { | |
| 4063 const String& fs_name = | |
| 4064 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4065 const String& path = | |
| 4066 String::Handle(String::RawCast(js->LookupObjectParam("path"))); | |
| 4067 const String& file_contents = | |
| 4068 String::Handle(String::RawCast(js->LookupObjectParam("fileContents"))); | |
| 4069 DevFS::WriteFile(js, fs_name, path, file_contents); | |
| 4070 return true; | |
| 4071 } | |
| 4072 | |
| 4073 | |
| 4074 static const MethodParameter* write_dev_fs_files_params[] = { | |
| 4075 NO_ISOLATE_PARAMETER, | |
| 4076 new DartStringParameter("fsName", true), | |
| 4077 new DartListParameter("files", true), | |
| 4078 NULL, | |
| 4079 }; | |
| 4080 | |
| 4081 | |
| 4082 static bool WriteDevFSFiles(Thread* thread, JSONStream* js) { | |
| 4083 const String& fs_name = | |
| 4084 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4085 Array& files = Array::Handle(); | |
| 4086 const Object& files_param = Object::Handle(js->LookupObjectParam("files")); | |
| 4087 if (files_param.IsArray()) { | |
| 4088 files ^= files_param.raw(); | |
| 4089 } else { | |
| 4090 ASSERT(files_param.IsGrowableObjectArray()); | |
| 4091 files ^= GrowableObjectArray::Cast(files_param).data(); | |
| 4092 } | |
| 4093 ASSERT(!files.IsNull()); | |
| 4094 DevFS::WriteFiles(js, fs_name, files); | |
| 4095 return true; | |
| 4096 } | |
| 4097 | |
| 4098 | |
| 4099 static const MethodParameter* read_dev_fs_file_params[] = { | |
| 4100 NO_ISOLATE_PARAMETER, | |
| 4101 new DartStringParameter("fsName", true), | |
| 4102 new DartStringParameter("path", true), | |
| 4103 NULL, | |
| 4104 }; | |
| 4105 | |
| 4106 | |
| 4107 static bool ReadDevFSFile(Thread* thread, JSONStream* js) { | |
| 4108 const String& fs_name = | |
| 4109 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4110 const String& path = | |
| 4111 String::Handle(String::RawCast(js->LookupObjectParam("path"))); | |
| 4112 DevFS::ReadFile(js, fs_name, path); | |
| 4113 return true; | |
| 4114 } | |
| 4115 | |
| 4116 | |
| 4117 static const MethodParameter* list_dev_fs_files_params[] = { | |
| 4118 NO_ISOLATE_PARAMETER, | |
| 4119 new DartStringParameter("fsName", true), | |
| 4120 NULL, | |
| 4121 }; | |
| 4122 | |
| 4123 | |
| 4124 static bool ListDevFSFiles(Thread* thread, JSONStream* js) { | |
| 4125 const String& fs_name = | |
| 4126 String::Handle(String::RawCast(js->LookupObjectParam("fsName"))); | |
| 4127 DevFS::ListFiles(js, fs_name); | |
| 4128 return true; | |
| 4129 } | |
| 4130 | |
| 4131 | |
| 4132 static const ServiceMethodDescriptor service_methods_[] = { | 4010 static const ServiceMethodDescriptor service_methods_[] = { |
| 4133 { "_dumpIdZone", DumpIdZone, NULL }, | 4011 { "_dumpIdZone", DumpIdZone, NULL }, |
| 4134 { "_echo", Echo, | 4012 { "_echo", Echo, |
| 4135 NULL }, | 4013 NULL }, |
| 4136 { "_respondWithMalformedJson", RespondWithMalformedJson, | 4014 { "_respondWithMalformedJson", RespondWithMalformedJson, |
| 4137 NULL }, | 4015 NULL }, |
| 4138 { "_respondWithMalformedObject", RespondWithMalformedObject, | 4016 { "_respondWithMalformedObject", RespondWithMalformedObject, |
| 4139 NULL }, | 4017 NULL }, |
| 4140 { "_triggerEchoEvent", TriggerEchoEvent, | 4018 { "_triggerEchoEvent", TriggerEchoEvent, |
| 4141 NULL }, | 4019 NULL }, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4234 { "setLibraryDebuggable", SetLibraryDebuggable, | 4112 { "setLibraryDebuggable", SetLibraryDebuggable, |
| 4235 set_library_debuggable_params }, | 4113 set_library_debuggable_params }, |
| 4236 { "setName", SetName, | 4114 { "setName", SetName, |
| 4237 set_name_params }, | 4115 set_name_params }, |
| 4238 { "_setTraceClassAllocation", SetTraceClassAllocation, | 4116 { "_setTraceClassAllocation", SetTraceClassAllocation, |
| 4239 set_trace_class_allocation_params }, | 4117 set_trace_class_allocation_params }, |
| 4240 { "setVMName", SetVMName, | 4118 { "setVMName", SetVMName, |
| 4241 set_vm_name_params }, | 4119 set_vm_name_params }, |
| 4242 { "_setVMTimelineFlags", SetVMTimelineFlags, | 4120 { "_setVMTimelineFlags", SetVMTimelineFlags, |
| 4243 set_vm_timeline_flags_params }, | 4121 set_vm_timeline_flags_params }, |
| 4244 { "_createDevFS", CreateDevFS, | |
| 4245 create_dev_fs_params }, | |
| 4246 { "_deleteDevFS", DeleteDevFS, | |
| 4247 delete_dev_fs_params }, | |
| 4248 { "_listDevFS", ListDevFS, | |
| 4249 list_dev_fs_params }, | |
| 4250 { "_writeDevFSFile", WriteDevFSFile, | |
| 4251 write_dev_fs_file_params }, | |
| 4252 { "_writeDevFSFiles", WriteDevFSFiles, | |
| 4253 write_dev_fs_files_params }, | |
| 4254 { "_readDevFSFile", ReadDevFSFile, | |
| 4255 read_dev_fs_file_params }, | |
| 4256 { "_listDevFSFiles", ListDevFSFiles, | |
| 4257 list_dev_fs_files_params }, | |
| 4258 }; | 4122 }; |
| 4259 | 4123 |
| 4260 | 4124 |
| 4261 const ServiceMethodDescriptor* FindMethod(const char* method_name) { | 4125 const ServiceMethodDescriptor* FindMethod(const char* method_name) { |
| 4262 intptr_t num_methods = sizeof(service_methods_) / | 4126 intptr_t num_methods = sizeof(service_methods_) / |
| 4263 sizeof(service_methods_[0]); | 4127 sizeof(service_methods_[0]); |
| 4264 for (intptr_t i = 0; i < num_methods; i++) { | 4128 for (intptr_t i = 0; i < num_methods; i++) { |
| 4265 const ServiceMethodDescriptor& method = service_methods_[i]; | 4129 const ServiceMethodDescriptor& method = service_methods_[i]; |
| 4266 if (strcmp(method_name, method.name) == 0) { | 4130 if (strcmp(method_name, method.name) == 0) { |
| 4267 return &method; | 4131 return &method; |
| 4268 } | 4132 } |
| 4269 } | 4133 } |
| 4270 return NULL; | 4134 return NULL; |
| 4271 } | 4135 } |
| 4272 | 4136 |
| 4273 #endif // !PRODUCT | 4137 #endif // !PRODUCT |
| 4274 | 4138 |
| 4275 } // namespace dart | 4139 } // namespace dart |
| OLD | NEW |