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

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;
988 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, &line_number, NULL);
989 OS::Print("Hit line %" Pd "\n", line_number);
siva 2014/06/12 23:11:34 Is the print necessary? You could just do intptr_
rmacnak 2014/06/12 23:50:15 This was for debugging why I wasn't hitting the ex
990
991 VerifyPointersVisitor::VerifyPointers();
992 }
993
994
995 static void NoopNativeFunction(Dart_NativeArguments args) {
996 Dart_EnterScope();
997 Dart_SetReturnValue(args, Dart_True());
998 Dart_ExitScope();
999 }
1000
1001
1002 static Dart_NativeFunction NoopNativeResolver(Dart_Handle name,
1003 int arg_count,
1004 bool* auto_setup_scope) {
1005 ASSERT(auto_setup_scope != NULL);
1006 *auto_setup_scope = false;
1007 return &NoopNativeFunction;
1008 }
1009
1010
1011 TEST_CASE(Debug_BreakpointStubPatching) {
siva 2014/06/12 23:11:34 Maybe you should add a comment here that if somebo
rmacnak 2014/06/12 23:50:15 Added.
1012 const char* kScriptChars =
1013 "bar(i) {} \n"
1014 "nat() native 'a'; \n"
1015 "foo(n) { \n"
1016 " for(var i = 0; i < n; i++) { \n"
1017 " bar(i); \n" // Static call.
1018 " i++; \n" // Instance call.
1019 " i == null; \n" // Equality.
1020 " var x = i; \n" // Debug step check.
1021 " i is int; \n" // Subtype test.
1022 " y(z) => () => z + i; \n" // Allocate context.
1023 " y(i)(); \n" // Closure call.
1024 " nat(); \n" // Runtime call.
1025 " return y; \n" // Return.
1026 " } \n"
1027 "} \n"
1028 " \n"
1029 "main() { \n"
1030 " var i = 3; \n"
1031 " foo(i); \n"
1032 "} \n";
1033
1034 LoadScript(kScriptChars);
1035 Dart_Handle result = Dart_SetNativeResolver(script_lib,
1036 &NoopNativeResolver,
1037 NULL);
1038 EXPECT_VALID(result);
1039 Dart_SetBreakpointHandler(&TestBreakpointHandlerWithVerify);
1040
1041 Dart_Handle script_url = NewString(TestCase::url());
1042
1043 const intptr_t num_breakpoints = 9;
1044 intptr_t breakpoint_lines[num_breakpoints] =
1045 {5, 6, 7, 8, 9, 10, 11, 12, 13};
1046
1047 for (intptr_t i = 0; i < num_breakpoints; i++) {
1048 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]);
1049 EXPECT_VALID(result);
1050 EXPECT(Dart_IsInteger(result));
1051 }
1052
1053 breakpoint_hit = false;
1054 breakpoint_hit_counter = 0;
1055 Dart_Handle retval = Invoke("main");
1056 EXPECT_VALID(retval);
1057 EXPECT(breakpoint_hit == true);
1058 EXPECT_EQ(num_breakpoints, breakpoint_hit_counter);
1059 }
1060
1061
977 static intptr_t bp_id_to_be_deleted; 1062 static intptr_t bp_id_to_be_deleted;
978 1063
979 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id, 1064 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id,
980 intptr_t bp_id, 1065 intptr_t bp_id,
981 const Dart_CodeLocation& location) { 1066 const Dart_CodeLocation& location) {
982 Dart_StackTrace trace; 1067 Dart_StackTrace trace;
983 Dart_GetStackTrace(&trace); 1068 Dart_GetStackTrace(&trace);
984 const char* expected_trace[] = {"foo", "main"}; 1069 const char* expected_trace[] = {"foo", "main"};
985 const intptr_t expected_trace_length = 2; 1070 const intptr_t expected_trace_length = 2;
986 breakpoint_hit_counter++; 1071 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," 2218 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13,"
2134 " null, 4, 13, 3, 14, 10," 2219 " null, 4, 13, 3, 14, 10,"
2135 " null, 5, 17, 5, 18, 9, 19, 12," 2220 " null, 5, 17, 5, 18, 9, 19, 12,"
2136 " null, 6, 21, 1," 2221 " null, 6, 21, 1,"
2137 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," 2222 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8,"
2138 " null, 9, 29, 1]", 2223 " null, 9, 29, 1]",
2139 tokens_cstr); 2224 tokens_cstr);
2140 } 2225 }
2141 2226
2142 } // namespace dart 2227 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm.cc » ('j') | runtime/vm/flow_graph_compiler_mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698