Chromium Code Reviews| 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 | 1050 |
| 1051 static bool HandleCpu(Isolate* isolate, JSONStream* js) { | 1051 static bool HandleCpu(Isolate* isolate, JSONStream* js) { |
| 1052 JSONObject jsobj(js); | 1052 JSONObject jsobj(js); |
| 1053 jsobj.AddProperty("type", "CPU"); | 1053 jsobj.AddProperty("type", "CPU"); |
| 1054 jsobj.AddProperty("targetCPU", CPU::Id()); | 1054 jsobj.AddProperty("targetCPU", CPU::Id()); |
| 1055 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); | 1055 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); |
| 1056 return true; | 1056 return true; |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 | 1059 |
| 1060 static bool HandleNativeCode(uintptr_t pc, JSONStream* js) { | |
| 1061 Object::null_object().PrintToJSONStream(js, false); | |
| 1062 return true; | |
| 1063 } | |
| 1064 | |
| 1065 | |
| 1066 static bool HandleCollectedCode(uintptr_t pc, JSONStream* js) { | |
| 1067 Object::null_object().PrintToJSONStream(js, false); | |
| 1068 return true; | |
| 1069 } | |
| 1070 | |
| 1071 | |
| 1060 static bool HandleCode(Isolate* isolate, JSONStream* js) { | 1072 static bool HandleCode(Isolate* isolate, JSONStream* js) { |
| 1061 REQUIRE_COLLECTION_ID("code"); | 1073 REQUIRE_COLLECTION_ID("code"); |
| 1062 uintptr_t pc; | 1074 uintptr_t pc; |
| 1075 if (js->num_arguments() > 3) { | |
| 1076 PrintError(js, "Command too long"); | |
| 1077 return true; | |
| 1078 } | |
| 1079 if (js->num_arguments() == 3) { | |
| 1080 const char* command = js->GetArgument(1); | |
| 1081 if (!strcmp("collected", command)) { | |
|
Ivan Posva
2014/02/28 21:46:35
strcmp does not return a bool.
| |
| 1082 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | |
| 1083 PrintError(js, "Must specify code address: code/collected/c0deadd0."); | |
| 1084 return true; | |
| 1085 } | |
| 1086 return HandleCollectedCode(pc, js); | |
| 1087 } else if (!strcmp("native", command)) { | |
| 1088 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | |
| 1089 PrintError(js, "Must specify code address: code/native/c0deadd0."); | |
| 1090 return true; | |
| 1091 } | |
|
turnidge
2014/02/28 19:45:43
Since this is simpler now, you could drop the help
Cutch
2014/02/28 19:48:08
Done.
| |
| 1092 return HandleNativeCode(pc, js); | |
| 1093 } else { | |
| 1094 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); | |
| 1095 return true; | |
| 1096 } | |
| 1097 } | |
| 1098 ASSERT(js->num_arguments() == 2); | |
| 1063 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | 1099 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { |
| 1064 PrintError(js, "Must specify code address: code/c0deadd0."); | 1100 PrintError(js, "Must specify code address: code/c0deadd0."); |
| 1065 return true; | 1101 return true; |
| 1066 } | 1102 } |
| 1067 Code& code = Code::Handle(Code::LookupCode(pc)); | 1103 Code& code = Code::Handle(); |
| 1068 if (code.IsNull()) { | 1104 code ^= Code::LookupCode(pc); |
| 1069 PrintError(js, "Could not find code at %" Px "", pc); | 1105 if (!code.IsNull()) { |
| 1106 code.PrintToJSONStream(js, false); | |
| 1070 return true; | 1107 return true; |
| 1071 } | 1108 } |
| 1072 code.PrintToJSONStream(js, false); | 1109 code ^= Code::LookupCodeInVmIsolate(pc); |
| 1110 if (!code.IsNull()) { | |
| 1111 code.PrintToJSONStream(js, false); | |
| 1112 return true; | |
| 1113 } | |
| 1114 PrintError(js, "Could not find code at %" Px "", pc); | |
| 1073 return true; | 1115 return true; |
| 1074 } | 1116 } |
| 1075 | 1117 |
| 1076 | 1118 |
| 1077 static bool HandleProfile(Isolate* isolate, JSONStream* js) { | 1119 static bool HandleProfile(Isolate* isolate, JSONStream* js) { |
| 1078 Profiler::PrintToJSONStream(isolate, js, true); | 1120 Profiler::PrintToJSONStream(isolate, js, true); |
| 1079 return true; | 1121 return true; |
| 1080 } | 1122 } |
| 1081 | 1123 |
| 1082 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { | 1124 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1326 while (current != NULL) { | 1368 while (current != NULL) { |
| 1327 if (!strcmp(name, current->name())) { | 1369 if (!strcmp(name, current->name())) { |
| 1328 return current; | 1370 return current; |
| 1329 } | 1371 } |
| 1330 current = current->next(); | 1372 current = current->next(); |
| 1331 } | 1373 } |
| 1332 return NULL; | 1374 return NULL; |
| 1333 } | 1375 } |
| 1334 | 1376 |
| 1335 } // namespace dart | 1377 } // namespace dart |
| OLD | NEW |