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 "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/thread.h" | 8 #include "vm/thread.h" |
9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
10 | 10 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 EXPECT_VALID(res); | 228 EXPECT_VALID(res); |
229 if (i < expected_frames) { | 229 if (i < expected_frames) { |
230 VerifyStackFrame(frame, func_names[i], local_vars[i]); | 230 VerifyStackFrame(frame, func_names[i], local_vars[i]); |
231 } else { | 231 } else { |
232 VerifyStackFrame(frame, NULL, Dart_Null()); | 232 VerifyStackFrame(frame, NULL, Dart_Null()); |
233 } | 233 } |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 void TestBreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) { | 238 void TestBreakpointHandler(Dart_IsolateId isolate_id, |
| 239 Dart_Breakpoint bpt, |
| 240 Dart_StackTrace trace) { |
239 const char* expected_trace[] = {"A.foo", "main"}; | 241 const char* expected_trace[] = {"A.foo", "main"}; |
240 const intptr_t expected_trace_length = 2; | 242 const intptr_t expected_trace_length = 2; |
241 breakpoint_hit = true; | 243 breakpoint_hit = true; |
242 breakpoint_hit_counter++; | 244 breakpoint_hit_counter++; |
243 intptr_t trace_len; | 245 intptr_t trace_len; |
244 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 246 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
245 EXPECT_VALID(res); | 247 EXPECT_VALID(res); |
246 EXPECT_EQ(expected_trace_length, trace_len); | 248 EXPECT_EQ(expected_trace_length, trace_len); |
247 for (int i = 0; i < trace_len; i++) { | 249 for (int i = 0; i < trace_len; i++) { |
248 Dart_ActivationFrame frame; | 250 Dart_ActivationFrame frame; |
(...skipping 27 matching lines...) Expand all Loading... |
276 Dart_SetBreakpointHandler(&TestBreakpointHandler); | 278 Dart_SetBreakpointHandler(&TestBreakpointHandler); |
277 SetBreakpointAtEntry("A", "foo"); | 279 SetBreakpointAtEntry("A", "foo"); |
278 | 280 |
279 breakpoint_hit = false; | 281 breakpoint_hit = false; |
280 Dart_Handle retval = Invoke("main"); | 282 Dart_Handle retval = Invoke("main"); |
281 EXPECT_VALID(retval); | 283 EXPECT_VALID(retval); |
282 EXPECT(breakpoint_hit == true); | 284 EXPECT(breakpoint_hit == true); |
283 } | 285 } |
284 | 286 |
285 | 287 |
286 void TestStepOutHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) { | 288 void TestStepOutHandler(Dart_IsolateId isolate_id, |
| 289 Dart_Breakpoint bpt, |
| 290 Dart_StackTrace trace) { |
287 const char* expected_bpts[] = {"f1", "foo", "main"}; | 291 const char* expected_bpts[] = {"f1", "foo", "main"}; |
288 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); | 292 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); |
289 intptr_t trace_len; | 293 intptr_t trace_len; |
290 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 294 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
291 EXPECT_VALID(res); | 295 EXPECT_VALID(res); |
292 EXPECT(breakpoint_hit_counter < expected_bpts_length); | 296 EXPECT(breakpoint_hit_counter < expected_bpts_length); |
293 Dart_ActivationFrame frame; | 297 Dart_ActivationFrame frame; |
294 res = Dart_GetActivationFrame(trace, 0, &frame); | 298 res = Dart_GetActivationFrame(trace, 0, &frame); |
295 EXPECT_VALID(res); | 299 EXPECT_VALID(res); |
296 Dart_Handle func_name; | 300 Dart_Handle func_name; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 Dart_Handle retval = Invoke("main"); | 342 Dart_Handle retval = Invoke("main"); |
339 EXPECT_VALID(retval); | 343 EXPECT_VALID(retval); |
340 EXPECT(Dart_IsInteger(retval)); | 344 EXPECT(Dart_IsInteger(retval)); |
341 int64_t int_value = 0; | 345 int64_t int_value = 0; |
342 Dart_IntegerToInt64(retval, &int_value); | 346 Dart_IntegerToInt64(retval, &int_value); |
343 EXPECT_EQ(2, int_value); | 347 EXPECT_EQ(2, int_value); |
344 EXPECT(breakpoint_hit == true); | 348 EXPECT(breakpoint_hit == true); |
345 } | 349 } |
346 | 350 |
347 | 351 |
348 void TestStepIntoHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) { | 352 void TestStepIntoHandler(Dart_IsolateId isolate_id, |
| 353 Dart_Breakpoint bpt, |
| 354 Dart_StackTrace trace) { |
349 const char* expected_bpts[] = { | 355 const char* expected_bpts[] = { |
350 "main", | 356 "main", |
351 "foo", | 357 "foo", |
352 "f1", | 358 "f1", |
353 "foo", | 359 "foo", |
354 "X.X.", | 360 "X.X.", |
355 "foo", | 361 "foo", |
356 "X.kvmk", | 362 "X.kvmk", |
357 "f2", | 363 "f2", |
358 "X.kvmk", | 364 "X.kvmk", |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 Dart_Handle retval = Invoke("main"); | 425 Dart_Handle retval = Invoke("main"); |
420 EXPECT_VALID(retval); | 426 EXPECT_VALID(retval); |
421 EXPECT(Dart_IsInteger(retval)); | 427 EXPECT(Dart_IsInteger(retval)); |
422 int64_t int_value = 0; | 428 int64_t int_value = 0; |
423 Dart_IntegerToInt64(retval, &int_value); | 429 Dart_IntegerToInt64(retval, &int_value); |
424 EXPECT_EQ(7, int_value); | 430 EXPECT_EQ(7, int_value); |
425 EXPECT(breakpoint_hit == true); | 431 EXPECT(breakpoint_hit == true); |
426 } | 432 } |
427 | 433 |
428 | 434 |
429 static void StepIntoHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) { | 435 static void StepIntoHandler(Dart_IsolateId isolate_id, |
| 436 Dart_Breakpoint bpt, |
| 437 Dart_StackTrace trace) { |
430 if (verbose) { | 438 if (verbose) { |
431 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", | 439 OS::Print(">>> Breakpoint nr. %d in %s <<<\n", |
432 breakpoint_hit_counter, BreakpointInfo(trace)); | 440 breakpoint_hit_counter, BreakpointInfo(trace)); |
433 PrintStackTrace(trace); | 441 PrintStackTrace(trace); |
434 } | 442 } |
435 breakpoint_hit = true; | 443 breakpoint_hit = true; |
436 breakpoint_hit_counter++; | 444 breakpoint_hit_counter++; |
437 Dart_SetStepInto(); | 445 Dart_SetStepInto(); |
438 } | 446 } |
439 | 447 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 Dart_Handle retval = Invoke("main"); | 508 Dart_Handle retval = Invoke("main"); |
501 EXPECT_VALID(retval); | 509 EXPECT_VALID(retval); |
502 EXPECT(Dart_IsInteger(retval)); | 510 EXPECT(Dart_IsInteger(retval)); |
503 int64_t int_value = 0; | 511 int64_t int_value = 0; |
504 Dart_IntegerToInt64(retval, &int_value); | 512 Dart_IntegerToInt64(retval, &int_value); |
505 EXPECT_EQ(2 * 99, int_value); | 513 EXPECT_EQ(2 * 99, int_value); |
506 EXPECT(breakpoint_hit == true); | 514 EXPECT(breakpoint_hit == true); |
507 } | 515 } |
508 | 516 |
509 | 517 |
510 void TestSingleStepHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) { | 518 void TestSingleStepHandler(Dart_IsolateId isolate_id, |
| 519 Dart_Breakpoint bpt, |
| 520 Dart_StackTrace trace) { |
511 const char* expected_bpts[] = { | 521 const char* expected_bpts[] = { |
512 "moo", "foo", "moo", "foo", "moo", "foo", "main"}; | 522 "moo", "foo", "moo", "foo", "moo", "foo", "main"}; |
513 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); | 523 const intptr_t expected_bpts_length = ARRAY_SIZE(expected_bpts); |
514 intptr_t trace_len; | 524 intptr_t trace_len; |
515 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 525 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
516 EXPECT_VALID(res); | 526 EXPECT_VALID(res); |
517 EXPECT(breakpoint_hit_counter < expected_bpts_length); | 527 EXPECT(breakpoint_hit_counter < expected_bpts_length); |
518 Dart_ActivationFrame frame; | 528 Dart_ActivationFrame frame; |
519 res = Dart_GetActivationFrame(trace, 0, &frame); | 529 res = Dart_GetActivationFrame(trace, 0, &frame); |
520 EXPECT_VALID(res); | 530 EXPECT_VALID(res); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 SetBreakpointAtEntry("", "moo"); | 566 SetBreakpointAtEntry("", "moo"); |
557 | 567 |
558 breakpoint_hit = false; | 568 breakpoint_hit = false; |
559 breakpoint_hit_counter = 0; | 569 breakpoint_hit_counter = 0; |
560 Dart_Handle retval = Invoke("main"); | 570 Dart_Handle retval = Invoke("main"); |
561 EXPECT_VALID(retval); | 571 EXPECT_VALID(retval); |
562 EXPECT(breakpoint_hit == true); | 572 EXPECT(breakpoint_hit == true); |
563 } | 573 } |
564 | 574 |
565 | 575 |
566 static void ClosureBreakpointHandler(Dart_Breakpoint bpt, | 576 static void ClosureBreakpointHandler(Dart_IsolateId isolate_id, |
| 577 Dart_Breakpoint bpt, |
567 Dart_StackTrace trace) { | 578 Dart_StackTrace trace) { |
568 const char* expected_trace[] = {"callback", "main"}; | 579 const char* expected_trace[] = {"callback", "main"}; |
569 const intptr_t expected_trace_length = 2; | 580 const intptr_t expected_trace_length = 2; |
570 breakpoint_hit_counter++; | 581 breakpoint_hit_counter++; |
571 intptr_t trace_len; | 582 intptr_t trace_len; |
572 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 583 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
573 EXPECT_VALID(res); | 584 EXPECT_VALID(res); |
574 EXPECT_EQ(expected_trace_length, trace_len); | 585 EXPECT_EQ(expected_trace_length, trace_len); |
575 for (int i = 0; i < trace_len; i++) { | 586 for (int i = 0; i < trace_len; i++) { |
576 Dart_ActivationFrame frame; | 587 Dart_ActivationFrame frame; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 breakpoint_hit_counter = 0; | 620 breakpoint_hit_counter = 0; |
610 Dart_Handle retval = Invoke("main"); | 621 Dart_Handle retval = Invoke("main"); |
611 EXPECT_VALID(retval); | 622 EXPECT_VALID(retval); |
612 int64_t int_value = 0; | 623 int64_t int_value = 0; |
613 Dart_IntegerToInt64(retval, &int_value); | 624 Dart_IntegerToInt64(retval, &int_value); |
614 EXPECT_EQ(442, int_value); | 625 EXPECT_EQ(442, int_value); |
615 EXPECT_EQ(2, breakpoint_hit_counter); | 626 EXPECT_EQ(2, breakpoint_hit_counter); |
616 } | 627 } |
617 | 628 |
618 | 629 |
619 static void ExprClosureBreakpointHandler(Dart_Breakpoint bpt, | 630 static void ExprClosureBreakpointHandler(Dart_IsolateId isolate_id, |
| 631 Dart_Breakpoint bpt, |
620 Dart_StackTrace trace) { | 632 Dart_StackTrace trace) { |
621 static const char* expected_trace[] = {"add", "main"}; | 633 static const char* expected_trace[] = {"add", "main"}; |
622 Dart_Handle add_locals = Dart_NewList(4); | 634 Dart_Handle add_locals = Dart_NewList(4); |
623 Dart_ListSetAt(add_locals, 0, Dart_NewString("a")); | 635 Dart_ListSetAt(add_locals, 0, Dart_NewString("a")); |
624 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10)); | 636 Dart_ListSetAt(add_locals, 1, Dart_NewInteger(10)); |
625 Dart_ListSetAt(add_locals, 2, Dart_NewString("b")); | 637 Dart_ListSetAt(add_locals, 2, Dart_NewString("b")); |
626 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20)); | 638 Dart_ListSetAt(add_locals, 3, Dart_NewInteger(20)); |
627 Dart_Handle expected_locals[] = {add_locals, Dart_Null()}; | 639 Dart_Handle expected_locals[] = {add_locals, Dart_Null()}; |
628 breakpoint_hit_counter++; | 640 breakpoint_hit_counter++; |
629 PrintStackTrace(trace); | 641 PrintStackTrace(trace); |
(...skipping 26 matching lines...) Expand all Loading... |
656 EXPECT_VALID(retval); | 668 EXPECT_VALID(retval); |
657 int64_t int_value = 0; | 669 int64_t int_value = 0; |
658 Dart_IntegerToInt64(retval, &int_value); | 670 Dart_IntegerToInt64(retval, &int_value); |
659 EXPECT_EQ(30, int_value); | 671 EXPECT_EQ(30, int_value); |
660 EXPECT_EQ(1, breakpoint_hit_counter); | 672 EXPECT_EQ(1, breakpoint_hit_counter); |
661 } | 673 } |
662 | 674 |
663 | 675 |
664 static intptr_t bp_id_to_be_deleted; | 676 static intptr_t bp_id_to_be_deleted; |
665 | 677 |
666 static void DeleteBreakpointHandler(Dart_Breakpoint bpt, | 678 static void DeleteBreakpointHandler(Dart_IsolateId isolate_id, |
| 679 Dart_Breakpoint bpt, |
667 Dart_StackTrace trace) { | 680 Dart_StackTrace trace) { |
668 const char* expected_trace[] = {"foo", "main"}; | 681 const char* expected_trace[] = {"foo", "main"}; |
669 const intptr_t expected_trace_length = 2; | 682 const intptr_t expected_trace_length = 2; |
670 breakpoint_hit_counter++; | 683 breakpoint_hit_counter++; |
671 intptr_t trace_len; | 684 intptr_t trace_len; |
672 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 685 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
673 EXPECT_VALID(res); | 686 EXPECT_VALID(res); |
674 EXPECT_EQ(expected_trace_length, trace_len); | 687 EXPECT_EQ(expected_trace_length, trace_len); |
675 for (int i = 0; i < trace_len; i++) { | 688 for (int i = 0; i < trace_len; i++) { |
676 Dart_ActivationFrame frame; | 689 Dart_ActivationFrame frame; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 // breakpoint is removed by the handler, so we expect the breakpoint | 738 // breakpoint is removed by the handler, so we expect the breakpoint |
726 // to fire twice only. | 739 // to fire twice only. |
727 bp_id_to_be_deleted = bp_id; | 740 bp_id_to_be_deleted = bp_id; |
728 breakpoint_hit_counter = 0; | 741 breakpoint_hit_counter = 0; |
729 Dart_Handle retval = Invoke("main"); | 742 Dart_Handle retval = Invoke("main"); |
730 EXPECT_VALID(retval); | 743 EXPECT_VALID(retval); |
731 EXPECT_EQ(2, breakpoint_hit_counter); | 744 EXPECT_EQ(2, breakpoint_hit_counter); |
732 } | 745 } |
733 | 746 |
734 | 747 |
735 static void InspectStaticFieldHandler(Dart_Breakpoint bpt, | 748 static void InspectStaticFieldHandler(Dart_IsolateId isolate_id, |
| 749 Dart_Breakpoint bpt, |
736 Dart_StackTrace trace) { | 750 Dart_StackTrace trace) { |
737 ASSERT(script_lib != NULL); | 751 ASSERT(script_lib != NULL); |
738 ASSERT(!Dart_IsError(script_lib)); | 752 ASSERT(!Dart_IsError(script_lib)); |
739 ASSERT(Dart_IsLibrary(script_lib)); | 753 ASSERT(Dart_IsLibrary(script_lib)); |
740 Dart_Handle class_A = Dart_GetClass(script_lib, Dart_NewString("A")); | 754 Dart_Handle class_A = Dart_GetClass(script_lib, Dart_NewString("A")); |
741 EXPECT_VALID(class_A); | 755 EXPECT_VALID(class_A); |
742 | 756 |
743 const int expected_num_fields = 2; | 757 const int expected_num_fields = 2; |
744 struct { | 758 struct { |
745 const char* field_name; | 759 const char* field_name; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { | 1220 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { |
1207 ml.Wait(); | 1221 ml.Wait(); |
1208 } | 1222 } |
1209 } | 1223 } |
1210 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); | 1224 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); |
1211 } | 1225 } |
1212 | 1226 |
1213 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 1227 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
1214 | 1228 |
1215 } // namespace dart | 1229 } // namespace dart |
OLD | NEW |