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 JSONObject jsobj(js); | |
| 1062 jsobj.AddProperty("type", "NativeCode"); | |
|
turnidge
2014/02/28 19:23:37
The references to native and collected code have t
Cutch
2014/02/28 19:37:08
Done.
| |
| 1063 jsobj.AddPropertyF("start", "%" Px "", pc); | |
| 1064 return true; | |
| 1065 } | |
| 1066 | |
| 1067 | |
| 1068 static bool HandleCollectedCode(uintptr_t pc, JSONStream* js) { | |
| 1069 JSONObject jsobj(js); | |
| 1070 jsobj.AddProperty("type", "CollectedCode"); | |
| 1071 jsobj.AddPropertyF("start", "%" Px "", pc); | |
| 1072 return true; | |
| 1073 } | |
| 1074 | |
| 1075 | |
| 1060 static bool HandleCode(Isolate* isolate, JSONStream* js) { | 1076 static bool HandleCode(Isolate* isolate, JSONStream* js) { |
| 1061 REQUIRE_COLLECTION_ID("code"); | 1077 REQUIRE_COLLECTION_ID("code"); |
| 1062 uintptr_t pc; | 1078 uintptr_t pc; |
| 1079 if (js->num_arguments() > 3) { | |
| 1080 PrintError(js, "Command too long"); | |
| 1081 return true; | |
| 1082 } | |
| 1083 if (js->num_arguments() == 3) { | |
| 1084 const char* command = js->GetArgument(1); | |
| 1085 if (!strcmp("collected", command)) { | |
| 1086 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | |
| 1087 PrintError(js, "Must specify code address: code/collected/c0deadd0."); | |
| 1088 return true; | |
| 1089 } | |
| 1090 return HandleCollectedCode(pc, js); | |
| 1091 } else if (!strcmp("native", command)) { | |
| 1092 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | |
| 1093 PrintError(js, "Must specify code address: code/native/c0deadd0."); | |
| 1094 return true; | |
| 1095 } | |
| 1096 return HandleNativeCode(pc, js); | |
| 1097 } else { | |
| 1098 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); | |
| 1099 return true; | |
| 1100 } | |
| 1101 } | |
|
turnidge
2014/02/28 19:23:37
Can you extend the unit test to cover some of thes
Cutch
2014/02/28 19:37:08
Done.
| |
| 1102 ASSERT(js->num_arguments() == 2); | |
| 1063 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { | 1103 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { |
| 1064 PrintError(js, "Must specify code address: code/c0deadd0."); | 1104 PrintError(js, "Must specify code address: code/c0deadd0."); |
| 1065 return true; | 1105 return true; |
| 1066 } | 1106 } |
| 1067 Code& code = Code::Handle(Code::LookupCode(pc)); | 1107 Code& code = Code::Handle(); |
| 1068 if (code.IsNull()) { | 1108 code ^= Code::LookupCode(pc); |
| 1069 PrintError(js, "Could not find code at %" Px "", pc); | 1109 if (!code.IsNull()) { |
| 1110 code.PrintToJSONStream(js, false); | |
| 1070 return true; | 1111 return true; |
| 1071 } | 1112 } |
| 1072 code.PrintToJSONStream(js, false); | 1113 code ^= Code::LookupCodeInVmIsolate(pc); |
| 1114 if (!code.IsNull()) { | |
| 1115 code.PrintToJSONStream(js, false); | |
| 1116 return true; | |
| 1117 } | |
| 1118 PrintError(js, "Could not find code at %" Px "", pc); | |
| 1073 return true; | 1119 return true; |
| 1074 } | 1120 } |
| 1075 | 1121 |
| 1076 | 1122 |
| 1077 static bool HandleProfile(Isolate* isolate, JSONStream* js) { | 1123 static bool HandleProfile(Isolate* isolate, JSONStream* js) { |
| 1078 Profiler::PrintToJSONStream(isolate, js, true); | 1124 Profiler::PrintToJSONStream(isolate, js, true); |
| 1079 return true; | 1125 return true; |
| 1080 } | 1126 } |
| 1081 | 1127 |
| 1082 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { | 1128 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1326 while (current != NULL) { | 1372 while (current != NULL) { |
| 1327 if (!strcmp(name, current->name())) { | 1373 if (!strcmp(name, current->name())) { |
| 1328 return current; | 1374 return current; |
| 1329 } | 1375 } |
| 1330 current = current->next(); | 1376 current = current->next(); |
| 1331 } | 1377 } |
| 1332 return NULL; | 1378 return NULL; |
| 1333 } | 1379 } |
| 1334 | 1380 |
| 1335 } // namespace dart | 1381 } // namespace dart |
| OLD | NEW |