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 3427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3460 GetObjectHelper(thread, addr)); | 3462 GetObjectHelper(thread, addr)); |
3461 if (obj.IsNull()) { | 3463 if (obj.IsNull()) { |
3462 PrintSentinel(js, kFreeSentinel); | 3464 PrintSentinel(js, kFreeSentinel); |
3463 } else { | 3465 } else { |
3464 obj.PrintJSON(js, ref); | 3466 obj.PrintJSON(js, ref); |
3465 } | 3467 } |
3466 return true; | 3468 return true; |
3467 } | 3469 } |
3468 | 3470 |
3469 | 3471 |
| 3472 static const MethodParameter* get_persistent_handles_params[] = { |
| 3473 ISOLATE_PARAMETER, |
| 3474 NULL, |
| 3475 }; |
| 3476 |
| 3477 |
| 3478 template<typename T> |
| 3479 class PersistentHandleVisitor : public HandleVisitor { |
| 3480 public: |
| 3481 PersistentHandleVisitor(Thread* thread, JSONArray* handles) |
| 3482 : HandleVisitor(thread), |
| 3483 handles_(handles) { |
| 3484 ASSERT(handles_ != NULL); |
| 3485 } |
| 3486 |
| 3487 void Append(PersistentHandle* persistent_handle) { |
| 3488 JSONObject obj(handles_); |
| 3489 obj.AddProperty("type", "_PersistentHandle"); |
| 3490 const Object& object = Object::Handle(persistent_handle->raw()); |
| 3491 obj.AddProperty("object", object); |
| 3492 } |
| 3493 |
| 3494 void Append(FinalizablePersistentHandle* weak_persistent_handle) { |
| 3495 JSONObject obj(handles_); |
| 3496 obj.AddProperty("type", "_WeakPersistentHandle"); |
| 3497 const Object& object = |
| 3498 Object::Handle(weak_persistent_handle->raw()); |
| 3499 obj.AddProperty("object", object); |
| 3500 obj.AddPropertyF( |
| 3501 "peer", |
| 3502 "0x%" Px "", |
| 3503 reinterpret_cast<uintptr_t>(weak_persistent_handle->peer())); |
| 3504 obj.AddPropertyF( |
| 3505 "callbackAddress", |
| 3506 "0x%" Px "", |
| 3507 reinterpret_cast<uintptr_t>(weak_persistent_handle->callback())); |
| 3508 // Attempt to include a native symbol name. |
| 3509 char* name = NativeSymbolResolver::LookupSymbolName( |
| 3510 reinterpret_cast<uintptr_t>(weak_persistent_handle->callback()), |
| 3511 NULL); |
| 3512 obj.AddProperty("callbackSymbolName", |
| 3513 (name == NULL) ? "" : name); |
| 3514 if (name != NULL) { |
| 3515 NativeSymbolResolver::FreeSymbolName(name); |
| 3516 } |
| 3517 obj.AddPropertyF("externalSize", |
| 3518 "%" Pd "", |
| 3519 weak_persistent_handle->external_size()); |
| 3520 } |
| 3521 |
| 3522 protected: |
| 3523 virtual void VisitHandle(uword addr) { |
| 3524 T* handle = reinterpret_cast<T*>(addr); |
| 3525 Append(handle); |
| 3526 } |
| 3527 |
| 3528 JSONArray* handles_; |
| 3529 }; |
| 3530 |
| 3531 |
| 3532 static bool GetPersistentHandles(Thread* thread, JSONStream* js) { |
| 3533 Isolate* isolate = thread->isolate(); |
| 3534 ASSERT(isolate != NULL); |
| 3535 |
| 3536 ApiState* api_state = isolate->api_state(); |
| 3537 ASSERT(api_state != NULL); |
| 3538 |
| 3539 { |
| 3540 JSONObject obj(js); |
| 3541 obj.AddProperty("type", "_PersistentHandles"); |
| 3542 // Persistent handles. |
| 3543 { |
| 3544 JSONArray persistent_handles(&obj, "persistentHandles"); |
| 3545 PersistentHandles& handles = api_state->persistent_handles(); |
| 3546 PersistentHandleVisitor<PersistentHandle> visitor( |
| 3547 thread, &persistent_handles); |
| 3548 handles.Visit(&visitor); |
| 3549 } |
| 3550 // Weak persistent handles. |
| 3551 { |
| 3552 JSONArray weak_persistent_handles(&obj, "weakPersistentHandles"); |
| 3553 FinalizablePersistentHandles& handles = |
| 3554 api_state->weak_persistent_handles(); |
| 3555 PersistentHandleVisitor<FinalizablePersistentHandle> visitor( |
| 3556 thread, &weak_persistent_handles); |
| 3557 handles.VisitHandles(&visitor); |
| 3558 } |
| 3559 } |
| 3560 |
| 3561 return true; |
| 3562 } |
| 3563 |
| 3564 |
3470 static const MethodParameter* get_ports_params[] = { | 3565 static const MethodParameter* get_ports_params[] = { |
3471 RUNNABLE_ISOLATE_PARAMETER, | 3566 RUNNABLE_ISOLATE_PARAMETER, |
3472 NULL, | 3567 NULL, |
3473 }; | 3568 }; |
3474 | 3569 |
3475 | 3570 |
3476 static bool GetPorts(Thread* thread, JSONStream* js) { | 3571 static bool GetPorts(Thread* thread, JSONStream* js) { |
3477 MessageHandler* message_handler = thread->isolate()->message_handler(); | 3572 MessageHandler* message_handler = thread->isolate()->message_handler(); |
3478 PortMap::PrintPortsForMessageHandler(message_handler, js); | 3573 PortMap::PrintPortsForMessageHandler(message_handler, js); |
3479 return true; | 3574 return true; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3931 { "getIsolate", GetIsolate, | 4026 { "getIsolate", GetIsolate, |
3932 get_isolate_params }, | 4027 get_isolate_params }, |
3933 { "_getIsolateMetric", GetIsolateMetric, | 4028 { "_getIsolateMetric", GetIsolateMetric, |
3934 get_isolate_metric_params }, | 4029 get_isolate_metric_params }, |
3935 { "_getIsolateMetricList", GetIsolateMetricList, | 4030 { "_getIsolateMetricList", GetIsolateMetricList, |
3936 get_isolate_metric_list_params }, | 4031 get_isolate_metric_list_params }, |
3937 { "getObject", GetObject, | 4032 { "getObject", GetObject, |
3938 get_object_params }, | 4033 get_object_params }, |
3939 { "_getObjectByAddress", GetObjectByAddress, | 4034 { "_getObjectByAddress", GetObjectByAddress, |
3940 get_object_by_address_params }, | 4035 get_object_by_address_params }, |
| 4036 { "_getPersistentHandles", GetPersistentHandles, |
| 4037 get_persistent_handles_params, }, |
3941 { "_getPorts", GetPorts, | 4038 { "_getPorts", GetPorts, |
3942 get_ports_params }, | 4039 get_ports_params }, |
3943 { "_getReachableSize", GetReachableSize, | 4040 { "_getReachableSize", GetReachableSize, |
3944 get_reachable_size_params }, | 4041 get_reachable_size_params }, |
3945 { "_getRetainedSize", GetRetainedSize, | 4042 { "_getRetainedSize", GetRetainedSize, |
3946 get_retained_size_params }, | 4043 get_retained_size_params }, |
3947 { "_getRetainingPath", GetRetainingPath, | 4044 { "_getRetainingPath", GetRetainingPath, |
3948 get_retaining_path_params }, | 4045 get_retaining_path_params }, |
3949 { "_getSourceReport", GetSourceReport, | 4046 { "_getSourceReport", GetSourceReport, |
3950 get_source_report_params }, | 4047 get_source_report_params }, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4001 if (strcmp(method_name, method.name) == 0) { | 4098 if (strcmp(method_name, method.name) == 0) { |
4002 return &method; | 4099 return &method; |
4003 } | 4100 } |
4004 } | 4101 } |
4005 return NULL; | 4102 return NULL; |
4006 } | 4103 } |
4007 | 4104 |
4008 #endif // !PRODUCT | 4105 #endif // !PRODUCT |
4009 | 4106 |
4010 } // namespace dart | 4107 } // namespace dart |
OLD | NEW |