Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: runtime/vm/service_test.cc

Issue 206583003: Add 'address' vm service message that finds heap objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service_test.cc
===================================================================
--- runtime/vm/service_test.cc (revision 34144)
+++ runtime/vm/service_test.cc (working copy)
@@ -1006,6 +1006,49 @@
}
+TEST_CASE(Service_Address) {
+ const char* kScript =
+ "var port;\n" // Set to our mock port by C++.
+ "\n"
+ "main() {\n"
+ "}";
+
+ Isolate* isolate = Isolate::Current();
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+
+ // Build a mock message handler and wrap it in a dart port.
+ ServiceTestMessageHandler handler;
+ Dart_Port port_id = PortMap::CreatePort(&handler);
+ Dart_Handle port =
+ Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
+ EXPECT_VALID(port);
+ EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
+
+ const String& str = String::Handle(String::New("foobar", Heap::kOld));
+ Instance& service_msg = Instance::Handle();
+ // Note: If we ever introduce old space compaction, this test might fail.
+ uword start_addr = RawObject::ToAddr(str.raw());
+ // Expect to find 'str', also from internal addresses.
+ for (int offset = 0; offset < kObjectAlignment; ++offset) {
+ uword addr = start_addr + offset;
+ char buf[1024];
+ OS::SNPrint(buf, sizeof(buf),
+ "[port, ['address', '%" Px "'], [], []]", addr);
+ service_msg = Eval(lib, buf);
+ Service::HandleIsolateMessage(isolate, service_msg);
+ handler.HandleNextMessage();
+ EXPECT_SUBSTRING("\"type\":\"@String\"", handler.msg());
+ EXPECT_SUBSTRING("foobar", handler.msg());
+ }
+ // Expect null when no object is found.
+ service_msg = Eval(lib, "[port, ['address', '7'], [], []]");
+ Service::HandleIsolateMessage(isolate, service_msg);
+ handler.HandleNextMessage();
+ EXPECT_SUBSTRING("\"type\":\"null\"", handler.msg());
+}
+
+
static const char* alpha_callback(
const char* name,
const char** arguments,
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698