Revision f230a1cf deps/v8/test/cctest/test-debug.cc

View differences:

deps/v8/test/cctest/test-debug.cc
29 29

  
30 30
#include <stdlib.h>
31 31

  
32
#define V8_DISABLE_DEPRECATIONS 1
33 32
#include "v8.h"
34 33

  
35 34
#include "api.h"
......
43 42
#include "platform/socket.h"
44 43
#include "stub-cache.h"
45 44
#include "utils.h"
46
#undef V8_DISABLE_DEPRECATIONS
47 45

  
48 46

  
49 47
using ::v8::internal::Mutex;
......
142 140
      v8::Handle<v8::ObjectTemplate> global_template =
143 141
          v8::Handle<v8::ObjectTemplate>(),
144 142
      v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
145
      : scope_(v8::Isolate::GetCurrent()),
143
      : scope_(CcTest::isolate()),
146 144
        context_(
147
          v8::Context::New(v8::Isolate::GetCurrent(),
145
          v8::Context::New(CcTest::isolate(),
148 146
                           extensions,
149 147
                           global_template,
150 148
                           global_object)) {
......
200 198
static v8::Local<v8::Function> CompileFunction(const char* source,
201 199
                                               const char* function_name) {
202 200
  v8::Script::Compile(v8::String::New(source))->Run();
201
  v8::Local<v8::Object> global =
202
      CcTest::isolate()->GetCurrentContext()->Global();
203 203
  return v8::Local<v8::Function>::Cast(
204
    v8::Context::GetCurrent()->Global()->Get(v8::String::New(function_name)));
204
      global->Get(v8::String::New(function_name)));
205 205
}
206 206

  
207 207

  
......
302 302

  
303 303
// Clear a break point.
304 304
static void ClearBreakPoint(int break_point) {
305
  v8::internal::Isolate* isolate = v8::internal::Isolate::Current();
305
  v8::internal::Isolate* isolate = CcTest::i_isolate();
306 306
  v8::internal::Debug* debug = isolate->debug();
307 307
  debug->ClearBreakPoint(
308 308
      Handle<Object>(v8::internal::Smi::FromInt(break_point), isolate));
......
364 364

  
365 365
// Change break on exception.
366 366
static void ChangeBreakOnException(bool caught, bool uncaught) {
367
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
367
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
368 368
  debug->ChangeBreakOnException(v8::internal::BreakException, caught);
369 369
  debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught);
370 370
}
......
391 391

  
392 392
// Prepare to step to next break location.
393 393
static void PrepareStep(StepAction step_action) {
394
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
394
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
395 395
  debug->PrepareStep(step_action, 1, StackFrame::NO_ID);
396 396
}
397 397

  
......
403 403

  
404 404
// Collect the currently debugged functions.
405 405
Handle<FixedArray> GetDebuggedFunctions() {
406
  Debug* debug = Isolate::Current()->debug();
406
  Debug* debug = CcTest::i_isolate()->debug();
407 407

  
408 408
  v8::internal::DebugInfoListNode* node = debug->debug_info_list_;
409 409

  
......
416 416

  
417 417
  // Allocate array for the debugged functions
418 418
  Handle<FixedArray> debugged_functions =
419
      Isolate::Current()->factory()->NewFixedArray(count);
419
      CcTest::i_isolate()->factory()->NewFixedArray(count);
420 420

  
421 421
  // Run through the debug info objects and collect all functions.
422 422
  count = 0;
......
430 430

  
431 431

  
432 432
static Handle<Code> ComputeCallDebugBreak(int argc) {
433
  return Isolate::Current()->stub_cache()->ComputeCallDebugBreak(argc,
433
  return CcTest::i_isolate()->stub_cache()->ComputeCallDebugBreak(argc,
434 434
                                                                 Code::CALL_IC);
435 435
}
436 436

  
......
439 439
void CheckDebuggerUnloaded(bool check_functions) {
440 440
  // Check that the debugger context is cleared and that there is no debug
441 441
  // information stored for the debugger.
442
  CHECK(Isolate::Current()->debug()->debug_context().is_null());
443
  CHECK_EQ(NULL, Isolate::Current()->debug()->debug_info_list_);
442
  CHECK(CcTest::i_isolate()->debug()->debug_context().is_null());
443
  CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_);
444 444

  
445 445
  // Collect garbage to ensure weak handles are cleared.
446
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
447
  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
446
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
447
  CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask);
448 448

  
449 449
  // Iterate the head and check that there are no debugger related objects left.
450
  HeapIterator iterator(HEAP);
450
  HeapIterator iterator(CcTest::heap());
451 451
  for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
452 452
    CHECK(!obj->IsDebugInfo());
453 453
    CHECK(!obj->IsBreakPointInfo());
......
472 472

  
473 473

  
474 474
void ForceUnloadDebugger() {
475
  Isolate::Current()->debugger()->never_unload_debugger_ = false;
476
  Isolate::Current()->debugger()->UnloadDebugger();
475
  CcTest::i_isolate()->debugger()->never_unload_debugger_ = false;
476
  CcTest::i_isolate()->debugger()->UnloadDebugger();
477 477
}
478 478

  
479 479

  
......
508 508
                             const char* source, const char* name,
509 509
                             int position, v8::internal::RelocInfo::Mode mode,
510 510
                             Code* debug_break) {
511
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
511
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
512 512

  
513 513
  // Create function and set the break point.
514 514
  Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle(
......
674 674
  v8::DebugEvent event = event_details.GetEvent();
675 675
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
676 676
  v8::Handle<v8::Object> event_data = event_details.GetEventData();
677
  v8::internal::Isolate* isolate = v8::internal::Isolate::Current();
677
  v8::internal::Isolate* isolate = CcTest::i_isolate();
678 678
  Debug* debug = isolate->debug();
679 679
  // When hitting a debug event listener there must be a break set.
680 680
  CHECK_NE(debug->break_id(), 0);
......
787 787
  v8::DebugEvent event = event_details.GetEvent();
788 788
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
789 789
  v8::Handle<v8::Object> event_data = event_details.GetEventData();
790
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
790
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
791 791

  
792 792
  // When hitting a debug event listener there must be a break set.
793 793
  CHECK_NE(debug->break_id(), 0);
......
849 849
    const v8::Debug::EventDetails& event_details) {
850 850
  v8::DebugEvent event = event_details.GetEvent();
851 851
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
852
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
852
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
853 853
  // When hitting a debug event listener there must be a break set.
854 854
  CHECK_NE(debug->break_id(), 0);
855 855

  
......
876 876
    const v8::Debug::EventDetails& event_details) {
877 877
  v8::DebugEvent event = event_details.GetEvent();
878 878
  v8::Handle<v8::Value> data = event_details.GetCallbackData();
879
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
879
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
880 880
  // When hitting a debug event listener there must be a break set.
881 881
  CHECK_NE(debug->break_id(), 0);
882 882

  
......
894 894
static void DebugEventStep(
895 895
    const v8::Debug::EventDetails& event_details) {
896 896
  v8::DebugEvent event = event_details.GetEvent();
897
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
897
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
898 898
  // When hitting a debug event listener there must be a break set.
899 899
  CHECK_NE(debug->break_id(), 0);
900 900

  
......
921 921
    const v8::Debug::EventDetails& event_details) {
922 922
  v8::DebugEvent event = event_details.GetEvent();
923 923
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
924
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
924
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
925 925
  // When hitting a debug event listener there must be a break set.
926 926
  CHECK_NE(debug->break_id(), 0);
927 927

  
......
950 950
static void DebugEventBreakPointCollectGarbage(
951 951
    const v8::Debug::EventDetails& event_details) {
952 952
  v8::DebugEvent event = event_details.GetEvent();
953
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
953
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
954 954
  // When hitting a debug event listener there must be a break set.
955 955
  CHECK_NE(debug->break_id(), 0);
956 956

  
......
961 961
    break_point_hit_count++;
962 962
    if (break_point_hit_count % 2 == 0) {
963 963
      // Scavenge.
964
      HEAP->CollectGarbage(v8::internal::NEW_SPACE);
964
      CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
965 965
    } else {
966 966
      // Mark sweep compact.
967
      HEAP->CollectAllGarbage(Heap::kNoGCFlags);
967
      CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
968 968
    }
969 969
  }
970 970
}
......
975 975
static void DebugEventBreak(
976 976
    const v8::Debug::EventDetails& event_details) {
977 977
  v8::DebugEvent event = event_details.GetEvent();
978
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
978
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
979 979
  // When hitting a debug event listener there must be a break set.
980 980
  CHECK_NE(debug->break_id(), 0);
981 981

  
......
985 985

  
986 986
    // Run the garbage collector to enforce heap verification if option
987 987
    // --verify-heap is set.
988
    HEAP->CollectGarbage(v8::internal::NEW_SPACE);
988
    CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
989 989

  
990 990
    // Set the break flag again to come back here as soon as possible.
991
    v8::Debug::DebugBreak();
991
    v8::Debug::DebugBreak(CcTest::isolate());
992 992
  }
993 993
}
994 994

  
......
1001 1001
    const v8::Debug::EventDetails& event_details) {
1002 1002
  v8::DebugEvent event = event_details.GetEvent();
1003 1003
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
1004
  v8::internal::Isolate* isolate = v8::internal::Isolate::Current();
1004
  v8::Isolate* v8_isolate = CcTest::isolate();
1005
  v8::internal::Isolate* isolate = CcTest::i_isolate();
1005 1006
  v8::internal::Debug* debug = isolate->debug();
1006 1007
  // When hitting a debug event listener there must be a break set.
1007 1008
  CHECK_NE(debug->break_id(), 0);
......
1023 1024
      }
1024 1025

  
1025 1026
      // Set the break flag again to come back here as soon as possible.
1026
      v8::Debug::DebugBreak();
1027
      v8::Debug::DebugBreak(v8_isolate);
1027 1028

  
1028 1029
    } else if (terminate_after_max_break_point_hit) {
1029 1030
      // Terminate execution after the last break if requested.
1030
      v8::V8::TerminateExecution();
1031
      v8::V8::TerminateExecution(v8_isolate);
1031 1032
    }
1032 1033

  
1033 1034
    // Perform a full deoptimization when the specified number of
......
1075 1076
                          "function f2(){x=1;}", "f2",
1076 1077
                          0,
1077 1078
                          v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1078
                          Isolate::Current()->builtins()->builtin(
1079
                          CcTest::i_isolate()->builtins()->builtin(
1079 1080
                              Builtins::kStoreIC_DebugBreak));
1080 1081
  CheckDebugBreakFunction(&env,
1081 1082
                          "function f3(){var a=x;}", "f3",
1082 1083
                          0,
1083 1084
                          v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1084
                          Isolate::Current()->builtins()->builtin(
1085
                          CcTest::i_isolate()->builtins()->builtin(
1085 1086
                              Builtins::kLoadIC_DebugBreak));
1086 1087

  
1087 1088
// TODO(1240753): Make the test architecture independent or split
......
1095 1096
      "f4",
1096 1097
      0,
1097 1098
      v8::internal::RelocInfo::CODE_TARGET,
1098
      Isolate::Current()->builtins()->builtin(
1099
      CcTest::i_isolate()->builtins()->builtin(
1099 1100
          Builtins::kKeyedStoreIC_DebugBreak));
1100 1101
  CheckDebugBreakFunction(
1101 1102
      &env,
......
1103 1104
      "f5",
1104 1105
      0,
1105 1106
      v8::internal::RelocInfo::CODE_TARGET,
1106
      Isolate::Current()->builtins()->builtin(
1107
      CcTest::i_isolate()->builtins()->builtin(
1107 1108
          Builtins::kKeyedLoadIC_DebugBreak));
1108 1109
#endif
1109 1110

  
......
1113 1114
      "f6",
1114 1115
      0,
1115 1116
      v8::internal::RelocInfo::CODE_TARGET,
1116
      Isolate::Current()->builtins()->builtin(
1117
      CcTest::i_isolate()->builtins()->builtin(
1117 1118
          Builtins::kCompareNilIC_DebugBreak));
1118 1119

  
1119 1120
  // Check the debug break code stubs for call ICs with different number of
......
1449 1450
    CHECK_EQ(1 + i * 3, break_point_hit_count);
1450 1451

  
1451 1452
    // Scavenge and call function.
1452
    HEAP->CollectGarbage(v8::internal::NEW_SPACE);
1453
    CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
1453 1454
    f->Call(recv, 0, NULL);
1454 1455
    CHECK_EQ(2 + i * 3, break_point_hit_count);
1455 1456

  
1456 1457
    // Mark sweep (and perhaps compact) and call function.
1457
    HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1458
    CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1458 1459
    f->Call(recv, 0, NULL);
1459 1460
    CHECK_EQ(3 + i * 3, break_point_hit_count);
1460 1461
  }
......
2258 2259
  }
2259 2260
  f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2260 2261

  
2261
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2262
  CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2262 2263

  
2263 2264
  SetScriptBreakPointByNameFromJS("test.html", 3, -1);
2264 2265

  
......
2397 2398
// the correct results.
2398 2399
TEST(DebugEvaluate) {
2399 2400
  DebugLocalContext env;
2400
  v8::HandleScope scope(env->GetIsolate());
2401
  v8::Isolate* isolate = env->GetIsolate();
2402
  v8::HandleScope scope(isolate);
2401 2403
  env.ExposeDebug();
2402 2404

  
2403 2405
  // Create a function for checking the evaluation when hitting a break point.
......
2410 2412
  // Different expected vaules of x and a when in a break point (u = undefined,
2411 2413
  // d = Hello, world!).
2412 2414
  struct EvaluateCheck checks_uu[] = {
2413
    {"x", v8::Undefined()},
2414
    {"a", v8::Undefined()},
2415
    {"x", v8::Undefined(isolate)},
2416
    {"a", v8::Undefined(isolate)},
2415 2417
    {NULL, v8::Handle<v8::Value>()}
2416 2418
  };
2417 2419
  struct EvaluateCheck checks_hu[] = {
2418 2420
    {"x", v8::String::New("Hello, world!")},
2419
    {"a", v8::Undefined()},
2421
    {"a", v8::Undefined(isolate)},
2420 2422
    {NULL, v8::Handle<v8::Value>()}
2421 2423
  };
2422 2424
  struct EvaluateCheck checks_hh[] = {
......
2482 2484
  // parameter.
2483 2485
  checks = checks_uu;
2484 2486
  v8::Handle<v8::Value> argv_bar_1[2] = {
2485
    v8::Undefined(),
2487
    v8::Undefined(isolate),
2486 2488
    v8::Number::New(barbar_break_position)
2487 2489
  };
2488 2490
  bar->Call(env->Global(), 2, argv_bar_1);
......
2551 2553
static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
2552 2554
  if (eventDetails.GetEvent() == v8::Break) {
2553 2555
    ++debugEventCount;
2554
    v8::HandleScope handleScope(v8::Isolate::GetCurrent());
2556
    v8::HandleScope handleScope(CcTest::isolate());
2555 2557

  
2556 2558
    v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() };
2557 2559
    CHECK(checkGlobalEvalFunction->Call(
......
2726 2728
      "    \"expression\":\"v1\",\"disable_break\":true"
2727 2729
      "}}";
2728 2730

  
2729
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_111, buffer));
2731
  v8::Isolate* isolate = CcTest::isolate();
2732
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_111, buffer));
2730 2733

  
2731 2734
  const char* command_112 = "{\"seq\":112,"
2732 2735
      "\"type\":\"request\","
......
2736 2739
      "    \"expression\":\"getAnimal()\",\"disable_break\":true"
2737 2740
      "}}";
2738 2741

  
2739
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_112, buffer));
2742
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_112, buffer));
2740 2743

  
2741 2744
  const char* command_113 = "{\"seq\":113,"
2742 2745
     "\"type\":\"request\","
......
2746 2749
     "    \"expression\":\"239 + 566\",\"disable_break\":true"
2747 2750
     "}}";
2748 2751

  
2749
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_113, buffer));
2752
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_113, buffer));
2750 2753

  
2751 2754
  v8::Debug::ProcessDebugMessages();
2752 2755

  
......
2847 2850
  foo->Call(env->Global(), kArgc, args);
2848 2851

  
2849 2852
  // With stepping all break locations are hit.
2850
  CHECK_EQ(34, break_point_hit_count);
2853
  CHECK_EQ(35, break_point_hit_count);
2851 2854

  
2852 2855
  v8::Debug::SetDebugEventListener2(NULL);
2853 2856
  CheckDebuggerUnloaded();
......
2894 2897
  foo->Call(env->Global(), kArgc, args);
2895 2898

  
2896 2899
  // With stepping all break locations are hit.
2897
  CHECK_EQ(33, break_point_hit_count);
2900
  CHECK_EQ(34, break_point_hit_count);
2898 2901

  
2899 2902
  v8::Debug::SetDebugEventListener2(NULL);
2900 2903
  CheckDebuggerUnloaded();
......
2938 2941
  foo->Call(env->Global(), 0, NULL);
2939 2942

  
2940 2943
  // With stepping all break locations are hit.
2941
  CHECK_EQ(54, break_point_hit_count);
2944
  CHECK_EQ(55, break_point_hit_count);
2942 2945

  
2943 2946
  v8::Debug::SetDebugEventListener2(NULL);
2944 2947
  CheckDebuggerUnloaded();
......
2982 2985

  
2983 2986
// Test of the stepping mechanism for named load in a loop.
2984 2987
TEST(DebugStepNamedStoreLoop) {
2985
  DoDebugStepNamedStoreLoop(23);
2988
  DoDebugStepNamedStoreLoop(24);
2986 2989
}
2987 2990

  
2988 2991

  
......
3101 3104

  
3102 3105
TEST(DebugStepIf) {
3103 3106
  DebugLocalContext env;
3104
  v8::HandleScope scope(env->GetIsolate());
3107
  v8::Isolate* isolate = env->GetIsolate();
3108
  v8::HandleScope scope(isolate);
3105 3109

  
3106 3110
  // Register a debug event listener which steps and counts.
3107 3111
  v8::Debug::SetDebugEventListener2(DebugEventStep);
......
3125 3129
  // Stepping through the true part.
3126 3130
  step_action = StepIn;
3127 3131
  break_point_hit_count = 0;
3128
  v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
3132
  v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
3129 3133
  foo->Call(env->Global(), argc, argv_true);
3130 3134
  CHECK_EQ(4, break_point_hit_count);
3131 3135

  
3132 3136
  // Stepping through the false part.
3133 3137
  step_action = StepIn;
3134 3138
  break_point_hit_count = 0;
3135
  v8::Handle<v8::Value> argv_false[argc] = { v8::False() };
3139
  v8::Handle<v8::Value> argv_false[argc] = { v8::False(isolate) };
3136 3140
  foo->Call(env->Global(), argc, argv_false);
3137 3141
  CHECK_EQ(5, break_point_hit_count);
3138 3142

  
......
3354 3358
  v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3355 3359
  result = foo->Call(env->Global(), argc, argv_10);
3356 3360
  CHECK_EQ(5, result->Int32Value());
3357
  CHECK_EQ(51, break_point_hit_count);
3361
  CHECK_EQ(52, break_point_hit_count);
3358 3362

  
3359 3363
  // Looping 100 times.
3360 3364
  step_action = StepIn;
......
3362 3366
  v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3363 3367
  result = foo->Call(env->Global(), argc, argv_100);
3364 3368
  CHECK_EQ(50, result->Int32Value());
3365
  CHECK_EQ(456, break_point_hit_count);
3369
  CHECK_EQ(457, break_point_hit_count);
3366 3370

  
3367 3371
  // Get rid of the debug event listener.
3368 3372
  v8::Debug::SetDebugEventListener2(NULL);
......
3406 3410
  v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3407 3411
  result = foo->Call(env->Global(), argc, argv_10);
3408 3412
  CHECK_EQ(9, result->Int32Value());
3409
  CHECK_EQ(54, break_point_hit_count);
3413
  CHECK_EQ(55, break_point_hit_count);
3410 3414

  
3411 3415
  // Looping 100 times.
3412 3416
  step_action = StepIn;
......
3414 3418
  v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3415 3419
  result = foo->Call(env->Global(), argc, argv_100);
3416 3420
  CHECK_EQ(99, result->Int32Value());
3417
  CHECK_EQ(504, break_point_hit_count);
3421
  CHECK_EQ(505, break_point_hit_count);
3418 3422

  
3419 3423
  // Get rid of the debug event listener.
3420 3424
  v8::Debug::SetDebugEventListener2(NULL);
......
3503 3507

  
3504 3508
TEST(DebugConditional) {
3505 3509
  DebugLocalContext env;
3506
  v8::HandleScope scope(env->GetIsolate());
3510
  v8::Isolate* isolate = env->GetIsolate();
3511
  v8::HandleScope scope(isolate);
3507 3512

  
3508 3513
  // Register a debug event listener which steps and counts.
3509 3514
  v8::Debug::SetDebugEventListener2(DebugEventStep);
......
3527 3532
  step_action = StepIn;
3528 3533
  break_point_hit_count = 0;
3529 3534
  const int argc = 1;
3530
  v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
3535
  v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
3531 3536
  foo->Call(env->Global(), argc, argv_true);
3532 3537
  CHECK_EQ(5, break_point_hit_count);
3533 3538

  
......
3755 3760
// Test that step in works with function.call.
3756 3761
TEST(DebugStepFunctionCall) {
3757 3762
  DebugLocalContext env;
3758
  v8::HandleScope scope(env->GetIsolate());
3763
  v8::Isolate* isolate = env->GetIsolate();
3764
  v8::HandleScope scope(isolate);
3759 3765

  
3760 3766
  // Create a function for testing stepping.
3761 3767
  v8::Local<v8::Function> foo = CompileFunction(
......
3782 3788
  // Check stepping where the if condition in bar is true.
3783 3789
  break_point_hit_count = 0;
3784 3790
  const int argc = 1;
3785
  v8::Handle<v8::Value> argv[argc] = { v8::True() };
3791
  v8::Handle<v8::Value> argv[argc] = { v8::True(isolate) };
3786 3792
  foo->Call(env->Global(), argc, argv);
3787 3793
  CHECK_EQ(8, break_point_hit_count);
3788 3794

  
......
3845 3851
  v8::HandleScope scope(env->GetIsolate());
3846 3852
  env.ExposeDebug();
3847 3853

  
3848
  v8::internal::Isolate::Current()->TraceException(false);
3854
  CcTest::i_isolate()->TraceException(false);
3849 3855

  
3850 3856
  // Create functions for testing break on exception.
3851 3857
  CompileFunction(&env, "function throws(){throw 1;}", "throws");
......
3991 3997
  // For this test, we want to break on uncaught exceptions:
3992 3998
  ChangeBreakOnException(false, true);
3993 3999

  
3994
  v8::internal::Isolate::Current()->TraceException(false);
4000
  CcTest::i_isolate()->TraceException(false);
3995 4001

  
3996 4002
  // Create a function for checking the function when hitting a break point.
3997 4003
  frame_count = CompileFunction(&env, frame_count_source, "frame_count");
......
4162 4168
  f3->Call(env->Global(), 0, NULL);
4163 4169

  
4164 4170
  // Set the debug break flag.
4165
  v8::Debug::DebugBreak();
4171
  v8::Debug::DebugBreak(env->GetIsolate());
4166 4172

  
4167 4173
  // Call all functions with different argument count.
4168 4174
  break_point_hit_count = 0;
......
4196 4202
  v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
4197 4203

  
4198 4204
  // Set the debug break flag.
4199
  v8::Debug::DebugBreak();
4205
  v8::Debug::DebugBreak(env->GetIsolate());
4200 4206

  
4201 4207
  // Call all functions with different argument count.
4202 4208
  break_point_hit_count = 0;
......
4204 4210
  CHECK_EQ(1, break_point_hit_count);
4205 4211

  
4206 4212
  {
4207
    v8::Debug::DebugBreak();
4213
    v8::Debug::DebugBreak(env->GetIsolate());
4208 4214
    i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
4209 4215
    v8::internal::DisableBreak disable_break(isolate, true);
4210 4216
    f->Call(env->Global(), 0, NULL);
......
4227 4233
// http://crbug.com/28933
4228 4234
// Test that debug break is disabled when bootstrapper is active.
4229 4235
TEST(NoBreakWhenBootstrapping) {
4230
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
4236
  v8::Isolate* isolate = CcTest::isolate();
4231 4237
  v8::HandleScope scope(isolate);
4232 4238

  
4233 4239
  // Register a debug event listener which sets the break flag and counts.
4234 4240
  v8::Debug::SetDebugEventListener2(DebugEventCounter);
4235 4241

  
4236 4242
  // Set the debug break flag.
4237
  v8::Debug::DebugBreak();
4243
  v8::Debug::DebugBreak(isolate);
4238 4244
  break_point_hit_count = 0;
4239 4245
  {
4240 4246
    // Create a context with an extension to make sure that some JavaScript
......
4889 4895
  // until the execution of source_2.
4890 4896
  // Note: AsciiToUtf16 executes before SendCommand, so command is copied
4891 4897
  // to buffer before buffer is sent to SendCommand.
4892
  v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_1, buffer_1));
4893
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_2, buffer_2));
4894
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4895
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4896
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4898
  v8::Isolate* isolate = CcTest::isolate();
4899
  v8::Debug::SendCommand(isolate, buffer_1, AsciiToUtf16(command_1, buffer_1));
4900
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_2, buffer_2));
4901
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_3, buffer_2));
4902
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_3, buffer_2));
4903
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_3, buffer_2));
4897 4904
  message_queue_barriers.barrier_2.Wait();
4898 4905
  // Main thread compiles and runs source_2.
4899 4906
  // Queued commands are executed at the start of compilation of source_2(
......
4913 4920
  // Wait on break event from hitting "debugger" statement
4914 4921
  message_queue_barriers.semaphore_2.Wait();
4915 4922
  // These should execute after the "debugger" statement in source_2
4916
  v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_1, buffer_1));
4917
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_2, buffer_2));
4918
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4919
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_single_step, buffer_2));
4923
  v8::Debug::SendCommand(isolate, buffer_1, AsciiToUtf16(command_1, buffer_1));
4924
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_2, buffer_2));
4925
  v8::Debug::SendCommand(isolate, buffer_2, AsciiToUtf16(command_3, buffer_2));
4926
  v8::Debug::SendCommand(
4927
      isolate, buffer_2, AsciiToUtf16(command_single_step, buffer_2));
4920 4928
  // Run after 2 break events, 4 responses.
4921 4929
  for (int i = 0; i < 6 ; ++i) {
4922 4930
    message_queue_barriers.semaphore_1.Signal();
4923 4931
  }
4924 4932
  // Wait on break event after a single step executes.
4925 4933
  message_queue_barriers.semaphore_2.Wait();
4926
  v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_2, buffer_1));
4927
  v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_continue, buffer_2));
4934
  v8::Debug::SendCommand(isolate, buffer_1, AsciiToUtf16(command_2, buffer_1));
4935
  v8::Debug::SendCommand(
4936
      isolate, buffer_2, AsciiToUtf16(command_continue, buffer_2));
4928 4937
  // Run after 2 responses.
4929 4938
  for (int i = 0; i < 2 ; ++i) {
4930 4939
    message_queue_barriers.semaphore_1.Signal();
......
5030 5039
TEST(SendClientDataToHandler) {
5031 5040
  // Create a V8 environment
5032 5041
  DebugLocalContext env;
5033
  v8::HandleScope scope(env->GetIsolate());
5042
  v8::Isolate* isolate = env->GetIsolate();
5043
  v8::HandleScope scope(isolate);
5034 5044
  TestClientData::ResetCounters();
5035 5045
  handled_client_data_instances_count = 0;
5036 5046
  v8::Debug::SetMessageHandler2(MessageHandlerCountingClientData);
......
5052 5062
     "\"type\":\"request\","
5053 5063
     "\"command\":\"continue\"}";
5054 5064

  
5055
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer),
5065
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer),
5056 5066
                         new TestClientData());
5057
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer), NULL);
5058
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer),
5067
  v8::Debug::SendCommand(
5068
      isolate, buffer, AsciiToUtf16(command_2, buffer), NULL);
5069
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer),
5059 5070
                         new TestClientData());
5060
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer),
5071
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer),
5061 5072
                         new TestClientData());
5062 5073
  // All the messages will be processed on beforeCompile event.
5063 5074
  CompileRun(source_1);
5064
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer));
5075
  v8::Debug::SendCommand(
5076
      isolate, buffer, AsciiToUtf16(command_continue, buffer));
5065 5077
  CHECK_EQ(3, TestClientData::constructor_call_counter);
5066 5078
  CHECK_EQ(TestClientData::constructor_call_counter,
5067 5079
           handled_client_data_instances_count);
......
5134 5146
      "\n"
5135 5147
      "foo();\n";
5136 5148

  
5137
  v8::V8::Initialize();
5149
  v8::Isolate::Scope isolate_scope(CcTest::isolate());
5138 5150
  DebugLocalContext env;
5139 5151
  v8::HandleScope scope(env->GetIsolate());
5140 5152
  v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
5141 5153
  v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5142 5154
  global_template->Set(v8::String::New("ThreadedAtBarrier1"),
5143 5155
                       v8::FunctionTemplate::New(ThreadedAtBarrier1));
5144
  v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(),
5156
  v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
5145 5157
                                                     NULL,
5146 5158
                                                     global_template);
5147 5159
  v8::Context::Scope context_scope(context);
......
5162 5174
      "\"type\":\"request\","
5163 5175
      "\"command\":\"continue\"}";
5164 5176

  
5177
  v8::Isolate* isolate = CcTest::isolate();
5165 5178
  threaded_debugging_barriers.barrier_1.Wait();
5166
  v8::Debug::DebugBreak();
5179
  v8::Debug::DebugBreak(isolate);
5167 5180
  threaded_debugging_barriers.barrier_2.Wait();
5168
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5169
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5181
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
5182
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
5170 5183
}
5171 5184

  
5172 5185

  
......
5249 5262
  const char* source_2 = "cat(17);\n"
5250 5263
    "cat(19);\n";
5251 5264

  
5252
  v8::V8::Initialize();
5265
  v8::Isolate* isolate = CcTest::isolate();
5266
  v8::Isolate::Scope isolate_scope(isolate);
5253 5267
  DebugLocalContext env;
5254
  v8::HandleScope scope(env->GetIsolate());
5268
  v8::HandleScope scope(isolate);
5255 5269
  v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler);
5256 5270

  
5257 5271
  CompileRun(source_1);
......
5323 5337
      "\"command\":\"continue\"}";
5324 5338

  
5325 5339

  
5340
  v8::Isolate* isolate = CcTest::isolate();
5341
  v8::Isolate::Scope isolate_scope(isolate);
5326 5342
  // v8 thread initializes, runs source_1
5327 5343
  breakpoints_barriers->barrier_1.Wait();
5328 5344
  // 1:Set breakpoint in cat() (will get id 1).
5329
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5345
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
5330 5346
  // 2:Set breakpoint in dog() (will get id 2).
5331
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5347
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
5332 5348
  breakpoints_barriers->barrier_2.Wait();
5333 5349
  // V8 thread starts compiling source_2.
5334 5350
  // Automatic break happens, to run queued commands
......
5340 5356
  // Must have hit breakpoint #1.
5341 5357
  CHECK_EQ(1, break_event_breakpoint_id);
5342 5358
  // 4:Evaluate dog() (which has a breakpoint).
5343
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_3, buffer));
5359
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_3, buffer));
5344 5360
  // V8 thread hits breakpoint in dog().
5345 5361
  breakpoints_barriers->semaphore_1.Wait();  // wait for break event
5346 5362
  // Must have hit breakpoint #2.
5347 5363
  CHECK_EQ(2, break_event_breakpoint_id);
5348 5364
  // 5:Evaluate (x + 1).
5349
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_4, buffer));
5365
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_4, buffer));
5350 5366
  // Evaluate (x + 1) finishes.
5351 5367
  breakpoints_barriers->semaphore_1.Wait();
5352 5368
  // Must have result 108.
5353 5369
  CHECK_EQ(108, evaluate_int_result);
5354 5370
  // 6:Continue evaluation of dog().
5355
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_5, buffer));
5371
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_5, buffer));
5356 5372
  // Evaluate dog() finishes.
5357 5373
  breakpoints_barriers->semaphore_1.Wait();
5358 5374
  // Must have result 107.
5359 5375
  CHECK_EQ(107, evaluate_int_result);
5360 5376
  // 7:Continue evaluation of source_2, finish cat(17), hit breakpoint
5361 5377
  // in cat(19).
5362
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_6, buffer));
5378
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_6, buffer));
5363 5379
  // Message callback gets break event.
5364 5380
  breakpoints_barriers->semaphore_1.Wait();  // wait for break event
5365 5381
  // Must have hit breakpoint #1.
5366 5382
  CHECK_EQ(1, break_event_breakpoint_id);
5367 5383
  // 8: Evaluate dog() with breaks disabled.
5368
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer));
5384
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_7, buffer));
5369 5385
  // Evaluate dog() finishes.
5370 5386
  breakpoints_barriers->semaphore_1.Wait();
5371 5387
  // Must have result 116.
5372 5388
  CHECK_EQ(116, evaluate_int_result);
5373 5389
  // 9: Continue evaluation of source2, reach end.
5374
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer));
5390
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_8, buffer));
5375 5391
}
5376 5392

  
5377 5393

  
......
5422 5438
}
5423 5439

  
5424 5440

  
5425
TEST(DebugBreakOnUninitializedVM) {
5426
  v8::Debug::DebugBreak();
5427
}
5428

  
5429

  
5430
TEST(SendCommandToUninitializedVM) {
5431
  const char* dummy_command = "{}";
5432
  uint16_t dummy_buffer[80];
5433
  int dummy_length = AsciiToUtf16(dummy_command, dummy_buffer);
5434
  v8::Debug::SendCommand(dummy_buffer, dummy_length);
5435
}
5436

  
5437

  
5438 5441
// Source for a JavaScript function which returns the data parameter of a
5439 5442
// function called in the context of the debugger. If no data parameter is
5440 5443
// passed it throws an exception.
......
5505 5508
TEST(CallFunctionInDebugger) {
5506 5509
  // Create and enter a context with the functions CheckFrameCount,
5507 5510
  // CheckSourceLine and CheckDataParameter installed.
5508
  v8::HandleScope scope(v8::Isolate::GetCurrent());
5511
  v8::HandleScope scope(CcTest::isolate());
5509 5512
  v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5510 5513
  global_template->Set(v8::String::New("CheckFrameCount"),
5511 5514
                       v8::FunctionTemplate::New(CheckFrameCount));
......
5515 5518
                       v8::FunctionTemplate::New(CheckDataParameter));
5516 5519
  global_template->Set(v8::String::New("CheckClosure"),
5517 5520
                       v8::FunctionTemplate::New(CheckClosure));
5518
  v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(),
5521
  v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
5519 5522
                                                     NULL,
5520 5523
                                                     global_template);
5521 5524
  v8::Context::Scope context_scope(context);
......
5664 5667
     "\"type\":\"request\","
5665 5668
     "\"command\":\"continue\"}";
5666 5669

  
5667
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer));
5670
  v8::Debug::SendCommand(
5671
      CcTest::isolate(), buffer, AsciiToUtf16(command_continue, buffer));
5668 5672
}
5669 5673

  
5670 5674

  
......
5791 5795
    "\n";
5792 5796
  const char* source_2 = "cat(17);\n";
5793 5797

  
5794
  v8::V8::Initialize();
5798
  v8::Isolate::Scope isolate_scope(CcTest::isolate());
5795 5799
  DebugLocalContext env;
5796 5800
  v8::HandleScope scope(env->GetIsolate());
5797 5801

  
......
5818 5822
      "\"type\":\"request\","
5819 5823
      "\"command\":\"continue\"}";
5820 5824

  
5825
  v8::Isolate* isolate = CcTest::isolate();
5821 5826
  // v8 thread initializes, runs source_1
5822 5827
  host_dispatch_barriers->barrier_1.Wait();
5823 5828
  // 1: Set breakpoint in cat().
5824
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5829
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
5825 5830

  
5826 5831
  host_dispatch_barriers->barrier_2.Wait();
5827 5832
  // v8 thread starts compiling source_2.
......
5829 5834
  // Wait for host dispatch to be processed.
5830 5835
  host_dispatch_barriers->semaphore_1.Wait();
5831 5836
  // 2: Continue evaluation
5832
  v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5837
  v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
5833 5838
}
5834 5839

  
5835 5840

  
......
5878 5883

  
5879 5884

  
5880 5885
void DebugMessageDispatchV8Thread::Run() {
5881
  v8::V8::Initialize();
5886
  v8::Isolate::Scope isolate_scope(CcTest::isolate());
5882 5887
  DebugLocalContext env;
5883 5888
  v8::HandleScope scope(env->GetIsolate());
5884 5889

  
......
5920 5925

  
5921 5926
TEST(DebuggerAgent) {
5922 5927
  v8::V8::Initialize();
5923
  i::Debugger* debugger = i::Isolate::Current()->debugger();
5928
  i::Debugger* debugger = CcTest::i_isolate()->debugger();
5924 5929
  // Make sure these ports is not used by other tests to allow tests to run in
5925 5930
  // parallel.
5926 5931
  const int kPort1 = 5858 + FlagDependentPortOffset();
......
6235 6240
// Checks that this data is set correctly and that when the debug message
6236 6241
// handler is called the expected context is the one active.
6237 6242
TEST(ContextData) {
6238
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
6243
  v8::Isolate* isolate = CcTest::isolate();
6239 6244
  v8::HandleScope scope(isolate);
6240 6245

  
6241 6246
  // Create two contexts.
......
6298 6303
  if (message.IsEvent() && message.GetEvent() == v8::Break) {
6299 6304
    message_handler_break_hit_count++;
6300 6305
    if (message_handler_break_hit_count == 1) {
6301
      v8::Debug::DebugBreak();
6306
      v8::Debug::DebugBreak(message.GetIsolate());
6302 6307
    }
6303 6308
  }
6304 6309

  
......
6364 6369

  
6365 6370
    // Keep forcing breaks.
6366 6371
    if (break_point_hit_count < 20) {
6367
      v8::Debug::DebugBreak();
6372
      v8::Debug::DebugBreak(CcTest::isolate());
6368 6373
    }
6369 6374
  }
6370 6375
}
......
6393 6398
  CHECK_EQ(12, result->Int32Value());
6394 6399

  
6395 6400
  v8::Debug::SetDebugEventListener2(DebugEventDebugBreak);
6396
  v8::Debug::DebugBreak();
6401
  v8::Debug::DebugBreak(env->GetIsolate());
6397 6402
  result = f->Call(env->Global(), argc, argv);
6398 6403

  
6399 6404
  // Check that there was only one break event. Matching RegExp should not
......
6412 6417
  v8::Handle<v8::ObjectTemplate> global_template =
6413 6418
      v8::Handle<v8::ObjectTemplate>();
6414 6419
  context_1 =
6415
      v8::Context::New(v8::Isolate::GetCurrent(), NULL, global_template);
6420
      v8::Context::New(CcTest::isolate(), NULL, global_template);
6416 6421

  
6417 6422
  v8::Debug::SetMessageHandler2(message_handler);
6418 6423

  
......
6445 6450
// break event in an eval statement the expected context is the one returned by
6446 6451
// Message.GetEventContext.
6447 6452
TEST(EvalContextData) {
6448
  v8::HandleScope scope(v8::Isolate::GetCurrent());
6453
  v8::HandleScope scope(CcTest::isolate());
6449 6454

  
6450 6455
  ExecuteScriptForContextCheck(ContextCheckMessageHandler);
6451 6456

  
......
6471 6476
  v8::String::Value json(message.GetJSON());
6472 6477
  Utf16ToAscii(*json, json.length(), print_buffer);
6473 6478

  
6479
  v8::Isolate* isolate = message.GetIsolate();
6474 6480
  if (IsBreakEventMessage(print_buffer)) {
6475 6481
    break_count++;
6476 6482
    if (!sent_eval) {
......
6486 6492
          "\"global\":true,\"disable_break\":false}}";
6487 6493

  
6488 6494
      // Send evaluate command.
6489
      v8::Debug::SendCommand(buffer, AsciiToUtf16(eval_command, buffer));
6495
      v8::Debug::SendCommand(
6496
          isolate, buffer, AsciiToUtf16(eval_command, buffer));
6490 6497
      return;
6491 6498
    } else {
6492 6499
      // It's a break event caused by the evaluation request above.
......
6506 6513
// Tests that context returned for break event is correct when the event occurs
6507 6514
// in 'evaluate' debugger request.
6508 6515
TEST(NestedBreakEventContextData) {
6509
  v8::HandleScope scope(v8::Isolate::GetCurrent());
6516
  v8::HandleScope scope(CcTest::isolate());
6510 6517
  break_count = 0;
6511 6518
  message_handler_hit_count = 0;
6512 6519

  
......
6535 6542

  
6536 6543
// Test that scripts collected are reported through the debug event listener.
6537 6544
TEST(ScriptCollectedEvent) {
6538
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
6545
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
6539 6546
  break_point_hit_count = 0;
6540 6547
  script_collected_count = 0;
6541 6548
  DebugLocalContext env;
......
6546 6553

  
6547 6554
  // Do garbage collection to ensure that only the script in this test will be
6548 6555
  // collected afterwards.
6549
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6556
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6550 6557

  
6551 6558
  script_collected_count = 0;
6552 6559
  v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent);
......
6557 6564

  
6558 6565
  // Do garbage collection to collect the script above which is no longer
6559 6566
  // referenced.
6560
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6567
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6561 6568

  
6562 6569
  CHECK_EQ(2, script_collected_count);
6563 6570

  
......
6582 6589
// ScriptCollected events.
6583 6590
TEST(ScriptCollectedEventContext) {
6584 6591
  i::FLAG_stress_compaction = false;
6585
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
6592
  v8::Isolate* isolate = CcTest::isolate();
6586 6593
  v8::internal::Debug* debug =
6587 6594
      reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
6588 6595
  script_collected_message_count = 0;
......
6608 6615

  
6609 6616
  // Do garbage collection to ensure that only the script in this test will be
6610 6617
  // collected afterwards.
6611
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6618
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6612 6619

  
6613 6620
  v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
6614 6621
  v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
......
6625 6632

  
6626 6633
  // Do garbage collection to collect the script above which is no longer
6627 6634
  // referenced.
6628
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6635
  CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6629 6636

  
6630 6637
  CHECK_EQ(2, script_collected_message_count);
6631 6638

  
......
6660 6667
  v8::Debug::SetMessageHandler2(NULL);
6661 6668

  
6662 6669
  v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6663
  v8::Debug::DebugBreak();
6670
  v8::Debug::DebugBreak(env->GetIsolate());
6664 6671
  v8::Script::Compile(v8::String::New(script))->Run();
6665 6672

  
6666 6673
  // Setting listener to NULL should cause debugger unload.
......
6684 6691
  v8::Debug::SetMessageHandler2(NULL);
6685 6692

  
6686 6693
  v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6687
  v8::Debug::DebugBreak();
6694
  v8::Debug::DebugBreak(env->GetIsolate());
6688 6695
  v8::Local<v8::Function> f =
6689 6696
      v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6690 6697
  f->Call(env->Global(), 0, NULL);
......
6773 6780

  
6774 6781

  
6775 6782
static void BreakMessageHandler(const v8::Debug::Message& message) {
6776
  i::Isolate* isolate = i::Isolate::Current();
6783
  i::Isolate* isolate = CcTest::i_isolate();
6777 6784
  if (message.IsEvent() && message.GetEvent() == v8::Break) {
6778 6785
    // Count the number of breaks.
6779 6786
    break_point_hit_count++;
......
6812 6819
  v8::Debug::SetMessageHandler2(BreakMessageHandler);
6813 6820

  
6814 6821
  // Set the debug break flag.
6815
  v8::Debug::DebugBreak();
6822
  v8::Debug::DebugBreak(env->GetIsolate());
6816 6823

  
6817 6824
  // Create a function for testing stepping.
6818 6825
  const char* src = "function f() { eval('var x = 10;'); } ";
......
6822 6829
  CHECK_EQ(1, break_point_hit_count);
6823 6830

  
6824 6831
  // Set the debug break flag again.
6825
  v8::Debug::DebugBreak();
6832
  v8::Debug::DebugBreak(env->GetIsolate());
6826 6833
  f->Call(env->Global(), 0, NULL);
6827 6834
  // There should be one more break event when the script is evaluated in 'f'.
6828 6835
  CHECK_EQ(2, break_point_hit_count);
......
6843 6850
// Test that debug messages get processed when ProcessDebugMessages is called.
6844 6851
TEST(ProcessDebugMessages) {
6845 6852
  DebugLocalContext env;
6846
  v8::HandleScope scope(env->GetIsolate());
6853
  v8::Isolate* isolate = env->GetIsolate();
6854
  v8::HandleScope scope(isolate);
6847 6855

  
6848 6856
  counting_message_handler_counter = 0;
6849 6857

  
......
6857 6865
     "\"command\":\"scripts\"}";
6858 6866

  
6859 6867
  // Send scripts command.
6860
  v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6868
  v8::Debug::SendCommand(
6869
      isolate, buffer, AsciiToUtf16(scripts_command, buffer));
6861 6870

  
6862 6871
  CHECK_EQ(0, counting_message_handler_counter);
6863 6872
  v8::Debug::ProcessDebugMessages();
......
6866 6875

  
6867 6876
  counting_message_handler_counter = 0;
6868 6877

  
6869
  v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6870
  v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6878
  v8::Debug::SendCommand(
6879
      isolate, buffer, AsciiToUtf16(scripts_command, buffer));
6880
  v8::Debug::SendCommand(
6881
      isolate, buffer, AsciiToUtf16(scripts_command, buffer));
6871 6882
  CHECK_EQ(0, counting_message_handler_counter);
6872 6883
  v8::Debug::ProcessDebugMessages();
6873 6884
  // At least two messages should come
......
6899 6910
// Test that debug messages get processed when ProcessDebugMessages is called.
6900 6911
TEST(Backtrace) {
6901 6912
  DebugLocalContext env;
6902
  v8::HandleScope scope(env->GetIsolate());
6913
  v8::Isolate* isolate = env->GetIsolate();
6914
  v8::HandleScope scope(isolate);
6903 6915

  
6904 6916
  v8::Debug::SetMessageHandler2(BacktraceData::MessageHandler);
6905 6917

  
......
6912 6924

  
6913 6925
  // Check backtrace from ProcessDebugMessages.
6914 6926
  BacktraceData::frame_counter = -10;
6915
  v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6927
  v8::Debug::SendCommand(
6928
      isolate,
6929
      buffer,
6930
      AsciiToUtf16(scripts_command, buffer),
6931
      NULL);
6916 6932
  v8::Debug::ProcessDebugMessages();
6917 6933
  CHECK_EQ(BacktraceData::frame_counter, 0);
6918 6934

  
......
6921 6937

  
6922 6938
  // Check backtrace from "void(0)" script.
6923 6939
  BacktraceData::frame_counter = -10;
6924
  v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6940
  v8::Debug::SendCommand(
6941
      isolate,
6942
      buffer,
6943
      AsciiToUtf16(scripts_command, buffer),
6944
      NULL);
6925 6945
  script->Run();
6926 6946
  CHECK_EQ(BacktraceData::frame_counter, 1);
6927 6947

  
......
6965 6985
  v8::Debug::SetDebugEventListener2(DebugEventBreakMax);
6966 6986

  
6967 6987
  // Set the debug break flag before calling the code using function.apply.
6968
  v8::Debug::DebugBreak();
6988
  v8::Debug::DebugBreak(env->GetIsolate());
6969 6989

  
6970 6990
  // Limit the number of debug breaks. This is a regression test for issue 493
6971 6991
  // where this test would enter an infinite loop.
......
6991 7011
    v8::Local<v8::String> name,
6992 7012
    const v8::PropertyCallbackInfo<v8::Value>& info) {
6993 7013
  CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a"));
6994
  v8::Handle<v8::Context> current = v8::Context::GetCurrent();
7014
  v8::Handle<v8::Context> current = info.GetIsolate()->GetCurrentContext();
6995 7015
  CHECK(current == debugee_context);
6996 7016
  CHECK(current != debugger_context);
6997
  v8::Handle<v8::Context> calling = v8::Context::GetCalling();
7017
  v8::Handle<v8::Context> calling = info.GetIsolate()->GetCallingContext();
6998 7018
  CHECK(calling == debugee_context);
6999 7019
  CHECK(calling != debugger_context);
7000 7020
  info.GetReturnValue().Set(1);
......
7010 7030
  v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7011 7031
  if (event == v8::Break) {
7012 7032
    break_point_hit_count++;
7013
    CHECK(debugger_context == v8::Context::GetCurrent());
7033
    CHECK(debugger_context == CcTest::isolate()->GetCurrentContext());
7014 7034
    v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun(
7015 7035
        "(function(exec_state) {\n"
7016 7036
        "    return (exec_state.frame(0).argumentValue(0).property('a').\n"
......
7025 7045

  
7026 7046

  
7027 7047
TEST(CallingContextIsNotDebugContext) {
7028
  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
7048
  v8::internal::Debug* debug = CcTest::i_isolate()->debug();
7029 7049
  // Create and enter a debugee context.
7030 7050
  DebugLocalContext env;
7031 7051
  v8::HandleScope scope(env->GetIsolate());
......
7065 7085

  
7066 7086

  
7067 7087
TEST(DebugContextIsPreservedBetweenAccesses) {
7068
  v8::HandleScope scope(v8::Isolate::GetCurrent());
7088
  v8::HandleScope scope(CcTest::isolate());
7069 7089
  v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
7070 7090
  v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
7071 7091
  CHECK_EQ(*context1, *context2);
......
7081 7101

  
7082 7102
// Check that event details contain context where debug event occured.
7083 7103
TEST(DebugEventContext) {
7084
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
7104
  v8::Isolate* isolate = CcTest::isolate();
7085 7105
  v8::HandleScope scope(isolate);
7086 7106
  expected_callback_data = v8::Int32::New(2010);
7087 7107
  expected_context = v8::Context::New(isolate);
......
7112 7132
// Check that event details contain context where debug event occured.
7113 7133
TEST(DebugEventBreakData) {
7114 7134
  DebugLocalContext env;
7115
  v8::HandleScope scope(env->GetIsolate());
7135
  v8::Isolate* isolate = env->GetIsolate();
7136
  v8::HandleScope scope(isolate);
7116 7137
  v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker);
7117 7138

  
7118 7139
  TestClientData::constructor_call_counter = 0;
......
7121 7142
  expected_break_data = NULL;
7122 7143
  was_debug_event_called = false;
7123 7144
  was_debug_break_called = false;
7124
  v8::Debug::DebugBreakForCommand();
7145
  v8::Debug::DebugBreakForCommand(NULL, isolate);
7125 7146
  v8::Script::Compile(v8::String::New("(function(x){return x;})(1);"))->Run();
7126 7147
  CHECK(was_debug_event_called);
7127 7148
  CHECK(!was_debug_break_called);
......
7130 7151
  expected_break_data = data1;
7131 7152
  was_debug_event_called = false;
7132 7153
  was_debug_break_called = false;
7133
  v8::Debug::DebugBreakForCommand(data1);
7154
  v8::Debug::DebugBreakForCommand(data1, isolate);
7134 7155
  v8::Script::Compile(v8::String::New("(function(x){return x+1;})(1);"))->Run();
7135 7156
  CHECK(was_debug_event_called);
7136 7157
  CHECK(!was_debug_break_called);
......
7138 7159
  expected_break_data = NULL;
7139 7160
  was_debug_event_called = false;
7140 7161
  was_debug_break_called = false;
7141
  v8::Debug::DebugBreak();
7162
  v8::Debug::DebugBreak(isolate);
7142 7163
  v8::Script::Compile(v8::String::New("(function(x){return x+2;})(1);"))->Run();
7143 7164
  CHECK(!was_debug_event_called);
7144 7165
  CHECK(was_debug_break_called);
......
7147 7168
  expected_break_data = data2;
7148 7169
  was_debug_event_called = false;
7149 7170
  was_debug_break_called = false;
7150
  v8::Debug::DebugBreak();
7151
  v8::Debug::DebugBreakForCommand(data2);
7171
  v8::Debug::DebugBreak(isolate);
7172
  v8::Debug::DebugBreakForCommand(data2, isolate);
7152 7173
  v8::Script::Compile(v8::String::New("(function(x){return x+3;})(1);"))->Run();
7153 7174
  CHECK(was_debug_event_called);
7154 7175
  CHECK(was_debug_break_called);
......
7180 7201
        v8::Handle<v8::String> function_name(result->ToString());
7181 7202
        function_name->WriteUtf8(fn);
7182 7203
        if (strcmp(fn, "bar") == 0) {
7183
          i::Deoptimizer::DeoptimizeAll(v8::internal::Isolate::Current());
7204
          i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
7184 7205
          debug_event_break_deoptimize_done = true;
7185 7206
        }
7186 7207
      }
7187 7208
    }
7188 7209

  
7189
    v8::Debug::DebugBreak();
7210
    v8::Debug::DebugBreak(CcTest::isolate());
7190 7211
  }
7191 7212
}
7192 7213

  
......
7215 7236
  v8::Script::Compile(v8::String::New("function bar(){}; bar()"))->Run();
7216 7237

  
7217 7238
  // Set debug break and call bar again.
7218
  v8::Debug::DebugBreak();
7239
  v8::Debug::DebugBreak(env->GetIsolate());
7219 7240
  v8::Script::Compile(v8::String::New("bar()"))->Run();
7220 7241

  
7221 7242
  CHECK(debug_event_break_deoptimize_done);
......
7273 7294

  
7274 7295
static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
7275 7296
  v8::Debug::SetDebugEventListener2(DebugEventBreakWithOptimizedStack);
7276
  v8::Debug::DebugBreak();
7297
  v8::Debug::DebugBreak(args.GetIsolate());
7277 7298
}
7278 7299

  
7279 7300

  
......
7338 7359
      CompileRun(buffer.start());
7339 7360

  
7340 7361
      // Set the debug break to enter the debugger as soon as possible.
7341
      v8::Debug::DebugBreak();
7362
      v8::Debug::DebugBreak(CcTest::isolate());
7342 7363

  
7343 7364
      // Call function with infinite loop.
7344 7365
      CompileRun("f();");
......
7408 7429
  i::Handle<i::Script> source_script = i::Handle<i::Script>(i::Script::cast(
7409 7430
      i::JSFunction::cast(*compiled_script)->shared()->script()));
7410 7431

  
7411
  int break_id = v8::internal::Isolate::Current()->debug()->break_id();
7432
  int break_id = CcTest::i_isolate()->debug()->break_id();
7412 7433
  char script[128];
7413 7434
  i::Vector<char> script_vector(script, sizeof(script));
7414 7435
  OS::SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
......
7426 7447
             i::GetScriptLineNumber(source_script, result->Int32Value()));
7427 7448
  }
7428 7449
  v8::Debug::SetDebugEventListener2(NULL);
7429
  v8::V8::TerminateExecution();
7450
  v8::V8::TerminateExecution(CcTest::isolate());
7430 7451
}
7431 7452

  
7432 7453

  
......
7526 7547
  v8::internal::FLAG_allow_natives_syntax = true;
7527 7548
  LocalContext env;
7528 7549
  v8::HandleScope scope(env->GetIsolate());
7529
  v8::Debug::SetLiveEditEnabled(true);
7550
  v8::Debug::SetLiveEditEnabled(true, env->GetIsolate());
7530 7551
  CompileRun("%LiveEditCompareStrings('', '')");
7531 7552
}
7532 7553

  
......
7535 7556
  v8::internal::FLAG_allow_natives_syntax = true;
7536 7557
  LocalContext env;
7537 7558
  v8::HandleScope scope(env->GetIsolate());
7538
  v8::Debug::SetLiveEditEnabled(false);
7559
  v8::Debug::SetLiveEditEnabled(false), env->GetIsolate();
7539 7560
  CompileRun("%LiveEditCompareStrings('', '')");
7540 7561
}
7541 7562

  

Also available in: Unified diff