OLD | NEW |
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_mirrors_api.h" | 5 #include "include/dart_mirrors_api.h" |
6 #include "include/dart_tools_api.h" | 6 #include "include/dart_tools_api.h" |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DECLARE_FLAG(bool, trace_shutdown); | 14 DECLARE_FLAG(bool, trace_shutdown); |
15 | 15 |
16 #ifndef PRODUCT | 16 #ifndef PRODUCT |
17 | 17 |
18 static bool breakpoint_hit = false; | 18 static bool breakpoint_hit = false; |
19 static int breakpoint_hit_counter = 0; | 19 static int breakpoint_hit_counter = 0; |
20 static Dart_Handle script_lib = NULL; | 20 static Dart_Handle script_lib = NULL; |
21 | 21 |
22 static const bool verbose = true; | 22 static const bool verbose = true; |
23 | 23 |
24 static void LoadScript(const char* source) { | 24 static void LoadScript(const char* source) { |
25 script_lib = TestCase::LoadTestScript(source, NULL); | 25 script_lib = TestCase::LoadTestScript(source, NULL); |
26 EXPECT_VALID(script_lib); | 26 EXPECT_VALID(script_lib); |
27 } | 27 } |
28 | 28 |
29 | 29 |
30 static void SetBreakpointAtEntry(const char* cname, const char* fname) { | 30 static void SetBreakpointAtEntry(const char* cname, const char* fname) { |
31 ASSERT(script_lib != NULL); | 31 ASSERT(script_lib != NULL); |
32 ASSERT(!Dart_IsError(script_lib)); | 32 ASSERT(!Dart_IsError(script_lib)); |
33 ASSERT(Dart_IsLibrary(script_lib)); | 33 ASSERT(Dart_IsLibrary(script_lib)); |
34 Dart_Handle res = Dart_SetBreakpointAtEntry(script_lib, | 34 Dart_Handle res = |
35 NewString(cname), | 35 Dart_SetBreakpointAtEntry(script_lib, NewString(cname), NewString(fname)); |
36 NewString(fname)); | |
37 EXPECT(Dart_IsInteger(res)); | 36 EXPECT(Dart_IsInteger(res)); |
38 } | 37 } |
39 | 38 |
40 | 39 |
41 static void DisableDebuggabilityOfDartColonLibraries() { | 40 static void DisableDebuggabilityOfDartColonLibraries() { |
42 const char* dart_colon = "dart:"; | 41 const char* dart_colon = "dart:"; |
43 const intptr_t dart_colon_length = strlen(dart_colon); | 42 const intptr_t dart_colon_length = strlen(dart_colon); |
44 // Disable debuggability of all dart: libraries. | 43 // Disable debuggability of all dart: libraries. |
45 Dart_Handle library_ids = Dart_GetLibraryIds(); | 44 Dart_Handle library_ids = Dart_GetLibraryIds(); |
46 intptr_t library_ids_length; | 45 intptr_t library_ids_length; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 96 |
98 static char const* BreakpointInfo(Dart_StackTrace trace) { | 97 static char const* BreakpointInfo(Dart_StackTrace trace) { |
99 static char info_str[128]; | 98 static char info_str[128]; |
100 Dart_ActivationFrame frame; | 99 Dart_ActivationFrame frame; |
101 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); | 100 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); |
102 EXPECT_TRUE(res); | 101 EXPECT_TRUE(res); |
103 Dart_Handle func_name; | 102 Dart_Handle func_name; |
104 Dart_Handle url; | 103 Dart_Handle url; |
105 intptr_t line_number = 0; | 104 intptr_t line_number = 0; |
106 intptr_t library_id = 0; | 105 intptr_t library_id = 0; |
107 res = Dart_ActivationFrameInfo( | 106 res = Dart_ActivationFrameInfo(frame, &func_name, &url, &line_number, |
108 frame, &func_name, &url, &line_number, &library_id); | 107 &library_id); |
109 EXPECT_TRUE(res); | 108 EXPECT_TRUE(res); |
110 OS::SNPrint(info_str, sizeof(info_str), "function %s (%s:%" Pd ")", | 109 OS::SNPrint(info_str, sizeof(info_str), "function %s (%s:%" Pd ")", |
111 ToCString(func_name), ToCString(url), line_number); | 110 ToCString(func_name), ToCString(url), line_number); |
112 return info_str; | 111 return info_str; |
113 } | 112 } |
114 | 113 |
115 | 114 |
116 static void PrintValue(Dart_Handle value, bool expand); | 115 static void PrintValue(Dart_Handle value, bool expand); |
117 | 116 |
118 | 117 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 Dart_Handle func_name; | 381 Dart_Handle func_name; |
383 | 382 |
384 char* buffer = stack_buffer; | 383 char* buffer = stack_buffer; |
385 int buffer_size = stack_buffer_size; | 384 int buffer_size = stack_buffer_size; |
386 | 385 |
387 intptr_t trace_len; | 386 intptr_t trace_len; |
388 EXPECT_VALID(Dart_StackTraceLength(trace, &trace_len)); | 387 EXPECT_VALID(Dart_StackTraceLength(trace, &trace_len)); |
389 | 388 |
390 for (intptr_t frame_index = 0; frame_index < trace_len; frame_index++) { | 389 for (intptr_t frame_index = 0; frame_index < trace_len; frame_index++) { |
391 EXPECT_VALID(Dart_GetActivationFrame(trace, frame_index, &frame)); | 390 EXPECT_VALID(Dart_GetActivationFrame(trace, frame_index, &frame)); |
392 EXPECT_VALID(Dart_ActivationFrameInfo(frame, &func_name, | 391 EXPECT_VALID(Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL)); |
393 NULL, NULL, NULL)); | 392 int pos = OS::SNPrint(buffer, buffer_size, "[%" Pd "] %s { ", frame_index, |
394 int pos = OS::SNPrint(buffer, buffer_size, "[%" Pd "] %s { ", | 393 ToCString(func_name)); |
395 frame_index, ToCString(func_name)); | |
396 buffer += pos; | 394 buffer += pos; |
397 buffer_size -= pos; | 395 buffer_size -= pos; |
398 | 396 |
399 Dart_Handle locals = Dart_GetLocalVariables(frame); | 397 Dart_Handle locals = Dart_GetLocalVariables(frame); |
400 EXPECT_VALID(locals); | 398 EXPECT_VALID(locals); |
401 intptr_t list_length = 0; | 399 intptr_t list_length = 0; |
402 EXPECT_VALID(Dart_ListLength(locals, &list_length)); | 400 EXPECT_VALID(Dart_ListLength(locals, &list_length)); |
403 | 401 |
404 for (intptr_t i = 0; i + 1 < list_length; i += 2) { | 402 for (intptr_t i = 0; i + 1 < list_length; i += 2) { |
405 Dart_Handle name = Dart_ListGetAt(locals, i); | 403 Dart_Handle name = Dart_ListGetAt(locals, i); |
406 EXPECT_VALID(name); | 404 EXPECT_VALID(name); |
407 EXPECT(Dart_IsString(name)); | 405 EXPECT(Dart_IsString(name)); |
408 | 406 |
409 Dart_Handle value = Dart_ListGetAt(locals, i + 1); | 407 Dart_Handle value = Dart_ListGetAt(locals, i + 1); |
410 EXPECT_VALID(value); | 408 EXPECT_VALID(value); |
411 Dart_Handle value_str = Dart_ToString(value); | 409 Dart_Handle value_str = Dart_ToString(value); |
412 EXPECT_VALID(value_str); | 410 EXPECT_VALID(value_str); |
413 | 411 |
414 const char* name_cstr = NULL; | 412 const char* name_cstr = NULL; |
415 const char* value_cstr = NULL; | 413 const char* value_cstr = NULL; |
416 EXPECT_VALID(Dart_StringToCString(name, &name_cstr)); | 414 EXPECT_VALID(Dart_StringToCString(name, &name_cstr)); |
417 EXPECT_VALID(Dart_StringToCString(value_str, &value_cstr)); | 415 EXPECT_VALID(Dart_StringToCString(value_str, &value_cstr)); |
418 pos = OS::SNPrint(buffer, buffer_size, "%s = %s ", | 416 pos = OS::SNPrint(buffer, buffer_size, "%s = %s ", name_cstr, value_cstr); |
419 name_cstr, value_cstr); | |
420 buffer += pos; | 417 buffer += pos; |
421 buffer_size -= pos; | 418 buffer_size -= pos; |
422 } | 419 } |
423 pos = OS::SNPrint(buffer, buffer_size, "}\n"); | 420 pos = OS::SNPrint(buffer, buffer_size, "}\n"); |
424 buffer += pos; | 421 buffer += pos; |
425 buffer_size -= pos; | 422 buffer_size -= pos; |
426 } | 423 } |
427 } | 424 } |
428 | 425 |
429 | 426 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // Set up the breakpoint. | 483 // Set up the breakpoint. |
487 Dart_SetPausedEventHandler(InspectOptimizedStack_Breakpoint); | 484 Dart_SetPausedEventHandler(InspectOptimizedStack_Breakpoint); |
488 SetBreakpointAtEntry("", "breakpointNow"); | 485 SetBreakpointAtEntry("", "breakpointNow"); |
489 | 486 |
490 // Run the code and inspect the stack. | 487 // Run the code and inspect the stack. |
491 stack_buffer[0] = '\0'; | 488 stack_buffer[0] = '\0'; |
492 dart_args[0] = Dart_True(); | 489 dart_args[0] = Dart_True(); |
493 dart_args[1] = Dart_NewInteger(kLowThreshold); | 490 dart_args[1] = Dart_NewInteger(kLowThreshold); |
494 EXPECT_VALID(Dart_Invoke(script_lib, NewString("test"), 2, dart_args)); | 491 EXPECT_VALID(Dart_Invoke(script_lib, NewString("test"), 2, dart_args)); |
495 if (optimize) { | 492 if (optimize) { |
496 EXPECT_STREQ("[0] breakpointNow { }\n" | 493 EXPECT_STREQ( |
497 "[1] helper { a = 5 b = 99 stop = <optimized out> }\n" | 494 "[0] breakpointNow { }\n" |
498 "[2] anotherMiddleMan { one = <optimized out> " | 495 "[1] helper { a = 5 b = 99 stop = <optimized out> }\n" |
499 "two = <optimized out> stop = <optimized out> }\n" | 496 "[2] anotherMiddleMan { one = <optimized out> " |
500 "[3] middleMan { x = 5 limit = 100 stop = true value = 24255" | 497 "two = <optimized out> stop = <optimized out> }\n" |
501 " i = 99 }\n" | 498 "[3] middleMan { x = 5 limit = 100 stop = true value = 24255" |
502 "[4] test { stop = true limit = 100 }\n", | 499 " i = 99 }\n" |
503 stack_buffer); | 500 "[4] test { stop = true limit = 100 }\n", |
| 501 stack_buffer); |
504 } else { | 502 } else { |
505 EXPECT_STREQ("[0] breakpointNow { }\n" | 503 EXPECT_STREQ( |
506 "[1] helper { a = 5 b = 99 stop = true }\n" | 504 "[0] breakpointNow { }\n" |
507 "[2] anotherMiddleMan { one = 5 two = 99 stop = true }\n" | 505 "[1] helper { a = 5 b = 99 stop = true }\n" |
508 "[3] middleMan { x = 5 limit = 100 stop = true value = 24255" | 506 "[2] anotherMiddleMan { one = 5 two = 99 stop = true }\n" |
509 " i = 99 }\n" | 507 "[3] middleMan { x = 5 limit = 100 stop = true value = 24255" |
510 "[4] test { stop = true limit = 100 }\n", | 508 " i = 99 }\n" |
511 stack_buffer); | 509 "[4] test { stop = true limit = 100 }\n", |
| 510 stack_buffer); |
512 } | 511 } |
513 | 512 |
514 FLAG_optimization_counter_threshold = saved_threshold; | 513 FLAG_optimization_counter_threshold = saved_threshold; |
515 FLAG_use_osr = saved_osr; | 514 FLAG_use_osr = saved_osr; |
516 } | 515 } |
517 | 516 |
518 | 517 |
519 TEST_CASE(Debug_InspectStack_NotOptimized) { | 518 TEST_CASE(Debug_InspectStack_NotOptimized) { |
520 InspectStackTest(false); | 519 InspectStackTest(false); |
521 } | 520 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 // Set up the breakpoint. | 579 // Set up the breakpoint. |
581 Dart_SetPausedEventHandler(InspectOptimizedStack_Breakpoint); | 580 Dart_SetPausedEventHandler(InspectOptimizedStack_Breakpoint); |
582 SetBreakpointAtEntry("", "breakpointNow"); | 581 SetBreakpointAtEntry("", "breakpointNow"); |
583 | 582 |
584 // Run the code and inspect the stack. | 583 // Run the code and inspect the stack. |
585 stack_buffer[0] = '\0'; | 584 stack_buffer[0] = '\0'; |
586 dart_args[0] = Dart_True(); | 585 dart_args[0] = Dart_True(); |
587 dart_args[1] = Dart_NewInteger(kLowThreshold); | 586 dart_args[1] = Dart_NewInteger(kLowThreshold); |
588 EXPECT_VALID(Dart_Invoke(script_lib, NewString("test"), 2, dart_args)); | 587 EXPECT_VALID(Dart_Invoke(script_lib, NewString("test"), 2, dart_args)); |
589 if (optimize) { | 588 if (optimize) { |
590 EXPECT_STREQ("[0] breakpointNow { }\n" | 589 EXPECT_STREQ( |
591 "[1] helper { a = 50 b = 99 stop = <optimized out> }\n" | 590 "[0] breakpointNow { }\n" |
592 "[2] <anonymous closure> { x = 5 i = 99 stop = true" | 591 "[1] helper { a = 50 b = 99 stop = <optimized out> }\n" |
593 " value = <optimized out> }\n" | 592 "[2] <anonymous closure> { x = 5 i = 99 stop = true" |
594 "[3] anotherMiddleMan { func = <optimized out> }\n" | 593 " value = <optimized out> }\n" |
595 "[4] middleMan { x = 5 limit = 100 stop = true" | 594 "[3] anotherMiddleMan { func = <optimized out> }\n" |
596 " value = 242550 i = 99 }\n" | 595 "[4] middleMan { x = 5 limit = 100 stop = true" |
597 "[5] test { stop = true limit = 100 }\n", | 596 " value = 242550 i = 99 }\n" |
598 stack_buffer); | 597 "[5] test { stop = true limit = 100 }\n", |
| 598 stack_buffer); |
599 } else { | 599 } else { |
600 EXPECT_STREQ("[0] breakpointNow { }\n" | 600 EXPECT_STREQ( |
601 "[1] helper { a = 50 b = 99 stop = true }\n" | 601 "[0] breakpointNow { }\n" |
602 "[2] <anonymous closure> { x = 5 i = 99 stop = true" | 602 "[1] helper { a = 50 b = 99 stop = true }\n" |
603 " value = 10 }\n" | 603 "[2] <anonymous closure> { x = 5 i = 99 stop = true" |
604 "[3] anotherMiddleMan {" | 604 " value = 10 }\n" |
605 " func = Closure: (dynamic) => dynamic }\n" | 605 "[3] anotherMiddleMan {" |
606 "[4] middleMan { x = 5 limit = 100 stop = true" | 606 " func = Closure: (dynamic) => dynamic }\n" |
607 " value = 242550 i = 99 }\n" | 607 "[4] middleMan { x = 5 limit = 100 stop = true" |
608 "[5] test { stop = true limit = 100 }\n", | 608 " value = 242550 i = 99 }\n" |
609 stack_buffer); | 609 "[5] test { stop = true limit = 100 }\n", |
| 610 stack_buffer); |
610 } | 611 } |
611 | 612 |
612 FLAG_optimization_counter_threshold = saved_threshold; | 613 FLAG_optimization_counter_threshold = saved_threshold; |
613 FLAG_use_osr = saved_osr; | 614 FLAG_use_osr = saved_osr; |
614 } | 615 } |
615 | 616 |
616 | 617 |
617 TEST_CASE(Debug_InspectStackWithClosure_NotOptimized) { | 618 TEST_CASE(Debug_InspectStackWithClosure_NotOptimized) { |
618 InspectStackWithClosureTest(false); | 619 InspectStackWithClosureTest(false); |
619 } | 620 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 breakpoint_hit_counter = 0; | 685 breakpoint_hit_counter = 0; |
685 Dart_Handle retval = Invoke("main"); | 686 Dart_Handle retval = Invoke("main"); |
686 EXPECT_VALID(retval); | 687 EXPECT_VALID(retval); |
687 EXPECT(Dart_IsInteger(retval)); | 688 EXPECT(Dart_IsInteger(retval)); |
688 int64_t int_value = ToInt64(retval); | 689 int64_t int_value = ToInt64(retval); |
689 EXPECT_EQ(2, int_value); | 690 EXPECT_EQ(2, int_value); |
690 EXPECT(breakpoint_hit == true); | 691 EXPECT(breakpoint_hit == true); |
691 } | 692 } |
692 | 693 |
693 static const char* step_into_expected_bpts[] = { | 694 static const char* step_into_expected_bpts[] = { |
694 "main", // entry | 695 "main", // entry |
695 "main", // call foo | 696 "main", // call foo |
696 "foo", // entry | 697 "foo", // entry |
697 "foo", // call f1 | 698 "foo", // call f1 |
698 "f1", // entry | 699 "f1", // entry |
699 "f1", // return | 700 "f1", // return |
700 "foo", // call initializer | 701 "foo", // call initializer |
701 "foo", // call kvmk | 702 "foo", // call kvmk |
702 "X.kvmk", // entry | 703 "X.kvmk", // entry |
703 "X.kvmk", // call | 704 "X.kvmk", // call |
704 "f2", // entry | 705 "f2", // entry |
705 "f2", // return | 706 "f2", // return |
706 "X.kvmk", // call + | 707 "X.kvmk", // call + |
707 "X.kvmk", // return | 708 "X.kvmk", // return |
708 "foo", // return | 709 "foo", // return |
709 "main" // return | 710 "main" // return |
710 }; | 711 }; |
711 | 712 |
712 void TestStepIntoHandler(Dart_IsolateId isolate_id, | 713 void TestStepIntoHandler(Dart_IsolateId isolate_id, |
713 intptr_t bp_id, | 714 intptr_t bp_id, |
714 const Dart_CodeLocation& location) { | 715 const Dart_CodeLocation& location) { |
715 Dart_StackTrace trace; | 716 Dart_StackTrace trace; |
716 Dart_GetStackTrace(&trace); | 717 Dart_GetStackTrace(&trace); |
717 const intptr_t expected_bpts_length = ARRAY_SIZE(step_into_expected_bpts); | 718 const intptr_t expected_bpts_length = ARRAY_SIZE(step_into_expected_bpts); |
718 intptr_t trace_len; | 719 intptr_t trace_len; |
719 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 720 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 EXPECT(breakpoint_hit_counter == ARRAY_SIZE(step_into_expected_bpts)); | 779 EXPECT(breakpoint_hit_counter == ARRAY_SIZE(step_into_expected_bpts)); |
779 } | 780 } |
780 | 781 |
781 | 782 |
782 static void StepIntoHandler(Dart_IsolateId isolate_id, | 783 static void StepIntoHandler(Dart_IsolateId isolate_id, |
783 intptr_t bp_id, | 784 intptr_t bp_id, |
784 const Dart_CodeLocation& location) { | 785 const Dart_CodeLocation& location) { |
785 Dart_StackTrace trace; | 786 Dart_StackTrace trace; |
786 Dart_GetStackTrace(&trace); | 787 Dart_GetStackTrace(&trace); |
787 if (verbose) { | 788 if (verbose) { |
788 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", | 789 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", breakpoint_hit_counter, |
789 breakpoint_hit_counter, BreakpointInfo(trace)); | 790 BreakpointInfo(trace)); |
790 PrintStackTrace(trace); | 791 PrintStackTrace(trace); |
791 } | 792 } |
792 breakpoint_hit = true; | 793 breakpoint_hit = true; |
793 breakpoint_hit_counter++; | 794 breakpoint_hit_counter++; |
794 Dart_SetStepInto(); | 795 Dart_SetStepInto(); |
795 } | 796 } |
796 | 797 |
797 | 798 |
798 TEST_CASE(Debug_IgnoreBP) { | 799 TEST_CASE(Debug_IgnoreBP) { |
799 const char* kScriptChars = | 800 const char* kScriptChars = |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 EXPECT_EQ(2 * 99, int_value); | 861 EXPECT_EQ(2 * 99, int_value); |
861 EXPECT(breakpoint_hit == true); | 862 EXPECT(breakpoint_hit == true); |
862 } | 863 } |
863 | 864 |
864 | 865 |
865 void TestSingleStepHandler(Dart_IsolateId isolate_id, | 866 void TestSingleStepHandler(Dart_IsolateId isolate_id, |
866 intptr_t bp_id, | 867 intptr_t bp_id, |
867 const Dart_CodeLocation& location) { | 868 const Dart_CodeLocation& location) { |
868 Dart_StackTrace trace; | 869 Dart_StackTrace trace; |
869 Dart_GetStackTrace(&trace); | 870 Dart_GetStackTrace(&trace); |
870 const char* expected_bpts[] = { | 871 const char* expected_bpts[] = {"moo", "moo", "foo", "moo", "moo", |
871 "moo", "moo", "foo", "moo", "moo", "foo", "moo", "moo", "foo", "main"}; | 872 "foo", "moo", "moo", "foo", "main"}; |
872 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); | 873 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); |
873 intptr_t trace_len; | 874 intptr_t trace_len; |
874 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 875 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
875 EXPECT_VALID(res); | 876 EXPECT_VALID(res); |
876 EXPECT(breakpoint_hit_counter < expected_bpts_length); | 877 EXPECT(breakpoint_hit_counter < expected_bpts_length); |
877 Dart_ActivationFrame frame; | 878 Dart_ActivationFrame frame; |
878 res = Dart_GetActivationFrame(trace, 0, &frame); | 879 res = Dart_GetActivationFrame(trace, 0, &frame); |
879 EXPECT_VALID(res); | 880 EXPECT_VALID(res); |
880 Dart_Handle func_name; | 881 Dart_Handle func_name; |
881 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL); | 882 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 " return y; \n" // Return. | 1080 " return y; \n" // Return. |
1080 " } \n" | 1081 " } \n" |
1081 "} \n" | 1082 "} \n" |
1082 " \n" | 1083 " \n" |
1083 "main() { \n" | 1084 "main() { \n" |
1084 " var i = 3; \n" | 1085 " var i = 3; \n" |
1085 " foo(i); \n" | 1086 " foo(i); \n" |
1086 "} \n"; | 1087 "} \n"; |
1087 | 1088 |
1088 LoadScript(kScriptChars); | 1089 LoadScript(kScriptChars); |
1089 Dart_Handle result = Dart_SetNativeResolver(script_lib, | 1090 Dart_Handle result = |
1090 &NoopNativeResolver, | 1091 Dart_SetNativeResolver(script_lib, &NoopNativeResolver, NULL); |
1091 NULL); | |
1092 EXPECT_VALID(result); | 1092 EXPECT_VALID(result); |
1093 Dart_SetPausedEventHandler(&TestBreakpointHandlerWithVerify); | 1093 Dart_SetPausedEventHandler(&TestBreakpointHandlerWithVerify); |
1094 | 1094 |
1095 Dart_Handle script_url = NewString(TestCase::url()); | 1095 Dart_Handle script_url = NewString(TestCase::url()); |
1096 | 1096 |
1097 const intptr_t num_breakpoints = 9; | 1097 const intptr_t num_breakpoints = 9; |
1098 intptr_t breakpoint_lines[num_breakpoints] = | 1098 intptr_t breakpoint_lines[num_breakpoints] = {5, 6, 7, 8, 9, 10, 11, 12, 13}; |
1099 {5, 6, 7, 8, 9, 10, 11, 12, 13}; | |
1100 | 1099 |
1101 for (intptr_t i = 0; i < num_breakpoints; i++) { | 1100 for (intptr_t i = 0; i < num_breakpoints; i++) { |
1102 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]); | 1101 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]); |
1103 EXPECT_VALID(result); | 1102 EXPECT_VALID(result); |
1104 EXPECT(Dart_IsInteger(result)); | 1103 EXPECT(Dart_IsInteger(result)); |
1105 } | 1104 } |
1106 | 1105 |
1107 breakpoint_hit = false; | 1106 breakpoint_hit = false; |
1108 breakpoint_hit_counter = 0; | 1107 breakpoint_hit_counter = 0; |
1109 Dart_Handle retval = Invoke("main"); | 1108 Dart_Handle retval = Invoke("main"); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 ASSERT(script_lib != NULL); | 1194 ASSERT(script_lib != NULL); |
1196 ASSERT(!Dart_IsError(script_lib)); | 1195 ASSERT(!Dart_IsError(script_lib)); |
1197 ASSERT(Dart_IsLibrary(script_lib)); | 1196 ASSERT(Dart_IsLibrary(script_lib)); |
1198 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A")); | 1197 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A")); |
1199 EXPECT_VALID(class_A); | 1198 EXPECT_VALID(class_A); |
1200 | 1199 |
1201 const int expected_num_fields = 2; | 1200 const int expected_num_fields = 2; |
1202 struct { | 1201 struct { |
1203 const char* field_name; | 1202 const char* field_name; |
1204 const char* field_value; | 1203 const char* field_value; |
1205 } expected[] = { | 1204 } expected[] = {// Expected values at first breakpoint. |
1206 // Expected values at first breakpoint. | 1205 {"bla", "yada yada yada"}, |
1207 { "bla", "yada yada yada"}, | 1206 {"u", "null"}, |
1208 { "u", "null" }, | 1207 // Expected values at second breakpoint. |
1209 // Expected values at second breakpoint. | 1208 {"bla", "silence is golden"}, |
1210 { "bla", "silence is golden" }, | 1209 {"u", "442"}}; |
1211 { "u", "442" } | |
1212 }; | |
1213 ASSERT(breakpoint_hit_counter < 2); | 1210 ASSERT(breakpoint_hit_counter < 2); |
1214 int expected_idx = breakpoint_hit_counter * expected_num_fields; | 1211 int expected_idx = breakpoint_hit_counter * expected_num_fields; |
1215 breakpoint_hit_counter++; | 1212 breakpoint_hit_counter++; |
1216 | 1213 |
1217 Dart_Handle fields = Dart_GetStaticFields(class_A); | 1214 Dart_Handle fields = Dart_GetStaticFields(class_A); |
1218 ASSERT(!Dart_IsError(fields)); | 1215 ASSERT(!Dart_IsError(fields)); |
1219 ASSERT(Dart_IsList(fields)); | 1216 ASSERT(Dart_IsList(fields)); |
1220 | 1217 |
1221 intptr_t list_length = 0; | 1218 intptr_t list_length = 0; |
1222 Dart_Handle retval = Dart_ListLength(fields, &list_length); | 1219 Dart_Handle retval = Dart_ListLength(fields, &list_length); |
(...skipping 18 matching lines...) Expand all Loading... |
1241 Dart_StringToCString(value_handle, &value); | 1238 Dart_StringToCString(value_handle, &value); |
1242 EXPECT_STREQ(expected[expected_idx].field_value, value); | 1239 EXPECT_STREQ(expected[expected_idx].field_value, value); |
1243 OS::Print(" %s: %s\n", name, value); | 1240 OS::Print(" %s: %s\n", name, value); |
1244 expected_idx++; | 1241 expected_idx++; |
1245 } | 1242 } |
1246 } | 1243 } |
1247 | 1244 |
1248 | 1245 |
1249 TEST_CASE(Debug_InspectStaticField) { | 1246 TEST_CASE(Debug_InspectStaticField) { |
1250 const char* kScriptChars = | 1247 const char* kScriptChars = |
1251 " class A { \n" | 1248 " class A { \n" |
1252 " static var bla = 'yada yada yada'; \n" | 1249 " static var bla = 'yada yada yada'; \n" |
1253 " static var u; \n" | 1250 " static var u; \n" |
1254 " } \n" | 1251 " } \n" |
1255 " \n" | 1252 " \n" |
1256 " debugBreak() { } \n" | 1253 " debugBreak() { } \n" |
1257 " main() { \n" | 1254 " main() { \n" |
1258 " var a = new A(); \n" | 1255 " var a = new A(); \n" |
1259 " debugBreak(); \n" | 1256 " debugBreak(); \n" |
1260 " A.u = 442; \n" | 1257 " A.u = 442; \n" |
1261 " A.bla = 'silence is golden'; \n" | 1258 " A.bla = 'silence is golden'; \n" |
1262 " debugBreak(); \n" | 1259 " debugBreak(); \n" |
1263 " } \n"; | 1260 " } \n"; |
1264 | 1261 |
1265 LoadScript(kScriptChars); | 1262 LoadScript(kScriptChars); |
1266 Dart_SetPausedEventHandler(&InspectStaticFieldHandler); | 1263 Dart_SetPausedEventHandler(&InspectStaticFieldHandler); |
1267 SetBreakpointAtEntry("", "debugBreak"); | 1264 SetBreakpointAtEntry("", "debugBreak"); |
1268 | 1265 |
1269 breakpoint_hit_counter = 0; | 1266 breakpoint_hit_counter = 0; |
1270 Dart_Handle retval = Invoke("main"); | 1267 Dart_Handle retval = Invoke("main"); |
1271 EXPECT_VALID(retval); | 1268 EXPECT_VALID(retval); |
1272 } | 1269 } |
1273 | 1270 |
1274 | 1271 |
1275 TEST_CASE(Debug_InspectObject) { | 1272 TEST_CASE(Debug_InspectObject) { |
1276 const char* kScriptChars = | 1273 const char* kScriptChars = |
1277 " class A { \n" | 1274 " class A { \n" |
1278 " var a_field = 'a'; \n" | 1275 " var a_field = 'a'; \n" |
1279 " static var bla = 'yada yada yada'; \n" | 1276 " static var bla = 'yada yada yada'; \n" |
1280 " static var error = unresolvedName(); \n" | 1277 " static var error = unresolvedName(); \n" |
1281 " var d = 42.1; \n" | 1278 " var d = 42.1; \n" |
1282 " } \n" | 1279 " } \n" |
1283 " class B extends A { \n" | 1280 " class B extends A { \n" |
1284 " var oneDay = const Duration(hours: 24); \n" | 1281 " var oneDay = const Duration(hours: 24); \n" |
1285 " static var bla = 'blah blah'; \n" | 1282 " static var bla = 'blah blah'; \n" |
1286 " } \n" | 1283 " } \n" |
1287 " get_b() { return new B(); } \n" | 1284 " get_b() { return new B(); } \n" |
1288 " get_int() { return 666; } \n"; | 1285 " get_int() { return 666; } \n"; |
1289 | 1286 |
1290 // Number of instance fields in an object of class B. | 1287 // Number of instance fields in an object of class B. |
1291 const intptr_t kNumObjectFields = 3; | 1288 const intptr_t kNumObjectFields = 3; |
1292 | 1289 |
1293 LoadScript(kScriptChars); | 1290 LoadScript(kScriptChars); |
1294 | 1291 |
1295 Dart_Handle object_b = Invoke("get_b"); | 1292 Dart_Handle object_b = Invoke("get_b"); |
1296 | 1293 |
1297 EXPECT_VALID(object_b); | 1294 EXPECT_VALID(object_b); |
1298 | 1295 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 "} \n" | 1518 "} \n" |
1522 "void main() { \n" | 1519 "void main() { \n" |
1523 " A.foo(); \n" | 1520 " A.foo(); \n" |
1524 "} \n"; | 1521 "} \n"; |
1525 | 1522 |
1526 Dart_Isolate isolate = TestCase::CreateTestIsolate(); | 1523 Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
1527 ASSERT(isolate != NULL); | 1524 ASSERT(isolate != NULL); |
1528 Dart_EnterScope(); | 1525 Dart_EnterScope(); |
1529 LoadScript(kScriptChars); | 1526 LoadScript(kScriptChars); |
1530 | 1527 |
1531 Dart_Handle result = Dart_SetNativeResolver(script_lib, | 1528 Dart_Handle result = |
1532 &InterruptNativeResolver, | 1529 Dart_SetNativeResolver(script_lib, &InterruptNativeResolver, NULL); |
1533 NULL); | |
1534 EXPECT_VALID(result); | 1530 EXPECT_VALID(result); |
1535 | 1531 |
1536 Dart_Handle retval = Invoke("main"); | 1532 Dart_Handle retval = Invoke("main"); |
1537 EXPECT_VALID(retval); | 1533 EXPECT_VALID(retval); |
1538 Dart_ExitScope(); | 1534 Dart_ExitScope(); |
1539 Dart_ShutdownIsolate(); | 1535 Dart_ShutdownIsolate(); |
1540 } | 1536 } |
1541 | 1537 |
1542 | 1538 |
1543 TEST_CASE(Debug_InterruptIsolate) { | 1539 TEST_CASE(Debug_InterruptIsolate) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 ml.Wait(); | 1579 ml.Wait(); |
1584 } | 1580 } |
1585 } | 1581 } |
1586 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); | 1582 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); |
1587 OS::PrintErr("Complete\n"); | 1583 OS::PrintErr("Complete\n"); |
1588 FLAG_trace_shutdown = saved_flag; | 1584 FLAG_trace_shutdown = saved_flag; |
1589 } | 1585 } |
1590 | 1586 |
1591 | 1587 |
1592 static void StackTraceDump1BreakpointHandler( | 1588 static void StackTraceDump1BreakpointHandler( |
1593 Dart_IsolateId isolate_id, | 1589 Dart_IsolateId isolate_id, |
1594 intptr_t bp_id, | 1590 intptr_t bp_id, |
1595 const Dart_CodeLocation& location) { | 1591 const Dart_CodeLocation& location) { |
1596 Dart_StackTrace trace; | 1592 Dart_StackTrace trace; |
1597 Dart_GetStackTrace(&trace); | 1593 Dart_GetStackTrace(&trace); |
1598 const int kStackTraceLen = 4; | 1594 const int kStackTraceLen = 4; |
1599 static const char* expected_trace[kStackTraceLen] = { | 1595 static const char* expected_trace[kStackTraceLen] = { |
1600 "local_to_main", | 1596 "local_to_main", "Test.local1_to_func1", "Test.func1", "main"}; |
1601 "Test.local1_to_func1", | |
1602 "Test.func1", | |
1603 "main" | |
1604 }; | |
1605 | 1597 |
1606 intptr_t trace_len; | 1598 intptr_t trace_len; |
1607 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 1599 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
1608 EXPECT_VALID(res); | 1600 EXPECT_VALID(res); |
1609 EXPECT_EQ(kStackTraceLen, trace_len); | 1601 EXPECT_EQ(kStackTraceLen, trace_len); |
1610 | 1602 |
1611 // Frame 0 corresponding to "local_to_main". | 1603 // Frame 0 corresponding to "local_to_main". |
1612 Dart_Handle frame0_locals = Dart_NewList(8); | 1604 Dart_Handle frame0_locals = Dart_NewList(8); |
1613 Dart_ListSetAt(frame0_locals, 0, NewString("i")); | 1605 Dart_ListSetAt(frame0_locals, 0, NewString("i")); |
1614 Dart_ListSetAt(frame0_locals, 1, Dart_NewInteger(76)); | 1606 Dart_ListSetAt(frame0_locals, 1, Dart_NewInteger(76)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 Dart_ListSetAt(frame3_locals, 5, Dart_Null()); | 1657 Dart_ListSetAt(frame3_locals, 5, Dart_Null()); |
1666 Dart_ListSetAt(frame3_locals, 6, NewString("sum")); | 1658 Dart_ListSetAt(frame3_locals, 6, NewString("sum")); |
1667 Dart_ListSetAt(frame3_locals, 7, Dart_NewInteger(0)); | 1659 Dart_ListSetAt(frame3_locals, 7, Dart_NewInteger(0)); |
1668 Dart_ListSetAt(frame3_locals, 8, NewString("value")); | 1660 Dart_ListSetAt(frame3_locals, 8, NewString("value")); |
1669 Dart_ListSetAt(frame3_locals, 9, Dart_Null()); | 1661 Dart_ListSetAt(frame3_locals, 9, Dart_Null()); |
1670 Dart_ListSetAt(frame3_locals, 10, NewString("func1")); | 1662 Dart_ListSetAt(frame3_locals, 10, NewString("func1")); |
1671 Dart_ListSetAt(frame3_locals, 11, Dart_Null()); | 1663 Dart_ListSetAt(frame3_locals, 11, Dart_Null()); |
1672 Dart_ListSetAt(frame3_locals, 12, NewString("main_local")); | 1664 Dart_ListSetAt(frame3_locals, 12, NewString("main_local")); |
1673 Dart_ListSetAt(frame3_locals, 13, Dart_Null()); | 1665 Dart_ListSetAt(frame3_locals, 13, Dart_Null()); |
1674 | 1666 |
1675 Dart_Handle expected_locals[] = { | 1667 Dart_Handle expected_locals[] = {frame0_locals, frame1_locals, frame2_locals, |
1676 frame0_locals, | 1668 frame3_locals}; |
1677 frame1_locals, | |
1678 frame2_locals, | |
1679 frame3_locals | |
1680 }; | |
1681 breakpoint_hit_counter++; | 1669 breakpoint_hit_counter++; |
1682 VerifyStackTrace(trace, expected_trace, expected_locals, | 1670 VerifyStackTrace(trace, expected_trace, expected_locals, kStackTraceLen, |
1683 kStackTraceLen, true); | 1671 true); |
1684 } | 1672 } |
1685 | 1673 |
1686 | 1674 |
1687 TEST_CASE(Debug_StackTraceDump1) { | 1675 TEST_CASE(Debug_StackTraceDump1) { |
1688 const char* kScriptChars = | 1676 const char* kScriptChars = |
1689 "class Test {\n" | 1677 "class Test {\n" |
1690 " Test(int local);\n" | 1678 " Test(int local);\n" |
1691 "\n" | 1679 "\n" |
1692 " int func1(int func(int i, int j)) {\n" | 1680 " int func1(int func(int i, int j)) {\n" |
1693 " var i = 0;\n" | 1681 " var i = 0;\n" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 EXPECT_EQ(195, int_value); | 1732 EXPECT_EQ(195, int_value); |
1745 EXPECT_EQ(1, breakpoint_hit_counter); | 1733 EXPECT_EQ(1, breakpoint_hit_counter); |
1746 } | 1734 } |
1747 | 1735 |
1748 | 1736 |
1749 static void StackTraceDump2ExceptionHandler(Dart_IsolateId isolate_id, | 1737 static void StackTraceDump2ExceptionHandler(Dart_IsolateId isolate_id, |
1750 Dart_Handle exception_object, | 1738 Dart_Handle exception_object, |
1751 Dart_StackTrace trace) { | 1739 Dart_StackTrace trace) { |
1752 const int kStackTraceLen = 5; | 1740 const int kStackTraceLen = 5; |
1753 static const char* expected_trace[kStackTraceLen] = { | 1741 static const char* expected_trace[kStackTraceLen] = { |
1754 "Object._noSuchMethod", | 1742 "Object._noSuchMethod", "Object.noSuchMethod", "Test.local1_to_func1", |
1755 "Object.noSuchMethod", | 1743 "Test.func1", "main"}; |
1756 "Test.local1_to_func1", | |
1757 "Test.func1", | |
1758 "main" | |
1759 }; | |
1760 | 1744 |
1761 intptr_t trace_len; | 1745 intptr_t trace_len; |
1762 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 1746 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
1763 EXPECT_VALID(res); | 1747 EXPECT_VALID(res); |
1764 EXPECT_EQ(kStackTraceLen, trace_len); | 1748 EXPECT_EQ(kStackTraceLen, trace_len); |
1765 | 1749 |
1766 // Frame 0 corresponding to "Object._noSuchMethod". | 1750 // Frame 0 corresponding to "Object._noSuchMethod". |
1767 Dart_Handle frame0_locals = Dart_NewList(12); | 1751 Dart_Handle frame0_locals = Dart_NewList(12); |
1768 Dart_ListSetAt(frame0_locals, 0, NewString("this")); | 1752 Dart_ListSetAt(frame0_locals, 0, NewString("this")); |
1769 Dart_ListSetAt(frame0_locals, 1, Dart_Null()); | 1753 Dart_ListSetAt(frame0_locals, 1, Dart_Null()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 Dart_ListSetAt(frame4_locals, 3, Dart_NewInteger(20)); | 1815 Dart_ListSetAt(frame4_locals, 3, Dart_NewInteger(20)); |
1832 Dart_ListSetAt(frame4_locals, 4, NewString("local_to_main")); | 1816 Dart_ListSetAt(frame4_locals, 4, NewString("local_to_main")); |
1833 Dart_ListSetAt(frame4_locals, 5, Dart_Null()); | 1817 Dart_ListSetAt(frame4_locals, 5, Dart_Null()); |
1834 Dart_ListSetAt(frame4_locals, 6, NewString("sum")); | 1818 Dart_ListSetAt(frame4_locals, 6, NewString("sum")); |
1835 Dart_ListSetAt(frame4_locals, 7, Dart_NewInteger(0)); | 1819 Dart_ListSetAt(frame4_locals, 7, Dart_NewInteger(0)); |
1836 Dart_ListSetAt(frame4_locals, 8, NewString("value")); | 1820 Dart_ListSetAt(frame4_locals, 8, NewString("value")); |
1837 Dart_ListSetAt(frame4_locals, 9, Dart_Null()); | 1821 Dart_ListSetAt(frame4_locals, 9, Dart_Null()); |
1838 Dart_ListSetAt(frame4_locals, 10, NewString("func1")); | 1822 Dart_ListSetAt(frame4_locals, 10, NewString("func1")); |
1839 Dart_ListSetAt(frame4_locals, 11, Dart_Null()); | 1823 Dart_ListSetAt(frame4_locals, 11, Dart_Null()); |
1840 | 1824 |
1841 Dart_Handle expected_locals[] = { | 1825 Dart_Handle expected_locals[] = {frame0_locals, frame1_locals, frame2_locals, |
1842 frame0_locals, | 1826 frame3_locals, frame4_locals}; |
1843 frame1_locals, | |
1844 frame2_locals, | |
1845 frame3_locals, | |
1846 frame4_locals | |
1847 }; | |
1848 breakpoint_hit_counter++; | 1827 breakpoint_hit_counter++; |
1849 VerifyStackTrace(trace, expected_trace, expected_locals, | 1828 VerifyStackTrace(trace, expected_trace, expected_locals, kStackTraceLen, |
1850 kStackTraceLen, true); | 1829 true); |
1851 } | 1830 } |
1852 | 1831 |
1853 | 1832 |
1854 TEST_CASE(Debug_StackTraceDump2) { | 1833 TEST_CASE(Debug_StackTraceDump2) { |
1855 const char* kScriptChars = | 1834 const char* kScriptChars = |
1856 "class Test {\n" | 1835 "class Test {\n" |
1857 " Test(int local);\n" | 1836 " Test(int local);\n" |
1858 "\n" | 1837 "\n" |
1859 " int func1(int func(int i, int j)) {\n" | 1838 " int func1(int func(int i, int j)) {\n" |
1860 " var i = 0;\n" | 1839 " var i = 0;\n" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 // List l now has 5 elements. | 2000 // List l now has 5 elements. |
2022 | 2001 |
2023 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1")); | 2002 len = Dart_EvaluateExpr(script_lib, NewString("l.length + 1")); |
2024 EXPECT_VALID(len); | 2003 EXPECT_VALID(len); |
2025 EXPECT(Dart_IsNumber(len)); | 2004 EXPECT(Dart_IsNumber(len)); |
2026 EXPECT_EQ(6, ToInt64(len)); | 2005 EXPECT_EQ(6, ToInt64(len)); |
2027 | 2006 |
2028 closure = Dart_EvaluateExpr(script_lib, NewString("(x) => l.length + x")); | 2007 closure = Dart_EvaluateExpr(script_lib, NewString("(x) => l.length + x")); |
2029 EXPECT_VALID(closure); | 2008 EXPECT_VALID(closure); |
2030 EXPECT(Dart_IsClosure(closure)); | 2009 EXPECT(Dart_IsClosure(closure)); |
2031 Dart_Handle args[1] = { Dart_NewInteger(1) }; | 2010 Dart_Handle args[1] = {Dart_NewInteger(1)}; |
2032 len = Dart_InvokeClosure(closure, 1, args); | 2011 len = Dart_InvokeClosure(closure, 1, args); |
2033 EXPECT_VALID(len); | 2012 EXPECT_VALID(len); |
2034 EXPECT(Dart_IsNumber(len)); | 2013 EXPECT(Dart_IsNumber(len)); |
2035 EXPECT_EQ(6, ToInt64(len)); | 2014 EXPECT_EQ(6, ToInt64(len)); |
2036 | 2015 |
2037 len = Dart_EvaluateExpr(script_lib, NewString("((x) => l.length + x)(1)")); | 2016 len = Dart_EvaluateExpr(script_lib, NewString("((x) => l.length + x)(1)")); |
2038 EXPECT_VALID(len); | 2017 EXPECT_VALID(len); |
2039 EXPECT(Dart_IsNumber(len)); | 2018 EXPECT(Dart_IsNumber(len)); |
2040 EXPECT_EQ(6, ToInt64(len)); | 2019 EXPECT_EQ(6, ToInt64(len)); |
2041 | 2020 |
(...skipping 28 matching lines...) Expand all Loading... |
2070 " Point(this.x, this.y); \n" | 2049 " Point(this.x, this.y); \n" |
2071 " get r => sqrt(x*x + y*y); \n" | 2050 " get r => sqrt(x*x + y*y); \n" |
2072 "} \n"; | 2051 "} \n"; |
2073 LoadScript(kScriptChars); | 2052 LoadScript(kScriptChars); |
2074 Dart_FinalizeLoading(false); | 2053 Dart_FinalizeLoading(false); |
2075 | 2054 |
2076 Dart_SetExceptionThrownHandler(&EvaluateInActivationOfEvaluateHandler); | 2055 Dart_SetExceptionThrownHandler(&EvaluateInActivationOfEvaluateHandler); |
2077 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); | 2056 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); |
2078 breakpoint_hit_counter = 0; | 2057 breakpoint_hit_counter = 0; |
2079 | 2058 |
2080 Dart_Handle result = Dart_EvaluateExpr(script_lib, NewString( | 2059 Dart_Handle result = Dart_EvaluateExpr( |
2081 "() { var p = new Point(3, 4); throw p; } ())")); | 2060 script_lib, NewString("() { var p = new Point(3, 4); throw p; } ())")); |
2082 EXPECT(Dart_IsError(result)); | 2061 EXPECT(Dart_IsError(result)); |
2083 EXPECT_EQ(1, breakpoint_hit_counter); | 2062 EXPECT_EQ(1, breakpoint_hit_counter); |
2084 } | 2063 } |
2085 | 2064 |
2086 | 2065 |
2087 static void UnhandledExceptionHandler(Dart_IsolateId isolate_id, | 2066 static void UnhandledExceptionHandler(Dart_IsolateId isolate_id, |
2088 Dart_Handle exception_object, | 2067 Dart_Handle exception_object, |
2089 Dart_StackTrace trace) { | 2068 Dart_StackTrace trace) { |
2090 breakpoint_hit_counter++; | 2069 breakpoint_hit_counter++; |
2091 } | 2070 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 Dart_Handle iterable_name = Dart_NewStringFromCString("Iterable"); | 2178 Dart_Handle iterable_name = Dart_NewStringFromCString("Iterable"); |
2200 Dart_Handle list_name = Dart_NewStringFromCString("List"); | 2179 Dart_Handle list_name = Dart_NewStringFromCString("List"); |
2201 | 2180 |
2202 Dart_Handle object_type = Dart_GetType(core_lib, object_name, 0, NULL); | 2181 Dart_Handle object_type = Dart_GetType(core_lib, object_name, 0, NULL); |
2203 Dart_Handle int_type = Dart_GetType(core_lib, int_name, 0, NULL); | 2182 Dart_Handle int_type = Dart_GetType(core_lib, int_name, 0, NULL); |
2204 EXPECT_VALID(int_type); | 2183 EXPECT_VALID(int_type); |
2205 Dart_Handle Test_type = Dart_GetType(script_lib, Test_name, 0, NULL); | 2184 Dart_Handle Test_type = Dart_GetType(script_lib, Test_name, 0, NULL); |
2206 Dart_Handle Test1_type = Dart_GetType(script_lib, Test1_name, 0, NULL); | 2185 Dart_Handle Test1_type = Dart_GetType(script_lib, Test1_name, 0, NULL); |
2207 Dart_Handle type_args = Dart_NewList(1); | 2186 Dart_Handle type_args = Dart_NewList(1); |
2208 Dart_ListSetAt(type_args, 0, int_type); | 2187 Dart_ListSetAt(type_args, 0, int_type); |
2209 Dart_Handle Test2_int_type = Dart_GetType(script_lib, | 2188 Dart_Handle Test2_int_type = |
2210 Test2_name, | 2189 Dart_GetType(script_lib, Test2_name, 1, &type_args); |
2211 1, | |
2212 &type_args); | |
2213 Dart_Handle Test3_type = Dart_GetType(script_lib, Test3_name, 0, NULL); | 2190 Dart_Handle Test3_type = Dart_GetType(script_lib, Test3_name, 0, NULL); |
2214 type_args = Dart_NewList(2); | 2191 type_args = Dart_NewList(2); |
2215 Dart_ListSetAt(type_args, 0, int_type); | 2192 Dart_ListSetAt(type_args, 0, int_type); |
2216 Dart_ListSetAt(type_args, 1, Test_type); | 2193 Dart_ListSetAt(type_args, 1, Test_type); |
2217 Dart_Handle Test4_int_type = Dart_GetType(script_lib, | 2194 Dart_Handle Test4_int_type = |
2218 Test4_name, | 2195 Dart_GetType(script_lib, Test4_name, 2, &type_args); |
2219 2, | |
2220 &type_args); | |
2221 type_args = Dart_NewList(3); | 2196 type_args = Dart_NewList(3); |
2222 Dart_ListSetAt(type_args, 0, int_type); | 2197 Dart_ListSetAt(type_args, 0, int_type); |
2223 Dart_ListSetAt(type_args, 1, Test_type); | 2198 Dart_ListSetAt(type_args, 1, Test_type); |
2224 Dart_ListSetAt(type_args, 2, int_type); | 2199 Dart_ListSetAt(type_args, 2, int_type); |
2225 Dart_Handle Test5_int_type = Dart_GetType(script_lib, | 2200 Dart_Handle Test5_int_type = |
2226 Test5_name, | 2201 Dart_GetType(script_lib, Test5_name, 3, &type_args); |
2227 3, | |
2228 &type_args); | |
2229 { | 2202 { |
2230 Dart_Handle super_type = Dart_GetSupertype(object_type); | 2203 Dart_Handle super_type = Dart_GetSupertype(object_type); |
2231 EXPECT(super_type == Dart_Null()); | 2204 EXPECT(super_type == Dart_Null()); |
2232 } | 2205 } |
2233 { | 2206 { |
2234 Dart_Handle super_type = Dart_GetSupertype(Test1_type); | 2207 Dart_Handle super_type = Dart_GetSupertype(Test1_type); |
2235 const Type& expected_type = Api::UnwrapTypeHandle(zone, Test_type); | 2208 const Type& expected_type = Api::UnwrapTypeHandle(zone, Test_type); |
2236 const Type& actual_type = Api::UnwrapTypeHandle(zone, super_type); | 2209 const Type& actual_type = Api::UnwrapTypeHandle(zone, super_type); |
2237 EXPECT(expected_type.raw() == actual_type.raw()); | 2210 EXPECT(expected_type.raw() == actual_type.raw()); |
2238 } | 2211 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2360 " null, 5, 17, 5, 18, 9, 19, 12," | 2333 " null, 5, 17, 5, 18, 9, 19, 12," |
2361 " null, 6, 21, 1," | 2334 " null, 6, 21, 1," |
2362 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," | 2335 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," |
2363 " null, 9, 29, 1]", | 2336 " null, 9, 29, 1]", |
2364 tokens_cstr); | 2337 tokens_cstr); |
2365 } | 2338 } |
2366 | 2339 |
2367 #endif | 2340 #endif |
2368 | 2341 |
2369 } // namespace dart | 2342 } // namespace dart |
OLD | NEW |