Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index afc31be2c2550e26e05d32107b94cd64f826fb00..1440be6d36e865cd4999399358c7b476d66f5d1b 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -1057,19 +1057,65 @@ static bool HandleCpu(Isolate* isolate, JSONStream* js) { |
} |
+static bool HandleNativeCode(uintptr_t pc, JSONStream* js) { |
+ JSONObject jsobj(js); |
+ 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.
|
+ jsobj.AddPropertyF("start", "%" Px "", pc); |
+ return true; |
+} |
+ |
+ |
+static bool HandleCollectedCode(uintptr_t pc, JSONStream* js) { |
+ JSONObject jsobj(js); |
+ jsobj.AddProperty("type", "CollectedCode"); |
+ jsobj.AddPropertyF("start", "%" Px "", pc); |
+ return true; |
+} |
+ |
+ |
static bool HandleCode(Isolate* isolate, JSONStream* js) { |
REQUIRE_COLLECTION_ID("code"); |
uintptr_t pc; |
+ if (js->num_arguments() > 3) { |
+ PrintError(js, "Command too long"); |
+ return true; |
+ } |
+ if (js->num_arguments() == 3) { |
+ const char* command = js->GetArgument(1); |
+ if (!strcmp("collected", command)) { |
+ if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { |
+ PrintError(js, "Must specify code address: code/collected/c0deadd0."); |
+ return true; |
+ } |
+ return HandleCollectedCode(pc, js); |
+ } else if (!strcmp("native", command)) { |
+ if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { |
+ PrintError(js, "Must specify code address: code/native/c0deadd0."); |
+ return true; |
+ } |
+ return HandleNativeCode(pc, js); |
+ } else { |
+ PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); |
+ return true; |
+ } |
+ } |
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.
|
+ ASSERT(js->num_arguments() == 2); |
if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { |
PrintError(js, "Must specify code address: code/c0deadd0."); |
return true; |
} |
- Code& code = Code::Handle(Code::LookupCode(pc)); |
- if (code.IsNull()) { |
- PrintError(js, "Could not find code at %" Px "", pc); |
+ Code& code = Code::Handle(); |
+ code ^= Code::LookupCode(pc); |
+ if (!code.IsNull()) { |
+ code.PrintToJSONStream(js, false); |
+ return true; |
+ } |
+ code ^= Code::LookupCodeInVmIsolate(pc); |
+ if (!code.IsNull()) { |
+ code.PrintToJSONStream(js, false); |
return true; |
} |
- code.PrintToJSONStream(js, false); |
+ PrintError(js, "Could not find code at %" Px "", pc); |
return true; |
} |