| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index 8991390491f3258fde761e22ea96b5170fe7b52e..8719a336f02f3d3f4e1ec52a96cc94bff88ca861 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -234,6 +234,7 @@ static void PrintSuccess(JSONStream* js) {
|
| jsobj.AddProperty("type", "Success");
|
| }
|
|
|
| +
|
| static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) {
|
| if ((s == NULL) || (*s == '\0')) {
|
| // Empty string.
|
| @@ -404,6 +405,12 @@ class MethodParameter {
|
| return required_;
|
| }
|
|
|
| + virtual void PrintError(const char* name,
|
| + const char* value,
|
| + JSONStream* js) const {
|
| + PrintInvalidParamError(js, name);
|
| + }
|
| +
|
| private:
|
| const char* name_;
|
| bool required_;
|
| @@ -422,9 +429,6 @@ class NoSuchParameter : public MethodParameter {
|
| };
|
|
|
|
|
| -#define NO_ISOLATE_PARAMETER new NoSuchParameter("isolateId")
|
| -
|
| -
|
| class BoolParameter : public MethodParameter {
|
| public:
|
| BoolParameter(const char* name, bool required)
|
| @@ -519,8 +523,29 @@ class IdParameter : public MethodParameter {
|
| };
|
|
|
|
|
| -#define ISOLATE_PARAMETER new IdParameter("isolateId", true)
|
| +class RunnableIsolateParameter : public MethodParameter {
|
| + public:
|
| + explicit RunnableIsolateParameter(const char* name)
|
| + : MethodParameter(name, true) {
|
| + }
|
|
|
| + virtual bool Validate(const char* value) const {
|
| + Isolate* isolate = Isolate::Current();
|
| + return (value != NULL) && (isolate != NULL) && (isolate->is_runnable());
|
| + }
|
| +
|
| + virtual void PrintError(const char* name,
|
| + const char* value,
|
| + JSONStream* js) const {
|
| + js->PrintError(kIsolateMustBeRunnable,
|
| + "Isolate must be runnable before this request is made.");
|
| + }
|
| +};
|
| +
|
| +
|
| +#define ISOLATE_PARAMETER new IdParameter("isolateId", true)
|
| +#define NO_ISOLATE_PARAMETER new NoSuchParameter("isolateId")
|
| +#define RUNNABLE_ISOLATE_PARAMETER new RunnableIsolateParameter("isolateId")
|
|
|
| class EnumParameter : public MethodParameter {
|
| public:
|
| @@ -708,7 +733,7 @@ static bool ValidateParameters(const MethodParameter* const* parameters,
|
| return false;
|
| }
|
| if (has_parameter && !parameter->Validate(value)) {
|
| - PrintInvalidParamError(js, name);
|
| + parameter->PrintError(name, value, js);
|
| return false;
|
| }
|
| }
|
| @@ -1170,7 +1195,7 @@ static bool GetIsolate(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_stack_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new BoolParameter("_full", false),
|
| NULL,
|
| };
|
| @@ -1779,7 +1804,7 @@ static bool PrintInboundReferences(Thread* thread,
|
|
|
|
|
| static const MethodParameter* get_inbound_references_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -1878,7 +1903,7 @@ static bool PrintRetainingPath(Thread* thread,
|
|
|
|
|
| static const MethodParameter* get_retaining_path_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -1921,7 +1946,7 @@ static bool GetRetainingPath(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_retained_size_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("targetId", true),
|
| NULL,
|
| };
|
| @@ -1963,7 +1988,7 @@ static bool GetRetainedSize(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_reachable_size_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("targetId", true),
|
| NULL,
|
| };
|
| @@ -2005,7 +2030,7 @@ static bool GetReachableSize(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* evaluate_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2076,7 +2101,7 @@ static bool Evaluate(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* evaluate_in_frame_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new UIntParameter("frameIndex", true),
|
| new MethodParameter("expression", true),
|
| NULL,
|
| @@ -2141,7 +2166,7 @@ class GetInstancesVisitor : public ObjectGraph::Visitor {
|
|
|
|
|
| static const MethodParameter* get_instances_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2299,7 +2324,7 @@ static bool GetHitsOrSites(Thread* thread, JSONStream* js, bool as_sites) {
|
|
|
|
|
| static const MethodParameter* get_coverage_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("targetId", false),
|
| NULL,
|
| };
|
| @@ -2329,7 +2354,7 @@ static const EnumListParameter* reports_parameter =
|
|
|
|
|
| static const MethodParameter* get_source_report_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| reports_parameter,
|
| new IdParameter("scriptId", false),
|
| new UIntParameter("tokenPos", false),
|
| @@ -2396,7 +2421,7 @@ static bool GetSourceReport(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_call_site_data_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("targetId", false),
|
| NULL,
|
| };
|
| @@ -2443,7 +2468,7 @@ static bool AddBreakpointCommon(Thread* thread,
|
|
|
|
|
| static const MethodParameter* add_breakpoint_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("scriptId", true),
|
| new UIntParameter("line", true),
|
| new UIntParameter("column", false),
|
| @@ -2471,7 +2496,7 @@ static bool AddBreakpoint(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* add_breakpoint_with_script_uri_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("scriptUri", true),
|
| new UIntParameter("line", true),
|
| new UIntParameter("column", false),
|
| @@ -2492,7 +2517,7 @@ static bool AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* add_breakpoint_at_entry_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("functionId", true),
|
| NULL,
|
| };
|
| @@ -2525,7 +2550,7 @@ static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* add_breakpoint_at_activation_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("objectId", true),
|
| NULL,
|
| };
|
| @@ -2558,7 +2583,7 @@ static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* remove_breakpoint_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2688,7 +2713,7 @@ static bool HandleDartMetric(Thread* thread, JSONStream* js, const char* id) {
|
|
|
|
|
| static const MethodParameter* get_isolate_metric_list_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2716,7 +2741,7 @@ static bool GetIsolateMetricList(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_isolate_metric_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2864,7 +2889,7 @@ static bool GetVMTimeline(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* resume_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2917,7 +2942,7 @@ static bool Resume(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* pause_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2936,7 +2961,7 @@ static bool Pause(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_tag_profile_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -2970,7 +2995,7 @@ static const Profile::TagOrder tags_enum_values[] = {
|
|
|
|
|
| static const MethodParameter* get_cpu_profile_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new EnumParameter("tags", true, tags_enum_names),
|
| new BoolParameter("_codeTransitionTags", false),
|
| new Int64Parameter("timeOriginMicros", false),
|
| @@ -3001,7 +3026,7 @@ static bool GetCpuProfile(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_cpu_profile_timeline_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new EnumParameter("tags", true, tags_enum_names),
|
| new Int64Parameter("timeOriginMicros", false),
|
| new Int64Parameter("timeExtentMicros", false),
|
| @@ -3025,7 +3050,7 @@ static bool GetCpuProfileTimeline(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_allocation_samples_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new EnumParameter("tags", true, tags_enum_names),
|
| new IdParameter("classId", false),
|
| new Int64Parameter("timeOriginMicros", false),
|
| @@ -3060,7 +3085,7 @@ static bool GetAllocationSamples(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* clear_cpu_profile_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3073,7 +3098,7 @@ static bool ClearCpuProfile(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_allocation_profile_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3112,7 +3137,7 @@ static bool GetAllocationProfile(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_heap_map_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3125,7 +3150,7 @@ static bool GetHeapMap(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* request_heap_snapshot_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3279,7 +3304,7 @@ class ContainsAddressVisitor : public FindObjectVisitor {
|
|
|
|
|
| static const MethodParameter* get_object_by_address_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3334,7 +3359,7 @@ static bool GetObjectByAddress(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_ports_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3367,7 +3392,7 @@ static bool RespondWithMalformedObject(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_object_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new UIntParameter("offset", false),
|
| new UIntParameter("count", false),
|
| NULL,
|
| @@ -3429,7 +3454,7 @@ static bool GetObject(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_class_list_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3443,7 +3468,7 @@ static bool GetClassList(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* get_type_arguments_list_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| NULL,
|
| };
|
|
|
| @@ -3652,7 +3677,7 @@ static bool SetFlag(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* set_library_debuggable_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("libraryId", true),
|
| new BoolParameter("isDebuggable", true),
|
| NULL,
|
| @@ -3716,7 +3741,7 @@ static bool SetVMName(Thread* thread, JSONStream* js) {
|
|
|
|
|
| static const MethodParameter* set_trace_class_allocation_params[] = {
|
| - ISOLATE_PARAMETER,
|
| + RUNNABLE_ISOLATE_PARAMETER,
|
| new IdParameter("classId", true),
|
| new BoolParameter("enable", true),
|
| NULL,
|
|
|