| 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 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 uword addr_; | 2567 uword addr_; |
| 2568 }; | 2568 }; |
| 2569 | 2569 |
| 2570 | 2570 |
| 2571 static const MethodParameter* get_object_by_address_params[] = { | 2571 static const MethodParameter* get_object_by_address_params[] = { |
| 2572 ISOLATE_PARAMETER, | 2572 ISOLATE_PARAMETER, |
| 2573 NULL, | 2573 NULL, |
| 2574 }; | 2574 }; |
| 2575 | 2575 |
| 2576 | 2576 |
| 2577 static RawObject* GetObjectHelper(Isolate* isolate, uword addr) { |
| 2578 Object& object = Object::Handle(isolate); |
| 2579 |
| 2580 { |
| 2581 NoSafepointScope no_safepoint; |
| 2582 ContainsAddressVisitor visitor(isolate, addr); |
| 2583 object = isolate->heap()->FindObject(&visitor); |
| 2584 } |
| 2585 |
| 2586 if (!object.IsNull()) { |
| 2587 return object.raw(); |
| 2588 } |
| 2589 |
| 2590 { |
| 2591 NoSafepointScope no_safepoint; |
| 2592 ContainsAddressVisitor visitor(Dart::vm_isolate(), addr); |
| 2593 object = Dart::vm_isolate()->heap()->FindObject(&visitor); |
| 2594 } |
| 2595 |
| 2596 return object.raw(); |
| 2597 } |
| 2598 |
| 2599 |
| 2577 static bool GetObjectByAddress(Isolate* isolate, JSONStream* js) { | 2600 static bool GetObjectByAddress(Isolate* isolate, JSONStream* js) { |
| 2578 const char* addr_str = js->LookupParam("address"); | 2601 const char* addr_str = js->LookupParam("address"); |
| 2579 if (addr_str == NULL) { | 2602 if (addr_str == NULL) { |
| 2580 PrintMissingParamError(js, "address"); | 2603 PrintMissingParamError(js, "address"); |
| 2581 return true; | 2604 return true; |
| 2582 } | 2605 } |
| 2583 | 2606 |
| 2584 // Handle heap objects. | 2607 // Handle heap objects. |
| 2585 uword addr = 0; | 2608 uword addr = 0; |
| 2586 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { | 2609 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { |
| 2587 PrintInvalidParamError(js, "address"); | 2610 PrintInvalidParamError(js, "address"); |
| 2588 return true; | 2611 return true; |
| 2589 } | 2612 } |
| 2590 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); | 2613 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); |
| 2591 Object& object = Object::Handle(isolate); | 2614 const Object& obj = Object::Handle(isolate, GetObjectHelper(isolate, addr)); |
| 2592 { | 2615 if (obj.IsNull()) { |
| 2593 NoSafepointScope no_safepoint; | |
| 2594 ContainsAddressVisitor visitor(isolate, addr); | |
| 2595 object = isolate->heap()->FindObject(&visitor); | |
| 2596 } | |
| 2597 if (object.IsNull()) { | |
| 2598 PrintSentinel(js, kFreeSentinel); | 2616 PrintSentinel(js, kFreeSentinel); |
| 2599 } else { | 2617 } else { |
| 2600 object.PrintJSON(js, ref); | 2618 obj.PrintJSON(js, ref); |
| 2601 } | 2619 } |
| 2602 return true; | 2620 return true; |
| 2603 } | 2621 } |
| 2604 | 2622 |
| 2605 | 2623 |
| 2606 static const MethodParameter* get_ports_params[] = { | 2624 static const MethodParameter* get_ports_params[] = { |
| 2607 ISOLATE_PARAMETER, | 2625 ISOLATE_PARAMETER, |
| 2608 NULL, | 2626 NULL, |
| 2609 }; | 2627 }; |
| 2610 | 2628 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3048 ServiceMethodDescriptor& method = service_methods_[i]; | 3066 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3049 if (strcmp(method_name, method.name) == 0) { | 3067 if (strcmp(method_name, method.name) == 0) { |
| 3050 return &method; | 3068 return &method; |
| 3051 } | 3069 } |
| 3052 } | 3070 } |
| 3053 return NULL; | 3071 return NULL; |
| 3054 } | 3072 } |
| 3055 | 3073 |
| 3056 | 3074 |
| 3057 } // namespace dart | 3075 } // namespace dart |
| OLD | NEW |