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

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

Issue 335443002: Setup R10/EDX to be valid Oops before stub calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 "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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 967
968 breakpoint_hit_counter = 0; 968 breakpoint_hit_counter = 0;
969 Dart_Handle retval = Invoke("main"); 969 Dart_Handle retval = Invoke("main");
970 EXPECT_VALID(retval); 970 EXPECT_VALID(retval);
971 int64_t int_value = ToInt64(retval); 971 int64_t int_value = ToInt64(retval);
972 EXPECT_EQ(30, int_value); 972 EXPECT_EQ(30, int_value);
973 EXPECT_EQ(1, breakpoint_hit_counter); 973 EXPECT_EQ(1, breakpoint_hit_counter);
974 } 974 }
975 975
976 976
977 void TestBreakpointHandlerWithVerify(Dart_IsolateId isolate_id,
978 Dart_Breakpoint bpt,
979 Dart_StackTrace trace) {
980 breakpoint_hit = true;
981 breakpoint_hit_counter++;
982
983 Dart_ActivationFrame frame;
984 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame);
985 EXPECT_VALID(res);
986 Dart_Handle func_name;
987 intptr_t line_number = -1;
988 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, &line_number, NULL);
989 EXPECT_NE(-1, line_number);
990 if (verbose) OS::Print("Hit line %" Pd "\n", line_number);
991
992 VerifyPointersVisitor::VerifyPointers();
993 }
994
995
996 static void NoopNativeFunction(Dart_NativeArguments args) {
997 Dart_EnterScope();
998 Dart_SetReturnValue(args, Dart_True());
999 Dart_ExitScope();
1000 }
1001
1002
1003 static Dart_NativeFunction NoopNativeResolver(Dart_Handle name,
1004 int arg_count,
1005 bool* auto_setup_scope) {
1006 ASSERT(auto_setup_scope != NULL);
1007 *auto_setup_scope = false;
1008 return &NoopNativeFunction;
1009 }
1010
1011
1012 TEST_CASE(Debug_BreakpointStubPatching) {
1013 // Note changes to this script may require changes to the breakpoint line
1014 // numbers below.
1015 const char* kScriptChars =
1016 "bar(i) {} \n"
1017 "nat() native 'a'; \n"
1018 "foo(n) { \n"
1019 " for(var i = 0; i < n; i++) { \n"
1020 " bar(i); \n" // Static call.
1021 " i++; \n" // Instance call.
1022 " i == null; \n" // Equality.
1023 " var x = i; \n" // Debug step check.
1024 " i is int; \n" // Subtype test.
1025 " y(z) => () => z + i; \n" // Allocate context.
1026 " y(i)(); \n" // Closure call.
1027 " nat(); \n" // Runtime call.
1028 " return y; \n" // Return.
1029 " } \n"
1030 "} \n"
1031 " \n"
1032 "main() { \n"
1033 " var i = 3; \n"
1034 " foo(i); \n"
1035 "} \n";
1036
1037 LoadScript(kScriptChars);
1038 Dart_Handle result = Dart_SetNativeResolver(script_lib,
1039 &NoopNativeResolver,
1040 NULL);
1041 EXPECT_VALID(result);
1042 Dart_SetBreakpointHandler(&TestBreakpointHandlerWithVerify);
1043
1044 Dart_Handle script_url = NewString(TestCase::url());
1045
1046 const intptr_t num_breakpoints = 9;
1047 intptr_t breakpoint_lines[num_breakpoints] =
1048 {5, 6, 7, 8, 9, 10, 11, 12, 13};
1049
1050 for (intptr_t i = 0; i < num_breakpoints; i++) {
1051 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]);
1052 EXPECT_VALID(result);
1053 EXPECT(Dart_IsInteger(result));
1054 }
1055
1056 breakpoint_hit = false;
1057 breakpoint_hit_counter = 0;
1058 Dart_Handle retval = Invoke("main");
1059 EXPECT_VALID(retval);
1060 EXPECT(breakpoint_hit == true);
1061 EXPECT_EQ(num_breakpoints, breakpoint_hit_counter);
1062 }
1063
1064
977 static intptr_t bp_id_to_be_deleted; 1065 static intptr_t bp_id_to_be_deleted;
978 1066
979 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id, 1067 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id,
980 intptr_t bp_id, 1068 intptr_t bp_id,
981 const Dart_CodeLocation& location) { 1069 const Dart_CodeLocation& location) {
982 Dart_StackTrace trace; 1070 Dart_StackTrace trace;
983 Dart_GetStackTrace(&trace); 1071 Dart_GetStackTrace(&trace);
984 const char* expected_trace[] = {"foo", "main"}; 1072 const char* expected_trace[] = {"foo", "main"};
985 const intptr_t expected_trace_length = 2; 1073 const intptr_t expected_trace_length = 2;
986 breakpoint_hit_counter++; 1074 breakpoint_hit_counter++;
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," 2221 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13,"
2134 " null, 4, 13, 3, 14, 10," 2222 " null, 4, 13, 3, 14, 10,"
2135 " null, 5, 17, 5, 18, 9, 19, 12," 2223 " null, 5, 17, 5, 18, 9, 19, 12,"
2136 " null, 6, 21, 1," 2224 " null, 6, 21, 1,"
2137 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," 2225 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8,"
2138 " null, 9, 29, 1]", 2226 " null, 9, 29, 1]",
2139 tokens_cstr); 2227 tokens_cstr);
2140 } 2228 }
2141 2229
2142 } // namespace dart 2230 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm.cc » ('j') | runtime/vm/flow_graph_compiler_ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698