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

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

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