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

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

Issue 257053003: Always use the same json for null in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js 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/profiler.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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // TODO(johnmccutchan): Support asynchronous replies. 679 // TODO(johnmccutchan): Support asynchronous replies.
680 js.PostReply(); 680 js.PostReply();
681 } 681 }
682 } 682 }
683 } 683 }
684 } 684 }
685 } 685 }
686 686
687 687
688 static bool HandleIsolate(Isolate* isolate, JSONStream* js) { 688 static bool HandleIsolate(Isolate* isolate, JSONStream* js) {
689 isolate->PrintToJSONStream(js, false); 689 isolate->PrintJSON(js, false);
690 return true; 690 return true;
691 } 691 }
692 692
693 693
694 static bool HandleStackTrace(Isolate* isolate, JSONStream* js) { 694 static bool HandleStackTrace(Isolate* isolate, JSONStream* js) {
695 if (js->num_arguments() > 1) { 695 if (js->num_arguments() > 1) {
696 PrintError(js, "Command too long"); 696 PrintError(js, "Command too long");
697 return true; 697 return true;
698 } 698 }
699 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); 699 DebuggerStackTrace* stack = isolate->debugger()->StackTrace();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 js->num_arguments()); 879 js->num_arguments());
880 return true; 880 return true;
881 } 881 }
882 const String& expr_str = String::Handle(isolate, String::New(expr)); 882 const String& expr_str = String::Handle(isolate, String::New(expr));
883 ASSERT(obj.IsInstance()); 883 ASSERT(obj.IsInstance());
884 const Instance& instance = Instance::Cast(obj); 884 const Instance& instance = Instance::Cast(obj);
885 const Object& result = 885 const Object& result =
886 Object::Handle(instance.Evaluate(expr_str, 886 Object::Handle(instance.Evaluate(expr_str,
887 Array::empty_array(), 887 Array::empty_array(),
888 Array::empty_array())); 888 Array::empty_array()));
889 if (result.IsNull()) { 889 result.PrintJSON(js, true);
890 Object::null_instance().PrintToJSONStream(js, true);
891 } else {
892 result.PrintToJSONStream(js, true);
893 }
894 return true; 890 return true;
895 } 891 }
896 892
897 PrintError(js, "unrecognized action '%s'\n", action); 893 PrintError(js, "unrecognized action '%s'\n", action);
898 return true; 894 return true;
899 } 895 }
900 896
901 897
902 static bool HandleClassesClosures(Isolate* isolate, const Class& cls, 898 static bool HandleClassesClosures(Isolate* isolate, const Class& cls,
903 JSONStream* js) { 899 JSONStream* js) {
904 intptr_t id; 900 intptr_t id;
905 if (js->num_arguments() > 4) { 901 if (js->num_arguments() > 4) {
906 PrintError(js, "Command too long"); 902 PrintError(js, "Command too long");
907 return true; 903 return true;
908 } 904 }
909 if (!GetIntegerId(js->GetArgument(3), &id)) { 905 if (!GetIntegerId(js->GetArgument(3), &id)) {
910 PrintError(js, "Must specify collection object id: closures/id"); 906 PrintError(js, "Must specify collection object id: closures/id");
911 return true; 907 return true;
912 } 908 }
913 Function& func = Function::Handle(); 909 Function& func = Function::Handle();
914 func ^= cls.ClosureFunctionFromIndex(id); 910 func ^= cls.ClosureFunctionFromIndex(id);
915 if (func.IsNull()) { 911 if (func.IsNull()) {
916 PrintError(js, "Closure function %" Pd " not found", id); 912 PrintError(js, "Closure function %" Pd " not found", id);
917 return true; 913 return true;
918 } 914 }
919 func.PrintToJSONStream(js, false); 915 func.PrintJSON(js, false);
920 return true; 916 return true;
921 } 917 }
922 918
923 919
924 static bool HandleClassesEval(Isolate* isolate, const Class& cls, 920 static bool HandleClassesEval(Isolate* isolate, const Class& cls,
925 JSONStream* js) { 921 JSONStream* js) {
926 if (js->num_arguments() > 3) { 922 if (js->num_arguments() > 3) {
927 PrintError(js, "Command too long"); 923 PrintError(js, "Command too long");
928 return true; 924 return true;
929 } 925 }
930 const char* expr = js->LookupOption("expr"); 926 const char* expr = js->LookupOption("expr");
931 if (expr == NULL) { 927 if (expr == NULL) {
932 PrintError(js, "eval expects an 'expr' option\n", 928 PrintError(js, "eval expects an 'expr' option\n",
933 js->num_arguments()); 929 js->num_arguments());
934 return true; 930 return true;
935 } 931 }
936 const String& expr_str = String::Handle(isolate, String::New(expr)); 932 const String& expr_str = String::Handle(isolate, String::New(expr));
937 const Object& result = Object::Handle(cls.Evaluate(expr_str, 933 const Object& result = Object::Handle(cls.Evaluate(expr_str,
938 Array::empty_array(), 934 Array::empty_array(),
939 Array::empty_array())); 935 Array::empty_array()));
940 if (result.IsNull()) { 936 result.PrintJSON(js, true);
941 Object::null_instance().PrintToJSONStream(js, true);
942 } else {
943 result.PrintToJSONStream(js, true);
944 }
945 return true; 937 return true;
946 } 938 }
947 939
948 940
949 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls, 941 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls,
950 JSONStream* js) { 942 JSONStream* js) {
951 intptr_t id; 943 intptr_t id;
952 if (js->num_arguments() > 4) { 944 if (js->num_arguments() > 4) {
953 PrintError(js, "Command too long"); 945 PrintError(js, "Command too long");
954 return true; 946 return true;
955 } 947 }
956 if (!GetIntegerId(js->GetArgument(3), &id)) { 948 if (!GetIntegerId(js->GetArgument(3), &id)) {
957 PrintError(js, "Must specify collection object id: dispatchers/id"); 949 PrintError(js, "Must specify collection object id: dispatchers/id");
958 return true; 950 return true;
959 } 951 }
960 Function& func = Function::Handle(); 952 Function& func = Function::Handle();
961 func ^= cls.InvocationDispatcherFunctionFromIndex(id); 953 func ^= cls.InvocationDispatcherFunctionFromIndex(id);
962 if (func.IsNull()) { 954 if (func.IsNull()) {
963 PrintError(js, "Dispatcher %" Pd " not found", id); 955 PrintError(js, "Dispatcher %" Pd " not found", id);
964 return true; 956 return true;
965 } 957 }
966 func.PrintToJSONStream(js, false); 958 func.PrintJSON(js, false);
967 return true; 959 return true;
968 } 960 }
969 961
970 962
971 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls, 963 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls,
972 JSONStream* js) { 964 JSONStream* js) {
973 intptr_t id; 965 intptr_t id;
974 if (js->num_arguments() > 4) { 966 if (js->num_arguments() > 4) {
975 PrintError(js, "Command too long"); 967 PrintError(js, "Command too long");
976 return true; 968 return true;
977 } 969 }
978 if (!GetIntegerId(js->GetArgument(3), &id)) { 970 if (!GetIntegerId(js->GetArgument(3), &id)) {
979 PrintError(js, "Must specify collection object id: functions/id"); 971 PrintError(js, "Must specify collection object id: functions/id");
980 return true; 972 return true;
981 } 973 }
982 Function& func = Function::Handle(); 974 Function& func = Function::Handle();
983 func ^= cls.FunctionFromIndex(id); 975 func ^= cls.FunctionFromIndex(id);
984 if (func.IsNull()) { 976 if (func.IsNull()) {
985 PrintError(js, "Function %" Pd " not found", id); 977 PrintError(js, "Function %" Pd " not found", id);
986 return true; 978 return true;
987 } 979 }
988 func.PrintToJSONStream(js, false); 980 func.PrintJSON(js, false);
989 return true; 981 return true;
990 } 982 }
991 983
992 984
993 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls, 985 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls,
994 JSONStream* js) { 986 JSONStream* js) {
995 intptr_t id; 987 intptr_t id;
996 if (js->num_arguments() > 4) { 988 if (js->num_arguments() > 4) {
997 PrintError(js, "Command too long"); 989 PrintError(js, "Command too long");
998 return true; 990 return true;
999 } 991 }
1000 if (!GetIntegerId(js->GetArgument(3), &id)) { 992 if (!GetIntegerId(js->GetArgument(3), &id)) {
1001 PrintError(js, "Must specify collection object id: implicit_closures/id"); 993 PrintError(js, "Must specify collection object id: implicit_closures/id");
1002 return true; 994 return true;
1003 } 995 }
1004 Function& func = Function::Handle(); 996 Function& func = Function::Handle();
1005 func ^= cls.ImplicitClosureFunctionFromIndex(id); 997 func ^= cls.ImplicitClosureFunctionFromIndex(id);
1006 if (func.IsNull()) { 998 if (func.IsNull()) {
1007 PrintError(js, "Implicit closure function %" Pd " not found", id); 999 PrintError(js, "Implicit closure function %" Pd " not found", id);
1008 return true; 1000 return true;
1009 } 1001 }
1010 func.PrintToJSONStream(js, false); 1002 func.PrintJSON(js, false);
1011 return true; 1003 return true;
1012 } 1004 }
1013 1005
1014 1006
1015 static bool HandleClassesFields(Isolate* isolate, const Class& cls, 1007 static bool HandleClassesFields(Isolate* isolate, const Class& cls,
1016 JSONStream* js) { 1008 JSONStream* js) {
1017 intptr_t id; 1009 intptr_t id;
1018 if (js->num_arguments() > 4) { 1010 if (js->num_arguments() > 4) {
1019 PrintError(js, "Command too long"); 1011 PrintError(js, "Command too long");
1020 return true; 1012 return true;
1021 } 1013 }
1022 if (!GetIntegerId(js->GetArgument(3), &id)) { 1014 if (!GetIntegerId(js->GetArgument(3), &id)) {
1023 PrintError(js, "Must specify collection object id: fields/id"); 1015 PrintError(js, "Must specify collection object id: fields/id");
1024 return true; 1016 return true;
1025 } 1017 }
1026 Field& field = Field::Handle(cls.FieldFromIndex(id)); 1018 Field& field = Field::Handle(cls.FieldFromIndex(id));
1027 if (field.IsNull()) { 1019 if (field.IsNull()) {
1028 PrintError(js, "Field %" Pd " not found", id); 1020 PrintError(js, "Field %" Pd " not found", id);
1029 return true; 1021 return true;
1030 } 1022 }
1031 field.PrintToJSONStream(js, false); 1023 field.PrintJSON(js, false);
1032 return true; 1024 return true;
1033 } 1025 }
1034 1026
1035 1027
1036 static bool HandleClassesTypes(Isolate* isolate, const Class& cls, 1028 static bool HandleClassesTypes(Isolate* isolate, const Class& cls,
1037 JSONStream* js) { 1029 JSONStream* js) {
1038 if (js->num_arguments() == 3) { 1030 if (js->num_arguments() == 3) {
1039 JSONObject jsobj(js); 1031 JSONObject jsobj(js);
1040 jsobj.AddProperty("type", "TypeList"); 1032 jsobj.AddProperty("type", "TypeList");
1041 JSONArray members(&jsobj, "members"); 1033 JSONArray members(&jsobj, "members");
(...skipping 11 matching lines...) Expand all
1053 PrintError(js, "Must specify collection object id: types/id"); 1045 PrintError(js, "Must specify collection object id: types/id");
1054 return true; 1046 return true;
1055 } 1047 }
1056 Type& type = Type::Handle(); 1048 Type& type = Type::Handle();
1057 type ^= cls.CanonicalTypeFromIndex(id); 1049 type ^= cls.CanonicalTypeFromIndex(id);
1058 if (type.IsNull()) { 1050 if (type.IsNull()) {
1059 PrintError(js, "Canonical type %" Pd " not found", id); 1051 PrintError(js, "Canonical type %" Pd " not found", id);
1060 return true; 1052 return true;
1061 } 1053 }
1062 if (js->num_arguments() == 4) { 1054 if (js->num_arguments() == 4) {
1063 type.PrintToJSONStream(js, false); 1055 type.PrintJSON(js, false);
1064 return true; 1056 return true;
1065 } 1057 }
1066 return HandleInstanceCommands(isolate, type, js, 4); 1058 return HandleInstanceCommands(isolate, type, js, 4);
1067 } 1059 }
1068 1060
1069 1061
1070 static bool HandleClasses(Isolate* isolate, JSONStream* js) { 1062 static bool HandleClasses(Isolate* isolate, JSONStream* js) {
1071 if (js->num_arguments() == 1) { 1063 if (js->num_arguments() == 1) {
1072 ClassTable* table = isolate->class_table(); 1064 ClassTable* table = isolate->class_table();
1073 JSONObject jsobj(js); 1065 JSONObject jsobj(js);
1074 table->PrintToJSONObject(&jsobj); 1066 table->PrintToJSONObject(&jsobj);
1075 return true; 1067 return true;
1076 } 1068 }
1077 ASSERT(js->num_arguments() >= 2); 1069 ASSERT(js->num_arguments() >= 2);
1078 intptr_t id; 1070 intptr_t id;
1079 if (!GetIntegerId(js->GetArgument(1), &id)) { 1071 if (!GetIntegerId(js->GetArgument(1), &id)) {
1080 PrintError(js, "Must specify collection object id: /classes/id"); 1072 PrintError(js, "Must specify collection object id: /classes/id");
1081 return true; 1073 return true;
1082 } 1074 }
1083 ClassTable* table = isolate->class_table(); 1075 ClassTable* table = isolate->class_table();
1084 if (!table->IsValidIndex(id)) { 1076 if (!table->IsValidIndex(id)) {
1085 PrintError(js, "%" Pd " is not a valid class id.", id); 1077 PrintError(js, "%" Pd " is not a valid class id.", id);
1086 return true; 1078 return true;
1087 } 1079 }
1088 Class& cls = Class::Handle(table->At(id)); 1080 Class& cls = Class::Handle(table->At(id));
1089 if (js->num_arguments() == 2) { 1081 if (js->num_arguments() == 2) {
1090 cls.PrintToJSONStream(js, false); 1082 cls.PrintJSON(js, false);
1091 return true; 1083 return true;
1092 } else if (js->num_arguments() >= 3) { 1084 } else if (js->num_arguments() >= 3) {
1093 const char* second = js->GetArgument(2); 1085 const char* second = js->GetArgument(2);
1094 if (strcmp(second, "eval") == 0) { 1086 if (strcmp(second, "eval") == 0) {
1095 return HandleClassesEval(isolate, cls, js); 1087 return HandleClassesEval(isolate, cls, js);
1096 } else if (strcmp(second, "closures") == 0) { 1088 } else if (strcmp(second, "closures") == 0) {
1097 return HandleClassesClosures(isolate, cls, js); 1089 return HandleClassesClosures(isolate, cls, js);
1098 } else if (strcmp(second, "fields") == 0) { 1090 } else if (strcmp(second, "fields") == 0) {
1099 return HandleClassesFields(isolate, cls, js); 1091 return HandleClassesFields(isolate, cls, js);
1100 } else if (strcmp(second, "functions") == 0) { 1092 } else if (strcmp(second, "functions") == 0) {
(...skipping 23 matching lines...) Expand all
1124 const char* expr = js->LookupOption("expr"); 1116 const char* expr = js->LookupOption("expr");
1125 if (expr == NULL) { 1117 if (expr == NULL) {
1126 PrintError(js, "eval expects an 'expr' option\n", 1118 PrintError(js, "eval expects an 'expr' option\n",
1127 js->num_arguments()); 1119 js->num_arguments());
1128 return true; 1120 return true;
1129 } 1121 }
1130 const String& expr_str = String::Handle(isolate, String::New(expr)); 1122 const String& expr_str = String::Handle(isolate, String::New(expr));
1131 const Object& result = Object::Handle(lib.Evaluate(expr_str, 1123 const Object& result = Object::Handle(lib.Evaluate(expr_str,
1132 Array::empty_array(), 1124 Array::empty_array(),
1133 Array::empty_array())); 1125 Array::empty_array()));
1134 if (result.IsNull()) { 1126 result.PrintJSON(js, true);
1135 Object::null_instance().PrintToJSONStream(js, true);
1136 } else {
1137 result.PrintToJSONStream(js, true);
1138 }
1139 return true; 1127 return true;
1140 } 1128 }
1141 1129
1142 1130
1143 static bool HandleLibraries(Isolate* isolate, JSONStream* js) { 1131 static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
1144 // TODO(johnmccutchan): Support fields and functions on libraries. 1132 // TODO(johnmccutchan): Support fields and functions on libraries.
1145 REQUIRE_COLLECTION_ID("libraries"); 1133 REQUIRE_COLLECTION_ID("libraries");
1146 const GrowableObjectArray& libs = 1134 const GrowableObjectArray& libs =
1147 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 1135 GrowableObjectArray::Handle(isolate->object_store()->libraries());
1148 ASSERT(!libs.IsNull()); 1136 ASSERT(!libs.IsNull());
1149 intptr_t id = 0; 1137 intptr_t id = 0;
1150 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), 1138 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1),
1151 id, js); 1139 id, js);
1152 Library& lib = Library::Handle(); 1140 Library& lib = Library::Handle();
1153 lib ^= libs.At(id); 1141 lib ^= libs.At(id);
1154 ASSERT(!lib.IsNull()); 1142 ASSERT(!lib.IsNull());
1155 if (js->num_arguments() == 2) { 1143 if (js->num_arguments() == 2) {
1156 lib.PrintToJSONStream(js, false); 1144 lib.PrintJSON(js, false);
1157 return true; 1145 return true;
1158 } else if (js->num_arguments() >= 3) { 1146 } else if (js->num_arguments() >= 3) {
1159 const char* second = js->GetArgument(2); 1147 const char* second = js->GetArgument(2);
1160 if (strcmp(second, "eval") == 0) { 1148 if (strcmp(second, "eval") == 0) {
1161 return HandleLibrariesEval(isolate, lib, js); 1149 return HandleLibrariesEval(isolate, lib, js);
1162 } else { 1150 } else {
1163 PrintError(js, "Invalid sub collection %s", second); 1151 PrintError(js, "Invalid sub collection %s", second);
1164 return true; 1152 return true;
1165 } 1153 }
1166 } 1154 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 return true; 1209 return true;
1222 } 1210 }
1223 const char* arg = js->GetArgument(1); 1211 const char* arg = js->GetArgument(1);
1224 1212
1225 // Handle special objects first. 1213 // Handle special objects first.
1226 if (strcmp(arg, "null") == 0) { 1214 if (strcmp(arg, "null") == 0) {
1227 if (js->num_arguments() > 2) { 1215 if (js->num_arguments() > 2) {
1228 PrintError(js, "expected at most 2 arguments but found %" Pd "\n", 1216 PrintError(js, "expected at most 2 arguments but found %" Pd "\n",
1229 js->num_arguments()); 1217 js->num_arguments());
1230 } else { 1218 } else {
1231 Instance::null_instance().PrintToJSONStream(js, false); 1219 Instance::null_instance().PrintJSON(js, false);
1232 } 1220 }
1233 return true; 1221 return true;
1234 1222
1235 } else if (strcmp(arg, "not-initialized") == 0) { 1223 } else if (strcmp(arg, "not-initialized") == 0) {
1236 if (js->num_arguments() > 2) { 1224 if (js->num_arguments() > 2) {
1237 PrintError(js, "expected at most 2 arguments but found %" Pd "\n", 1225 PrintError(js, "expected at most 2 arguments but found %" Pd "\n",
1238 js->num_arguments()); 1226 js->num_arguments());
1239 } else { 1227 } else {
1240 Object::sentinel().PrintToJSONStream(js, false); 1228 Object::sentinel().PrintJSON(js, false);
1241 } 1229 }
1242 return true; 1230 return true;
1243 1231
1244 } else if (strcmp(arg, "being-initialized") == 0) { 1232 } else if (strcmp(arg, "being-initialized") == 0) {
1245 if (js->num_arguments() > 2) { 1233 if (js->num_arguments() > 2) {
1246 PrintError(js, "expected at most 2 arguments but found %" Pd "\n", 1234 PrintError(js, "expected at most 2 arguments but found %" Pd "\n",
1247 js->num_arguments()); 1235 js->num_arguments());
1248 } else { 1236 } else {
1249 Object::transition_sentinel().PrintToJSONStream(js, false); 1237 Object::transition_sentinel().PrintJSON(js, false);
1250 } 1238 }
1251 return true; 1239 return true;
1252 1240
1253 } else if (strcmp(arg, "optimized-out") == 0) { 1241 } else if (strcmp(arg, "optimized-out") == 0) {
1254 if (js->num_arguments() > 2) { 1242 if (js->num_arguments() > 2) {
1255 PrintError(js, "expected at most 2 arguments but found %" Pd "\n", 1243 PrintError(js, "expected at most 2 arguments but found %" Pd "\n",
1256 js->num_arguments()); 1244 js->num_arguments());
1257 } else { 1245 } else {
1258 Symbols::OptimizedOut().PrintToJSONStream(js, false); 1246 Symbols::OptimizedOut().PrintJSON(js, false);
1259 } 1247 }
1260 return true; 1248 return true;
1261 1249
1262 } else if (strcmp(arg, "collected") == 0) { 1250 } else if (strcmp(arg, "collected") == 0) {
1263 if (js->num_arguments() > 2) { 1251 if (js->num_arguments() > 2) {
1264 PrintError(js, "expected at most 2 arguments but found %" Pd "\n", 1252 PrintError(js, "expected at most 2 arguments but found %" Pd "\n",
1265 js->num_arguments()); 1253 js->num_arguments());
1266 } else { 1254 } else {
1267 PrintPseudoNull(js, "objects/collected", "<collected>"); 1255 PrintPseudoNull(js, "objects/collected", "<collected>");
1268 } 1256 }
(...skipping 21 matching lines...) Expand all
1290 // Print. 1278 // Print.
1291 if (obj.IsNull()) { 1279 if (obj.IsNull()) {
1292 // The object has been collected by the gc. 1280 // The object has been collected by the gc.
1293 PrintPseudoNull(js, "objects/collected", "<collected>"); 1281 PrintPseudoNull(js, "objects/collected", "<collected>");
1294 return true; 1282 return true;
1295 } else if (obj.raw() == Object::sentinel().raw()) { 1283 } else if (obj.raw() == Object::sentinel().raw()) {
1296 // The object id has expired. 1284 // The object id has expired.
1297 PrintPseudoNull(js, "objects/expired", "<expired>"); 1285 PrintPseudoNull(js, "objects/expired", "<expired>");
1298 return true; 1286 return true;
1299 } 1287 }
1300 obj.PrintToJSONStream(js, false); 1288 obj.PrintJSON(js, false);
1301 return true; 1289 return true;
1302 } 1290 }
1303 return HandleInstanceCommands(isolate, obj, js, 2); 1291 return HandleInstanceCommands(isolate, obj, js, 2);
1304 } 1292 }
1305 1293
1306 1294
1307 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { 1295 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) {
1308 JSONObject jsobj(js); 1296 JSONObject jsobj(js);
1309 jsobj.AddProperty("type", "ScriptList"); 1297 jsobj.AddProperty("type", "ScriptList");
1310 jsobj.AddProperty("id", "scripts"); 1298 jsobj.AddProperty("id", "scripts");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 ASSERT(!lib.IsNull()); 1334 ASSERT(!lib.IsNull());
1347 ASSERT(Smi::IsValid(lib.index())); 1335 ASSERT(Smi::IsValid(lib.index()));
1348 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); 1336 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts());
1349 ASSERT(!loaded_scripts.IsNull()); 1337 ASSERT(!loaded_scripts.IsNull());
1350 intptr_t num_scripts = loaded_scripts.Length(); 1338 intptr_t num_scripts = loaded_scripts.Length();
1351 for (intptr_t i = 0; i < num_scripts; i++) { 1339 for (intptr_t i = 0; i < num_scripts; i++) {
1352 script ^= loaded_scripts.At(i); 1340 script ^= loaded_scripts.At(i);
1353 ASSERT(!script.IsNull()); 1341 ASSERT(!script.IsNull());
1354 url ^= script.url(); 1342 url ^= script.url();
1355 if (url.Equals(requested_url)) { 1343 if (url.Equals(requested_url)) {
1356 script.PrintToJSONStream(js, false); 1344 script.PrintJSON(js, false);
1357 return true; 1345 return true;
1358 } 1346 }
1359 } 1347 }
1360 } 1348 }
1361 PrintErrorWithKind(js, "NotFoundError", "Cannot find script %s", 1349 PrintErrorWithKind(js, "NotFoundError", "Cannot find script %s",
1362 requested_url.ToCString()); 1350 requested_url.ToCString());
1363 return true; 1351 return true;
1364 } 1352 }
1365 1353
1366 1354
(...skipping 26 matching lines...) Expand all
1393 isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr); 1381 isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr);
1394 return true; 1382 return true;
1395 } else if (js->num_arguments() == 3) { 1383 } else if (js->num_arguments() == 3) {
1396 // Print individual breakpoint. 1384 // Print individual breakpoint.
1397 intptr_t id = 0; 1385 intptr_t id = 0;
1398 SourceBreakpoint* bpt = NULL; 1386 SourceBreakpoint* bpt = NULL;
1399 if (GetIntegerId(js->GetArgument(2), &id)) { 1387 if (GetIntegerId(js->GetArgument(2), &id)) {
1400 bpt = isolate->debugger()->GetBreakpointById(id); 1388 bpt = isolate->debugger()->GetBreakpointById(id);
1401 } 1389 }
1402 if (bpt != NULL) { 1390 if (bpt != NULL) {
1403 bpt->PrintToJSONStream(js); 1391 bpt->PrintJSON(js);
1404 return true; 1392 return true;
1405 } else { 1393 } else {
1406 PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2)); 1394 PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2));
1407 return true; 1395 return true;
1408 } 1396 }
1409 } else { 1397 } else {
1410 PrintError(js, "Command too long"); 1398 PrintError(js, "Command too long");
1411 return true; 1399 return true;
1412 } 1400 }
1413 } else { 1401 } else {
1414 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); 1402 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1));
1415 return true; 1403 return true;
1416 } 1404 }
1417 } 1405 }
1418 1406
1419 1407
1420 static bool HandleNullCode(uintptr_t pc, JSONStream* js) { 1408 static bool HandleNullCode(uintptr_t pc, JSONStream* js) {
1421 // TODO(turnidge): Consider adding/using Object::null_code() for 1409 // TODO(turnidge): Consider adding/using Object::null_code() for
1422 // consistent "type". 1410 // consistent "type".
1423 Object::null_object().PrintToJSONStream(js, false); 1411 Object::null_object().PrintJSON(js, false);
1424 return true; 1412 return true;
1425 } 1413 }
1426 1414
1427 1415
1428 static bool HandleCode(Isolate* isolate, JSONStream* js) { 1416 static bool HandleCode(Isolate* isolate, JSONStream* js) {
1429 REQUIRE_COLLECTION_ID("code"); 1417 REQUIRE_COLLECTION_ID("code");
1430 uword pc; 1418 uword pc;
1431 if (js->num_arguments() > 2) { 1419 if (js->num_arguments() > 2) {
1432 PrintError(js, "Command too long"); 1420 PrintError(js, "Command too long");
1433 return true; 1421 return true;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 } 1453 }
1466 return HandleNullCode(pc, js); 1454 return HandleNullCode(pc, js);
1467 } 1455 }
1468 int64_t timestamp = 0; 1456 int64_t timestamp = 0;
1469 if (!GetCodeId(command, &timestamp, &pc) || (timestamp < 0)) { 1457 if (!GetCodeId(command, &timestamp, &pc) || (timestamp < 0)) {
1470 PrintError(js, "Malformed code id: %s", command); 1458 PrintError(js, "Malformed code id: %s", command);
1471 return true; 1459 return true;
1472 } 1460 }
1473 Code& code = Code::Handle(Code::FindCode(pc, timestamp)); 1461 Code& code = Code::Handle(Code::FindCode(pc, timestamp));
1474 if (!code.IsNull()) { 1462 if (!code.IsNull()) {
1475 code.PrintToJSONStream(js, false); 1463 code.PrintJSON(js, false);
1476 return true; 1464 return true;
1477 } 1465 }
1478 PrintError(js, "Could not find code with id: %s", command); 1466 PrintError(js, "Could not find code with id: %s", command);
1479 return true; 1467 return true;
1480 } 1468 }
1481 1469
1482 1470
1483 static bool HandleProfile(Isolate* isolate, JSONStream* js) { 1471 static bool HandleProfile(Isolate* isolate, JSONStream* js) {
1484 if (js->num_arguments() == 2) { 1472 if (js->num_arguments() == 2) {
1485 const char* sub_command = js->GetArgument(1); 1473 const char* sub_command = js->GetArgument(1);
(...skipping 24 matching lines...) Expand all
1510 tag_order = Profiler::kUser; 1498 tag_order = Profiler::kUser;
1511 } else if (js->OptionIs("tags", "vu")) { 1499 } else if (js->OptionIs("tags", "vu")) {
1512 tag_order = Profiler::kVMUser; 1500 tag_order = Profiler::kVMUser;
1513 } else if (js->OptionIs("tags", "v")) { 1501 } else if (js->OptionIs("tags", "v")) {
1514 tag_order = Profiler::kVM; 1502 tag_order = Profiler::kVM;
1515 } else { 1503 } else {
1516 PrintError(js, "Invalid tags option value: %s\n", tags_option); 1504 PrintError(js, "Invalid tags option value: %s\n", tags_option);
1517 return true; 1505 return true;
1518 } 1506 }
1519 } 1507 }
1520 Profiler::PrintToJSONStream(isolate, js, full_profile, tag_order); 1508 Profiler::PrintJSON(isolate, js, full_profile, tag_order);
1521 return true; 1509 return true;
1522 } 1510 }
1523 1511
1524 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { 1512 static bool HandleCoverage(Isolate* isolate, JSONStream* js) {
1525 CodeCoverage::PrintToJSONStream(isolate, js); 1513 CodeCoverage::PrintJSON(isolate, js);
1526 return true; 1514 return true;
1527 } 1515 }
1528 1516
1529 1517
1530 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) { 1518 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) {
1531 bool should_reset_accumulator = false; 1519 bool should_reset_accumulator = false;
1532 bool should_collect = false; 1520 bool should_collect = false;
1533 if (js->num_arguments() != 1) { 1521 if (js->num_arguments() != 1) {
1534 PrintError(js, "Command too long"); 1522 PrintError(js, "Command too long");
1535 return true; 1523 return true;
(...skipping 14 matching lines...) Expand all
1550 PrintError(js, "Unrecognized gc option '%s'", js->LookupOption("gc")); 1538 PrintError(js, "Unrecognized gc option '%s'", js->LookupOption("gc"));
1551 return true; 1539 return true;
1552 } 1540 }
1553 } 1541 }
1554 if (should_reset_accumulator) { 1542 if (should_reset_accumulator) {
1555 isolate->class_table()->ResetAllocationAccumulators(); 1543 isolate->class_table()->ResetAllocationAccumulators();
1556 } 1544 }
1557 if (should_collect) { 1545 if (should_collect) {
1558 isolate->heap()->CollectAllGarbage(); 1546 isolate->heap()->CollectAllGarbage();
1559 } 1547 }
1560 isolate->class_table()->AllocationProfilePrintToJSONStream(js); 1548 isolate->class_table()->AllocationProfilePrintJSON(js);
1561 return true; 1549 return true;
1562 } 1550 }
1563 1551
1564 1552
1565 static bool HandleResume(Isolate* isolate, JSONStream* js) { 1553 static bool HandleResume(Isolate* isolate, JSONStream* js) {
1566 if (isolate->message_handler()->pause_on_start()) { 1554 if (isolate->message_handler()->pause_on_start()) {
1567 isolate->message_handler()->set_pause_on_start(false); 1555 isolate->message_handler()->set_pause_on_start(false);
1568 JSONObject jsobj(js); 1556 JSONObject jsobj(js);
1569 jsobj.AddProperty("type", "Success"); 1557 jsobj.AddProperty("type", "Success");
1570 jsobj.AddProperty("id", ""); 1558 jsobj.AddProperty("id", "");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 // Note that the table index of the canonical type arguments will change 1611 // Note that the table index of the canonical type arguments will change
1624 // when the table grows. Should we not support this access at all? 1612 // when the table grows. Should we not support this access at all?
1625 PrintError(js, "Must specify collection object id: /typearguments/id"); 1613 PrintError(js, "Must specify collection object id: /typearguments/id");
1626 return true; 1614 return true;
1627 } 1615 }
1628 if ((id < 0) || (id >= table_size) || (table.At(id) == Object::null())) { 1616 if ((id < 0) || (id >= table_size) || (table.At(id) == Object::null())) {
1629 PrintError(js, "%" Pd " is not a valid typearguments id.", id); 1617 PrintError(js, "%" Pd " is not a valid typearguments id.", id);
1630 return true; 1618 return true;
1631 } 1619 }
1632 type_args ^= table.At(id); 1620 type_args ^= table.At(id);
1633 type_args.PrintToJSONStream(js, false); 1621 type_args.PrintJSON(js, false);
1634 return true; 1622 return true;
1635 } 1623 }
1636 1624
1637 1625
1638 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) { 1626 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) {
1639 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); 1627 isolate->heap()->PrintHeapMapToJSONStream(isolate, js);
1640 return true; 1628 return true;
1641 } 1629 }
1642 1630
1643 1631
(...skipping 26 matching lines...) Expand all
1670 static const uword kExampleAddr = static_cast<uword>(kIntptrMax / 7); 1658 static const uword kExampleAddr = static_cast<uword>(kIntptrMax / 7);
1671 PrintError(js, "Must specify address: address/" Px ".", kExampleAddr); 1659 PrintError(js, "Must specify address: address/" Px ".", kExampleAddr);
1672 return true; 1660 return true;
1673 } 1661 }
1674 Object& object = Object::Handle(isolate); 1662 Object& object = Object::Handle(isolate);
1675 { 1663 {
1676 NoGCScope no_gc; 1664 NoGCScope no_gc;
1677 ContainsAddressVisitor visitor(isolate, addr); 1665 ContainsAddressVisitor visitor(isolate, addr);
1678 object = isolate->heap()->FindObject(&visitor); 1666 object = isolate->heap()->FindObject(&visitor);
1679 } 1667 }
1680 object.PrintToJSONStream(js, true); 1668 object.PrintJSON(js, true);
1681 return true; 1669 return true;
1682 } 1670 }
1683 1671
1684 1672
1685 static bool HandleMalformedJson(Isolate* isolate, JSONStream* js) { 1673 static bool HandleMalformedJson(Isolate* isolate, JSONStream* js) {
1686 JSONObject jsobj(js); 1674 JSONObject jsobj(js);
1687 jsobj.AddProperty("a", "a"); 1675 jsobj.AddProperty("a", "a");
1688 JSONObject jsobj1(js); 1676 JSONObject jsobj1(js);
1689 jsobj1.AddProperty("a", "a"); 1677 jsobj1.AddProperty("a", "a");
1690 JSONObject jsobj2(js); 1678 JSONObject jsobj2(js);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 while (current != NULL) { 1962 while (current != NULL) {
1975 if (strcmp(name, current->name()) == 0) { 1963 if (strcmp(name, current->name()) == 0) {
1976 return current; 1964 return current;
1977 } 1965 }
1978 current = current->next(); 1966 current = current->next();
1979 } 1967 }
1980 return NULL; 1968 return NULL;
1981 } 1969 }
1982 1970
1983 } // namespace dart 1971 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698