Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index 9d76bd5feae64aa0acaba5f3b54ed7d452ca2caf..5d5c24609fb93c642fd5df1dd9e326c3099cfa6e 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -1461,24 +1461,34 @@ static bool HandleCoverage(Isolate* isolate, JSONStream* js) { |
static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) { |
- if (js->num_arguments() == 2) { |
- const char* sub_command = js->GetArgument(1); |
- if (!strcmp(sub_command, "reset")) { |
- isolate->class_table()->ResetAllocationAccumulators(); |
- isolate->class_table()->AllocationProfilePrintToJSONStream(js); |
- return true; |
- } else if (!strcmp(sub_command, "fullgc")) { |
- isolate->heap()->CollectAllGarbage(); |
- isolate->class_table()->AllocationProfilePrintToJSONStream(js); |
+ bool should_reset_accumulator = false; |
+ bool should_collect = false; |
+ if (js->num_arguments() != 1) { |
+ PrintError(js, "Command too long"); |
+ return true; |
+ } |
+ if (js->HasOption("reset")) { |
+ if (js->OptionIs("reset", "true")) { |
+ should_reset_accumulator = true; |
+ } else { |
+ PrintError(js, "Unrecognized reset option '%s'", |
+ js->LookupOption("reset")); |
return true; |
+ } |
+ } |
+ if (js->HasOption("gc")) { |
+ if (js->OptionIs("gc", "full")) { |
+ should_collect = true; |
} else { |
- PrintError(js, "Unrecognized subcommand '%s'", sub_command); |
+ PrintError(js, "Unrecognized gc option '%s'", js->LookupOption("gc")); |
return true; |
} |
} |
- if (js->num_arguments() != 1) { |
- PrintError(js, "Command too long"); |
- return true; |
+ if (should_reset_accumulator) { |
+ isolate->class_table()->ResetAllocationAccumulators(); |
+ } |
+ if (should_collect) { |
+ isolate->heap()->CollectAllGarbage(); |
} |
isolate->class_table()->AllocationProfilePrintToJSONStream(js); |
return true; |