Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1296)

Side by Side Diff: runtime/vm/service.cc

Issue 1690333002: Add fine grained command line and service protocol control over timeline streams recording (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/timeline.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 2400
2402 2401
2403 static const char* const report_enum_names[] = { 2402 static const char* const report_enum_names[] = {
2404 kCallSitesStr, 2403 kCallSitesStr,
2405 kCoverageStr, 2404 kCoverageStr,
2406 kPossibleBreakpointsStr, 2405 kPossibleBreakpointsStr,
2407 NULL, 2406 NULL,
2408 }; 2407 };
2409 2408
2410 2409
2411 static const EnumListParameter* reports_parameter =
2412 new EnumListParameter("reports", true, report_enum_names);
2413
2414
2415 static const MethodParameter* get_source_report_params[] = { 2410 static const MethodParameter* get_source_report_params[] = {
2416 RUNNABLE_ISOLATE_PARAMETER, 2411 RUNNABLE_ISOLATE_PARAMETER,
2417 reports_parameter, 2412 new EnumListParameter("reports", true, report_enum_names),
2418 new IdParameter("scriptId", false), 2413 new IdParameter("scriptId", false),
2419 new UIntParameter("tokenPos", false), 2414 new UIntParameter("tokenPos", false),
2420 new UIntParameter("endTokenPos", false), 2415 new UIntParameter("endTokenPos", false),
2421 new BoolParameter("forceCompile", false), 2416 new BoolParameter("forceCompile", false),
2422 NULL, 2417 NULL,
2423 }; 2418 };
2424 2419
2425 2420
2426 static bool GetSourceReport(Thread* thread, JSONStream* js) { 2421 static bool GetSourceReport(Thread* thread, JSONStream* js) {
2427 const char* reports_str = js->LookupParam("reports"); 2422 const char* reports_str = js->LookupParam("reports");
2423 const EnumListParameter* reports_parameter =
2424 static_cast<const EnumListParameter*>(get_source_report_params[1]);
2428 const char** reports = reports_parameter->Parse(thread->zone(), reports_str); 2425 const char** reports = reports_parameter->Parse(thread->zone(), reports_str);
2429 intptr_t report_set = 0; 2426 intptr_t report_set = 0;
2430 while (*reports != NULL) { 2427 while (*reports != NULL) {
2431 if (strcmp(*reports, kCallSitesStr) == 0) { 2428 if (strcmp(*reports, kCallSitesStr) == 0) {
2432 report_set |= SourceReport::kCallSites; 2429 report_set |= SourceReport::kCallSites;
2433 } else if (strcmp(*reports, kCoverageStr) == 0) { 2430 } else if (strcmp(*reports, kCoverageStr) == 0) {
2434 report_set |= SourceReport::kCoverage; 2431 report_set |= SourceReport::kCoverage;
2435 } else if (strcmp(*reports, kPossibleBreakpointsStr) == 0) { 2432 } else if (strcmp(*reports, kPossibleBreakpointsStr) == 0) {
2436 report_set |= SourceReport::kPossibleBreakpoints; 2433 report_set |= SourceReport::kPossibleBreakpoints;
2437 } 2434 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 2850
2854 2851
2855 static bool GetVMMetric(Thread* thread, JSONStream* js) { 2852 static bool GetVMMetric(Thread* thread, JSONStream* js) {
2856 const char* metric_id = js->LookupParam("metricId"); 2853 const char* metric_id = js->LookupParam("metricId");
2857 if (metric_id == NULL) { 2854 if (metric_id == NULL) {
2858 PrintMissingParamError(js, "metricId"); 2855 PrintMissingParamError(js, "metricId");
2859 } 2856 }
2860 return false; 2857 return false;
2861 } 2858 }
2862 2859
2860 static const char* const timeline_streams_enum_names[] = {
2861 "all",
2862 #define DEFINE_NAME(name, unused) \
2863 #name,
2864 ISOLATE_TIMELINE_STREAM_LIST(DEFINE_NAME)
2865 #undef DEFINE_NAME
2866 "VM",
2867 NULL
2868 };
2869
2870 static const MethodParameter* set_vm_timeline_flags_params[] = {
2871 NO_ISOLATE_PARAMETER,
2872 new EnumListParameter("recordedStreams",
2873 false,
2874 timeline_streams_enum_names),
2875 NULL,
2876 };
2877
2878
2879 static bool HasStream(const char** recorded_streams, const char* stream) {
2880 while (*recorded_streams != NULL) {
2881 if ((strcasestr(*recorded_streams, "all") != NULL) ||
2882 (strcasestr(*recorded_streams, stream) != NULL)) {
2883 return true;
2884 }
2885 recorded_streams++;
2886 }
2887 return false;
2888 }
2889
2863 2890
2864 static const MethodParameter* set_vm_timeline_flag_params[] = { 2891 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(); 2892 Isolate* isolate = thread->isolate();
2873 ASSERT(isolate != NULL); 2893 ASSERT(isolate != NULL);
2874 StackZone zone(thread); 2894 StackZone zone(thread);
2875 2895
2876 bool recording = strcmp(js->LookupParam("_record"), "all") == 0; 2896 const EnumListParameter* recorded_streams_param =
2877 Timeline::SetStreamAPIEnabled(recording); 2897 static_cast<const EnumListParameter*>(set_vm_timeline_flags_params[1]);
2878 Timeline::SetStreamCompilerEnabled(recording); 2898
2879 Timeline::SetStreamDartEnabled(recording); 2899 const char* recorded_streams_str = js->LookupParam("recordedStreams");
2880 Timeline::SetStreamDebuggerEnabled(recording); 2900 const char** recorded_streams =
2881 Timeline::SetStreamEmbedderEnabled(recording); 2901 recorded_streams_param->Parse(thread->zone(), recorded_streams_str);
2882 Timeline::SetStreamGCEnabled(recording); 2902
2883 Timeline::SetStreamIsolateEnabled(recording); 2903 #define SET_ENABLE_STREAM(name, unused) \
2904 Timeline::SetStream##name##Enabled(HasStream(recorded_streams, #name));
2905 ISOLATE_TIMELINE_STREAM_LIST(SET_ENABLE_STREAM);
2906 #undef SET_ENABLE_STREAM
2907 Timeline::SetVMStreamEnabled(HasStream(recorded_streams, "VM"));
2884 2908
2885 PrintSuccess(js); 2909 PrintSuccess(js);
2886 2910
2887 return true; 2911 return true;
2888 } 2912 }
2889 2913
2890 2914
2891 static const MethodParameter* get_vm_timeline_flag_params[] = { 2915 static const MethodParameter* get_vm_timeline_flags_params[] = {
2892 NO_ISOLATE_PARAMETER, 2916 NO_ISOLATE_PARAMETER,
2893 new MethodParameter("_record", false),
2894 NULL, 2917 NULL,
2895 }; 2918 };
2896 2919
2897 2920
2898 static bool GetVMTimelineFlag(Thread* thread, JSONStream* js) { 2921 static bool GetVMTimelineFlags(Thread* thread, JSONStream* js) {
2899 Isolate* isolate = thread->isolate(); 2922 Isolate* isolate = thread->isolate();
2900 ASSERT(isolate != NULL); 2923 ASSERT(isolate != NULL);
2901 StackZone zone(thread); 2924 StackZone zone(thread);
2902 2925 Timeline::PrintFlagsToJSON(js);
2903 js->PrintError(kFeatureDisabled, "TODO(johnmccutchan)");
2904 return true; 2926 return true;
2905 } 2927 }
2906 2928
2907 2929
2908 static const MethodParameter* clear_vm_timeline_params[] = { 2930 static const MethodParameter* clear_vm_timeline_params[] = {
2909 NO_ISOLATE_PARAMETER, 2931 NO_ISOLATE_PARAMETER,
2910 NULL, 2932 NULL,
2911 }; 2933 };
2912 2934
2913 2935
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 { "getVersion", GetVersion, 3933 { "getVersion", GetVersion,
3912 get_version_params }, 3934 get_version_params },
3913 { "getVM", GetVM, 3935 { "getVM", GetVM,
3914 get_vm_params }, 3936 get_vm_params },
3915 { "_getVMMetric", GetVMMetric, 3937 { "_getVMMetric", GetVMMetric,
3916 get_vm_metric_params }, 3938 get_vm_metric_params },
3917 { "_getVMMetricList", GetVMMetricList, 3939 { "_getVMMetricList", GetVMMetricList,
3918 get_vm_metric_list_params }, 3940 get_vm_metric_list_params },
3919 { "_getVMTimeline", GetVMTimeline, 3941 { "_getVMTimeline", GetVMTimeline,
3920 get_vm_timeline_params }, 3942 get_vm_timeline_params },
3921 { "_getVMTimelineFlag", GetVMTimelineFlag, 3943 { "_getVMTimelineFlags", GetVMTimelineFlags,
3922 get_vm_timeline_flag_params }, 3944 get_vm_timeline_flags_params },
3923 { "pause", Pause, 3945 { "pause", Pause,
3924 pause_params }, 3946 pause_params },
3925 { "removeBreakpoint", RemoveBreakpoint, 3947 { "removeBreakpoint", RemoveBreakpoint,
3926 remove_breakpoint_params }, 3948 remove_breakpoint_params },
3927 { "_restartVM", RestartVM, 3949 { "_restartVM", RestartVM,
3928 restart_vm_params }, 3950 restart_vm_params },
3929 { "resume", Resume, 3951 { "resume", Resume,
3930 resume_params }, 3952 resume_params },
3931 { "_requestHeapSnapshot", RequestHeapSnapshot, 3953 { "_requestHeapSnapshot", RequestHeapSnapshot,
3932 request_heap_snapshot_params }, 3954 request_heap_snapshot_params },
3933 { "setExceptionPauseMode", SetExceptionPauseMode, 3955 { "setExceptionPauseMode", SetExceptionPauseMode,
3934 set_exception_pause_mode_params }, 3956 set_exception_pause_mode_params },
3935 { "_setFlag", SetFlag, 3957 { "_setFlag", SetFlag,
3936 set_flags_params }, 3958 set_flags_params },
3937 { "setLibraryDebuggable", SetLibraryDebuggable, 3959 { "setLibraryDebuggable", SetLibraryDebuggable,
3938 set_library_debuggable_params }, 3960 set_library_debuggable_params },
3939 { "setName", SetName, 3961 { "setName", SetName,
3940 set_name_params }, 3962 set_name_params },
3941 { "_setTraceClassAllocation", SetTraceClassAllocation, 3963 { "_setTraceClassAllocation", SetTraceClassAllocation,
3942 set_trace_class_allocation_params }, 3964 set_trace_class_allocation_params },
3943 { "setVMName", SetVMName, 3965 { "setVMName", SetVMName,
3944 set_vm_name_params }, 3966 set_vm_name_params },
3945 { "_setVMTimelineFlag", SetVMTimelineFlag, 3967 { "_setVMTimelineFlags", SetVMTimelineFlags,
3946 set_vm_timeline_flag_params }, 3968 set_vm_timeline_flags_params },
3947 }; 3969 };
3948 3970
3949 3971
3950 const ServiceMethodDescriptor* FindMethod(const char* method_name) { 3972 const ServiceMethodDescriptor* FindMethod(const char* method_name) {
3951 intptr_t num_methods = sizeof(service_methods_) / 3973 intptr_t num_methods = sizeof(service_methods_) /
3952 sizeof(service_methods_[0]); 3974 sizeof(service_methods_[0]);
3953 for (intptr_t i = 0; i < num_methods; i++) { 3975 for (intptr_t i = 0; i < num_methods; i++) {
3954 const ServiceMethodDescriptor& method = service_methods_[i]; 3976 const ServiceMethodDescriptor& method = service_methods_[i];
3955 if (strcmp(method_name, method.name) == 0) { 3977 if (strcmp(method_name, method.name) == 0) {
3956 return &method; 3978 return &method;
3957 } 3979 }
3958 } 3980 }
3959 return NULL; 3981 return NULL;
3960 } 3982 }
3961 3983
3962 #endif // !PRODUCT 3984 #endif // !PRODUCT
3963 3985
3964 } // namespace dart 3986 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/timeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698