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

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

Issue 110913002: Transmit breakpoint id on paused event (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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/debugger_api_impl.cc ('k') | tools/ddbg.dart » ('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) 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 "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_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/thread.h" 9 #include "vm/thread.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 buffer_size -= pos; 382 buffer_size -= pos;
383 } 383 }
384 pos = OS::SNPrint(buffer, buffer_size, "}\n"); 384 pos = OS::SNPrint(buffer, buffer_size, "}\n");
385 buffer += pos; 385 buffer += pos;
386 buffer_size -= pos; 386 buffer_size -= pos;
387 } 387 }
388 } 388 }
389 389
390 390
391 static void InspectOptimizedStack_Breakpoint(Dart_IsolateId isolate_id, 391 static void InspectOptimizedStack_Breakpoint(Dart_IsolateId isolate_id,
392 intptr_t bp_id,
392 const Dart_CodeLocation& loc) { 393 const Dart_CodeLocation& loc) {
393 Dart_StackTrace trace; 394 Dart_StackTrace trace;
394 Dart_GetStackTrace(&trace); 395 Dart_GetStackTrace(&trace);
395 SaveStackTrace(trace); 396 SaveStackTrace(trace);
396 } 397 }
397 398
398 399
399 static void InspectStackTest(bool optimize) { 400 static void InspectStackTest(bool optimize) {
400 const char* kScriptChars = 401 const char* kScriptChars =
401 "void breakpointNow() {\n" 402 "void breakpointNow() {\n"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 InspectStackWithClosureTest(false); 577 InspectStackWithClosureTest(false);
577 } 578 }
578 579
579 580
580 TEST_CASE(Debug_InspectStackWithClosure_Optimized) { 581 TEST_CASE(Debug_InspectStackWithClosure_Optimized) {
581 InspectStackWithClosureTest(true); 582 InspectStackWithClosureTest(true);
582 } 583 }
583 584
584 585
585 void TestStepOutHandler(Dart_IsolateId isolate_id, 586 void TestStepOutHandler(Dart_IsolateId isolate_id,
587 intptr_t bp_id,
586 const Dart_CodeLocation& location) { 588 const Dart_CodeLocation& location) {
587 Dart_StackTrace trace; 589 Dart_StackTrace trace;
588 Dart_GetStackTrace(&trace); 590 Dart_GetStackTrace(&trace);
589 const char* expected_bpts[] = {"f1", "foo", "main"}; 591 const char* expected_bpts[] = {"f1", "foo", "main"};
590 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); 592 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts);
591 intptr_t trace_len; 593 intptr_t trace_len;
592 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 594 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
593 EXPECT_VALID(res); 595 EXPECT_VALID(res);
594 EXPECT(breakpoint_hit_counter < expected_bpts_length); 596 EXPECT(breakpoint_hit_counter < expected_bpts_length);
595 Dart_ActivationFrame frame; 597 Dart_ActivationFrame frame;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 Dart_Handle retval = Invoke("main"); 642 Dart_Handle retval = Invoke("main");
641 EXPECT_VALID(retval); 643 EXPECT_VALID(retval);
642 EXPECT(Dart_IsInteger(retval)); 644 EXPECT(Dart_IsInteger(retval));
643 int64_t int_value = ToInt64(retval); 645 int64_t int_value = ToInt64(retval);
644 EXPECT_EQ(2, int_value); 646 EXPECT_EQ(2, int_value);
645 EXPECT(breakpoint_hit == true); 647 EXPECT(breakpoint_hit == true);
646 } 648 }
647 649
648 650
649 void TestStepIntoHandler(Dart_IsolateId isolate_id, 651 void TestStepIntoHandler(Dart_IsolateId isolate_id,
652 intptr_t bp_id,
650 const Dart_CodeLocation& location) { 653 const Dart_CodeLocation& location) {
651 Dart_StackTrace trace; 654 Dart_StackTrace trace;
652 Dart_GetStackTrace(&trace); 655 Dart_GetStackTrace(&trace);
653 const char* expected_bpts[] = { 656 const char* expected_bpts[] = {
654 "main", 657 "main",
655 "foo", 658 "foo",
656 "f1", 659 "f1",
657 "foo", 660 "foo",
658 "X.X.", 661 "X.X.",
659 "X.X.", 662 "X.X.",
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 Dart_Handle retval = Invoke("main"); 724 Dart_Handle retval = Invoke("main");
722 EXPECT_VALID(retval); 725 EXPECT_VALID(retval);
723 EXPECT(Dart_IsInteger(retval)); 726 EXPECT(Dart_IsInteger(retval));
724 int64_t int_value = ToInt64(retval); 727 int64_t int_value = ToInt64(retval);
725 EXPECT_EQ(7, int_value); 728 EXPECT_EQ(7, int_value);
726 EXPECT(breakpoint_hit == true); 729 EXPECT(breakpoint_hit == true);
727 } 730 }
728 731
729 732
730 static void StepIntoHandler(Dart_IsolateId isolate_id, 733 static void StepIntoHandler(Dart_IsolateId isolate_id,
734 intptr_t bp_id,
731 const Dart_CodeLocation& location) { 735 const Dart_CodeLocation& location) {
732 Dart_StackTrace trace; 736 Dart_StackTrace trace;
733 Dart_GetStackTrace(&trace); 737 Dart_GetStackTrace(&trace);
734 if (verbose) { 738 if (verbose) {
735 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", 739 OS::Print(">>> Breakpoint nr. %d in %s <<<\n",
736 breakpoint_hit_counter, BreakpointInfo(trace)); 740 breakpoint_hit_counter, BreakpointInfo(trace));
737 PrintStackTrace(trace); 741 PrintStackTrace(trace);
738 } 742 }
739 breakpoint_hit = true; 743 breakpoint_hit = true;
740 breakpoint_hit_counter++; 744 breakpoint_hit_counter++;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 Dart_Handle retval = Invoke("main"); 807 Dart_Handle retval = Invoke("main");
804 EXPECT_VALID(retval); 808 EXPECT_VALID(retval);
805 EXPECT(Dart_IsInteger(retval)); 809 EXPECT(Dart_IsInteger(retval));
806 int64_t int_value = ToInt64(retval); 810 int64_t int_value = ToInt64(retval);
807 EXPECT_EQ(2 * 99, int_value); 811 EXPECT_EQ(2 * 99, int_value);
808 EXPECT(breakpoint_hit == true); 812 EXPECT(breakpoint_hit == true);
809 } 813 }
810 814
811 815
812 void TestSingleStepHandler(Dart_IsolateId isolate_id, 816 void TestSingleStepHandler(Dart_IsolateId isolate_id,
817 intptr_t bp_id,
813 const Dart_CodeLocation& location) { 818 const Dart_CodeLocation& location) {
814 Dart_StackTrace trace; 819 Dart_StackTrace trace;
815 Dart_GetStackTrace(&trace); 820 Dart_GetStackTrace(&trace);
816 const char* expected_bpts[] = { 821 const char* expected_bpts[] = {
817 "moo", "foo", "moo", "foo", "moo", "foo", "main"}; 822 "moo", "foo", "moo", "foo", "moo", "foo", "main"};
818 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); 823 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts);
819 intptr_t trace_len; 824 intptr_t trace_len;
820 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 825 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
821 EXPECT_VALID(res); 826 EXPECT_VALID(res);
822 EXPECT(breakpoint_hit_counter < expected_bpts_length); 827 EXPECT(breakpoint_hit_counter < expected_bpts_length);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 867
863 breakpoint_hit = false; 868 breakpoint_hit = false;
864 breakpoint_hit_counter = 0; 869 breakpoint_hit_counter = 0;
865 Dart_Handle retval = Invoke("main"); 870 Dart_Handle retval = Invoke("main");
866 EXPECT_VALID(retval); 871 EXPECT_VALID(retval);
867 EXPECT(breakpoint_hit == true); 872 EXPECT(breakpoint_hit == true);
868 } 873 }
869 874
870 875
871 static void ClosureBreakpointHandler(Dart_IsolateId isolate_id, 876 static void ClosureBreakpointHandler(Dart_IsolateId isolate_id,
877 intptr_t bp_id,
872 const Dart_CodeLocation& location) { 878 const Dart_CodeLocation& location) {
873 Dart_StackTrace trace; 879 Dart_StackTrace trace;
874 Dart_GetStackTrace(&trace); 880 Dart_GetStackTrace(&trace);
875 const char* expected_trace[] = {"callback", "main"}; 881 const char* expected_trace[] = {"callback", "main"};
876 const intptr_t expected_trace_length = 2; 882 const intptr_t expected_trace_length = 2;
877 breakpoint_hit_counter++; 883 breakpoint_hit_counter++;
878 intptr_t trace_len; 884 intptr_t trace_len;
879 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 885 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
880 EXPECT_VALID(res); 886 EXPECT_VALID(res);
881 EXPECT_EQ(expected_trace_length, trace_len); 887 EXPECT_EQ(expected_trace_length, trace_len);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 breakpoint_hit_counter = 0; 922 breakpoint_hit_counter = 0;
917 Dart_Handle retval = Invoke("main"); 923 Dart_Handle retval = Invoke("main");
918 EXPECT_VALID(retval); 924 EXPECT_VALID(retval);
919 int64_t int_value = ToInt64(retval); 925 int64_t int_value = ToInt64(retval);
920 EXPECT_EQ(442, int_value); 926 EXPECT_EQ(442, int_value);
921 EXPECT_EQ(2, breakpoint_hit_counter); 927 EXPECT_EQ(2, breakpoint_hit_counter);
922 } 928 }
923 929
924 930
925 static void ExprClosureBreakpointHandler(Dart_IsolateId isolate_id, 931 static void ExprClosureBreakpointHandler(Dart_IsolateId isolate_id,
932 intptr_t bp_id,
926 const Dart_CodeLocation& location) { 933 const Dart_CodeLocation& location) {
927 Dart_StackTrace trace; 934 Dart_StackTrace trace;
928 Dart_GetStackTrace(&trace); 935 Dart_GetStackTrace(&trace);
929 static const char* expected_trace[] = {"<anonymous closure>", "main"}; 936 static const char* expected_trace[] = {"<anonymous closure>", "main"};
930 Dart_Handle add_locals = Dart_NewList(4); 937 Dart_Handle add_locals = Dart_NewList(4);
931 Dart_ListSetAt(add_locals, 0, NewString("a")); 938 Dart_ListSetAt(add_locals, 0, NewString("a"));
932 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10)); 939 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10));
933 Dart_ListSetAt(add_locals, 2, NewString("b")); 940 Dart_ListSetAt(add_locals, 2, NewString("b"));
934 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20)); 941 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20));
935 Dart_Handle expected_locals[] = {add_locals, Dart_Null()}; 942 Dart_Handle expected_locals[] = {add_locals, Dart_Null()};
(...skipping 28 matching lines...) Expand all
964 EXPECT_VALID(retval); 971 EXPECT_VALID(retval);
965 int64_t int_value = ToInt64(retval); 972 int64_t int_value = ToInt64(retval);
966 EXPECT_EQ(30, int_value); 973 EXPECT_EQ(30, int_value);
967 EXPECT_EQ(1, breakpoint_hit_counter); 974 EXPECT_EQ(1, breakpoint_hit_counter);
968 } 975 }
969 976
970 977
971 static intptr_t bp_id_to_be_deleted; 978 static intptr_t bp_id_to_be_deleted;
972 979
973 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id, 980 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id,
981 intptr_t bp_id,
974 const Dart_CodeLocation& location) { 982 const Dart_CodeLocation& location) {
975 Dart_StackTrace trace; 983 Dart_StackTrace trace;
976 Dart_GetStackTrace(&trace); 984 Dart_GetStackTrace(&trace);
977 const char* expected_trace[] = {"foo", "main"}; 985 const char* expected_trace[] = {"foo", "main"};
978 const intptr_t expected_trace_length = 2; 986 const intptr_t expected_trace_length = 2;
979 breakpoint_hit_counter++; 987 breakpoint_hit_counter++;
980 intptr_t trace_len; 988 intptr_t trace_len;
981 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 989 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
982 EXPECT_VALID(res); 990 EXPECT_VALID(res);
983 EXPECT_EQ(expected_trace_length, trace_len); 991 EXPECT_EQ(expected_trace_length, trace_len);
984 for (int i = 0; i < trace_len; i++) { 992 for (int i = 0; i < trace_len; i++) {
985 Dart_ActivationFrame frame; 993 Dart_ActivationFrame frame;
986 res = Dart_GetActivationFrame(trace, i, &frame); 994 res = Dart_GetActivationFrame(trace, i, &frame);
987 EXPECT_VALID(res); 995 EXPECT_VALID(res);
988 Dart_Handle func_name; 996 Dart_Handle func_name;
989 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL); 997 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL);
990 EXPECT_VALID(res); 998 EXPECT_VALID(res);
991 EXPECT(Dart_IsString(func_name)); 999 EXPECT(Dart_IsString(func_name));
992 const char* name_chars; 1000 const char* name_chars;
993 Dart_StringToCString(func_name, &name_chars); 1001 Dart_StringToCString(func_name, &name_chars);
994 EXPECT_STREQ(expected_trace[i], name_chars); 1002 EXPECT_STREQ(expected_trace[i], name_chars);
995 if (verbose) OS::Print(" >> %d: %s\n", i, name_chars); 1003 if (verbose) OS::Print(" >> %d: %s\n", i, name_chars);
996 } 1004 }
997 // Remove the breakpoint after we've hit it twice 1005 // Remove the breakpoint after we've hit it twice
998 if (breakpoint_hit_counter == 2) { 1006 if (breakpoint_hit_counter == 2) {
999 if (verbose) OS::Print("uninstalling breakpoint\n"); 1007 if (verbose) OS::Print("uninstalling breakpoint\n");
1000 Dart_Handle res = Dart_RemoveBreakpoint(bp_id_to_be_deleted); 1008 EXPECT_EQ(bp_id_to_be_deleted, bp_id);
1009 Dart_Handle res = Dart_RemoveBreakpoint(bp_id);
1001 EXPECT_VALID(res); 1010 EXPECT_VALID(res);
1002 } 1011 }
1003 } 1012 }
1004 1013
1005 1014
1006 TEST_CASE(Debug_DeleteBreakpoint) { 1015 TEST_CASE(Debug_DeleteBreakpoint) {
1007 const char* kScriptChars = 1016 const char* kScriptChars =
1008 "moo(s) { } \n" 1017 "moo(s) { } \n"
1009 " \n" 1018 " \n"
1010 "foo() { \n" 1019 "foo() { \n"
(...skipping 23 matching lines...) Expand all
1034 // to fire twice only. 1043 // to fire twice only.
1035 bp_id_to_be_deleted = bp_id; 1044 bp_id_to_be_deleted = bp_id;
1036 breakpoint_hit_counter = 0; 1045 breakpoint_hit_counter = 0;
1037 Dart_Handle retval = Invoke("main"); 1046 Dart_Handle retval = Invoke("main");
1038 EXPECT_VALID(retval); 1047 EXPECT_VALID(retval);
1039 EXPECT_EQ(2, breakpoint_hit_counter); 1048 EXPECT_EQ(2, breakpoint_hit_counter);
1040 } 1049 }
1041 1050
1042 1051
1043 static void InspectStaticFieldHandler(Dart_IsolateId isolate_id, 1052 static void InspectStaticFieldHandler(Dart_IsolateId isolate_id,
1053 intptr_t bp_id,
1044 const Dart_CodeLocation& location) { 1054 const Dart_CodeLocation& location) {
1045 Dart_StackTrace trace; 1055 Dart_StackTrace trace;
1046 Dart_GetStackTrace(&trace); 1056 Dart_GetStackTrace(&trace);
1047 ASSERT(script_lib != NULL); 1057 ASSERT(script_lib != NULL);
1048 ASSERT(!Dart_IsError(script_lib)); 1058 ASSERT(!Dart_IsError(script_lib));
1049 ASSERT(Dart_IsLibrary(script_lib)); 1059 ASSERT(Dart_IsLibrary(script_lib));
1050 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A")); 1060 Dart_Handle class_A = Dart_GetClass(script_lib, NewString("A"));
1051 EXPECT_VALID(class_A); 1061 EXPECT_VALID(class_A);
1052 1062
1053 const int expected_num_fields = 2; 1063 const int expected_num_fields = 2;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { 1422 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
1413 ml.Wait(); 1423 ml.Wait();
1414 } 1424 }
1415 } 1425 }
1416 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1426 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1417 } 1427 }
1418 1428
1419 1429
1420 static void StackTraceDump1BreakpointHandler( 1430 static void StackTraceDump1BreakpointHandler(
1421 Dart_IsolateId isolate_id, 1431 Dart_IsolateId isolate_id,
1432 intptr_t bp_id,
1422 const Dart_CodeLocation& location) { 1433 const Dart_CodeLocation& location) {
1423 Dart_StackTrace trace; 1434 Dart_StackTrace trace;
1424 Dart_GetStackTrace(&trace); 1435 Dart_GetStackTrace(&trace);
1425 const int kStackTraceLen = 4; 1436 const int kStackTraceLen = 4;
1426 static const char* expected_trace[kStackTraceLen] = { 1437 static const char* expected_trace[kStackTraceLen] = {
1427 "local_to_main", 1438 "local_to_main",
1428 "Test.local1_to_func1", 1439 "Test.local1_to_func1",
1429 "Test.func1", 1440 "Test.func1",
1430 "main" 1441 "main"
1431 }; 1442 };
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); 1740 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions);
1730 1741
1731 Dart_Handle retval = Invoke("main"); 1742 Dart_Handle retval = Invoke("main");
1732 EXPECT(Dart_IsError(retval)); 1743 EXPECT(Dart_IsError(retval));
1733 EXPECT(Dart_IsUnhandledExceptionError(retval)); 1744 EXPECT(Dart_IsUnhandledExceptionError(retval));
1734 EXPECT_EQ(1, breakpoint_hit_counter); 1745 EXPECT_EQ(1, breakpoint_hit_counter);
1735 } 1746 }
1736 1747
1737 1748
1738 void TestEvaluateHandler(Dart_IsolateId isolate_id, 1749 void TestEvaluateHandler(Dart_IsolateId isolate_id,
1750 intptr_t bp_id,
1739 const Dart_CodeLocation& location) { 1751 const Dart_CodeLocation& location) {
1740 Dart_StackTrace trace; 1752 Dart_StackTrace trace;
1741 Dart_GetStackTrace(&trace); 1753 Dart_GetStackTrace(&trace);
1742 intptr_t trace_len; 1754 intptr_t trace_len;
1743 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 1755 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
1744 EXPECT_VALID(res); 1756 EXPECT_VALID(res);
1745 EXPECT_EQ(1, trace_len); 1757 EXPECT_EQ(1, trace_len);
1746 Dart_ActivationFrame frame; 1758 Dart_ActivationFrame frame;
1747 res = Dart_GetActivationFrame(trace, 0, &frame); 1759 res = Dart_GetActivationFrame(trace, 0, &frame);
1748 EXPECT_VALID(res); 1760 EXPECT_VALID(res);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 2058
2047 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); 2059 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj);
2048 Dart_Handle super_type = Dart_GetSupertype(list_type); 2060 Dart_Handle super_type = Dart_GetSupertype(list_type);
2049 EXPECT(!Dart_IsError(super_type)); 2061 EXPECT(!Dart_IsError(super_type));
2050 super_type = Dart_GetSupertype(super_type); 2062 super_type = Dart_GetSupertype(super_type);
2051 EXPECT(!Dart_IsError(super_type)); 2063 EXPECT(!Dart_IsError(super_type));
2052 EXPECT(super_type == Dart_Null()); 2064 EXPECT(super_type == Dart_Null());
2053 } 2065 }
2054 2066
2055 } // namespace dart 2067 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | tools/ddbg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698