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

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

Issue 14298002: Deprecate old debugger breakpoint handler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/thread.h" 8 #include "vm/thread.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 EXPECT_TRUE(res); 230 EXPECT_TRUE(res);
231 if (i < expected_frames) { 231 if (i < expected_frames) {
232 VerifyStackFrame(frame, func_names[i], local_vars[i], skip_null_expects); 232 VerifyStackFrame(frame, func_names[i], local_vars[i], skip_null_expects);
233 } else { 233 } else {
234 VerifyStackFrame(frame, NULL, Dart_Null(), skip_null_expects); 234 VerifyStackFrame(frame, NULL, Dart_Null(), skip_null_expects);
235 } 235 }
236 } 236 }
237 } 237 }
238 238
239 239
240 // TODO(hausner): Convert this one remaining use of the legacy
241 // breakpoint handler once Dart_SetBreakpointHandler goes away.
240 void TestBreakpointHandler(Dart_IsolateId isolate_id, 242 void TestBreakpointHandler(Dart_IsolateId isolate_id,
241 Dart_Breakpoint bpt, 243 Dart_Breakpoint bpt,
242 Dart_StackTrace trace) { 244 Dart_StackTrace trace) {
243 const char* expected_trace[] = {"A.foo", "main"}; 245 const char* expected_trace[] = {"A.foo", "main"};
244 const intptr_t expected_trace_length = 2; 246 const intptr_t expected_trace_length = 2;
245 breakpoint_hit = true; 247 breakpoint_hit = true;
246 breakpoint_hit_counter++; 248 breakpoint_hit_counter++;
247 intptr_t trace_len; 249 intptr_t trace_len;
248 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 250 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
249 EXPECT_VALID(res); 251 EXPECT_VALID(res);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 SetBreakpointAtEntry("A", "foo"); 283 SetBreakpointAtEntry("A", "foo");
282 284
283 breakpoint_hit = false; 285 breakpoint_hit = false;
284 Dart_Handle retval = Invoke("main"); 286 Dart_Handle retval = Invoke("main");
285 EXPECT_VALID(retval); 287 EXPECT_VALID(retval);
286 EXPECT(breakpoint_hit == true); 288 EXPECT(breakpoint_hit == true);
287 } 289 }
288 290
289 291
290 void TestStepOutHandler(Dart_IsolateId isolate_id, 292 void TestStepOutHandler(Dart_IsolateId isolate_id,
291 Dart_Breakpoint bpt, 293 const Dart_CodeLocation& location) {
292 Dart_StackTrace trace) { 294 Dart_StackTrace trace;
295 Dart_GetStackTrace(&trace);
293 const char* expected_bpts[] = {"f1", "foo", "main"}; 296 const char* expected_bpts[] = {"f1", "foo", "main"};
294 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); 297 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts);
295 intptr_t trace_len; 298 intptr_t trace_len;
296 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 299 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
297 EXPECT_VALID(res); 300 EXPECT_VALID(res);
298 EXPECT(breakpoint_hit_counter < expected_bpts_length); 301 EXPECT(breakpoint_hit_counter < expected_bpts_length);
299 Dart_ActivationFrame frame; 302 Dart_ActivationFrame frame;
300 res = Dart_GetActivationFrame(trace, 0, &frame); 303 res = Dart_GetActivationFrame(trace, 0, &frame);
301 EXPECT_VALID(res); 304 EXPECT_VALID(res);
302 Dart_Handle func_name; 305 Dart_Handle func_name;
(...skipping 22 matching lines...) Expand all
325 "foo() { \n" 328 "foo() { \n"
326 " f1(); \n" 329 " f1(); \n"
327 " return f2(); \n" 330 " return f2(); \n"
328 "} \n" 331 "} \n"
329 " \n" 332 " \n"
330 "main() { \n" 333 "main() { \n"
331 " return foo(); \n" 334 " return foo(); \n"
332 "} \n"; 335 "} \n";
333 336
334 LoadScript(kScriptChars); 337 LoadScript(kScriptChars);
335 Dart_SetBreakpointHandler(&TestStepOutHandler); 338 Dart_SetPausedEventHandler(&TestStepOutHandler);
336 339
337 // Set a breakpoint in function f1, then repeatedly step out until 340 // Set a breakpoint in function f1, then repeatedly step out until
338 // we get to main. We should see one breakpoint each in f1, 341 // we get to main. We should see one breakpoint each in f1,
339 // foo, main, but not in f2. 342 // foo, main, but not in f2.
340 SetBreakpointAtEntry("", "f1"); 343 SetBreakpointAtEntry("", "f1");
341 344
342 breakpoint_hit = false; 345 breakpoint_hit = false;
343 breakpoint_hit_counter = 0; 346 breakpoint_hit_counter = 0;
344 Dart_Handle retval = Invoke("main"); 347 Dart_Handle retval = Invoke("main");
345 EXPECT_VALID(retval); 348 EXPECT_VALID(retval);
346 EXPECT(Dart_IsInteger(retval)); 349 EXPECT(Dart_IsInteger(retval));
347 int64_t int_value = 0; 350 int64_t int_value = 0;
348 Dart_IntegerToInt64(retval, &int_value); 351 Dart_IntegerToInt64(retval, &int_value);
349 EXPECT_EQ(2, int_value); 352 EXPECT_EQ(2, int_value);
350 EXPECT(breakpoint_hit == true); 353 EXPECT(breakpoint_hit == true);
351 } 354 }
352 355
353 356
354 void TestStepIntoHandler(Dart_IsolateId isolate_id, 357 void TestStepIntoHandler(Dart_IsolateId isolate_id,
355 Dart_Breakpoint bpt, 358 const Dart_CodeLocation& location) {
356 Dart_StackTrace trace) { 359 Dart_StackTrace trace;
360 Dart_GetStackTrace(&trace);
357 const char* expected_bpts[] = { 361 const char* expected_bpts[] = {
358 "main", 362 "main",
359 "foo", 363 "foo",
360 "f1", 364 "f1",
361 "foo", 365 "foo",
362 "X.X.", 366 "X.X.",
363 "foo", 367 "foo",
364 "X.kvmk", 368 "X.kvmk",
365 "f2", 369 "f2",
366 "X.kvmk", 370 "X.kvmk",
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 " f1(); \n" 412 " f1(); \n"
409 " var o = new X(); \n" 413 " var o = new X(); \n"
410 " return o.kvmk(3, c:5); \n" 414 " return o.kvmk(3, c:5); \n"
411 "} \n" 415 "} \n"
412 " \n" 416 " \n"
413 "main() { \n" 417 "main() { \n"
414 " return foo(); \n" 418 " return foo(); \n"
415 "} \n"; 419 "} \n";
416 420
417 LoadScript(kScriptChars); 421 LoadScript(kScriptChars);
418 Dart_SetBreakpointHandler(&TestStepIntoHandler); 422 Dart_SetPausedEventHandler(&TestStepIntoHandler);
419 423
420 // Set a breakpoint in function f1, then repeatedly step out until 424 // Set a breakpoint in function f1, then repeatedly step out until
421 // we get to main. We should see one breakpoint each in f1, 425 // we get to main. We should see one breakpoint each in f1,
422 // foo, main, but not in f2. 426 // foo, main, but not in f2.
423 SetBreakpointAtEntry("", "main"); 427 SetBreakpointAtEntry("", "main");
424 428
425 breakpoint_hit = false; 429 breakpoint_hit = false;
426 breakpoint_hit_counter = 0; 430 breakpoint_hit_counter = 0;
427 Dart_Handle retval = Invoke("main"); 431 Dart_Handle retval = Invoke("main");
428 EXPECT_VALID(retval); 432 EXPECT_VALID(retval);
429 EXPECT(Dart_IsInteger(retval)); 433 EXPECT(Dart_IsInteger(retval));
430 int64_t int_value = 0; 434 int64_t int_value = 0;
431 Dart_IntegerToInt64(retval, &int_value); 435 Dart_IntegerToInt64(retval, &int_value);
432 EXPECT_EQ(7, int_value); 436 EXPECT_EQ(7, int_value);
433 EXPECT(breakpoint_hit == true); 437 EXPECT(breakpoint_hit == true);
434 } 438 }
435 439
436 440
437 static void StepIntoHandler(Dart_IsolateId isolate_id, 441 static void StepIntoHandler(Dart_IsolateId isolate_id,
438 Dart_Breakpoint bpt, 442 const Dart_CodeLocation& location) {
439 Dart_StackTrace trace) { 443 Dart_StackTrace trace;
444 Dart_GetStackTrace(&trace);
440 if (verbose) { 445 if (verbose) {
441 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", 446 OS::Print(">>> Breakpoint nr. %d in %s <<<\n",
442 breakpoint_hit_counter, BreakpointInfo(trace)); 447 breakpoint_hit_counter, BreakpointInfo(trace));
443 PrintStackTrace(trace); 448 PrintStackTrace(trace);
444 } 449 }
445 breakpoint_hit = true; 450 breakpoint_hit = true;
446 breakpoint_hit_counter++; 451 breakpoint_hit_counter++;
447 Dart_SetStepInto(); 452 Dart_SetStepInto();
448 } 453 }
449 454
450 455
451 TEST_CASE(Debug_IgnoreBP) { 456 TEST_CASE(Debug_IgnoreBP) {
452 const char* kScriptChars = 457 const char* kScriptChars =
453 "class B { \n" 458 "class B { \n"
454 " static var z = 0; \n" 459 " static var z = 0; \n"
455 " var i = 100; \n" 460 " var i = 100; \n"
456 " var d = 3.14; \n" 461 " var d = 3.14; \n"
457 " var s = 'Dr Seuss'; \n" 462 " var s = 'Dr Seuss'; \n"
458 "} \n" 463 "} \n"
459 " \n" 464 " \n"
460 "main() { \n" 465 "main() { \n"
461 " var x = new B(); \n" 466 " var x = new B(); \n"
462 " return x.i + 1; \n" 467 " return x.i + 1; \n"
463 "} \n"; 468 "} \n";
464 469
465 LoadScript(kScriptChars); 470 LoadScript(kScriptChars);
466 Dart_SetBreakpointHandler(&StepIntoHandler); 471 Dart_SetPausedEventHandler(&StepIntoHandler);
467 472
468 SetBreakpointAtEntry("", "main"); 473 SetBreakpointAtEntry("", "main");
469 474
470 breakpoint_hit = false; 475 breakpoint_hit = false;
471 breakpoint_hit_counter = 0; 476 breakpoint_hit_counter = 0;
472 Dart_Handle retval = Invoke("main"); 477 Dart_Handle retval = Invoke("main");
473 EXPECT_VALID(retval); 478 EXPECT_VALID(retval);
474 EXPECT(Dart_IsInteger(retval)); 479 EXPECT(Dart_IsInteger(retval));
475 int64_t int_value = 0; 480 int64_t int_value = 0;
476 Dart_IntegerToInt64(retval, &int_value); 481 Dart_IntegerToInt64(retval, &int_value);
(...skipping 10 matching lines...) Expand all
487 " for (int i = 0; i < 5000; i++) { \n" 492 " for (int i = 0; i < 5000; i++) { \n"
488 " foo(i); \n" 493 " foo(i); \n"
489 " } \n" 494 " } \n"
490 "} \n" 495 "} \n"
491 " \n" 496 " \n"
492 "main() { \n" 497 "main() { \n"
493 " return foo(99); \n" 498 " return foo(99); \n"
494 "} \n"; 499 "} \n";
495 500
496 LoadScript(kScriptChars); 501 LoadScript(kScriptChars);
497 Dart_SetBreakpointHandler(&StepIntoHandler); 502 Dart_SetPausedEventHandler(&StepIntoHandler);
498 503
499 504
500 // Cause function foo to be optimized before we set a BP. 505 // Cause function foo to be optimized before we set a BP.
501 Dart_Handle res = Invoke("warmup"); 506 Dart_Handle res = Invoke("warmup");
502 EXPECT_VALID(res); 507 EXPECT_VALID(res);
503 508
504 // Now set breakpoint in main and then step into optimized function foo. 509 // Now set breakpoint in main and then step into optimized function foo.
505 SetBreakpointAtEntry("", "main"); 510 SetBreakpointAtEntry("", "main");
506 511
507 512
508 breakpoint_hit = false; 513 breakpoint_hit = false;
509 breakpoint_hit_counter = 0; 514 breakpoint_hit_counter = 0;
510 Dart_Handle retval = Invoke("main"); 515 Dart_Handle retval = Invoke("main");
511 EXPECT_VALID(retval); 516 EXPECT_VALID(retval);
512 EXPECT(Dart_IsInteger(retval)); 517 EXPECT(Dart_IsInteger(retval));
513 int64_t int_value = 0; 518 int64_t int_value = 0;
514 Dart_IntegerToInt64(retval, &int_value); 519 Dart_IntegerToInt64(retval, &int_value);
515 EXPECT_EQ(2 * 99, int_value); 520 EXPECT_EQ(2 * 99, int_value);
516 EXPECT(breakpoint_hit == true); 521 EXPECT(breakpoint_hit == true);
517 } 522 }
518 523
519 524
520 void TestSingleStepHandler(Dart_IsolateId isolate_id, 525 void TestSingleStepHandler(Dart_IsolateId isolate_id,
521 Dart_Breakpoint bpt, 526 const Dart_CodeLocation& location) {
522 Dart_StackTrace trace) { 527 Dart_StackTrace trace;
528 Dart_GetStackTrace(&trace);
523 const char* expected_bpts[] = { 529 const char* expected_bpts[] = {
524 "moo", "foo", "moo", "foo", "moo", "foo", "main"}; 530 "moo", "foo", "moo", "foo", "moo", "foo", "main"};
525 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); 531 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts);
526 intptr_t trace_len; 532 intptr_t trace_len;
527 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 533 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
528 EXPECT_VALID(res); 534 EXPECT_VALID(res);
529 EXPECT(breakpoint_hit_counter < expected_bpts_length); 535 EXPECT(breakpoint_hit_counter < expected_bpts_length);
530 Dart_ActivationFrame frame; 536 Dart_ActivationFrame frame;
531 res = Dart_GetActivationFrame(trace, 0, &frame); 537 res = Dart_GetActivationFrame(trace, 0, &frame);
532 EXPECT_VALID(res); 538 EXPECT_VALID(res);
(...skipping 23 matching lines...) Expand all
556 " moo('step one'); \n" 562 " moo('step one'); \n"
557 " moo('step two'); \n" 563 " moo('step two'); \n"
558 " moo('step three'); \n" 564 " moo('step three'); \n"
559 "} \n" 565 "} \n"
560 " \n" 566 " \n"
561 "void main() { \n" 567 "void main() { \n"
562 " foo(); \n" 568 " foo(); \n"
563 "} \n"; 569 "} \n";
564 570
565 LoadScript(kScriptChars); 571 LoadScript(kScriptChars);
566 Dart_SetBreakpointHandler(&TestSingleStepHandler); 572 Dart_SetPausedEventHandler(&TestSingleStepHandler);
567 573
568 SetBreakpointAtEntry("", "moo"); 574 SetBreakpointAtEntry("", "moo");
569 575
570 breakpoint_hit = false; 576 breakpoint_hit = false;
571 breakpoint_hit_counter = 0; 577 breakpoint_hit_counter = 0;
572 Dart_Handle retval = Invoke("main"); 578 Dart_Handle retval = Invoke("main");
573 EXPECT_VALID(retval); 579 EXPECT_VALID(retval);
574 EXPECT(breakpoint_hit == true); 580 EXPECT(breakpoint_hit == true);
575 } 581 }
576 582
577 583
578 static void ClosureBreakpointHandler(Dart_IsolateId isolate_id, 584 static void ClosureBreakpointHandler(Dart_IsolateId isolate_id,
579 Dart_Breakpoint bpt, 585 const Dart_CodeLocation& location) {
580 Dart_StackTrace trace) { 586 Dart_StackTrace trace;
587 Dart_GetStackTrace(&trace);
581 const char* expected_trace[] = {"callback", "main"}; 588 const char* expected_trace[] = {"callback", "main"};
582 const intptr_t expected_trace_length = 2; 589 const intptr_t expected_trace_length = 2;
583 breakpoint_hit_counter++; 590 breakpoint_hit_counter++;
584 intptr_t trace_len; 591 intptr_t trace_len;
585 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 592 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
586 EXPECT_VALID(res); 593 EXPECT_VALID(res);
587 EXPECT_EQ(expected_trace_length, trace_len); 594 EXPECT_EQ(expected_trace_length, trace_len);
588 for (int i = 0; i < trace_len; i++) { 595 for (int i = 0; i < trace_len; i++) {
589 Dart_ActivationFrame frame; 596 Dart_ActivationFrame frame;
590 res = Dart_GetActivationFrame(trace, i, &frame); 597 res = Dart_GetActivationFrame(trace, i, &frame);
(...skipping 17 matching lines...) Expand all
608 "} \n" 615 "} \n"
609 " \n" 616 " \n"
610 "main() { \n" 617 "main() { \n"
611 " var h = callback; \n" 618 " var h = callback; \n"
612 " h('bla'); \n" 619 " h('bla'); \n"
613 " callback('jada'); \n" 620 " callback('jada'); \n"
614 " return 442; \n" 621 " return 442; \n"
615 "} \n"; 622 "} \n";
616 623
617 LoadScript(kScriptChars); 624 LoadScript(kScriptChars);
618 Dart_SetBreakpointHandler(&ClosureBreakpointHandler); 625 Dart_SetPausedEventHandler(&ClosureBreakpointHandler);
619 626
620 SetBreakpointAtEntry("", "callback"); 627 SetBreakpointAtEntry("", "callback");
621 628
622 breakpoint_hit_counter = 0; 629 breakpoint_hit_counter = 0;
623 Dart_Handle retval = Invoke("main"); 630 Dart_Handle retval = Invoke("main");
624 EXPECT_VALID(retval); 631 EXPECT_VALID(retval);
625 int64_t int_value = 0; 632 int64_t int_value = 0;
626 Dart_IntegerToInt64(retval, &int_value); 633 Dart_IntegerToInt64(retval, &int_value);
627 EXPECT_EQ(442, int_value); 634 EXPECT_EQ(442, int_value);
628 EXPECT_EQ(2, breakpoint_hit_counter); 635 EXPECT_EQ(2, breakpoint_hit_counter);
629 } 636 }
630 637
631 638
632 static void ExprClosureBreakpointHandler(Dart_IsolateId isolate_id, 639 static void ExprClosureBreakpointHandler(Dart_IsolateId isolate_id,
633 Dart_Breakpoint bpt, 640 const Dart_CodeLocation& location) {
634 Dart_StackTrace trace) { 641 Dart_StackTrace trace;
642 Dart_GetStackTrace(&trace);
635 static const char* expected_trace[] = {"<anonymous closure>", "main"}; 643 static const char* expected_trace[] = {"<anonymous closure>", "main"};
636 Dart_Handle add_locals = Dart_NewList(4); 644 Dart_Handle add_locals = Dart_NewList(4);
637 Dart_ListSetAt(add_locals, 0, NewString("a")); 645 Dart_ListSetAt(add_locals, 0, NewString("a"));
638 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10)); 646 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10));
639 Dart_ListSetAt(add_locals, 2, NewString("b")); 647 Dart_ListSetAt(add_locals, 2, NewString("b"));
640 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20)); 648 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20));
641 Dart_Handle expected_locals[] = {add_locals, Dart_Null()}; 649 Dart_Handle expected_locals[] = {add_locals, Dart_Null()};
642 breakpoint_hit_counter++; 650 breakpoint_hit_counter++;
643 PrintStackTrace(trace); 651 PrintStackTrace(trace);
644 VerifyStackTrace(trace, expected_trace, expected_locals, 2, false); 652 VerifyStackTrace(trace, expected_trace, expected_locals, 2, false);
645 } 653 }
646 654
647 655
648 TEST_CASE(Debug_ExprClosureBreakpoint) { 656 TEST_CASE(Debug_ExprClosureBreakpoint) {
649 const char* kScriptChars = 657 const char* kScriptChars =
650 "var c; \n" 658 "var c; \n"
651 " \n" 659 " \n"
652 "main() { \n" 660 "main() { \n"
653 " c = (a, b) { \n" 661 " c = (a, b) { \n"
654 " return a + b; \n" 662 " return a + b; \n"
655 " }; \n" 663 " }; \n"
656 " return c(10, 20); \n" 664 " return c(10, 20); \n"
657 "} \n"; 665 "} \n";
658 666
659 LoadScript(kScriptChars); 667 LoadScript(kScriptChars);
660 Dart_SetBreakpointHandler(&ExprClosureBreakpointHandler); 668 Dart_SetPausedEventHandler(&ExprClosureBreakpointHandler);
661 669
662 Dart_Handle script_url = NewString(TestCase::url()); 670 Dart_Handle script_url = NewString(TestCase::url());
663 intptr_t line_no = 5; // In closure 'add'. 671 intptr_t line_no = 5; // In closure 'add'.
664 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no); 672 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no);
665 EXPECT_VALID(res); 673 EXPECT_VALID(res);
666 EXPECT(Dart_IsInteger(res)); 674 EXPECT(Dart_IsInteger(res));
667 675
668 breakpoint_hit_counter = 0; 676 breakpoint_hit_counter = 0;
669 Dart_Handle retval = Invoke("main"); 677 Dart_Handle retval = Invoke("main");
670 EXPECT_VALID(retval); 678 EXPECT_VALID(retval);
671 int64_t int_value = 0; 679 int64_t int_value = 0;
672 Dart_IntegerToInt64(retval, &int_value); 680 Dart_IntegerToInt64(retval, &int_value);
673 EXPECT_EQ(30, int_value); 681 EXPECT_EQ(30, int_value);
674 EXPECT_EQ(1, breakpoint_hit_counter); 682 EXPECT_EQ(1, breakpoint_hit_counter);
675 } 683 }
676 684
677 685
678 static intptr_t bp_id_to_be_deleted; 686 static intptr_t bp_id_to_be_deleted;
679 687
680 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id, 688 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id,
681 Dart_Breakpoint bpt, 689 const Dart_CodeLocation& location) {
682 Dart_StackTrace trace) { 690 Dart_StackTrace trace;
691 Dart_GetStackTrace(&trace);
683 const char* expected_trace[] = {"foo", "main"}; 692 const char* expected_trace[] = {"foo", "main"};
684 const intptr_t expected_trace_length = 2; 693 const intptr_t expected_trace_length = 2;
685 breakpoint_hit_counter++; 694 breakpoint_hit_counter++;
686 intptr_t trace_len; 695 intptr_t trace_len;
687 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 696 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
688 EXPECT_VALID(res); 697 EXPECT_VALID(res);
689 EXPECT_EQ(expected_trace_length, trace_len); 698 EXPECT_EQ(expected_trace_length, trace_len);
690 for (int i = 0; i < trace_len; i++) { 699 for (int i = 0; i < trace_len; i++) {
691 Dart_ActivationFrame frame; 700 Dart_ActivationFrame frame;
692 res = Dart_GetActivationFrame(trace, i, &frame); 701 res = Dart_GetActivationFrame(trace, i, &frame);
(...skipping 28 matching lines...) Expand all
721 " foo(); \n" 730 " foo(); \n"
722 " foo(); \n" 731 " foo(); \n"
723 " foo(); \n" 732 " foo(); \n"
724 "} \n"; 733 "} \n";
725 734
726 LoadScript(kScriptChars); 735 LoadScript(kScriptChars);
727 736
728 Dart_Handle script_url = NewString(TestCase::url()); 737 Dart_Handle script_url = NewString(TestCase::url());
729 intptr_t line_no = 4; // In function 'foo'. 738 intptr_t line_no = 4; // In function 'foo'.
730 739
731 Dart_SetBreakpointHandler(&DeleteBreakpointHandler); 740 Dart_SetPausedEventHandler(&DeleteBreakpointHandler);
732 741
733 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no); 742 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no);
734 EXPECT_VALID(res); 743 EXPECT_VALID(res);
735 EXPECT(Dart_IsInteger(res)); 744 EXPECT(Dart_IsInteger(res));
736 int64_t bp_id = 0; 745 int64_t bp_id = 0;
737 Dart_IntegerToInt64(res, &bp_id); 746 Dart_IntegerToInt64(res, &bp_id);
738 747
739 // Function main() calls foo() 3 times. On the second iteration, the 748 // Function main() calls foo() 3 times. On the second iteration, the
740 // breakpoint is removed by the handler, so we expect the breakpoint 749 // breakpoint is removed by the handler, so we expect the breakpoint
741 // to fire twice only. 750 // to fire twice only.
742 bp_id_to_be_deleted = bp_id; 751 bp_id_to_be_deleted = bp_id;
743 breakpoint_hit_counter = 0; 752 breakpoint_hit_counter = 0;
744 Dart_Handle retval = Invoke("main"); 753 Dart_Handle retval = Invoke("main");
745 EXPECT_VALID(retval); 754 EXPECT_VALID(retval);
746 EXPECT_EQ(2, breakpoint_hit_counter); 755 EXPECT_EQ(2, breakpoint_hit_counter);
747 } 756 }
748 757
749 758
750 static void InspectStaticFieldHandler(Dart_IsolateId isolate_id, 759 static void InspectStaticFieldHandler(Dart_IsolateId isolate_id,
751 Dart_Breakpoint bpt, 760 const Dart_CodeLocation& location) {
752 Dart_StackTrace trace) { 761 Dart_StackTrace trace;
762 Dart_GetStackTrace(&trace);
753 ASSERT(script_lib != NULL); 763 ASSERT(script_lib != NULL);
754 ASSERT(!Dart_IsError(script_lib)); 764 ASSERT(!Dart_IsError(script_lib));
755 ASSERT(Dart_IsLibrary(script_lib)); 765 ASSERT(Dart_IsLibrary(script_lib));
756 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A")); 766 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A"));
757 EXPECT_VALID(class_A); 767 EXPECT_VALID(class_A);
758 768
759 const int expected_num_fields = 2; 769 const int expected_num_fields = 2;
760 struct { 770 struct {
761 const char* field_name; 771 const char* field_name;
762 const char* field_value; 772 const char* field_value;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 " debugBreak() { } \n" 824 " debugBreak() { } \n"
815 " main() { \n" 825 " main() { \n"
816 " var a = new A(); \n" 826 " var a = new A(); \n"
817 " debugBreak(); \n" 827 " debugBreak(); \n"
818 " A.u = 442; \n" 828 " A.u = 442; \n"
819 " A.bla = 'silence is golden'; \n" 829 " A.bla = 'silence is golden'; \n"
820 " debugBreak(); \n" 830 " debugBreak(); \n"
821 " } \n"; 831 " } \n";
822 832
823 LoadScript(kScriptChars); 833 LoadScript(kScriptChars);
824 Dart_SetBreakpointHandler(&InspectStaticFieldHandler); 834 Dart_SetPausedEventHandler(&InspectStaticFieldHandler);
825 SetBreakpointAtEntry("", "debugBreak"); 835 SetBreakpointAtEntry("", "debugBreak");
826 836
827 breakpoint_hit_counter = 0; 837 breakpoint_hit_counter = 0;
828 Dart_Handle retval = Invoke("main"); 838 Dart_Handle retval = Invoke("main");
829 EXPECT_VALID(retval); 839 EXPECT_VALID(retval);
830 } 840 }
831 841
832 842
833 TEST_CASE(Debug_InspectObject) { 843 TEST_CASE(Debug_InspectObject) {
834 const char* kScriptChars = 844 const char* kScriptChars =
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 { 1208 {
1199 MonitorLocker ml(sync); 1209 MonitorLocker ml(sync);
1200 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { 1210 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
1201 ml.Wait(); 1211 ml.Wait();
1202 } 1212 }
1203 } 1213 }
1204 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1214 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1205 } 1215 }
1206 1216
1207 1217
1208 static void StackTraceDump1BreakpointHandler(Dart_IsolateId isolate_id, 1218 static void StackTraceDump1BreakpointHandler(
1209 Dart_Breakpoint bpt, 1219 Dart_IsolateId isolate_id,
1210 Dart_StackTrace trace) { 1220 const Dart_CodeLocation& location) {
1221 Dart_StackTrace trace;
1222 Dart_GetStackTrace(&trace);
1211 const int kStackTraceLen = 4; 1223 const int kStackTraceLen = 4;
1212 static const char* expected_trace[kStackTraceLen] = { 1224 static const char* expected_trace[kStackTraceLen] = {
1213 "local_to_main", 1225 "local_to_main",
1214 "Test.local1_to_func1", 1226 "Test.local1_to_func1",
1215 "Test.func1", 1227 "Test.func1",
1216 "main" 1228 "main"
1217 }; 1229 };
1218 1230
1219 intptr_t trace_len; 1231 intptr_t trace_len;
1220 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 1232 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 " return i + j;\n" 1349 " return i + j;\n"
1338 " }\n" 1350 " }\n"
1339 " var sum = 0;\n" 1351 " var sum = 0;\n"
1340 " Test value = new Test(10);\n" 1352 " Test value = new Test(10);\n"
1341 " var func1 = value.func1;\n" 1353 " var func1 = value.func1;\n"
1342 " var main_local = local_to_main;\n" 1354 " var main_local = local_to_main;\n"
1343 " return func1(main_local);\n" 1355 " return func1(main_local);\n"
1344 "}\n"; 1356 "}\n";
1345 1357
1346 LoadScript(kScriptChars); 1358 LoadScript(kScriptChars);
1347 Dart_SetBreakpointHandler(&StackTraceDump1BreakpointHandler); 1359 Dart_SetPausedEventHandler(&StackTraceDump1BreakpointHandler);
1348 1360
1349 Dart_Handle script_url = NewString(TestCase::url()); 1361 Dart_Handle script_url = NewString(TestCase::url());
1350 intptr_t line_no = 34; // In closure 'local_to_main'. 1362 intptr_t line_no = 34; // In closure 'local_to_main'.
1351 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no); 1363 Dart_Handle res = Dart_SetBreakpoint(script_url, line_no);
1352 EXPECT_VALID(res); 1364 EXPECT_VALID(res);
1353 EXPECT(Dart_IsInteger(res)); 1365 EXPECT(Dart_IsInteger(res));
1354 1366
1355 breakpoint_hit_counter = 0; 1367 breakpoint_hit_counter = 0;
1356 Dart_Handle retval = Invoke("main"); 1368 Dart_Handle retval = Invoke("main");
1357 EXPECT_VALID(retval); 1369 EXPECT_VALID(retval);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1529
1518 Dart_Handle retval = Invoke("main"); 1530 Dart_Handle retval = Invoke("main");
1519 EXPECT(Dart_IsError(retval)); 1531 EXPECT(Dart_IsError(retval));
1520 EXPECT(Dart_IsUnhandledExceptionError(retval)); 1532 EXPECT(Dart_IsUnhandledExceptionError(retval));
1521 EXPECT_EQ(1, breakpoint_hit_counter); 1533 EXPECT_EQ(1, breakpoint_hit_counter);
1522 } 1534 }
1523 1535
1524 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 1536 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
1525 1537
1526 } // namespace dart 1538 } // namespace dart
OLDNEW
« runtime/include/dart_debugger_api.h ('K') | « runtime/vm/debugger_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698