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 "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 | 9 |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1877 return true; | 1877 return true; |
| 1878 } | 1878 } |
| 1879 const char* bpt_id = js->LookupParam("breakpointId"); | 1879 const char* bpt_id = js->LookupParam("breakpointId"); |
| 1880 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 1880 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); |
| 1881 if (bpt == NULL) { | 1881 if (bpt == NULL) { |
| 1882 PrintInvalidParamError(js, "breakpointId"); | 1882 PrintInvalidParamError(js, "breakpointId"); |
| 1883 return true; | 1883 return true; |
| 1884 } | 1884 } |
| 1885 isolate->debugger()->RemoveBreakpoint(bpt->id()); | 1885 isolate->debugger()->RemoveBreakpoint(bpt->id()); |
| 1886 | 1886 |
| 1887 // TODO(turnidge): Consider whether the 'Success' type is proper. | |
| 1888 JSONObject jsobj(js); | 1887 JSONObject jsobj(js); |
|
Cutch
2015/05/28 19:59:19
Might be worth making a Success function so we can
turnidge
2015/05/28 20:06:58
Added PrintSuccess.... now looks like:
PrintSucce
| |
| 1889 jsobj.AddProperty("type", "Success"); | 1888 jsobj.AddProperty("type", "Success"); |
| 1890 return true; | 1889 return true; |
| 1891 } | 1890 } |
| 1892 | 1891 |
| 1893 | 1892 |
| 1894 static RawClass* GetMetricsClass(Isolate* isolate) { | 1893 static RawClass* GetMetricsClass(Isolate* isolate) { |
| 1895 const Library& prof_lib = | 1894 const Library& prof_lib = |
| 1896 Library::Handle(isolate, Library::DeveloperLibrary()); | 1895 Library::Handle(isolate, Library::DeveloperLibrary()); |
| 1897 ASSERT(!prof_lib.IsNull()); | 1896 ASSERT(!prof_lib.IsNull()); |
| 1898 const String& metrics_cls_name = | 1897 const String& metrics_cls_name = |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2477 if (!type_args.IsNull()) { | 2476 if (!type_args.IsNull()) { |
| 2478 if (!only_with_instantiations || type_args.HasInstantiations()) { | 2477 if (!only_with_instantiations || type_args.HasInstantiations()) { |
| 2479 members.AddValue(type_args); | 2478 members.AddValue(type_args); |
| 2480 } | 2479 } |
| 2481 } | 2480 } |
| 2482 } | 2481 } |
| 2483 return true; | 2482 return true; |
| 2484 } | 2483 } |
| 2485 | 2484 |
| 2486 | 2485 |
| 2486 static const MethodParameter* get_version_params[] = { | |
| 2487 NO_ISOLATE_PARAMETER, | |
| 2488 NULL, | |
| 2489 }; | |
| 2490 | |
| 2491 | |
| 2492 static bool GetVersion(Isolate* isolate, JSONStream* js) { | |
| 2493 JSONObject jsobj(js); | |
| 2494 jsobj.AddProperty("type", "Version"); | |
| 2495 jsobj.AddProperty("major", static_cast<intptr_t>(1)); | |
| 2496 jsobj.AddProperty("minor", static_cast<intptr_t>(0)); | |
| 2497 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); | |
| 2498 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); | |
| 2499 return true; | |
| 2500 } | |
| 2501 | |
| 2502 | |
| 2487 class ServiceIsolateVisitor : public IsolateVisitor { | 2503 class ServiceIsolateVisitor : public IsolateVisitor { |
| 2488 public: | 2504 public: |
| 2489 explicit ServiceIsolateVisitor(JSONArray* jsarr) | 2505 explicit ServiceIsolateVisitor(JSONArray* jsarr) |
| 2490 : jsarr_(jsarr) { | 2506 : jsarr_(jsarr) { |
| 2491 } | 2507 } |
| 2492 | 2508 |
| 2493 virtual ~ServiceIsolateVisitor() {} | 2509 virtual ~ServiceIsolateVisitor() {} |
| 2494 | 2510 |
| 2495 void VisitIsolate(Isolate* isolate) { | 2511 void VisitIsolate(Isolate* isolate) { |
| 2496 if ((isolate != Dart::vm_isolate()) && | 2512 if ((isolate != Dart::vm_isolate()) && |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2571 jsobj.AddProperty("type", "Success"); | 2587 jsobj.AddProperty("type", "Success"); |
| 2572 return true; | 2588 return true; |
| 2573 } else { | 2589 } else { |
| 2574 jsobj.AddProperty("type", "Error"); | 2590 jsobj.AddProperty("type", "Error"); |
| 2575 jsobj.AddProperty("message", error); | 2591 jsobj.AddProperty("message", error); |
| 2576 return true; | 2592 return true; |
| 2577 } | 2593 } |
| 2578 } | 2594 } |
| 2579 | 2595 |
| 2580 | 2596 |
| 2597 static const MethodParameter* set_library_debuggable_params[] = { | |
| 2598 ISOLATE_PARAMETER, | |
| 2599 new IdParameter("libraryId", true), | |
| 2600 new BoolParameter("isDebuggable", true), | |
| 2601 NULL, | |
| 2602 }; | |
| 2603 | |
| 2604 | |
| 2605 static bool SetLibraryDebuggable(Isolate* isolate, JSONStream* js) { | |
| 2606 const char* lib_id = js->LookupParam("libraryId"); | |
| 2607 ObjectIdRing::LookupResult lookup_result; | |
| 2608 Object& obj = Object::Handle(LookupHeapObject(isolate, lib_id, | |
| 2609 &lookup_result)); | |
| 2610 const bool is_debuggable = | |
| 2611 BoolParameter::Parse(js->LookupParam("isDebuggable"), false); | |
| 2612 if (obj.IsLibrary()) { | |
| 2613 const Library& lib = Library::Cast(obj); | |
| 2614 lib.set_debuggable(is_debuggable); | |
| 2615 JSONObject jsobj(js); | |
| 2616 jsobj.AddProperty("type", "Success"); | |
| 2617 return true; | |
| 2618 } | |
| 2619 PrintInvalidParamError(js, "libraryId"); | |
| 2620 return true; | |
| 2621 } | |
| 2622 | |
| 2623 | |
| 2581 static const MethodParameter* set_name_params[] = { | 2624 static const MethodParameter* set_name_params[] = { |
| 2582 ISOLATE_PARAMETER, | 2625 ISOLATE_PARAMETER, |
| 2583 new MethodParameter("name", true), | 2626 new MethodParameter("name", true), |
| 2584 NULL, | 2627 NULL, |
| 2585 }; | 2628 }; |
| 2586 | 2629 |
| 2587 | 2630 |
| 2588 static bool SetName(Isolate* isolate, JSONStream* js) { | 2631 static bool SetName(Isolate* isolate, JSONStream* js) { |
| 2589 isolate->set_debugger_name(js->LookupParam("name")); | 2632 isolate->set_debugger_name(js->LookupParam("name")); |
| 2590 { | 2633 { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2650 { "_getRetainedSize", GetRetainedSize, | 2693 { "_getRetainedSize", GetRetainedSize, |
| 2651 get_retained_size_params }, | 2694 get_retained_size_params }, |
| 2652 { "_getRetainingPath", GetRetainingPath, | 2695 { "_getRetainingPath", GetRetainingPath, |
| 2653 get_retaining_path_params }, | 2696 get_retaining_path_params }, |
| 2654 { "getStack", GetStack, | 2697 { "getStack", GetStack, |
| 2655 get_stack_params }, | 2698 get_stack_params }, |
| 2656 { "_getTagProfile", GetTagProfile, | 2699 { "_getTagProfile", GetTagProfile, |
| 2657 get_tag_profile_params }, | 2700 get_tag_profile_params }, |
| 2658 { "_getTypeArgumentsList", GetTypeArgumentsList, | 2701 { "_getTypeArgumentsList", GetTypeArgumentsList, |
| 2659 get_type_arguments_list_params }, | 2702 get_type_arguments_list_params }, |
| 2703 { "getVersion", GetVersion, | |
| 2704 get_version_params }, | |
| 2660 { "getVM", GetVM, | 2705 { "getVM", GetVM, |
| 2661 get_vm_params }, | 2706 get_vm_params }, |
| 2662 { "_getVMMetric", GetVMMetric, | 2707 { "_getVMMetric", GetVMMetric, |
| 2663 get_vm_metric_params }, | 2708 get_vm_metric_params }, |
| 2664 { "_getVMMetricList", GetVMMetricList, | 2709 { "_getVMMetricList", GetVMMetricList, |
| 2665 get_vm_metric_list_params }, | 2710 get_vm_metric_list_params }, |
| 2666 { "pause", Pause, | 2711 { "pause", Pause, |
| 2667 pause_params }, | 2712 pause_params }, |
| 2668 { "removeBreakpoint", RemoveBreakpoint, | 2713 { "removeBreakpoint", RemoveBreakpoint, |
| 2669 remove_breakpoint_params }, | 2714 remove_breakpoint_params }, |
| 2670 { "resume", Resume, | 2715 { "resume", Resume, |
| 2671 resume_params }, | 2716 resume_params }, |
| 2672 { "_requestHeapSnapshot", RequestHeapSnapshot, | 2717 { "_requestHeapSnapshot", RequestHeapSnapshot, |
| 2673 request_heap_snapshot_params }, | 2718 request_heap_snapshot_params }, |
| 2674 { "_setFlag", SetFlag, | 2719 { "_setFlag", SetFlag, |
| 2675 set_flags_params }, | 2720 set_flags_params }, |
| 2721 { "setLibraryDebuggable", SetLibraryDebuggable, | |
| 2722 set_library_debuggable_params }, | |
| 2676 { "setName", SetName, | 2723 { "setName", SetName, |
| 2677 set_name_params }, | 2724 set_name_params }, |
| 2678 }; | 2725 }; |
| 2679 | 2726 |
| 2680 | 2727 |
| 2681 ServiceMethodDescriptor* FindMethod(const char* method_name) { | 2728 ServiceMethodDescriptor* FindMethod(const char* method_name) { |
| 2682 intptr_t num_methods = sizeof(service_methods_) / | 2729 intptr_t num_methods = sizeof(service_methods_) / |
| 2683 sizeof(service_methods_[0]); | 2730 sizeof(service_methods_[0]); |
| 2684 for (intptr_t i = 0; i < num_methods; i++) { | 2731 for (intptr_t i = 0; i < num_methods; i++) { |
| 2685 ServiceMethodDescriptor& method = service_methods_[i]; | 2732 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2686 if (strcmp(method_name, method.name) == 0) { | 2733 if (strcmp(method_name, method.name) == 0) { |
| 2687 return &method; | 2734 return &method; |
| 2688 } | 2735 } |
| 2689 } | 2736 } |
| 2690 return NULL; | 2737 return NULL; |
| 2691 } | 2738 } |
| 2692 | 2739 |
| 2693 | 2740 |
| 2694 } // namespace dart | 2741 } // namespace dart |
| OLD | NEW |