Chromium Code Reviews| 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/coverage.h" | 12 #include "vm/coverage.h" |
| 13 #include "vm/cpu.h" | 13 #include "vm/cpu.h" |
| 14 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
| 15 #include "vm/dart_api_state.h" | |
| 15 #include "vm/dart_entry.h" | 16 #include "vm/dart_entry.h" |
| 16 #include "vm/debugger.h" | 17 #include "vm/debugger.h" |
| 17 #include "vm/isolate.h" | 18 #include "vm/isolate.h" |
| 18 #include "vm/lockers.h" | 19 #include "vm/lockers.h" |
| 19 #include "vm/message.h" | 20 #include "vm/message.h" |
| 20 #include "vm/message_handler.h" | 21 #include "vm/message_handler.h" |
| 21 #include "vm/native_entry.h" | 22 #include "vm/native_entry.h" |
| 22 #include "vm/native_arguments.h" | 23 #include "vm/native_arguments.h" |
| 24 #include "vm/native_symbol.h" | |
| 23 #include "vm/object.h" | 25 #include "vm/object.h" |
| 24 #include "vm/object_graph.h" | 26 #include "vm/object_graph.h" |
| 25 #include "vm/object_id_ring.h" | 27 #include "vm/object_id_ring.h" |
| 26 #include "vm/object_store.h" | 28 #include "vm/object_store.h" |
| 27 #include "vm/parser.h" | 29 #include "vm/parser.h" |
| 28 #include "vm/port.h" | 30 #include "vm/port.h" |
| 29 #include "vm/profiler_service.h" | 31 #include "vm/profiler_service.h" |
| 30 #include "vm/reusable_handles.h" | 32 #include "vm/reusable_handles.h" |
| 31 #include "vm/service_event.h" | 33 #include "vm/service_event.h" |
| 32 #include "vm/service_isolate.h" | 34 #include "vm/service_isolate.h" |
| (...skipping 3423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3456 GetObjectHelper(thread, addr)); | 3458 GetObjectHelper(thread, addr)); |
| 3457 if (obj.IsNull()) { | 3459 if (obj.IsNull()) { |
| 3458 PrintSentinel(js, kFreeSentinel); | 3460 PrintSentinel(js, kFreeSentinel); |
| 3459 } else { | 3461 } else { |
| 3460 obj.PrintJSON(js, ref); | 3462 obj.PrintJSON(js, ref); |
| 3461 } | 3463 } |
| 3462 return true; | 3464 return true; |
| 3463 } | 3465 } |
| 3464 | 3466 |
| 3465 | 3467 |
| 3468 static const MethodParameter* get_persistent_handles_params[] = { | |
| 3469 ISOLATE_PARAMETER, | |
| 3470 NULL, | |
| 3471 }; | |
| 3472 | |
| 3473 | |
| 3474 template<typename T> | |
| 3475 class PersistentHandleVisitor : public HandleVisitor { | |
| 3476 public: | |
| 3477 PersistentHandleVisitor(Thread* thread, JSONArray* handles) | |
| 3478 : HandleVisitor(thread), | |
| 3479 handles_(handles) { | |
| 3480 ASSERT(handles_ != NULL); | |
| 3481 } | |
| 3482 | |
| 3483 void Append(PersistentHandle* persistent_handle) { | |
| 3484 JSONObject obj(handles_); | |
| 3485 obj.AddProperty("type", "_PersistentHandle"); | |
| 3486 const Object& object = Object::Handle(persistent_handle->raw()); | |
| 3487 obj.AddProperty("object", object); | |
| 3488 } | |
| 3489 | |
| 3490 void Append(FinalizablePersistentHandle* weak_persistent_handle) { | |
| 3491 JSONObject obj(handles_); | |
| 3492 obj.AddProperty("type", "_WeakPersistentHandle"); | |
| 3493 const Object& object = | |
| 3494 Object::Handle(weak_persistent_handle->raw()); | |
| 3495 obj.AddProperty("object", object); | |
| 3496 obj.AddPropertyF( | |
| 3497 "peer", | |
| 3498 "0x%" Px "", | |
| 3499 reinterpret_cast<uintptr_t>(weak_persistent_handle->peer())); | |
| 3500 obj.AddPropertyF( | |
| 3501 "callbackAddress", | |
| 3502 "0x%" Px "", | |
| 3503 reinterpret_cast<uintptr_t>(weak_persistent_handle->callback())); | |
| 3504 // Attempt to include a native symbol name. | |
| 3505 char* name = NativeSymbolResolver::LookupSymbolName( | |
| 3506 reinterpret_cast<uintptr_t>(weak_persistent_handle->callback()), | |
| 3507 NULL); | |
| 3508 obj.AddProperty("callbackSymbolName", | |
| 3509 (name == NULL) ? "" : name); | |
| 3510 if (name != NULL) { | |
| 3511 free(name); | |
|
rmacnak
2016/02/23 20:58:22
NativeSymbolResolver::FreeSymbolName
Cutch
2016/02/25 17:23:42
Done.
| |
| 3512 } | |
| 3513 obj.AddPropertyF("externalSize", | |
| 3514 "%" Pd "", | |
| 3515 weak_persistent_handle->external_size()); | |
| 3516 } | |
| 3517 | |
| 3518 protected: | |
| 3519 virtual void VisitHandle(uword addr) { | |
| 3520 T* handle = reinterpret_cast<T*>(addr); | |
| 3521 Append(handle); | |
| 3522 } | |
| 3523 | |
| 3524 JSONArray* handles_; | |
| 3525 }; | |
| 3526 | |
| 3527 | |
| 3528 static bool GetPersistentHandles(Thread* thread, JSONStream* js) { | |
| 3529 Isolate* isolate = thread->isolate(); | |
| 3530 ASSERT(isolate != NULL); | |
| 3531 | |
| 3532 ApiState* api_state = isolate->api_state(); | |
| 3533 ASSERT(api_state != NULL); | |
| 3534 | |
| 3535 { | |
| 3536 JSONObject obj(js); | |
| 3537 obj.AddProperty("type", "_PersistentHandles"); | |
| 3538 // Persistent handles. | |
| 3539 { | |
| 3540 JSONArray persistent_handles(&obj, "persistentHandles"); | |
| 3541 PersistentHandles& handles = api_state->persistent_handles(); | |
| 3542 PersistentHandleVisitor<PersistentHandle> visitor( | |
| 3543 thread, &persistent_handles); | |
| 3544 handles.Visit(&visitor); | |
| 3545 } | |
| 3546 // Weak persistent handles. | |
| 3547 { | |
| 3548 JSONArray weak_persistent_handles(&obj, "weakPersistentHandles"); | |
| 3549 FinalizablePersistentHandles& handles = | |
| 3550 api_state->weak_persistent_handles(); | |
| 3551 PersistentHandleVisitor<FinalizablePersistentHandle> visitor( | |
| 3552 thread, &weak_persistent_handles); | |
| 3553 handles.VisitHandles(&visitor); | |
| 3554 } | |
| 3555 } | |
| 3556 | |
| 3557 return true; | |
| 3558 } | |
| 3559 | |
| 3560 | |
| 3466 static const MethodParameter* get_ports_params[] = { | 3561 static const MethodParameter* get_ports_params[] = { |
| 3467 RUNNABLE_ISOLATE_PARAMETER, | 3562 RUNNABLE_ISOLATE_PARAMETER, |
| 3468 NULL, | 3563 NULL, |
| 3469 }; | 3564 }; |
| 3470 | 3565 |
| 3471 | 3566 |
| 3472 static bool GetPorts(Thread* thread, JSONStream* js) { | 3567 static bool GetPorts(Thread* thread, JSONStream* js) { |
| 3473 MessageHandler* message_handler = thread->isolate()->message_handler(); | 3568 MessageHandler* message_handler = thread->isolate()->message_handler(); |
| 3474 PortMap::PrintPortsForMessageHandler(message_handler, js); | 3569 PortMap::PrintPortsForMessageHandler(message_handler, js); |
| 3475 return true; | 3570 return true; |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3927 { "getIsolate", GetIsolate, | 4022 { "getIsolate", GetIsolate, |
| 3928 get_isolate_params }, | 4023 get_isolate_params }, |
| 3929 { "_getIsolateMetric", GetIsolateMetric, | 4024 { "_getIsolateMetric", GetIsolateMetric, |
| 3930 get_isolate_metric_params }, | 4025 get_isolate_metric_params }, |
| 3931 { "_getIsolateMetricList", GetIsolateMetricList, | 4026 { "_getIsolateMetricList", GetIsolateMetricList, |
| 3932 get_isolate_metric_list_params }, | 4027 get_isolate_metric_list_params }, |
| 3933 { "getObject", GetObject, | 4028 { "getObject", GetObject, |
| 3934 get_object_params }, | 4029 get_object_params }, |
| 3935 { "_getObjectByAddress", GetObjectByAddress, | 4030 { "_getObjectByAddress", GetObjectByAddress, |
| 3936 get_object_by_address_params }, | 4031 get_object_by_address_params }, |
| 4032 { "_getPersistentHandles", GetPersistentHandles, | |
| 4033 get_persistent_handles_params, }, | |
| 3937 { "_getPorts", GetPorts, | 4034 { "_getPorts", GetPorts, |
| 3938 get_ports_params }, | 4035 get_ports_params }, |
| 3939 { "_getReachableSize", GetReachableSize, | 4036 { "_getReachableSize", GetReachableSize, |
| 3940 get_reachable_size_params }, | 4037 get_reachable_size_params }, |
| 3941 { "_getRetainedSize", GetRetainedSize, | 4038 { "_getRetainedSize", GetRetainedSize, |
| 3942 get_retained_size_params }, | 4039 get_retained_size_params }, |
| 3943 { "_getRetainingPath", GetRetainingPath, | 4040 { "_getRetainingPath", GetRetainingPath, |
| 3944 get_retaining_path_params }, | 4041 get_retaining_path_params }, |
| 3945 { "_getSourceReport", GetSourceReport, | 4042 { "_getSourceReport", GetSourceReport, |
| 3946 get_source_report_params }, | 4043 get_source_report_params }, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3997 if (strcmp(method_name, method.name) == 0) { | 4094 if (strcmp(method_name, method.name) == 0) { |
| 3998 return &method; | 4095 return &method; |
| 3999 } | 4096 } |
| 4000 } | 4097 } |
| 4001 return NULL; | 4098 return NULL; |
| 4002 } | 4099 } |
| 4003 | 4100 |
| 4004 #endif // !PRODUCT | 4101 #endif // !PRODUCT |
| 4005 | 4102 |
| 4006 } // namespace dart | 4103 } // namespace dart |
| OLD | NEW |