| 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_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/lockers.h" | 9 #include "vm/lockers.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 last_frame_pointer = frame_pointer; | 287 last_frame_pointer = frame_pointer; |
| 288 if (i < expected_frames) { | 288 if (i < expected_frames) { |
| 289 VerifyStackFrame(frame, func_names[i], local_vars[i], skip_null_expects); | 289 VerifyStackFrame(frame, func_names[i], local_vars[i], skip_null_expects); |
| 290 } else { | 290 } else { |
| 291 VerifyStackFrame(frame, NULL, Dart_Null(), skip_null_expects); | 291 VerifyStackFrame(frame, NULL, Dart_Null(), skip_null_expects); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 // TODO(hausner): Convert this one remaining use of the legacy | |
| 298 // breakpoint handler once Dart_SetBreakpointHandler goes away. | |
| 299 void TestBreakpointHandler(Dart_IsolateId isolate_id, | 297 void TestBreakpointHandler(Dart_IsolateId isolate_id, |
| 300 Dart_Breakpoint bpt, | 298 intptr_t bp_id, |
| 301 Dart_StackTrace trace) { | 299 const Dart_CodeLocation& location) { |
| 302 const char* expected_trace[] = {"A.foo", "main"}; | 300 const char* expected_trace[] = {"A.foo", "main"}; |
| 303 const intptr_t expected_trace_length = 2; | 301 const intptr_t expected_trace_length = 2; |
| 304 breakpoint_hit = true; | 302 breakpoint_hit = true; |
| 305 breakpoint_hit_counter++; | 303 breakpoint_hit_counter++; |
| 304 Dart_StackTrace trace; |
| 305 Dart_GetStackTrace(&trace); |
| 306 intptr_t trace_len; | 306 intptr_t trace_len; |
| 307 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 307 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
| 308 EXPECT_VALID(res); | 308 EXPECT_VALID(res); |
| 309 EXPECT_EQ(expected_trace_length, trace_len); | 309 EXPECT_EQ(expected_trace_length, trace_len); |
| 310 for (int i = 0; i < trace_len; i++) { | 310 for (int i = 0; i < trace_len; i++) { |
| 311 Dart_ActivationFrame frame; | 311 Dart_ActivationFrame frame; |
| 312 res = Dart_GetActivationFrame(trace, i, &frame); | 312 res = Dart_GetActivationFrame(trace, i, &frame); |
| 313 EXPECT_VALID(res); | 313 EXPECT_VALID(res); |
| 314 Dart_Handle func_name; | 314 Dart_Handle func_name; |
| 315 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL); | 315 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL, NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 329 "class A { \n" | 329 "class A { \n" |
| 330 " static void foo() { \n" | 330 " static void foo() { \n" |
| 331 " moo('good news'); \n" | 331 " moo('good news'); \n" |
| 332 " } \n" | 332 " } \n" |
| 333 "} \n" | 333 "} \n" |
| 334 "void main() { \n" | 334 "void main() { \n" |
| 335 " A.foo(); \n" | 335 " A.foo(); \n" |
| 336 "} \n"; | 336 "} \n"; |
| 337 | 337 |
| 338 LoadScript(kScriptChars); | 338 LoadScript(kScriptChars); |
| 339 Dart_SetBreakpointHandler(&TestBreakpointHandler); | 339 Dart_SetPausedEventHandler(&TestBreakpointHandler); |
| 340 SetBreakpointAtEntry("A", "foo"); | 340 SetBreakpointAtEntry("A", "foo"); |
| 341 | 341 |
| 342 breakpoint_hit = false; | 342 breakpoint_hit = false; |
| 343 Dart_Handle retval = Invoke("main"); | 343 Dart_Handle retval = Invoke("main"); |
| 344 EXPECT_VALID(retval); | 344 EXPECT_VALID(retval); |
| 345 EXPECT(breakpoint_hit == true); | 345 EXPECT(breakpoint_hit == true); |
| 346 } | 346 } |
| 347 | 347 |
| 348 static const int stack_buffer_size = 1024; | 348 static const int stack_buffer_size = 1024; |
| 349 static char stack_buffer[stack_buffer_size]; | 349 static char stack_buffer[stack_buffer_size]; |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 breakpoint_hit_counter = 0; | 978 breakpoint_hit_counter = 0; |
| 979 Dart_Handle retval = Invoke("main"); | 979 Dart_Handle retval = Invoke("main"); |
| 980 EXPECT_VALID(retval); | 980 EXPECT_VALID(retval); |
| 981 int64_t int_value = ToInt64(retval); | 981 int64_t int_value = ToInt64(retval); |
| 982 EXPECT_EQ(30, int_value); | 982 EXPECT_EQ(30, int_value); |
| 983 EXPECT_EQ(1, breakpoint_hit_counter); | 983 EXPECT_EQ(1, breakpoint_hit_counter); |
| 984 } | 984 } |
| 985 | 985 |
| 986 | 986 |
| 987 void TestBreakpointHandlerWithVerify(Dart_IsolateId isolate_id, | 987 void TestBreakpointHandlerWithVerify(Dart_IsolateId isolate_id, |
| 988 Dart_Breakpoint bpt, | 988 intptr_t bp_id, |
| 989 Dart_StackTrace trace) { | 989 const Dart_CodeLocation& location) { |
| 990 breakpoint_hit = true; | 990 breakpoint_hit = true; |
| 991 breakpoint_hit_counter++; | 991 breakpoint_hit_counter++; |
| 992 | 992 Dart_StackTrace trace; |
| 993 Dart_GetStackTrace(&trace); |
| 993 Dart_ActivationFrame frame; | 994 Dart_ActivationFrame frame; |
| 994 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); | 995 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); |
| 995 EXPECT_VALID(res); | 996 EXPECT_VALID(res); |
| 996 Dart_Handle func_name; | 997 Dart_Handle func_name; |
| 997 intptr_t line_number = -1; | 998 intptr_t line_number = -1; |
| 998 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, &line_number, NULL); | 999 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, &line_number, NULL); |
| 999 EXPECT_NE(-1, line_number); | 1000 EXPECT_NE(-1, line_number); |
| 1000 if (verbose) OS::Print("Hit line %" Pd "\n", line_number); | 1001 if (verbose) OS::Print("Hit line %" Pd "\n", line_number); |
| 1001 | 1002 |
| 1002 VerifyPointersVisitor::VerifyPointers(); | 1003 VerifyPointersVisitor::VerifyPointers(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 "main() { \n" | 1043 "main() { \n" |
| 1043 " var i = 3; \n" | 1044 " var i = 3; \n" |
| 1044 " foo(i); \n" | 1045 " foo(i); \n" |
| 1045 "} \n"; | 1046 "} \n"; |
| 1046 | 1047 |
| 1047 LoadScript(kScriptChars); | 1048 LoadScript(kScriptChars); |
| 1048 Dart_Handle result = Dart_SetNativeResolver(script_lib, | 1049 Dart_Handle result = Dart_SetNativeResolver(script_lib, |
| 1049 &NoopNativeResolver, | 1050 &NoopNativeResolver, |
| 1050 NULL); | 1051 NULL); |
| 1051 EXPECT_VALID(result); | 1052 EXPECT_VALID(result); |
| 1052 Dart_SetBreakpointHandler(&TestBreakpointHandlerWithVerify); | 1053 Dart_SetPausedEventHandler(&TestBreakpointHandlerWithVerify); |
| 1053 | 1054 |
| 1054 Dart_Handle script_url = NewString(TestCase::url()); | 1055 Dart_Handle script_url = NewString(TestCase::url()); |
| 1055 | 1056 |
| 1056 const intptr_t num_breakpoints = 9; | 1057 const intptr_t num_breakpoints = 9; |
| 1057 intptr_t breakpoint_lines[num_breakpoints] = | 1058 intptr_t breakpoint_lines[num_breakpoints] = |
| 1058 {5, 6, 7, 8, 9, 10, 11, 12, 13}; | 1059 {5, 6, 7, 8, 9, 10, 11, 12, 13}; |
| 1059 | 1060 |
| 1060 for (intptr_t i = 0; i < num_breakpoints; i++) { | 1061 for (intptr_t i = 0; i < num_breakpoints; i++) { |
| 1061 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]); | 1062 result = Dart_SetBreakpoint(script_url, breakpoint_lines[i]); |
| 1062 EXPECT_VALID(result); | 1063 EXPECT_VALID(result); |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," | 2313 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," |
| 2313 " null, 4, 13, 3, 14, 10," | 2314 " null, 4, 13, 3, 14, 10," |
| 2314 " null, 5, 17, 5, 18, 9, 19, 12," | 2315 " null, 5, 17, 5, 18, 9, 19, 12," |
| 2315 " null, 6, 21, 1," | 2316 " null, 6, 21, 1," |
| 2316 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," | 2317 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," |
| 2317 " null, 9, 29, 1]", | 2318 " null, 9, 29, 1]", |
| 2318 tokens_cstr); | 2319 tokens_cstr); |
| 2319 } | 2320 } |
| 2320 | 2321 |
| 2321 } // namespace dart | 2322 } // namespace dart |
| OLD | NEW |