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

Side by Side Diff: test/cctest/test-debug.cc

Issue 13720: Changed the debugger break handling to support situations where there are no ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 427
428 428
429 // Source for The JavaScript function which picks out the function name on the 429 // Source for The JavaScript function which picks out the function name on the
430 // top frame. 430 // top frame.
431 const char* frame_function_name_source = 431 const char* frame_function_name_source =
432 "function frame_function_name(exec_state) {" 432 "function frame_function_name(exec_state) {"
433 " return exec_state.frame(0).func().name();" 433 " return exec_state.frame(0).func().name();"
434 "}"; 434 "}";
435 v8::Local<v8::Function> frame_function_name; 435 v8::Local<v8::Function> frame_function_name;
436 436
437
438 // Source for The JavaScript function which returns the number of frames.
439 static const char* frame_count_source =
440 "function frame_count(exec_state) {"
441 " return exec_state.frameCount();"
442 "}";
443 v8::Handle<v8::Function> frame_count;
444
445
437 // Global variable to store the last function hit - used by some tests. 446 // Global variable to store the last function hit - used by some tests.
438 char last_function_hit[80]; 447 char last_function_hit[80];
439 448
440 // Debug event handler which counts the break points which have been hit. 449 // Debug event handler which counts the break points which have been hit.
441 int break_point_hit_count = 0; 450 int break_point_hit_count = 0;
442 static void DebugEventBreakPointHitCount(v8::DebugEvent event, 451 static void DebugEventBreakPointHitCount(v8::DebugEvent event,
443 v8::Handle<v8::Object> exec_state, 452 v8::Handle<v8::Object> exec_state,
444 v8::Handle<v8::Object> event_data, 453 v8::Handle<v8::Object> event_data,
445 v8::Handle<v8::Value> data) { 454 v8::Handle<v8::Value> data) {
455 // When hitting a debug event listener there must be a break set.
456 CHECK(v8::internal::Top::is_break());
457
446 // Count the number of breaks. 458 // Count the number of breaks.
447 if (event == v8::Break) { 459 if (event == v8::Break) {
448 break_point_hit_count++; 460 break_point_hit_count++;
449 if (!frame_function_name.IsEmpty()) { 461 if (!frame_function_name.IsEmpty()) {
450 // Get the name of the function. 462 // Get the name of the function.
451 const int argc = 1; 463 const int argc = 1;
452 v8::Handle<v8::Value> argv[argc] = { exec_state }; 464 v8::Handle<v8::Value> argv[argc] = { exec_state };
453 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 465 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
454 argc, argv); 466 argc, argv);
455 if (result->IsUndefined()) { 467 if (result->IsUndefined()) {
456 last_function_hit[0] = '\0'; 468 last_function_hit[0] = '\0';
457 } else { 469 } else {
458 CHECK(result->IsString()); 470 CHECK(result->IsString());
459 v8::Handle<v8::String> function_name(result->ToString()); 471 v8::Handle<v8::String> function_name(result->ToString());
460 function_name->WriteAscii(last_function_hit); 472 function_name->WriteAscii(last_function_hit);
461 } 473 }
462 } 474 }
463 } 475 }
464 } 476 }
465 477
466 478
467 // Debug event handler which counts a number of events. 479 // Debug event handler which counts a number of events and collects the stack
480 // height is there is a function compiled for that.
Mads Ager (chromium) 2008/12/11 07:56:54 is there -> if there
Søren Thygesen Gjesse 2008/12/11 08:04:49 Done.
468 int exception_hit_count = 0; 481 int exception_hit_count = 0;
469 int uncaught_exception_hit_count = 0; 482 int uncaught_exception_hit_count = 0;
483 int last_js_stack_height = -1;
470 484
471 static void DebugEventCounterClear() { 485 static void DebugEventCounterClear() {
472 break_point_hit_count = 0; 486 break_point_hit_count = 0;
473 exception_hit_count = 0; 487 exception_hit_count = 0;
474 uncaught_exception_hit_count = 0; 488 uncaught_exception_hit_count = 0;
475 } 489 }
476 490
477 static void DebugEventCounter(v8::DebugEvent event, 491 static void DebugEventCounter(v8::DebugEvent event,
478 v8::Handle<v8::Object> exec_state, 492 v8::Handle<v8::Object> exec_state,
479 v8::Handle<v8::Object> event_data, 493 v8::Handle<v8::Object> event_data,
480 v8::Handle<v8::Value> data) { 494 v8::Handle<v8::Value> data) {
495 // When hitting a debug event listener there must be a break set.
496 CHECK(v8::internal::Top::is_break());
497
481 // Count the number of breaks. 498 // Count the number of breaks.
482 if (event == v8::Break) { 499 if (event == v8::Break) {
483 break_point_hit_count++; 500 break_point_hit_count++;
484 } else if (event == v8::Exception) { 501 } else if (event == v8::Exception) {
485 exception_hit_count++; 502 exception_hit_count++;
486 503
487 // Check whether the exception was uncaught. 504 // Check whether the exception was uncaught.
488 v8::Local<v8::String> fun_name = v8::String::New("uncaught"); 505 v8::Local<v8::String> fun_name = v8::String::New("uncaught");
489 v8::Local<v8::Function> fun = 506 v8::Local<v8::Function> fun =
490 v8::Function::Cast(*event_data->Get(fun_name)); 507 v8::Function::Cast(*event_data->Get(fun_name));
491 v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL); 508 v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL);
492 if (result->IsTrue()) { 509 if (result->IsTrue()) {
493 uncaught_exception_hit_count++; 510 uncaught_exception_hit_count++;
494 } 511 }
495 } 512 }
513
514 // Collect the JavsScript stack height if the function frame_count is
515 // compiled.
516 if (!frame_count.IsEmpty()) {
517 static const int kArgc = 1;
518 v8::Handle<v8::Value> argv[kArgc] = { exec_state };
519 // Using exec_state as receiver is just to have a receiver.
520 v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv);
521 last_js_stack_height = result->Int32Value();
522 }
496 } 523 }
497 524
498 525
499 // Debug event handler which evaluates a number of expressions when a break 526 // Debug event handler which evaluates a number of expressions when a break
500 // point is hit. Each evaluated expression is compared with an expected value. 527 // point is hit. Each evaluated expression is compared with an expected value.
501 // For this debug event handler to work the following two global varaibles 528 // For this debug event handler to work the following two global varaibles
502 // must be initialized. 529 // must be initialized.
503 // checks: An array of expressions and expected results 530 // checks: An array of expressions and expected results
504 // evaluate_check_function: A JavaScript function (see below) 531 // evaluate_check_function: A JavaScript function (see below)
505 532
(...skipping 10 matching lines...) Expand all
516 "function evaluate_check(exec_state, expr, expected) {" 543 "function evaluate_check(exec_state, expr, expected) {"
517 " return exec_state.frame(0).evaluate(expr).value() === expected;" 544 " return exec_state.frame(0).evaluate(expr).value() === expected;"
518 "}"; 545 "}";
519 v8::Local<v8::Function> evaluate_check_function; 546 v8::Local<v8::Function> evaluate_check_function;
520 547
521 // The actual debug event described by the longer comment above. 548 // The actual debug event described by the longer comment above.
522 static void DebugEventEvaluate(v8::DebugEvent event, 549 static void DebugEventEvaluate(v8::DebugEvent event,
523 v8::Handle<v8::Object> exec_state, 550 v8::Handle<v8::Object> exec_state,
524 v8::Handle<v8::Object> event_data, 551 v8::Handle<v8::Object> event_data,
525 v8::Handle<v8::Value> data) { 552 v8::Handle<v8::Value> data) {
553 // When hitting a debug event listener there must be a break set.
554 CHECK(v8::internal::Top::is_break());
555
526 if (event == v8::Break) { 556 if (event == v8::Break) {
527 for (int i = 0; checks[i].expr != NULL; i++) { 557 for (int i = 0; checks[i].expr != NULL; i++) {
528 const int argc = 3; 558 const int argc = 3;
529 v8::Handle<v8::Value> argv[argc] = { exec_state, 559 v8::Handle<v8::Value> argv[argc] = { exec_state,
530 v8::String::New(checks[i].expr), 560 v8::String::New(checks[i].expr),
531 checks[i].expected }; 561 checks[i].expected };
532 v8::Handle<v8::Value> result = 562 v8::Handle<v8::Value> result =
533 evaluate_check_function->Call(exec_state, argc, argv); 563 evaluate_check_function->Call(exec_state, argc, argv);
534 if (!result->IsTrue()) { 564 if (!result->IsTrue()) {
535 v8::String::AsciiValue ascii(checks[i].expected->ToString()); 565 v8::String::AsciiValue ascii(checks[i].expected->ToString());
536 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *ascii); 566 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *ascii);
537 } 567 }
538 } 568 }
539 } 569 }
540 } 570 }
541 571
542 572
543 // This debug event listener removes a breakpoint in a function 573 // This debug event listener removes a breakpoint in a function
544 int debug_event_remove_break_point = 0; 574 int debug_event_remove_break_point = 0;
545 static void DebugEventRemoveBreakPoint(v8::DebugEvent event, 575 static void DebugEventRemoveBreakPoint(v8::DebugEvent event,
546 v8::Handle<v8::Object> exec_state, 576 v8::Handle<v8::Object> exec_state,
547 v8::Handle<v8::Object> event_data, 577 v8::Handle<v8::Object> event_data,
548 v8::Handle<v8::Value> data) { 578 v8::Handle<v8::Value> data) {
579 // When hitting a debug event listener there must be a break set.
580 CHECK(v8::internal::Top::is_break());
581
549 if (event == v8::Break) { 582 if (event == v8::Break) {
550 break_point_hit_count++; 583 break_point_hit_count++;
551 v8::Handle<v8::Function> fun = v8::Handle<v8::Function>::Cast(data); 584 v8::Handle<v8::Function> fun = v8::Handle<v8::Function>::Cast(data);
552 ClearBreakPoint(debug_event_remove_break_point); 585 ClearBreakPoint(debug_event_remove_break_point);
553 } 586 }
554 } 587 }
555 588
556 589
557 // Debug event handler which counts break points hit and performs a step 590 // Debug event handler which counts break points hit and performs a step
558 // afterwards. 591 // afterwards.
559 StepAction step_action = StepIn; // Step action to perform when stepping. 592 StepAction step_action = StepIn; // Step action to perform when stepping.
560 static void DebugEventStep(v8::DebugEvent event, 593 static void DebugEventStep(v8::DebugEvent event,
561 v8::Handle<v8::Object> exec_state, 594 v8::Handle<v8::Object> exec_state,
562 v8::Handle<v8::Object> event_data, 595 v8::Handle<v8::Object> event_data,
563 v8::Handle<v8::Value> data) { 596 v8::Handle<v8::Value> data) {
597 // When hitting a debug event listener there must be a break set.
598 CHECK(v8::internal::Top::is_break());
599
564 if (event == v8::Break) { 600 if (event == v8::Break) {
565 break_point_hit_count++; 601 break_point_hit_count++;
566 PrepareStep(step_action); 602 PrepareStep(step_action);
567 } 603 }
568 } 604 }
569 605
570 606
571 // Debug event handler which counts break points hit and performs a step 607 // Debug event handler which counts break points hit and performs a step
572 // afterwards. For each call the expected function is checked. 608 // afterwards. For each call the expected function is checked.
573 // For this debug event handler to work the following two global varaibles 609 // For this debug event handler to work the following two global varaibles
574 // must be initialized. 610 // must be initialized.
575 // expected_step_sequence: An array of the expected function call sequence. 611 // expected_step_sequence: An array of the expected function call sequence.
576 // frame_function_name: A JavaScript function (see below). 612 // frame_function_name: A JavaScript function (see below).
577 613
578 // String containing the expected function call sequence. Note: this only works 614 // String containing the expected function call sequence. Note: this only works
579 // if functions have name length of one. 615 // if functions have name length of one.
580 const char* expected_step_sequence = NULL; 616 const char* expected_step_sequence = NULL;
581 617
582 // The actual debug event described by the longer comment above. 618 // The actual debug event described by the longer comment above.
583 static void DebugEventStepSequence(v8::DebugEvent event, 619 static void DebugEventStepSequence(v8::DebugEvent event,
584 v8::Handle<v8::Object> exec_state, 620 v8::Handle<v8::Object> exec_state,
585 v8::Handle<v8::Object> event_data, 621 v8::Handle<v8::Object> event_data,
586 v8::Handle<v8::Value> data) { 622 v8::Handle<v8::Value> data) {
623 // When hitting a debug event listener there must be a break set.
624 CHECK(v8::internal::Top::is_break());
625
587 if (event == v8::Break || event == v8::Exception) { 626 if (event == v8::Break || event == v8::Exception) {
588 // Check that the current function is the expected. 627 // Check that the current function is the expected.
589 CHECK(break_point_hit_count < 628 CHECK(break_point_hit_count <
590 static_cast<int>(strlen(expected_step_sequence))); 629 static_cast<int>(strlen(expected_step_sequence)));
591 const int argc = 1; 630 const int argc = 1;
592 v8::Handle<v8::Value> argv[argc] = { exec_state }; 631 v8::Handle<v8::Value> argv[argc] = { exec_state };
593 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 632 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
594 argc, argv); 633 argc, argv);
595 CHECK(result->IsString()); 634 CHECK(result->IsString());
596 v8::String::AsciiValue function_name(result->ToString()); 635 v8::String::AsciiValue function_name(result->ToString());
597 CHECK_EQ(1, strlen(*function_name)); 636 CHECK_EQ(1, strlen(*function_name));
598 CHECK_EQ((*function_name)[0], 637 CHECK_EQ((*function_name)[0],
599 expected_step_sequence[break_point_hit_count]); 638 expected_step_sequence[break_point_hit_count]);
600 639
601 // Perform step. 640 // Perform step.
602 break_point_hit_count++; 641 break_point_hit_count++;
603 PrepareStep(step_action); 642 PrepareStep(step_action);
604 } 643 }
605 } 644 }
606 645
607 646
608 // Debug event handler which performs a garbage collection. 647 // Debug event handler which performs a garbage collection.
609 static void DebugEventBreakPointCollectGarbage( 648 static void DebugEventBreakPointCollectGarbage(
610 v8::DebugEvent event, 649 v8::DebugEvent event,
611 v8::Handle<v8::Object> exec_state, 650 v8::Handle<v8::Object> exec_state,
612 v8::Handle<v8::Object> event_data, 651 v8::Handle<v8::Object> event_data,
613 v8::Handle<v8::Value> data) { 652 v8::Handle<v8::Value> data) {
653 // When hitting a debug event listener there must be a break set.
654 CHECK(v8::internal::Top::is_break());
655
614 // Perform a garbage collection when break point is hit and continue. Based 656 // Perform a garbage collection when break point is hit and continue. Based
615 // on the number of break points hit either scavenge or mark compact 657 // on the number of break points hit either scavenge or mark compact
616 // collector is used. 658 // collector is used.
617 if (event == v8::Break) { 659 if (event == v8::Break) {
618 break_point_hit_count++; 660 break_point_hit_count++;
619 if (break_point_hit_count % 2 == 0) { 661 if (break_point_hit_count % 2 == 0) {
620 // Scavenge. 662 // Scavenge.
621 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); 663 Heap::CollectGarbage(0, v8::internal::NEW_SPACE);
622 } else { 664 } else {
623 // Mark sweep (and perhaps compact). 665 // Mark sweep (and perhaps compact).
624 Heap::CollectAllGarbage(); 666 Heap::CollectAllGarbage();
625 } 667 }
626 } 668 }
627 } 669 }
628 670
629 671
630 // Debug event handler which re-issues a debug break and calls the garbage 672 // Debug event handler which re-issues a debug break and calls the garbage
631 // collector to have the heap verified. 673 // collector to have the heap verified.
632 static void DebugEventBreak(v8::DebugEvent event, 674 static void DebugEventBreak(v8::DebugEvent event,
633 v8::Handle<v8::Object> exec_state, 675 v8::Handle<v8::Object> exec_state,
634 v8::Handle<v8::Object> event_data, 676 v8::Handle<v8::Object> event_data,
635 v8::Handle<v8::Value> data) { 677 v8::Handle<v8::Value> data) {
678 // When hitting a debug event listener there must be a break set.
679 CHECK(v8::internal::Top::is_break());
680
636 if (event == v8::Break) { 681 if (event == v8::Break) {
637 // Count the number of breaks. 682 // Count the number of breaks.
638 break_point_hit_count++; 683 break_point_hit_count++;
639 684
640 // Run the garbage collector to enforce heap verification if option 685 // Run the garbage collector to enforce heap verification if option
641 // --verify-heap is set. 686 // --verify-heap is set.
642 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); 687 Heap::CollectGarbage(0, v8::internal::NEW_SPACE);
643 688
644 // Set the break flag again to come back here as soon as possible. 689 // Set the break flag again to come back here as soon as possible.
645 v8::Debug::DebugBreak(); 690 v8::Debug::DebugBreak();
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 2202
2158 // Without stepping only active break points are hit. 2203 // Without stepping only active break points are hit.
2159 CHECK_EQ(1, break_point_hit_count); 2204 CHECK_EQ(1, break_point_hit_count);
2160 2205
2161 v8::Debug::RemoveDebugEventListener(DebugEventBreakPointHitCount); 2206 v8::Debug::RemoveDebugEventListener(DebugEventBreakPointHitCount);
2162 } 2207 }
2163 2208
2164 2209
2165 // Test break on exceptions. For each exception break combination the number 2210 // Test break on exceptions. For each exception break combination the number
2166 // of debug event exception callbacks and message callbacks are collected. The 2211 // of debug event exception callbacks and message callbacks are collected. The
2167 // number of debug event exception callbacks are cused to check that the 2212 // number of debug event exception callbacks are used to check that the
2168 // debugger is called correctly and the number of message callbacks is used to 2213 // debugger is called correctly and the number of message callbacks is used to
2169 // check that uncaught exceptions are still returned even if there is a break 2214 // check that uncaught exceptions are still returned even if there is a break
2170 // for them. 2215 // for them.
2171 TEST(BreakOnException) { 2216 TEST(BreakOnException) {
2172 v8::HandleScope scope; 2217 v8::HandleScope scope;
2173 DebugLocalContext env; 2218 DebugLocalContext env;
2174 env.ExposeDebug(); 2219 env.ExposeDebug();
2175 2220
2176 v8::internal::Top::TraceException(false); 2221 v8::internal::Top::TraceException(false);
2177 2222
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 notCaught->Call(env->Global(), 0, NULL); 2347 notCaught->Call(env->Global(), 0, NULL);
2303 CHECK_EQ(2, exception_hit_count); 2348 CHECK_EQ(2, exception_hit_count);
2304 CHECK_EQ(1, uncaught_exception_hit_count); 2349 CHECK_EQ(1, uncaught_exception_hit_count);
2305 CHECK_EQ(1, message_callback_count); 2350 CHECK_EQ(1, message_callback_count);
2306 2351
2307 v8::Debug::RemoveDebugEventListener(DebugEventCounter); 2352 v8::Debug::RemoveDebugEventListener(DebugEventCounter);
2308 v8::V8::RemoveMessageListeners(MessageCallbackCount); 2353 v8::V8::RemoveMessageListeners(MessageCallbackCount);
2309 } 2354 }
2310 2355
2311 2356
2357 // Test break on exception from compiler errors. When compiling using using
Mads Ager (chromium) 2008/12/11 07:56:54 using using -> using
Søren Thygesen Gjesse 2008/12/11 08:04:49 Done.
2358 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
2359 // eval there are JavaScript frames.
2360 TEST(BreakOnCompileException) {
2361 v8::HandleScope scope;
2362 DebugLocalContext env;
2363
2364 v8::internal::Top::TraceException(false);
2365
2366 // Create a function for checking the function when hitting a break point.
2367 frame_count = CompileFunction(&env, frame_count_source, "frame_count");
2368
2369 v8::V8::AddMessageListener(MessageCallbackCount);
2370 v8::Debug::AddDebugEventListener(DebugEventCounter);
2371
2372 DebugEventCounterClear();
2373 MessageCallbackCountClear();
2374
2375 // Check initial state.
2376 CHECK_EQ(0, exception_hit_count);
2377 CHECK_EQ(0, uncaught_exception_hit_count);
2378 CHECK_EQ(0, message_callback_count);
2379 CHECK_EQ(-1, last_js_stack_height);
2380
2381 // Throws SyntaxError: Unexpected end of input
2382 v8::Script::Compile(v8::String::New("+++"));
2383 CHECK_EQ(1, exception_hit_count);
2384 CHECK_EQ(1, uncaught_exception_hit_count);
2385 CHECK_EQ(1, message_callback_count);
2386 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack.
2387
2388 // Throws SyntaxError: Unexpected identifier
2389 v8::Script::Compile(v8::String::New("x x"));
2390 CHECK_EQ(2, exception_hit_count);
2391 CHECK_EQ(2, uncaught_exception_hit_count);
2392 CHECK_EQ(2, message_callback_count);
2393 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack.
2394
2395 // Throws SyntaxError: Unexpected end of input
2396 v8::Script::Compile(v8::String::New("eval('+++')"))->Run();
2397 CHECK_EQ(3, exception_hit_count);
2398 CHECK_EQ(3, uncaught_exception_hit_count);
2399 CHECK_EQ(3, message_callback_count);
2400 CHECK_EQ(1, last_js_stack_height);
2401
2402 // Throws SyntaxError: Unexpected identifier
2403 v8::Script::Compile(v8::String::New("eval('x x')"))->Run();
2404 CHECK_EQ(4, exception_hit_count);
2405 CHECK_EQ(4, uncaught_exception_hit_count);
2406 CHECK_EQ(4, message_callback_count);
2407 CHECK_EQ(1, last_js_stack_height);
2408 }
2409
2410
2312 TEST(StepWithException) { 2411 TEST(StepWithException) {
2313 v8::HandleScope scope; 2412 v8::HandleScope scope;
2314 DebugLocalContext env; 2413 DebugLocalContext env;
2315 2414
2316 // Create a function for checking the function when hitting a break point. 2415 // Create a function for checking the function when hitting a break point.
2317 frame_function_name = CompileFunction(&env, 2416 frame_function_name = CompileFunction(&env,
2318 frame_function_name_source, 2417 frame_function_name_source,
2319 "frame_function_name"); 2418 "frame_function_name");
2320 2419
2321 // Register a debug event listener which steps and counts. 2420 // Register a debug event listener which steps and counts.
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 3260
3162 3261
3163 TEST(SendCommandToUninitializedVM) { 3262 TEST(SendCommandToUninitializedVM) {
3164 const char* dummy_command = "{}"; 3263 const char* dummy_command = "{}";
3165 uint16_t dummy_buffer[80]; 3264 uint16_t dummy_buffer[80];
3166 int dummy_length = AsciiToUtf16(dummy_command, dummy_buffer); 3265 int dummy_length = AsciiToUtf16(dummy_command, dummy_buffer);
3167 v8::Debug::SendCommand(dummy_buffer, dummy_length); 3266 v8::Debug::SendCommand(dummy_buffer, dummy_length);
3168 } 3267 }
3169 3268
3170 3269
3171 // Source for The JavaScript function which returns the number of frames.
3172 static const char* frame_count_source =
3173 "function frame_count(exec_state) {"
3174 " return exec_state.frameCount();"
3175 "}";
3176 v8::Handle<v8::Function> frame_count;
3177
3178
3179 // Source for a JavaScript function which returns the source line for the top 3270 // Source for a JavaScript function which returns the source line for the top
3180 // frame. 3271 // frame.
3181 static const char* frame_source_line_source = 3272 static const char* frame_source_line_source =
3182 "function frame_source_line(exec_state) {" 3273 "function frame_source_line(exec_state) {"
3183 " return exec_state.frame(0).sourceLine();" 3274 " return exec_state.frame(0).sourceLine();"
3184 "}"; 3275 "}";
3185 v8::Handle<v8::Function> frame_source_line; 3276 v8::Handle<v8::Function> frame_source_line;
3186 3277
3187 3278
3188 // Source for a JavaScript function which returns the data parameter of a 3279 // Source for a JavaScript function which returns the data parameter of a
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3311 " CheckSourceLine(2)\n" 3402 " CheckSourceLine(2)\n"
3312 " CheckSourceLine(3)\n" 3403 " CheckSourceLine(3)\n"
3313 "}; f()"))->Run(); 3404 "}; f()"))->Run();
3314 3405
3315 // Test that a parameter can be passed to a function called in the debugger. 3406 // Test that a parameter can be passed to a function called in the debugger.
3316 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run(); 3407 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run();
3317 3408
3318 // Test that a function with closure can be run in the debugger. 3409 // Test that a function with closure can be run in the debugger.
3319 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run(); 3410 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run();
3320 } 3411 }
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698