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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 // For now observatory enums are ascii letters plus underscore. | 640 // For now observatory enums are ascii letters plus underscore. |
641 static bool IsEnumChar(char c) { | 641 static bool IsEnumChar(char c) { |
642 return (((c >= 'a') && (c <= 'z')) || | 642 return (((c >= 'a') && (c <= 'z')) || |
643 ((c >= 'A') && (c <= 'Z')) || | 643 ((c >= 'A') && (c <= 'Z')) || |
644 (c == '_')); | 644 (c == '_')); |
645 } | 645 } |
646 | 646 |
647 // Returns number of elements in the list. -1 on parse error. | 647 // Returns number of elements in the list. -1 on parse error. |
648 intptr_t ElementCount(const char* value) const { | 648 intptr_t ElementCount(const char* value) const { |
649 const char* kJsonWhitespaceChars = " \t\r\n"; | 649 const char* kJsonWhitespaceChars = " \t\r\n"; |
650 | |
651 if (value == NULL) { | 650 if (value == NULL) { |
652 return -1; | 651 return -1; |
653 } | 652 } |
654 const char* cp = value; | 653 const char* cp = value; |
655 cp += strspn(cp, kJsonWhitespaceChars); | 654 cp += strspn(cp, kJsonWhitespaceChars); |
656 if (*cp++ != '[') { | 655 if (*cp++ != '[') { |
657 // Missing initial [. | 656 // Missing initial [. |
658 return -1; | 657 return -1; |
659 } | 658 } |
660 bool closed = false; | 659 bool closed = false; |
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2853 | 2852 |
2854 | 2853 |
2855 static bool GetVMMetric(Thread* thread, JSONStream* js) { | 2854 static bool GetVMMetric(Thread* thread, JSONStream* js) { |
2856 const char* metric_id = js->LookupParam("metricId"); | 2855 const char* metric_id = js->LookupParam("metricId"); |
2857 if (metric_id == NULL) { | 2856 if (metric_id == NULL) { |
2858 PrintMissingParamError(js, "metricId"); | 2857 PrintMissingParamError(js, "metricId"); |
2859 } | 2858 } |
2860 return false; | 2859 return false; |
2861 } | 2860 } |
2862 | 2861 |
2862 static const char* const timeline_streams_enum_names[] = { | |
2863 "all", | |
2864 #define DEFINE_NAME(name, unused) \ | |
2865 #name, | |
2866 ISOLATE_TIMELINE_STREAM_LIST(DEFINE_NAME) | |
2867 #undef DEFINE_NAME | |
2868 "VM", | |
2869 NULL | |
2870 }; | |
2871 | |
2872 static const EnumListParameter* recorded_streams_param = | |
2873 new EnumListParameter("recordedStreams", | |
zra
2016/02/12 18:57:56
Where is this deleted?
Cutch
2016/02/12 20:13:57
It's not and none of our parameter lists are.
zra
2016/02/12 20:23:55
If there isn't one already, please file a bug to c
| |
2874 false, | |
2875 timeline_streams_enum_names); | |
2876 | |
2877 static const MethodParameter* set_vm_timeline_flags_params[] = { | |
2878 NO_ISOLATE_PARAMETER, | |
2879 recorded_streams_param, | |
zra
2016/02/12 18:57:56
Does this rely on the order that globals are initi
Cutch
2016/02/12 20:13:57
Fixed here and elsewhere.
| |
2880 NULL, | |
2881 }; | |
2882 | |
2883 | |
2884 static bool HasStream(const char** recorded_streams, const char* stream) { | |
2885 while (*recorded_streams != NULL) { | |
2886 if ((strcasestr(*recorded_streams, "all") != NULL) || | |
2887 (strcasestr(*recorded_streams, stream) != NULL)) { | |
2888 return true; | |
2889 } | |
2890 recorded_streams++; | |
2891 } | |
2892 return false; | |
2893 } | |
2894 | |
2863 | 2895 |
2864 static const MethodParameter* set_vm_timeline_flag_params[] = { | 2896 static bool SetVMTimelineFlags(Thread* thread, JSONStream* js) { |
2865 NO_ISOLATE_PARAMETER, | |
2866 new MethodParameter("_record", true), | |
2867 NULL, | |
2868 }; | |
2869 | |
2870 | |
2871 static bool SetVMTimelineFlag(Thread* thread, JSONStream* js) { | |
2872 Isolate* isolate = thread->isolate(); | 2897 Isolate* isolate = thread->isolate(); |
2873 ASSERT(isolate != NULL); | 2898 ASSERT(isolate != NULL); |
2874 StackZone zone(thread); | 2899 StackZone zone(thread); |
2875 | 2900 |
2876 bool recording = strcmp(js->LookupParam("_record"), "all") == 0; | 2901 const char* recorded_streams_str = js->LookupParam("recordedStreams"); |
2877 Timeline::SetStreamAPIEnabled(recording); | 2902 const char** recorded_streams = |
2878 Timeline::SetStreamCompilerEnabled(recording); | 2903 recorded_streams_param->Parse(thread->zone(), recorded_streams_str); |
2879 Timeline::SetStreamDartEnabled(recording); | 2904 |
2880 Timeline::SetStreamDebuggerEnabled(recording); | 2905 Timeline::SetStreamAPIEnabled(HasStream(recorded_streams, "API")); |
zra
2016/02/12 18:57:56
Is it possible to use ISOLATE_TIMELINE_STREAM_LIST
Cutch
2016/02/12 20:13:57
Done.
| |
2881 Timeline::SetStreamEmbedderEnabled(recording); | 2906 Timeline::SetStreamCompilerEnabled(HasStream(recorded_streams, "Compiler")); |
2882 Timeline::SetStreamGCEnabled(recording); | 2907 Timeline::SetStreamDartEnabled(HasStream(recorded_streams, "Dart")); |
2883 Timeline::SetStreamIsolateEnabled(recording); | 2908 Timeline::SetStreamDebuggerEnabled(HasStream(recorded_streams, "Debugger")); |
2909 Timeline::SetStreamEmbedderEnabled(HasStream(recorded_streams, "Embedder")); | |
2910 Timeline::SetStreamGCEnabled(HasStream(recorded_streams, "GC")); | |
2911 Timeline::SetStreamIsolateEnabled(HasStream(recorded_streams, "Isolate")); | |
2912 Timeline::SetVMStreamEnabled(HasStream(recorded_streams, "VM")); | |
2884 | 2913 |
2885 PrintSuccess(js); | 2914 PrintSuccess(js); |
2886 | 2915 |
2887 return true; | 2916 return true; |
2888 } | 2917 } |
2889 | 2918 |
2890 | 2919 |
2891 static const MethodParameter* get_vm_timeline_flag_params[] = { | 2920 static const MethodParameter* get_vm_timeline_flags_params[] = { |
2892 NO_ISOLATE_PARAMETER, | 2921 NO_ISOLATE_PARAMETER, |
2893 new MethodParameter("_record", false), | |
2894 NULL, | 2922 NULL, |
2895 }; | 2923 }; |
2896 | 2924 |
2897 | 2925 |
2898 static bool GetVMTimelineFlag(Thread* thread, JSONStream* js) { | 2926 static bool GetVMTimelineFlags(Thread* thread, JSONStream* js) { |
2899 Isolate* isolate = thread->isolate(); | 2927 Isolate* isolate = thread->isolate(); |
2900 ASSERT(isolate != NULL); | 2928 ASSERT(isolate != NULL); |
2901 StackZone zone(thread); | 2929 StackZone zone(thread); |
2902 | 2930 Timeline::PrintFlagsToJSON(js); |
2903 js->PrintError(kFeatureDisabled, "TODO(johnmccutchan)"); | |
2904 return true; | 2931 return true; |
2905 } | 2932 } |
2906 | 2933 |
2907 | 2934 |
2908 static const MethodParameter* clear_vm_timeline_params[] = { | 2935 static const MethodParameter* clear_vm_timeline_params[] = { |
2909 NO_ISOLATE_PARAMETER, | 2936 NO_ISOLATE_PARAMETER, |
2910 NULL, | 2937 NULL, |
2911 }; | 2938 }; |
2912 | 2939 |
2913 | 2940 |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3911 { "getVersion", GetVersion, | 3938 { "getVersion", GetVersion, |
3912 get_version_params }, | 3939 get_version_params }, |
3913 { "getVM", GetVM, | 3940 { "getVM", GetVM, |
3914 get_vm_params }, | 3941 get_vm_params }, |
3915 { "_getVMMetric", GetVMMetric, | 3942 { "_getVMMetric", GetVMMetric, |
3916 get_vm_metric_params }, | 3943 get_vm_metric_params }, |
3917 { "_getVMMetricList", GetVMMetricList, | 3944 { "_getVMMetricList", GetVMMetricList, |
3918 get_vm_metric_list_params }, | 3945 get_vm_metric_list_params }, |
3919 { "_getVMTimeline", GetVMTimeline, | 3946 { "_getVMTimeline", GetVMTimeline, |
3920 get_vm_timeline_params }, | 3947 get_vm_timeline_params }, |
3921 { "_getVMTimelineFlag", GetVMTimelineFlag, | 3948 { "_getVMTimelineFlags", GetVMTimelineFlags, |
3922 get_vm_timeline_flag_params }, | 3949 get_vm_timeline_flags_params }, |
3923 { "pause", Pause, | 3950 { "pause", Pause, |
3924 pause_params }, | 3951 pause_params }, |
3925 { "removeBreakpoint", RemoveBreakpoint, | 3952 { "removeBreakpoint", RemoveBreakpoint, |
3926 remove_breakpoint_params }, | 3953 remove_breakpoint_params }, |
3927 { "_restartVM", RestartVM, | 3954 { "_restartVM", RestartVM, |
3928 restart_vm_params }, | 3955 restart_vm_params }, |
3929 { "resume", Resume, | 3956 { "resume", Resume, |
3930 resume_params }, | 3957 resume_params }, |
3931 { "_requestHeapSnapshot", RequestHeapSnapshot, | 3958 { "_requestHeapSnapshot", RequestHeapSnapshot, |
3932 request_heap_snapshot_params }, | 3959 request_heap_snapshot_params }, |
3933 { "setExceptionPauseMode", SetExceptionPauseMode, | 3960 { "setExceptionPauseMode", SetExceptionPauseMode, |
3934 set_exception_pause_mode_params }, | 3961 set_exception_pause_mode_params }, |
3935 { "_setFlag", SetFlag, | 3962 { "_setFlag", SetFlag, |
3936 set_flags_params }, | 3963 set_flags_params }, |
3937 { "setLibraryDebuggable", SetLibraryDebuggable, | 3964 { "setLibraryDebuggable", SetLibraryDebuggable, |
3938 set_library_debuggable_params }, | 3965 set_library_debuggable_params }, |
3939 { "setName", SetName, | 3966 { "setName", SetName, |
3940 set_name_params }, | 3967 set_name_params }, |
3941 { "_setTraceClassAllocation", SetTraceClassAllocation, | 3968 { "_setTraceClassAllocation", SetTraceClassAllocation, |
3942 set_trace_class_allocation_params }, | 3969 set_trace_class_allocation_params }, |
3943 { "setVMName", SetVMName, | 3970 { "setVMName", SetVMName, |
3944 set_vm_name_params }, | 3971 set_vm_name_params }, |
3945 { "_setVMTimelineFlag", SetVMTimelineFlag, | 3972 { "_setVMTimelineFlags", SetVMTimelineFlags, |
3946 set_vm_timeline_flag_params }, | 3973 set_vm_timeline_flags_params }, |
3947 }; | 3974 }; |
3948 | 3975 |
3949 | 3976 |
3950 const ServiceMethodDescriptor* FindMethod(const char* method_name) { | 3977 const ServiceMethodDescriptor* FindMethod(const char* method_name) { |
3951 intptr_t num_methods = sizeof(service_methods_) / | 3978 intptr_t num_methods = sizeof(service_methods_) / |
3952 sizeof(service_methods_[0]); | 3979 sizeof(service_methods_[0]); |
3953 for (intptr_t i = 0; i < num_methods; i++) { | 3980 for (intptr_t i = 0; i < num_methods; i++) { |
3954 const ServiceMethodDescriptor& method = service_methods_[i]; | 3981 const ServiceMethodDescriptor& method = service_methods_[i]; |
3955 if (strcmp(method_name, method.name) == 0) { | 3982 if (strcmp(method_name, method.name) == 0) { |
3956 return &method; | 3983 return &method; |
3957 } | 3984 } |
3958 } | 3985 } |
3959 return NULL; | 3986 return NULL; |
3960 } | 3987 } |
3961 | 3988 |
3962 #endif // !PRODUCT | 3989 #endif // !PRODUCT |
3963 | 3990 |
3964 } // namespace dart | 3991 } // namespace dart |
OLD | NEW |