OLD | NEW |
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 | 8 |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/coverage.h" | 10 #include "vm/coverage.h" |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), | 850 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), |
851 id, js); | 851 id, js); |
852 Library& lib = Library::Handle(); | 852 Library& lib = Library::Handle(); |
853 lib ^= libs.At(id); | 853 lib ^= libs.At(id); |
854 ASSERT(!lib.IsNull()); | 854 ASSERT(!lib.IsNull()); |
855 lib.PrintToJSONStream(js, false); | 855 lib.PrintToJSONStream(js, false); |
856 return true; | 856 return true; |
857 } | 857 } |
858 | 858 |
859 | 859 |
| 860 static void PrintPseudoNull(JSONStream* js, |
| 861 const char* id, |
| 862 const char* preview) { |
| 863 JSONObject jsobj(js); |
| 864 jsobj.AddProperty("type", "Null"); |
| 865 jsobj.AddProperty("id", id); |
| 866 jsobj.AddProperty("preview", preview); |
| 867 } |
| 868 |
| 869 |
860 static bool HandleObjects(Isolate* isolate, JSONStream* js) { | 870 static bool HandleObjects(Isolate* isolate, JSONStream* js) { |
861 REQUIRE_COLLECTION_ID("objects"); | 871 REQUIRE_COLLECTION_ID("objects"); |
862 ASSERT(js->num_arguments() >= 2); | 872 ASSERT(js->num_arguments() >= 2); |
863 const char* arg = js->GetArgument(1); | 873 const char* arg = js->GetArgument(1); |
864 | 874 |
865 // TODO(turnidge): Handle <optimized out> the same way as other | 875 // TODO(turnidge): Handle <optimized out> the same way as other |
866 // special nulls. | 876 // special nulls. |
867 if (strcmp(arg, "null") == 0 || | 877 if (strcmp(arg, "null") == 0) { |
868 strcmp(arg, "not-initialized") == 0 || | |
869 strcmp(arg, "being-initialized") == 0 || | |
870 strcmp(arg, "optimized-out") == 0) { | |
871 Object::null_object().PrintToJSONStream(js, false); | 878 Object::null_object().PrintToJSONStream(js, false); |
872 return true; | 879 return true; |
873 | 880 |
| 881 } else if (strcmp(arg, "not-initialized") == 0) { |
| 882 Object::sentinel().PrintToJSONStream(js, false); |
| 883 return true; |
| 884 |
| 885 } else if (strcmp(arg, "being-initialized") == 0) { |
| 886 Object::transition_sentinel().PrintToJSONStream(js, false); |
| 887 return true; |
| 888 |
| 889 } else if (strcmp(arg, "optimized-out") == 0) { |
| 890 Symbols::OptimizedOut().PrintToJSONStream(js, false); |
| 891 return true; |
| 892 |
| 893 } else if (strcmp(arg, "collected") == 0) { |
| 894 PrintPseudoNull(js, "objects/collected", "<collected>"); |
| 895 return true; |
| 896 |
| 897 } else if (strcmp(arg, "expired") == 0) { |
| 898 PrintPseudoNull(js, "objects/expired", "<expired>"); |
| 899 return true; |
| 900 |
874 } else if (strcmp(arg, "int") == 0) { | 901 } else if (strcmp(arg, "int") == 0) { |
875 if (js->num_arguments() < 3) { | 902 if (js->num_arguments() < 3) { |
876 PrintError(js, "expected 3 arguments but found %" Pd "\n", | 903 PrintError(js, "expected 3 arguments but found %" Pd "\n", |
877 js->num_arguments()); | 904 js->num_arguments()); |
878 return true; | 905 return true; |
879 } | 906 } |
880 int64_t value = 0; | 907 int64_t value = 0; |
881 if (!OS::StringToInt64(js->GetArgument(2), &value) || | 908 if (!OS::StringToInt64(js->GetArgument(2), &value) || |
882 !Smi::IsValid64(value)) { | 909 !Smi::IsValid64(value)) { |
883 PrintError(js, "integer value too large\n", | 910 PrintError(js, "integer value too large\n", |
(...skipping 26 matching lines...) Expand all Loading... |
910 } | 937 } |
911 | 938 |
912 ObjectIdRing* ring = isolate->object_id_ring(); | 939 ObjectIdRing* ring = isolate->object_id_ring(); |
913 ASSERT(ring != NULL); | 940 ASSERT(ring != NULL); |
914 intptr_t id = -1; | 941 intptr_t id = -1; |
915 if (!GetIntegerId(arg, &id)) { | 942 if (!GetIntegerId(arg, &id)) { |
916 Object::null_object().PrintToJSONStream(js, false); | 943 Object::null_object().PrintToJSONStream(js, false); |
917 return true; | 944 return true; |
918 } | 945 } |
919 Object& obj = Object::Handle(ring->GetObjectForId(id)); | 946 Object& obj = Object::Handle(ring->GetObjectForId(id)); |
| 947 if (obj.IsNull()) { |
| 948 // The object has been collected by the gc. |
| 949 PrintPseudoNull(js, "objects/collected", "<collected>"); |
| 950 return true; |
| 951 } else if (obj.raw() == Object::sentinel().raw()) { |
| 952 // The object id has expired. |
| 953 PrintPseudoNull(js, "objects/expired", "<expired>"); |
| 954 return true; |
| 955 } |
920 obj.PrintToJSONStream(js, false); | 956 obj.PrintToJSONStream(js, false); |
921 return true; | 957 return true; |
922 } | 958 } |
923 | 959 |
924 | 960 |
925 | 961 |
926 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { | 962 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { |
927 JSONObject jsobj(js); | 963 JSONObject jsobj(js); |
928 jsobj.AddProperty("type", "ScriptList"); | 964 jsobj.AddProperty("type", "ScriptList"); |
929 JSONArray members(&jsobj, "members"); | 965 JSONArray members(&jsobj, "members"); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 while (current != NULL) { | 1396 while (current != NULL) { |
1361 if (strcmp(name, current->name()) == 0) { | 1397 if (strcmp(name, current->name()) == 0) { |
1362 return current; | 1398 return current; |
1363 } | 1399 } |
1364 current = current->next(); | 1400 current = current->next(); |
1365 } | 1401 } |
1366 return NULL; | 1402 return NULL; |
1367 } | 1403 } |
1368 | 1404 |
1369 } // namespace dart | 1405 } // namespace dart |
OLD | NEW |