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 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 result.PrintJSON(js, true); | 974 result.PrintJSON(js, true); |
975 return true; | 975 return true; |
976 } else if (strcmp(action, "retaining_path") == 0) { | 976 } else if (strcmp(action, "retaining_path") == 0) { |
977 intptr_t limit; | 977 intptr_t limit; |
978 if (!GetIntegerId(js->LookupOption("limit"), &limit)) { | 978 if (!GetIntegerId(js->LookupOption("limit"), &limit)) { |
979 PrintError(js, "retaining_path expects a 'limit' option\n", | 979 PrintError(js, "retaining_path expects a 'limit' option\n", |
980 js->num_arguments()); | 980 js->num_arguments()); |
981 return true; | 981 return true; |
982 } | 982 } |
983 ObjectGraph graph(isolate); | 983 ObjectGraph graph(isolate); |
984 Array& path = Array::Handle(Array::New(limit)); | 984 Array& path = Array::Handle(Array::New(limit * 2)); |
985 intptr_t length = graph.RetainingPath(obj, path); | 985 intptr_t length = graph.RetainingPath(obj, path); |
986 JSONObject jsobj(js); | 986 JSONObject jsobj(js); |
987 jsobj.AddProperty("type", "RetainingPath"); | 987 jsobj.AddProperty("type", "RetainingPath"); |
988 jsobj.AddProperty("id", "retaining_path"); | 988 jsobj.AddProperty("id", "retaining_path"); |
989 jsobj.AddProperty("length", length); | 989 jsobj.AddProperty("length", length); |
990 JSONArray elements(&jsobj, "elements"); | 990 JSONArray elements(&jsobj, "elements"); |
991 for (intptr_t i = 0; i < path.Length() && i < length; ++i) { | 991 Object& element = Object::Handle(); |
| 992 Smi& offset_from_parent = Smi::Handle(); |
| 993 for (intptr_t i = 0; i < limit && i < length; ++i) { |
992 JSONObject jselement(&elements); | 994 JSONObject jselement(&elements); |
993 Object& element = Object::Handle(); | 995 element = path.At(i * 2); |
994 element = path.At(i); | |
995 jselement.AddProperty("index", i); | 996 jselement.AddProperty("index", i); |
996 jselement.AddProperty("value", element); | 997 jselement.AddProperty("value", element); |
| 998 offset_from_parent ^= path.At((i * 2) + 1); |
| 999 // TODO(koda): Interpret offset as field, list index or map entry. |
997 } | 1000 } |
998 return true; | 1001 return true; |
999 } | 1002 } |
1000 | 1003 |
1001 PrintError(js, "unrecognized action '%s'\n", action); | 1004 PrintError(js, "unrecognized action '%s'\n", action); |
1002 return true; | 1005 return true; |
1003 } | 1006 } |
1004 | 1007 |
1005 | 1008 |
1006 static bool HandleClassesClosures(Isolate* isolate, const Class& cls, | 1009 static bool HandleClassesClosures(Isolate* isolate, const Class& cls, |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 while (current != NULL) { | 2271 while (current != NULL) { |
2269 if (strcmp(name, current->name()) == 0) { | 2272 if (strcmp(name, current->name()) == 0) { |
2270 return current; | 2273 return current; |
2271 } | 2274 } |
2272 current = current->next(); | 2275 current = current->next(); |
2273 } | 2276 } |
2274 return NULL; | 2277 return NULL; |
2275 } | 2278 } |
2276 | 2279 |
2277 } // namespace dart | 2280 } // namespace dart |
OLD | NEW |