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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/service.cc ('K') | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "vm/dart_api_impl.h" 6 #include "vm/dart_api_impl.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/message_handler.h" 10 #include "vm/message_handler.h"
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 Instance& service_msg = Instance::Handle(); 999 Instance& service_msg = Instance::Handle();
1000 service_msg = Eval(lib, "[port, ['heapmap'], [], []]"); 1000 service_msg = Eval(lib, "[port, ['heapmap'], [], []]");
1001 Service::HandleIsolateMessage(isolate, service_msg); 1001 Service::HandleIsolateMessage(isolate, service_msg);
1002 handler.HandleNextMessage(); 1002 handler.HandleNextMessage();
1003 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg()); 1003 EXPECT_SUBSTRING("\"type\":\"HeapMap\"", handler.msg());
1004 EXPECT_SUBSTRING("\"pages\":[[", handler.msg()); 1004 EXPECT_SUBSTRING("\"pages\":[[", handler.msg());
1005 EXPECT_SUBSTRING("]]", handler.msg()); 1005 EXPECT_SUBSTRING("]]", handler.msg());
1006 } 1006 }
1007 1007
1008 1008
1009 TEST_CASE(Service_Address) {
1010 const char* kScript =
1011 "var port;\n" // Set to our mock port by C++.
1012 "\n"
1013 "main() {\n"
1014 "}";
1015
1016 Isolate* isolate = Isolate::Current();
1017 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1018 EXPECT_VALID(lib);
1019
1020 // Build a mock message handler and wrap it in a dart port.
1021 ServiceTestMessageHandler handler;
1022 Dart_Port port_id = PortMap::CreatePort(&handler);
1023 Dart_Handle port =
1024 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1025 EXPECT_VALID(port);
1026 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
1027
1028 const String& str = String::Handle(String::New("foobar", Heap::kOld));
1029 Instance& service_msg = Instance::Handle();
1030 // Note: If we ever introduce old space compaction, this test might fail.
1031 uword start_addr = RawObject::ToAddr(str.raw());
1032 // Expect to find 'str', also from internal addresses.
1033 for (int offset = 0; offset < kObjectAlignment; ++offset) {
1034 uword addr = start_addr + offset;
1035 char buf[1024];
1036 OS::SNPrint(buf, sizeof(buf),
1037 "[port, ['address', '%" Px "'], [], []]", addr);
1038 service_msg = Eval(lib, buf);
1039 Service::HandleIsolateMessage(isolate, service_msg);
1040 handler.HandleNextMessage();
1041 EXPECT_SUBSTRING("\"type\":\"@String\"", handler.msg());
1042 EXPECT_SUBSTRING("foobar", handler.msg());
1043 }
1044 // Expect null when no object is found.
1045 service_msg = Eval(lib, "[port, ['address', '7'], [], []]");
1046 Service::HandleIsolateMessage(isolate, service_msg);
1047 handler.HandleNextMessage();
1048 EXPECT_SUBSTRING("\"type\":\"null\"", handler.msg());
turnidge 2014/03/20 17:01:19 This result will look a bit different once you use
1049 }
1050
1051
1009 static const char* alpha_callback( 1052 static const char* alpha_callback(
1010 const char* name, 1053 const char* name,
1011 const char** arguments, 1054 const char** arguments,
1012 intptr_t num_arguments, 1055 intptr_t num_arguments,
1013 const char** option_keys, 1056 const char** option_keys,
1014 const char** option_values, 1057 const char** option_values,
1015 intptr_t num_options, 1058 intptr_t num_options,
1016 void* user_data) { 1059 void* user_data) {
1017 return strdup("alpha"); 1060 return strdup("alpha");
1018 } 1061 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg()); 1191 EXPECT_SUBSTRING("\"type\":\"Profile\"", handler.msg());
1149 1192
1150 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]"); 1193 service_msg = Eval(h_lib, "[port, ['profile'], ['tags'], ['hidden']]");
1151 Service::HandleIsolateMessage(isolate, service_msg); 1194 Service::HandleIsolateMessage(isolate, service_msg);
1152 handler.HandleNextMessage(); 1195 handler.HandleNextMessage();
1153 // Expect error. 1196 // Expect error.
1154 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); 1197 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg());
1155 } 1198 }
1156 1199
1157 } // namespace dart 1200 } // namespace dart
OLDNEW
« runtime/vm/service.cc ('K') | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698