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

Side by Side Diff: runtime/vm/service_test.cc

Issue 137483010: Add more timing information in the VM to track time spent is dart code Vs native code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | 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 27 matching lines...) Expand all
38 return true; 38 return true;
39 } 39 }
40 40
41 const char* msg() const { return _msg; } 41 const char* msg() const { return _msg; }
42 42
43 private: 43 private:
44 char* _msg; 44 char* _msg;
45 }; 45 };
46 46
47 47
48 static void ServiceIsolateMessage(Isolate* isolate, const Instance& msg) {
49 NativeToVmTimerScope timer(isolate);
50 Service::HandleIsolateMessage(isolate, msg);
51 }
52
53
48 static RawInstance* Eval(Dart_Handle lib, const char* expr) { 54 static RawInstance* Eval(Dart_Handle lib, const char* expr) {
49 Dart_Handle result = Dart_EvaluateExpr(lib, NewString(expr)); 55 Dart_Handle result = Dart_EvaluateExpr(lib, NewString(expr));
50 EXPECT_VALID(result); 56 EXPECT_VALID(result);
51 Isolate* isolate = Isolate::Current(); 57 Isolate* isolate = Isolate::Current();
52 const Instance& instance = Api::UnwrapInstanceHandle(isolate, result); 58 const Instance& instance = Api::UnwrapInstanceHandle(isolate, result);
53 return instance.raw(); 59 return instance.raw();
54 } 60 }
55 61
56 62
57 static RawInstance* EvalF(Dart_Handle lib, const char* fmt, ...) { 63 static RawInstance* EvalF(Dart_Handle lib, const char* fmt, ...) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 Dart_Port port_id = PortMap::CreatePort(&handler); 129 Dart_Port port_id = PortMap::CreatePort(&handler);
124 Dart_Handle port = 130 Dart_Handle port =
125 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 131 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
126 EXPECT_VALID(port); 132 EXPECT_VALID(port);
127 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 133 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
128 134
129 Instance& service_msg = Instance::Handle(); 135 Instance& service_msg = Instance::Handle();
130 136
131 // Get the isolate summary. 137 // Get the isolate summary.
132 service_msg = Eval(lib, "[port, [], [], []]"); 138 service_msg = Eval(lib, "[port, [], [], []]");
133 Service::HandleIsolateMessage(isolate, service_msg); 139 ServiceIsolateMessage(isolate, service_msg);
134 handler.HandleNextMessage(); 140 handler.HandleNextMessage();
135 141
136 JSONReader reader(handler.msg()); 142 JSONReader reader(handler.msg());
137 143
138 const int kBufferSize = 128; 144 const int kBufferSize = 128;
139 char buffer[kBufferSize]; 145 char buffer[kBufferSize];
140 146
141 // Check that the response string is somewhat sane. 147 // Check that the response string is somewhat sane.
142 148
143 // type 149 // type
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Dart_Port port_id = PortMap::CreatePort(&handler); 185 Dart_Port port_id = PortMap::CreatePort(&handler);
180 Dart_Handle port = 186 Dart_Handle port =
181 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 187 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
182 EXPECT_VALID(port); 188 EXPECT_VALID(port);
183 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 189 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
184 190
185 Instance& service_msg = Instance::Handle(); 191 Instance& service_msg = Instance::Handle();
186 192
187 // Get the stacktrace. 193 // Get the stacktrace.
188 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]"); 194 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]");
189 Service::HandleIsolateMessage(isolate, service_msg); 195 ServiceIsolateMessage(isolate, service_msg);
190 handler.HandleNextMessage(); 196 handler.HandleNextMessage();
191 EXPECT_STREQ( 197 EXPECT_STREQ(
192 "{\"type\":\"StackTrace\",\"members\":[]}", 198 "{\"type\":\"StackTrace\",\"members\":[]}",
193 handler.msg()); 199 handler.msg());
194 200
195 // Malformed request. 201 // Malformed request.
196 service_msg = Eval(lib, "[port, ['stacktrace', 'jamboree'], [], []]"); 202 service_msg = Eval(lib, "[port, ['stacktrace', 'jamboree'], [], []]");
197 Service::HandleIsolateMessage(isolate, service_msg); 203 ServiceIsolateMessage(isolate, service_msg);
198 handler.HandleNextMessage(); 204 handler.HandleNextMessage();
199 EXPECT_STREQ( 205 EXPECT_STREQ(
200 "{\"type\":\"Error\",\"text\":\"Command too long\"," 206 "{\"type\":\"Error\",\"text\":\"Command too long\","
201 "\"message\":{\"arguments\":[\"stacktrace\",\"jamboree\"]," 207 "\"message\":{\"arguments\":[\"stacktrace\",\"jamboree\"],"
202 "\"option_keys\":[],\"option_values\":[]}}", 208 "\"option_keys\":[],\"option_values\":[]}}",
203 handler.msg()); 209 handler.msg());
204 } 210 }
205 211
206 212
207 TEST_CASE(Service_DebugBreakpoints) { 213 TEST_CASE(Service_DebugBreakpoints) {
(...skipping 16 matching lines...) Expand all
224 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 230 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
225 231
226 Instance& service_msg = Instance::Handle(); 232 Instance& service_msg = Instance::Handle();
227 233
228 // Add a breakpoint. 234 // Add a breakpoint.
229 const String& url = String::Handle(String::New(TestCase::url())); 235 const String& url = String::Handle(String::New(TestCase::url()));
230 isolate->debugger()->SetBreakpointAtLine(url, 3); 236 isolate->debugger()->SetBreakpointAtLine(url, 3);
231 237
232 // Get the breakpoint list. 238 // Get the breakpoint list.
233 service_msg = Eval(lib, "[port, ['debug', 'breakpoints'], [], []]"); 239 service_msg = Eval(lib, "[port, ['debug', 'breakpoints'], [], []]");
234 Service::HandleIsolateMessage(isolate, service_msg); 240 ServiceIsolateMessage(isolate, service_msg);
235 handler.HandleNextMessage(); 241 handler.HandleNextMessage();
236 EXPECT_STREQ( 242 EXPECT_STREQ(
237 "{\"type\":\"BreakpointList\",\"breakpoints\":[{" 243 "{\"type\":\"BreakpointList\",\"breakpoints\":[{"
238 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," 244 "\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true,"
239 "\"resolved\":false," 245 "\"resolved\":false,"
240 "\"location\":{\"type\":\"Location\"," 246 "\"location\":{\"type\":\"Location\","
241 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}]}", 247 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}]}",
242 handler.msg()); 248 handler.msg());
243 249
244 // Individual breakpoint. 250 // Individual breakpoint.
245 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1'], [], []]"); 251 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1'], [], []]");
246 Service::HandleIsolateMessage(isolate, service_msg); 252 ServiceIsolateMessage(isolate, service_msg);
247 handler.HandleNextMessage(); 253 handler.HandleNextMessage();
248 EXPECT_STREQ( 254 EXPECT_STREQ(
249 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true," 255 "{\"type\":\"Breakpoint\",\"id\":1,\"enabled\":true,"
250 "\"resolved\":false," 256 "\"resolved\":false,"
251 "\"location\":{\"type\":\"Location\"," 257 "\"location\":{\"type\":\"Location\","
252 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}", 258 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}",
253 handler.msg()); 259 handler.msg());
254 260
255 // Missing sub-command. 261 // Missing sub-command.
256 service_msg = Eval(lib, "[port, ['debug'], [], []]"); 262 service_msg = Eval(lib, "[port, ['debug'], [], []]");
257 Service::HandleIsolateMessage(isolate, service_msg); 263 ServiceIsolateMessage(isolate, service_msg);
258 handler.HandleNextMessage(); 264 handler.HandleNextMessage();
259 EXPECT_STREQ( 265 EXPECT_STREQ(
260 "{\"type\":\"Error\"," 266 "{\"type\":\"Error\","
261 "\"text\":\"Must specify a subcommand\"," 267 "\"text\":\"Must specify a subcommand\","
262 "\"message\":{\"arguments\":[\"debug\"],\"option_keys\":[]," 268 "\"message\":{\"arguments\":[\"debug\"],\"option_keys\":[],"
263 "\"option_values\":[]}}", 269 "\"option_values\":[]}}",
264 handler.msg()); 270 handler.msg());
265 271
266 // Unrecognized breakpoint. 272 // Unrecognized breakpoint.
267 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1111'], [], []]"); 273 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1111'], [], []]");
268 Service::HandleIsolateMessage(isolate, service_msg); 274 ServiceIsolateMessage(isolate, service_msg);
269 handler.HandleNextMessage(); 275 handler.HandleNextMessage();
270 EXPECT_STREQ("{\"type\":\"Error\"," 276 EXPECT_STREQ("{\"type\":\"Error\","
271 "\"text\":\"Unrecognized breakpoint id 1111\"," 277 "\"text\":\"Unrecognized breakpoint id 1111\","
272 "\"message\":{" 278 "\"message\":{"
273 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"]," 279 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"],"
274 "\"option_keys\":[],\"option_values\":[]}}", 280 "\"option_keys\":[],\"option_values\":[]}}",
275 handler.msg()); 281 handler.msg());
276 282
277 // Command too long. 283 // Command too long.
278 service_msg = 284 service_msg =
279 Eval(lib, "[port, ['debug', 'breakpoints', '1111', 'green'], [], []]"); 285 Eval(lib, "[port, ['debug', 'breakpoints', '1111', 'green'], [], []]");
280 Service::HandleIsolateMessage(isolate, service_msg); 286 ServiceIsolateMessage(isolate, service_msg);
281 handler.HandleNextMessage(); 287 handler.HandleNextMessage();
282 EXPECT_STREQ("{\"type\":\"Error\",\"text\":\"Command too long\"," 288 EXPECT_STREQ("{\"type\":\"Error\",\"text\":\"Command too long\","
283 "\"message\":{\"arguments\":[\"debug\",\"breakpoints\"," 289 "\"message\":{\"arguments\":[\"debug\",\"breakpoints\","
284 "\"1111\",\"green\"]," 290 "\"1111\",\"green\"],"
285 "\"option_keys\":[],\"option_values\":[]}}", 291 "\"option_keys\":[],\"option_values\":[]}}",
286 handler.msg()); 292 handler.msg());
287 293
288 // Unrecognized subcommand. 294 // Unrecognized subcommand.
289 service_msg = Eval(lib, "[port, ['debug', 'nosferatu'], [], []]"); 295 service_msg = Eval(lib, "[port, ['debug', 'nosferatu'], [], []]");
290 Service::HandleIsolateMessage(isolate, service_msg); 296 ServiceIsolateMessage(isolate, service_msg);
291 handler.HandleNextMessage(); 297 handler.HandleNextMessage();
292 EXPECT_STREQ("{\"type\":\"Error\"," 298 EXPECT_STREQ("{\"type\":\"Error\","
293 "\"text\":\"Unrecognized subcommand 'nosferatu'\"," 299 "\"text\":\"Unrecognized subcommand 'nosferatu'\","
294 "\"message\":{\"arguments\":[\"debug\",\"nosferatu\"]," 300 "\"message\":{\"arguments\":[\"debug\",\"nosferatu\"],"
295 "\"option_keys\":[],\"option_values\":[]}}", 301 "\"option_keys\":[],\"option_values\":[]}}",
296 handler.msg()); 302 handler.msg());
297 } 303 }
298 304
299 305
300 TEST_CASE(Service_Classes) { 306 TEST_CASE(Service_Classes) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 Dart_Port port_id = PortMap::CreatePort(&handler); 338 Dart_Port port_id = PortMap::CreatePort(&handler);
333 Dart_Handle port = 339 Dart_Handle port =
334 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 340 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
335 EXPECT_VALID(port); 341 EXPECT_VALID(port);
336 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 342 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
337 343
338 Instance& service_msg = Instance::Handle(); 344 Instance& service_msg = Instance::Handle();
339 345
340 // Request an invalid class id. 346 // Request an invalid class id.
341 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]"); 347 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]");
342 Service::HandleIsolateMessage(isolate, service_msg); 348 ServiceIsolateMessage(isolate, service_msg);
343 handler.HandleNextMessage(); 349 handler.HandleNextMessage();
344 EXPECT_STREQ( 350 EXPECT_STREQ(
345 "{\"type\":\"Error\",\"text\":\"999999 is not a valid class id.\"," 351 "{\"type\":\"Error\",\"text\":\"999999 is not a valid class id.\","
346 "\"message\":{\"arguments\":[\"classes\",\"999999\"]," 352 "\"message\":{\"arguments\":[\"classes\",\"999999\"],"
347 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); 353 "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
348 354
349 // Request the class A over the service. 355 // Request the class A over the service.
350 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); 356 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid);
351 Service::HandleIsolateMessage(isolate, service_msg); 357 ServiceIsolateMessage(isolate, service_msg);
352 handler.HandleNextMessage(); 358 handler.HandleNextMessage();
353 359
354 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); 360 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg());
355 ExpectSubstringF(handler.msg(), 361 ExpectSubstringF(handler.msg(),
356 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid); 362 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid);
357 363
358 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '0']," 364 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '0'],"
359 "[], []]", cid); 365 "[], []]", cid);
360 Service::HandleIsolateMessage(isolate, service_msg); 366 ServiceIsolateMessage(isolate, service_msg);
361 handler.HandleNextMessage(); 367 handler.HandleNextMessage();
362 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg()); 368 EXPECT_SUBSTRING("\"type\":\"Function\"", handler.msg());
363 ExpectSubstringF(handler.msg(), 369 ExpectSubstringF(handler.msg(),
364 "\"id\":\"classes\\/%" Pd "\\/functions\\/0\"," 370 "\"id\":\"classes\\/%" Pd "\\/functions\\/0\","
365 "\"name\":\"get:a\",", cid); 371 "\"name\":\"get:a\",", cid);
366 372
367 // Request field 0 from class A. 373 // Request field 0 from class A.
368 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '0']," 374 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '0'],"
369 "[], []]", cid); 375 "[], []]", cid);
370 Service::HandleIsolateMessage(isolate, service_msg); 376 ServiceIsolateMessage(isolate, service_msg);
371 handler.HandleNextMessage(); 377 handler.HandleNextMessage();
372 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg()); 378 EXPECT_SUBSTRING("\"type\":\"Field\"", handler.msg());
373 ExpectSubstringF(handler.msg(), 379 ExpectSubstringF(handler.msg(),
374 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," 380 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\","
375 "\"name\":\"a\",", cid); 381 "\"name\":\"a\",", cid);
376 382
377 // Invalid sub command. 383 // Invalid sub command.
378 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0']," 384 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0'],"
379 "[], []]", cid); 385 "[], []]", cid);
380 Service::HandleIsolateMessage(isolate, service_msg); 386 ServiceIsolateMessage(isolate, service_msg);
381 handler.HandleNextMessage(); 387 handler.HandleNextMessage();
382 ExpectSubstringF(handler.msg(), 388 ExpectSubstringF(handler.msg(),
383 "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":" 389 "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":"
384 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[]," 390 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[],"
385 "\"option_values\":[]}}", cid); 391 "\"option_values\":[]}}", cid);
386 392
387 // Invalid field request. 393 // Invalid field request.
388 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9']," 394 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9'],"
389 "[], []]", cid); 395 "[], []]", cid);
390 Service::HandleIsolateMessage(isolate, service_msg); 396 ServiceIsolateMessage(isolate, service_msg);
391 handler.HandleNextMessage(); 397 handler.HandleNextMessage();
392 ExpectSubstringF(handler.msg(), 398 ExpectSubstringF(handler.msg(),
393 "{\"type\":\"Error\",\"text\":\"Field 9 not found\"," 399 "{\"type\":\"Error\",\"text\":\"Field 9 not found\","
394 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"]," 400 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"],"
395 "\"option_keys\":[],\"option_values\":[]}}", cid); 401 "\"option_keys\":[],\"option_values\":[]}}", cid);
396 402
397 // Invalid function request. 403 // Invalid function request.
398 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9']," 404 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'],"
399 "[], []]", cid); 405 "[], []]", cid);
400 Service::HandleIsolateMessage(isolate, service_msg); 406 ServiceIsolateMessage(isolate, service_msg);
401 handler.HandleNextMessage(); 407 handler.HandleNextMessage();
402 ExpectSubstringF(handler.msg(), 408 ExpectSubstringF(handler.msg(),
403 "{\"type\":\"Error\",\"text\":\"Function 9 not found\"," 409 "{\"type\":\"Error\",\"text\":\"Function 9 not found\","
404 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"]," 410 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"],"
405 "\"option_keys\":[],\"option_values\":[]}}", cid); 411 "\"option_keys\":[],\"option_values\":[]}}", cid);
406 412
407 413
408 // Invalid field subcommand. 414 // Invalid field subcommand.
409 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']" 415 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']"
410 ",[], []]", cid); 416 ",[], []]", cid);
411 Service::HandleIsolateMessage(isolate, service_msg); 417 ServiceIsolateMessage(isolate, service_msg);
412 handler.HandleNextMessage(); 418 handler.HandleNextMessage();
413 ExpectSubstringF(handler.msg(), 419 ExpectSubstringF(handler.msg(),
414 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" 420 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":"
415 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," 421 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"],"
416 "\"option_keys\":[],\"option_values\":[]}}", cid); 422 "\"option_keys\":[],\"option_values\":[]}}", cid);
417 423
418 // Invalid function request. 424 // Invalid function request.
419 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'," 425 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9',"
420 "'x'], [], []]", cid); 426 "'x'], [], []]", cid);
421 Service::HandleIsolateMessage(isolate, service_msg); 427 ServiceIsolateMessage(isolate, service_msg);
422 handler.HandleNextMessage(); 428 handler.HandleNextMessage();
423 ExpectSubstringF(handler.msg(), 429 ExpectSubstringF(handler.msg(),
424 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" 430 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":"
425 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"]," 431 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"],"
426 "\"option_keys\":[],\"option_values\":[]}}", cid); 432 "\"option_keys\":[],\"option_values\":[]}}", cid);
427 } 433 }
428 434
429 435
430 TEST_CASE(Service_Code) { 436 TEST_CASE(Service_Code) {
431 const char* kScript = 437 const char* kScript =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 Dart_Port port_id = PortMap::CreatePort(&handler); 475 Dart_Port port_id = PortMap::CreatePort(&handler);
470 Dart_Handle port = 476 Dart_Handle port =
471 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 477 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
472 EXPECT_VALID(port); 478 EXPECT_VALID(port);
473 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 479 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
474 480
475 Instance& service_msg = Instance::Handle(); 481 Instance& service_msg = Instance::Handle();
476 482
477 // Request an invalid code object. 483 // Request an invalid code object.
478 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]"); 484 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]");
479 Service::HandleIsolateMessage(isolate, service_msg); 485 ServiceIsolateMessage(isolate, service_msg);
480 handler.HandleNextMessage(); 486 handler.HandleNextMessage();
481 EXPECT_STREQ( 487 EXPECT_STREQ(
482 "{\"type\":\"Error\",\"text\":\"Could not find code at 0\",\"message\":" 488 "{\"type\":\"Error\",\"text\":\"Could not find code at 0\",\"message\":"
483 "{\"arguments\":[\"code\",\"0\"]," 489 "{\"arguments\":[\"code\",\"0\"],"
484 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); 490 "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
485 491
486 // The following four tests check that a code object can be found 492 // The following four tests check that a code object can be found
487 // inside the range: [code.EntryPoint(), code.EntryPoint() + code.Size()). 493 // inside the range: [code.EntryPoint(), code.EntryPoint() + code.Size()).
488 // Request code object at code.EntryPoint() 494 // Request code object at code.EntryPoint()
489 // Expect this to succeed as it is inside [entry, entry + size). 495 // Expect this to succeed as it is inside [entry, entry + size).
490 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", entry); 496 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", entry);
491 Service::HandleIsolateMessage(isolate, service_msg); 497 ServiceIsolateMessage(isolate, service_msg);
492 handler.HandleNextMessage(); 498 handler.HandleNextMessage();
493 { 499 {
494 // Only perform a partial match. 500 // Only perform a partial match.
495 const intptr_t kBufferSize = 512; 501 const intptr_t kBufferSize = 512;
496 char buffer[kBufferSize]; 502 char buffer[kBufferSize];
497 OS::SNPrint(buffer, kBufferSize-1, 503 OS::SNPrint(buffer, kBufferSize-1,
498 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry); 504 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry);
499 EXPECT_SUBSTRING(buffer, handler.msg()); 505 EXPECT_SUBSTRING(buffer, handler.msg());
500 } 506 }
501 507
502 // Request code object at code.EntryPoint() + 16. 508 // Request code object at code.EntryPoint() + 16.
503 // Expect this to succeed as it is inside [entry, entry + size). 509 // Expect this to succeed as it is inside [entry, entry + size).
504 uintptr_t address = entry + 16; 510 uintptr_t address = entry + 16;
505 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address); 511 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address);
506 Service::HandleIsolateMessage(isolate, service_msg); 512 ServiceIsolateMessage(isolate, service_msg);
507 handler.HandleNextMessage(); 513 handler.HandleNextMessage();
508 { 514 {
509 // Only perform a partial match. 515 // Only perform a partial match.
510 const intptr_t kBufferSize = 512; 516 const intptr_t kBufferSize = 512;
511 char buffer[kBufferSize]; 517 char buffer[kBufferSize];
512 OS::SNPrint(buffer, kBufferSize-1, 518 OS::SNPrint(buffer, kBufferSize-1,
513 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry); 519 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry);
514 EXPECT_SUBSTRING(buffer, handler.msg()); 520 EXPECT_SUBSTRING(buffer, handler.msg());
515 } 521 }
516 522
517 // Request code object at code.EntryPoint() + code.Size() - 1. 523 // Request code object at code.EntryPoint() + code.Size() - 1.
518 // Expect this to succeed as it is inside [entry, entry + size). 524 // Expect this to succeed as it is inside [entry, entry + size).
519 address = last - 1; 525 address = last - 1;
520 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address); 526 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address);
521 Service::HandleIsolateMessage(isolate, service_msg); 527 ServiceIsolateMessage(isolate, service_msg);
522 handler.HandleNextMessage(); 528 handler.HandleNextMessage();
523 { 529 {
524 // Only perform a partial match. 530 // Only perform a partial match.
525 const intptr_t kBufferSize = 512; 531 const intptr_t kBufferSize = 512;
526 char buffer[kBufferSize]; 532 char buffer[kBufferSize];
527 OS::SNPrint(buffer, kBufferSize-1, 533 OS::SNPrint(buffer, kBufferSize-1,
528 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry); 534 "{\"type\":\"Code\",\"id\":\"code\\/%" Px "\",", entry);
529 EXPECT_SUBSTRING(buffer, handler.msg()); 535 EXPECT_SUBSTRING(buffer, handler.msg());
530 } 536 }
531 537
532 // Request code object at code.EntryPoint() + code.Size(). Expect this 538 // Request code object at code.EntryPoint() + code.Size(). Expect this
533 // to fail as it's outside of [entry, entry + size). 539 // to fail as it's outside of [entry, entry + size).
534 address = last; 540 address = last;
535 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address); 541 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address);
536 Service::HandleIsolateMessage(isolate, service_msg); 542 ServiceIsolateMessage(isolate, service_msg);
537 handler.HandleNextMessage(); 543 handler.HandleNextMessage();
538 { 544 {
539 const intptr_t kBufferSize = 1024; 545 const intptr_t kBufferSize = 1024;
540 char buffer[kBufferSize]; 546 char buffer[kBufferSize];
541 OS::SNPrint(buffer, kBufferSize-1, 547 OS::SNPrint(buffer, kBufferSize-1,
542 "{\"type\":\"Error\",\"text\":\"Could not find code at %" Px "\"," 548 "{\"type\":\"Error\",\"text\":\"Could not find code at %" Px "\","
543 "\"message\":{\"arguments\":[\"code\",\"%" Px "\"]," 549 "\"message\":{\"arguments\":[\"code\",\"%" Px "\"],"
544 "\"option_keys\":[],\"option_values\":[]}}", address, address); 550 "\"option_keys\":[],\"option_values\":[]}}", address, address);
545 EXPECT_STREQ(buffer, handler.msg()); 551 EXPECT_STREQ(buffer, handler.msg());
546 } 552 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // Build a mock message handler and wrap it in a dart port. 603 // Build a mock message handler and wrap it in a dart port.
598 ServiceTestMessageHandler handler; 604 ServiceTestMessageHandler handler;
599 Dart_Port port_id = PortMap::CreatePort(&handler); 605 Dart_Port port_id = PortMap::CreatePort(&handler);
600 Dart_Handle port = 606 Dart_Handle port =
601 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 607 Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
602 EXPECT_VALID(port); 608 EXPECT_VALID(port);
603 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 609 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
604 610
605 Instance& service_msg = Instance::Handle(); 611 Instance& service_msg = Instance::Handle();
606 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]"); 612 service_msg = Eval(h_lib, "[port, ['coverage'], [], []]");
607 Service::HandleIsolateMessage(isolate, service_msg); 613 ServiceIsolateMessage(isolate, service_msg);
608 handler.HandleNextMessage(); 614 handler.HandleNextMessage();
609 EXPECT_SUBSTRING( 615 EXPECT_SUBSTRING(
610 "{\"source\":\"dart:test-lib\",\"script\":{" 616 "{\"source\":\"dart:test-lib\",\"script\":{"
611 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\"," 617 "\"type\":\"@Script\",\"id\":\"scripts\\/dart%3Atest-lib\","
612 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\"," 618 "\"name\":\"dart:test-lib\",\"user_name\":\"dart:test-lib\","
613 "\"kind\":\"script\"},\"hits\":" 619 "\"kind\":\"script\"},\"hits\":"
614 "[3,0,3,1,5,1,5,1,5,1,6,1,6,1]}", handler.msg()); 620 "[3,0,3,1,5,1,5,1,5,1,6,1,6,1]}", handler.msg());
615 } 621 }
616 622
617 623
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 Service::HandleIsolateMessage(isolate, service_msg); 716 Service::HandleIsolateMessage(isolate, service_msg);
711 handler.HandleNextMessage(); 717 handler.HandleNextMessage();
712 EXPECT_STREQ("alpha", handler.msg()); 718 EXPECT_STREQ("alpha", handler.msg());
713 service_msg = Eval(lib, "[port, ['beta'], [], []]"); 719 service_msg = Eval(lib, "[port, ['beta'], [], []]");
714 Service::HandleIsolateMessage(isolate, service_msg); 720 Service::HandleIsolateMessage(isolate, service_msg);
715 handler.HandleNextMessage(); 721 handler.HandleNextMessage();
716 EXPECT_STREQ("beta", handler.msg()); 722 EXPECT_STREQ("beta", handler.msg());
717 } 723 }
718 724
719 } // namespace dart 725 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698