| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index 195f017ee3fa23e6ab48ce344b38a84906a1d45e..0648411af9311da69f6e9212918cd1692c7a76f4 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -1594,6 +1594,37 @@ static RawClass* GetMetricsClass(Isolate* isolate) {
|
| }
|
|
|
|
|
| +static bool HandleVMMetricsList(Isolate* isolate, JSONStream* js) {
|
| + JSONObject obj(js);
|
| + obj.AddProperty("type", "MetricList");
|
| + obj.AddProperty("id", "metrics/vm");
|
| + {
|
| + JSONArray members(&obj, "members");
|
| + VMMetric* current = isolate->metrics_list_head();
|
| + while (current != NULL) {
|
| + members.AddValue(current);
|
| + current = current->next();
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +
|
| +static bool HandleVMMetric(Isolate* isolate, JSONStream* js, const char* id) {
|
| + VMMetric* current = isolate->metrics_list_head();
|
| + while (current != NULL) {
|
| + const char* name = current->name();
|
| + ASSERT(name != NULL);
|
| + if (strcmp(name, id) == 0) {
|
| + current->PrintJSON(js);
|
| + return true;
|
| + }
|
| + current = current->next();
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +
|
| static bool HandleMetricsList(Isolate* isolate, JSONStream* js) {
|
| const Class& metrics_cls = Class::Handle(isolate, GetMetricsClass(isolate));
|
| const String& print_metrics_name =
|
| @@ -1645,11 +1676,23 @@ static bool HandleMetrics(Isolate* isolate, JSONStream* js) {
|
| if (js->num_arguments() == 1) {
|
| return HandleMetricsList(isolate, js);
|
| }
|
| + ASSERT(js->num_arguments() > 1);
|
| + const char* arg = js->GetArgument(1);
|
| + if (strcmp(arg, "vm") == 0) {
|
| + if (js->num_arguments() == 2) {
|
| + return HandleVMMetricsList(isolate, js);
|
| + } else {
|
| + if (js->num_arguments() > 3) {
|
| + PrintError(js, "Command too long");
|
| + return true;
|
| + }
|
| + return HandleVMMetric(isolate, js, js->GetArgument(2));
|
| + }
|
| + }
|
| if (js->num_arguments() > 2) {
|
| PrintError(js, "Command too long");
|
| return true;
|
| }
|
| - const char* arg = js->GetArgument(1);
|
| return HandleMetric(isolate, js, arg);
|
| }
|
|
|
|
|