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

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

Issue 292663012: Retaining path in Observatory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object_graph_test.cc ('k') | runtime/vm/service_test.cc » ('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 "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 return true; 871 return true;
872 } 872 }
873 } 873 }
874 return false; 874 return false;
875 } else { 875 } else {
876 return !obj.IsInstance(); 876 return !obj.IsInstance();
877 } 877 }
878 } 878 }
879 879
880 880
881 // Takes an Object* only because RetainingPath temporarily clears it.
881 static bool HandleInstanceCommands(Isolate* isolate, 882 static bool HandleInstanceCommands(Isolate* isolate,
882 const Object& obj, 883 Object* obj,
883 JSONStream* js, 884 JSONStream* js,
884 intptr_t arg_pos) { 885 intptr_t arg_pos) {
885 ASSERT(js->num_arguments() > arg_pos); 886 ASSERT(js->num_arguments() > arg_pos);
886 const char* action = js->GetArgument(arg_pos); 887 const char* action = js->GetArgument(arg_pos);
887 if (strcmp(action, "eval") == 0) { 888 if (strcmp(action, "eval") == 0) {
888 if (js->num_arguments() > (arg_pos + 1)) { 889 if (js->num_arguments() > (arg_pos + 1)) {
889 PrintError(js, "expected at most %" Pd " arguments but found %" Pd "\n", 890 PrintError(js, "expected at most %" Pd " arguments but found %" Pd "\n",
890 arg_pos + 1, 891 arg_pos + 1,
891 js->num_arguments()); 892 js->num_arguments());
892 return true; 893 return true;
893 } 894 }
894 if (obj.IsNull()) { 895 if (obj->IsNull()) {
895 PrintErrorWithKind(js, "EvalCollected", 896 PrintErrorWithKind(js, "EvalCollected",
896 "attempt to evaluate against collected object\n", 897 "attempt to evaluate against collected object\n",
897 js->num_arguments()); 898 js->num_arguments());
898 return true; 899 return true;
899 } 900 }
900 if (obj.raw() == Object::sentinel().raw()) { 901 if (obj->raw() == Object::sentinel().raw()) {
901 PrintErrorWithKind(js, "EvalExpired", 902 PrintErrorWithKind(js, "EvalExpired",
902 "attempt to evaluate against expired object\n", 903 "attempt to evaluate against expired object\n",
903 js->num_arguments()); 904 js->num_arguments());
904 return true; 905 return true;
905 } 906 }
906 if (ContainsNonInstance(obj)) { 907 if (ContainsNonInstance(*obj)) {
907 PrintError(js, "attempt to evaluate against internal VM object\n"); 908 PrintError(js, "attempt to evaluate against internal VM object\n");
908 return true; 909 return true;
909 } 910 }
910 const char* expr = js->LookupOption("expr"); 911 const char* expr = js->LookupOption("expr");
911 if (expr == NULL) { 912 if (expr == NULL) {
912 PrintError(js, "eval expects an 'expr' option\n", 913 PrintError(js, "eval expects an 'expr' option\n",
913 js->num_arguments()); 914 js->num_arguments());
914 return true; 915 return true;
915 } 916 }
916 const String& expr_str = String::Handle(isolate, String::New(expr)); 917 const String& expr_str = String::Handle(isolate, String::New(expr));
917 ASSERT(obj.IsInstance()); 918 ASSERT(obj->IsInstance());
918 const Instance& instance = Instance::Cast(obj); 919 const Instance& instance = Instance::Cast(*obj);
919 const Object& result = 920 const Object& result =
920 Object::Handle(instance.Evaluate(expr_str, 921 Object::Handle(instance.Evaluate(expr_str,
921 Array::empty_array(), 922 Array::empty_array(),
922 Array::empty_array())); 923 Array::empty_array()));
923 result.PrintJSON(js, true); 924 result.PrintJSON(js, true);
924 return true; 925 return true;
925 } else if (strcmp(action, "retained") == 0) { 926 } else if (strcmp(action, "retained") == 0) {
926 ObjectGraph graph(isolate); 927 ObjectGraph graph(isolate);
927 intptr_t retained_size = graph.SizeRetainedByInstance(obj); 928 intptr_t retained_size = graph.SizeRetainedByInstance(*obj);
928 const Object& result = Object::Handle(Integer::New(retained_size)); 929 const Object& result = Object::Handle(Integer::New(retained_size));
929 result.PrintJSON(js, true); 930 result.PrintJSON(js, true);
930 return true; 931 return true;
932 } else if (strcmp(action, "retaining_path") == 0) {
933 intptr_t limit;
934 if (!GetIntegerId(js->LookupOption("limit"), &limit)) {
935 PrintError(js, "retaining_path expects a 'limit' option\n",
936 js->num_arguments());
937 return true;
938 }
939 ObjectGraph graph(isolate);
940 Array& path = Array::Handle(Array::New(limit));
941 intptr_t length = graph.RetainingPath(obj, path);
942 JSONObject jsobj(js);
943 jsobj.AddProperty("type", "RetainingPath");
944 jsobj.AddProperty("id", "retaining_path");
945 jsobj.AddProperty("length", length);
946 JSONArray elements(&jsobj, "elements");
947 for (intptr_t i = 0; i < path.Length() && i < length; ++i) {
948 JSONObject jselement(&elements);
949 Object& element = Object::Handle();
950 element = path.At(i);
951 jselement.AddProperty("index", i);
952 jselement.AddProperty("value", element);
953 }
954 return true;
931 } 955 }
932 956
933 PrintError(js, "unrecognized action '%s'\n", action); 957 PrintError(js, "unrecognized action '%s'\n", action);
934 return true; 958 return true;
935 } 959 }
936 960
937 961
938 static bool HandleClassesClosures(Isolate* isolate, const Class& cls, 962 static bool HandleClassesClosures(Isolate* isolate, const Class& cls,
939 JSONStream* js) { 963 JSONStream* js) {
940 intptr_t id; 964 intptr_t id;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 Type& type = Type::Handle(); 1112 Type& type = Type::Handle();
1089 type ^= cls.CanonicalTypeFromIndex(id); 1113 type ^= cls.CanonicalTypeFromIndex(id);
1090 if (type.IsNull()) { 1114 if (type.IsNull()) {
1091 PrintError(js, "Canonical type %" Pd " not found", id); 1115 PrintError(js, "Canonical type %" Pd " not found", id);
1092 return true; 1116 return true;
1093 } 1117 }
1094 if (js->num_arguments() == 4) { 1118 if (js->num_arguments() == 4) {
1095 type.PrintJSON(js, false); 1119 type.PrintJSON(js, false);
1096 return true; 1120 return true;
1097 } 1121 }
1098 return HandleInstanceCommands(isolate, type, js, 4); 1122 return HandleInstanceCommands(isolate, &type, js, 4);
1099 } 1123 }
1100 1124
1101 1125
1102 static bool HandleClassesRetained(Isolate* isolate, const Class& cls, 1126 static bool HandleClassesRetained(Isolate* isolate, const Class& cls,
1103 JSONStream* js) { 1127 JSONStream* js) {
1104 if (js->num_arguments() != 3) { 1128 if (js->num_arguments() != 3) {
1105 PrintError(js, "Command too long"); 1129 PrintError(js, "Command too long");
1106 return true; 1130 return true;
1107 } 1131 }
1108 ObjectGraph graph(isolate); 1132 ObjectGraph graph(isolate);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 PrintPseudoNull(js, "objects/collected", "<collected>"); 1361 PrintPseudoNull(js, "objects/collected", "<collected>");
1338 return true; 1362 return true;
1339 } else if (obj.raw() == Object::sentinel().raw()) { 1363 } else if (obj.raw() == Object::sentinel().raw()) {
1340 // The object id has expired. 1364 // The object id has expired.
1341 PrintPseudoNull(js, "objects/expired", "<expired>"); 1365 PrintPseudoNull(js, "objects/expired", "<expired>");
1342 return true; 1366 return true;
1343 } 1367 }
1344 obj.PrintJSON(js, false); 1368 obj.PrintJSON(js, false);
1345 return true; 1369 return true;
1346 } 1370 }
1347 return HandleInstanceCommands(isolate, obj, js, 2); 1371 return HandleInstanceCommands(isolate, &obj, js, 2);
1348 } 1372 }
1349 1373
1350 1374
1351 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { 1375 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) {
1352 JSONObject jsobj(js); 1376 JSONObject jsobj(js);
1353 jsobj.AddProperty("type", "ScriptList"); 1377 jsobj.AddProperty("type", "ScriptList");
1354 jsobj.AddProperty("id", "scripts"); 1378 jsobj.AddProperty("id", "scripts");
1355 JSONArray members(&jsobj, "members"); 1379 JSONArray members(&jsobj, "members");
1356 const GrowableObjectArray& libs = 1380 const GrowableObjectArray& libs =
1357 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 1381 GrowableObjectArray::Handle(isolate->object_store()->libraries());
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 while (current != NULL) { 2067 while (current != NULL) {
2044 if (strcmp(name, current->name()) == 0) { 2068 if (strcmp(name, current->name()) == 0) {
2045 return current; 2069 return current;
2046 } 2070 }
2047 current = current->next(); 2071 current = current->next();
2048 } 2072 }
2049 return NULL; 2073 return NULL;
2050 } 2074 }
2051 2075
2052 } // namespace dart 2076 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_graph_test.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698