vendor/v8/test/cctest/test-debug.cc in mustang-0.0.1 vs vendor/v8/test/cctest/test-debug.cc in mustang-0.1.0
- old
+ new
@@ -141,21 +141,23 @@
}
inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; }
inline bool IsReady() { return !context_.IsEmpty(); }
void ExposeDebug() {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// Expose the debug context global object in the global object for testing.
- Debug::Load();
- Debug::debug_context()->set_security_token(
+ debug->Load();
+ debug->debug_context()->set_security_token(
v8::Utils::OpenHandle(*context_)->security_token());
Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
- v8::internal::Factory::LookupAsciiSymbol("debug");
+ FACTORY->LookupAsciiSymbol("debug");
SetProperty(global, debug_string,
- Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM);
+ Handle<Object>(debug->debug_context()->global_proxy()), DONT_ENUM,
+ ::v8::internal::kNonStrictMode);
}
private:
v8::Persistent<v8::Context> context_;
};
@@ -193,11 +195,12 @@
// Set a break point in a function and return the associated break point
// number.
static int SetBreakPoint(Handle<v8::internal::JSFunction> fun, int position) {
static int break_point = 0;
Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
- Debug::SetBreakPoint(
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+ debug->SetBreakPoint(
shared,
Handle<Object>(v8::internal::Smi::FromInt(++break_point)),
&position);
return break_point;
}
@@ -276,11 +279,12 @@
}
// Clear a break point.
static void ClearBreakPoint(int break_point) {
- Debug::ClearBreakPoint(
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+ debug->ClearBreakPoint(
Handle<Object>(v8::internal::Smi::FromInt(break_point)));
}
// Clear a break point using the global Debug object.
@@ -336,12 +340,13 @@
}
// Change break on exception.
static void ChangeBreakOnException(bool caught, bool uncaught) {
- Debug::ChangeBreakOnException(v8::internal::BreakException, caught);
- Debug::ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught);
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+ debug->ChangeBreakOnException(v8::internal::BreakException, caught);
+ debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught);
}
// Change break on exception using the global Debug object.
static void ChangeBreakOnExceptionFromJS(bool caught, bool uncaught) {
@@ -362,33 +367,36 @@
}
// Prepare to step to next break location.
static void PrepareStep(StepAction step_action) {
- Debug::PrepareStep(step_action, 1);
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+ debug->PrepareStep(step_action, 1);
}
// This function is in namespace v8::internal to be friend with class
// v8::internal::Debug.
namespace v8 {
namespace internal {
// Collect the currently debugged functions.
Handle<FixedArray> GetDebuggedFunctions() {
- v8::internal::DebugInfoListNode* node = Debug::debug_info_list_;
+ Debug* debug = Isolate::Current()->debug();
+ v8::internal::DebugInfoListNode* node = debug->debug_info_list_;
+
// Find the number of debugged functions.
int count = 0;
while (node) {
count++;
node = node->next();
}
// Allocate array for the debugged functions
Handle<FixedArray> debugged_functions =
- v8::internal::Factory::NewFixedArray(count);
+ FACTORY->NewFixedArray(count);
// Run through the debug info objects and collect all functions.
count = 0;
while (node) {
debugged_functions->set(count++, *node->debug_info());
@@ -399,25 +407,27 @@
}
static Handle<Code> ComputeCallDebugBreak(int argc) {
CALL_HEAP_FUNCTION(
- v8::internal::StubCache::ComputeCallDebugBreak(argc, Code::CALL_IC),
+ v8::internal::Isolate::Current(),
+ v8::internal::Isolate::Current()->stub_cache()->ComputeCallDebugBreak(
+ argc, Code::CALL_IC),
Code);
}
// Check that the debugger has been fully unloaded.
void CheckDebuggerUnloaded(bool check_functions) {
// Check that the debugger context is cleared and that there is no debug
// information stored for the debugger.
- CHECK(Debug::debug_context().is_null());
- CHECK_EQ(NULL, Debug::debug_info_list_);
+ CHECK(Isolate::Current()->debug()->debug_context().is_null());
+ CHECK_EQ(NULL, Isolate::Current()->debug()->debug_info_list_);
// Collect garbage to ensure weak handles are cleared.
- Heap::CollectAllGarbage(false);
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
// Iterate the head and check that there are no debugger related objects left.
HeapIterator iterator;
for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
CHECK(!obj->IsDebugInfo());
@@ -441,12 +451,12 @@
}
}
void ForceUnloadDebugger() {
- Debugger::never_unload_debugger_ = false;
- Debugger::UnloadDebugger();
+ Isolate::Current()->debugger()->never_unload_debugger_ = false;
+ Isolate::Current()->debugger()->UnloadDebugger();
}
} } // namespace v8::internal
@@ -477,10 +487,12 @@
// location in the code is the expected debug_break function.
void CheckDebugBreakFunction(DebugLocalContext* env,
const char* source, const char* name,
int position, v8::internal::RelocInfo::Mode mode,
Code* debug_break) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+
// Create function and set the break point.
Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle(
*CompileFunction(env, source, name));
int bp = SetBreakPoint(fun, position);
@@ -498,12 +510,12 @@
}
// Clear the break point and check that the debug break function is no longer
// there
ClearBreakPoint(bp);
- CHECK(!Debug::HasDebugInfo(shared));
- CHECK(Debug::EnsureDebugInfo(shared));
+ CHECK(!debug->HasDebugInfo(shared));
+ CHECK(debug->EnsureDebugInfo(shared));
TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
it2.FindBreakLocationFromPosition(position);
CHECK_EQ(mode, it2.it()->rinfo()->rmode());
if (mode == v8::internal::RelocInfo::JS_RETURN) {
CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo()));
@@ -631,12 +643,13 @@
int break_point_hit_count = 0;
static void DebugEventBreakPointHitCount(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
// Count the number of breaks.
if (event == v8::Break) {
break_point_hit_count++;
if (!frame_function_name.IsEmpty()) {
@@ -735,12 +748,14 @@
static void DebugEventCounter(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
// Count the number of breaks.
if (event == v8::Break) {
break_point_hit_count++;
} else if (event == v8::Exception) {
@@ -793,12 +808,13 @@
// The actual debug event described by the longer comment above.
static void DebugEventEvaluate(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break) {
for (int i = 0; checks[i].expr != NULL; i++) {
const int argc = 3;
v8::Handle<v8::Value> argv[argc] = { exec_state,
@@ -819,12 +835,13 @@
int debug_event_remove_break_point = 0;
static void DebugEventRemoveBreakPoint(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break) {
break_point_hit_count++;
v8::Handle<v8::Function> fun = v8::Handle<v8::Function>::Cast(data);
ClearBreakPoint(debug_event_remove_break_point);
@@ -837,12 +854,13 @@
StepAction step_action = StepIn; // Step action to perform when stepping.
static void DebugEventStep(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break) {
break_point_hit_count++;
PrepareStep(step_action);
}
@@ -863,12 +881,13 @@
// The actual debug event described by the longer comment above.
static void DebugEventStepSequence(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break || event == v8::Exception) {
// Check that the current function is the expected.
CHECK(break_point_hit_count <
StrLength(expected_step_sequence));
@@ -893,24 +912,25 @@
static void DebugEventBreakPointCollectGarbage(
v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
// Perform a garbage collection when break point is hit and continue. Based
// on the number of break points hit either scavenge or mark compact
// collector is used.
if (event == v8::Break) {
break_point_hit_count++;
if (break_point_hit_count % 2 == 0) {
// Scavenge.
- Heap::CollectGarbage(v8::internal::NEW_SPACE);
+ HEAP->CollectGarbage(v8::internal::NEW_SPACE);
} else {
// Mark sweep compact.
- Heap::CollectAllGarbage(true);
+ HEAP->CollectAllGarbage(true);
}
}
}
@@ -918,20 +938,21 @@
// collector to have the heap verified.
static void DebugEventBreak(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break) {
// Count the number of breaks.
break_point_hit_count++;
// Run the garbage collector to enforce heap verification if option
// --verify-heap is set.
- Heap::CollectGarbage(v8::internal::NEW_SPACE);
+ HEAP->CollectGarbage(v8::internal::NEW_SPACE);
// Set the break flag again to come back here as soon as possible.
v8::Debug::DebugBreak();
}
}
@@ -943,12 +964,13 @@
bool terminate_after_max_break_point_hit = false;
static void DebugEventBreakMax(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
v8::Handle<v8::Value> data) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// When hitting a debug event listener there must be a break set.
- CHECK_NE(v8::internal::Debug::break_id(), 0);
+ CHECK_NE(debug->break_id(), 0);
if (event == v8::Break) {
if (break_point_hit_count < max_break_point_hit_count) {
// Count the number of breaks.
break_point_hit_count++;
@@ -984,10 +1006,11 @@
// Test that the debug break function is the expected one for different kinds
// of break locations.
TEST(DebugStub) {
using ::v8::internal::Builtins;
+ using ::v8::internal::Isolate;
v8::HandleScope scope;
DebugLocalContext env;
CheckDebugBreakFunction(&env,
"function f1(){}", "f1",
@@ -996,16 +1019,18 @@
NULL);
CheckDebugBreakFunction(&env,
"function f2(){x=1;}", "f2",
0,
v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
- Builtins::builtin(Builtins::StoreIC_DebugBreak));
+ Isolate::Current()->builtins()->builtin(
+ Builtins::kStoreIC_DebugBreak));
CheckDebugBreakFunction(&env,
"function f3(){var a=x;}", "f3",
0,
v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
- Builtins::builtin(Builtins::LoadIC_DebugBreak));
+ Isolate::Current()->builtins()->builtin(
+ Builtins::kLoadIC_DebugBreak));
// TODO(1240753): Make the test architecture independent or split
// parts of the debugger into architecture dependent files. This
// part currently disabled as it is not portable between IA32/ARM.
// Currently on ICs for keyed store/load on ARM.
@@ -1014,18 +1039,20 @@
&env,
"function f4(){var index='propertyName'; var a={}; a[index] = 'x';}",
"f4",
0,
v8::internal::RelocInfo::CODE_TARGET,
- Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak));
+ Isolate::Current()->builtins()->builtin(
+ Builtins::kKeyedStoreIC_DebugBreak));
CheckDebugBreakFunction(
&env,
"function f5(){var index='propertyName'; var a={}; return a[index];}",
"f5",
0,
v8::internal::RelocInfo::CODE_TARGET,
- Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak));
+ Isolate::Current()->builtins()->builtin(
+ Builtins::kKeyedLoadIC_DebugBreak));
#endif
// Check the debug break code stubs for call ICs with different number of
// parameters.
Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0);
@@ -1136,11 +1163,11 @@
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- // Run with breakpoint
+ // Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
@@ -1169,11 +1196,11 @@
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- // Run with breakpoint.
+ // Run with breakpoint
int bp = SetBreakPoint(foo, 0);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
@@ -1364,16 +1391,16 @@
// Call function.
f->Call(recv, 0, NULL);
CHECK_EQ(1 + i * 3, break_point_hit_count);
// Scavenge and call function.
- Heap::CollectGarbage(v8::internal::NEW_SPACE);
+ HEAP->CollectGarbage(v8::internal::NEW_SPACE);
f->Call(recv, 0, NULL);
CHECK_EQ(2 + i * 3, break_point_hit_count);
// Mark sweep (and perhaps compact) and call function.
- Heap::CollectAllGarbage(force_compaction);
+ HEAP->CollectAllGarbage(force_compaction);
f->Call(recv, 0, NULL);
CHECK_EQ(3 + i * 3, break_point_hit_count);
}
}
@@ -2196,11 +2223,11 @@
v8::HandleScope scope;
v8::Script::Compile(script, v8::String::New("test.html"))->Run();
}
f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
SetScriptBreakPointByNameFromJS("test.html", 3, -1);
// Call f and check that there was no break points.
break_point_hit_count = 0;
@@ -3695,11 +3722,11 @@
TEST(BreakOnException) {
v8::HandleScope scope;
DebugLocalContext env;
env.ExposeDebug();
- v8::internal::Top::TraceException(false);
+ v8::internal::Isolate::Current()->TraceException(false);
// Create functions for testing break on exception.
v8::Local<v8::Function> throws =
CompileFunction(&env, "function throws(){throw 1;}", "throws");
v8::Local<v8::Function> caught =
@@ -3842,11 +3869,11 @@
DebugLocalContext env;
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
- v8::internal::Top::TraceException(false);
+ v8::internal::Isolate::Current()->TraceException(false);
// Create a function for checking the function when hitting a break point.
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
v8::V8::AddMessageListener(MessageCallbackCount);
@@ -4691,10 +4718,12 @@
// This is the debugger thread, that executes no v8 calls except
// placing JSON debugger commands in the queue.
class MessageQueueDebuggerThread : public v8::internal::Thread {
public:
+ explicit MessageQueueDebuggerThread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "MessageQueueDebuggerThread") { }
void Run();
};
static void MessageHandler(const uint16_t* message, int length,
v8::Debug::ClientData* client_data) {
@@ -4790,14 +4819,16 @@
message_queue_barriers.semaphore_1->Signal();
}
// Main thread continues running source_3 to end, waits for this thread.
}
-MessageQueueDebuggerThread message_queue_debugger_thread;
// This thread runs the v8 engine.
TEST(MessageQueues) {
+ MessageQueueDebuggerThread message_queue_debugger_thread(
+ i::Isolate::Current());
+
// Create a V8 environment
v8::HandleScope scope;
DebugLocalContext env;
message_queue_barriers.Initialize();
v8::Debug::SetMessageHandler(MessageHandler);
@@ -4939,15 +4970,19 @@
Barriers threaded_debugging_barriers;
class V8Thread : public v8::internal::Thread {
public:
+ explicit V8Thread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "V8Thread") { }
void Run();
};
class DebuggerThread : public v8::internal::Thread {
public:
+ explicit DebuggerThread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "DebuggerThread") { }
void Run();
};
static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) {
@@ -5018,14 +5053,15 @@
threaded_debugging_barriers.barrier_2.Wait();
v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
}
-DebuggerThread debugger_thread;
-V8Thread v8_thread;
TEST(ThreadedDebugging) {
+ DebuggerThread debugger_thread(i::Isolate::Current());
+ V8Thread v8_thread(i::Isolate::Current());
+
// Create a V8 environment
threaded_debugging_barriers.Initialize();
v8_thread.Start();
debugger_thread.Start();
@@ -5041,17 +5077,21 @@
* breakpoint is hit when enabled, and missed when disabled.
*/
class BreakpointsV8Thread : public v8::internal::Thread {
public:
+ explicit BreakpointsV8Thread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "BreakpointsV8Thread") { }
void Run();
};
class BreakpointsDebuggerThread : public v8::internal::Thread {
public:
- explicit BreakpointsDebuggerThread(bool global_evaluate)
- : global_evaluate_(global_evaluate) {}
+ explicit BreakpointsDebuggerThread(v8::internal::Isolate* isolate,
+ bool global_evaluate)
+ : Thread(isolate, "BreakpointsDebuggerThread"),
+ global_evaluate_(global_evaluate) {}
void Run();
private:
bool global_evaluate_;
};
@@ -5223,12 +5263,13 @@
}
void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
i::FLAG_debugger_auto_break = true;
- BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate);
- BreakpointsV8Thread breakpoints_v8_thread;
+ BreakpointsDebuggerThread breakpoints_debugger_thread(i::Isolate::Current(),
+ global_evaluate);
+ BreakpointsV8Thread breakpoints_v8_thread(i::Isolate::Current());
// Create a V8 environment
Barriers stack_allocated_breakpoints_barriers;
stack_allocated_breakpoints_barriers.Initialize();
breakpoints_barriers = &stack_allocated_breakpoints_barriers;
@@ -5606,15 +5647,19 @@
* and is dispatching host commands while in the infinite loop.
*/
class HostDispatchV8Thread : public v8::internal::Thread {
public:
+ explicit HostDispatchV8Thread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "HostDispatchV8Thread") { }
void Run();
};
class HostDispatchDebuggerThread : public v8::internal::Thread {
public:
+ explicit HostDispatchDebuggerThread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "HostDispatchDebuggerThread") { }
void Run();
};
Barriers* host_dispatch_barriers;
@@ -5680,15 +5725,15 @@
host_dispatch_barriers->semaphore_1->Wait();
// 2: Continue evaluation
v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
}
-HostDispatchDebuggerThread host_dispatch_debugger_thread;
-HostDispatchV8Thread host_dispatch_v8_thread;
-
TEST(DebuggerHostDispatch) {
+ HostDispatchDebuggerThread host_dispatch_debugger_thread(
+ i::Isolate::Current());
+ HostDispatchV8Thread host_dispatch_v8_thread(i::Isolate::Current());
i::FLAG_debugger_auto_break = true;
// Create a V8 environment
Barriers stack_allocated_host_dispatch_barriers;
stack_allocated_host_dispatch_barriers.Initialize();
@@ -5708,15 +5753,19 @@
* which signals the V8 thread to wake up.
*/
class DebugMessageDispatchV8Thread : public v8::internal::Thread {
public:
+ explicit DebugMessageDispatchV8Thread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "DebugMessageDispatchV8Thread") { }
void Run();
};
class DebugMessageDispatchDebuggerThread : public v8::internal::Thread {
public:
+ explicit DebugMessageDispatchDebuggerThread(v8::internal::Isolate* isolate)
+ : Thread(isolate, "DebugMessageDispatchDebuggerThread") { }
void Run();
};
Barriers* debug_message_dispatch_barriers;
@@ -5744,15 +5793,17 @@
debug_message_dispatch_barriers->barrier_1.Wait();
SendContinueCommand();
debug_message_dispatch_barriers->barrier_2.Wait();
}
-DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread;
-DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread;
-
TEST(DebuggerDebugMessageDispatch) {
+ DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread(
+ i::Isolate::Current());
+ DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread(
+ i::Isolate::Current());
+
i::FLAG_debugger_auto_break = true;
// Create a V8 environment
Barriers stack_allocated_debug_message_dispatch_barriers;
stack_allocated_debug_message_dispatch_barriers.Initialize();
@@ -5766,10 +5817,11 @@
debug_message_dispatch_debugger_thread.Join();
}
TEST(DebuggerAgent) {
+ i::Debugger* debugger = i::Isolate::Current()->debugger();
// Make sure these ports is not used by other tests to allow tests to run in
// parallel.
const int kPort1 = 5858;
const int kPort2 = 5857;
const int kPort3 = 5856;
@@ -5783,40 +5835,43 @@
// Initialize the socket library.
i::Socket::Setup();
// Test starting and stopping the agent without any client connection.
- i::Debugger::StartAgent("test", kPort1);
- i::Debugger::StopAgent();
+ debugger->StartAgent("test", kPort1);
+ debugger->StopAgent();
// Test starting the agent, connecting a client and shutting down the agent
// with the client connected.
- ok = i::Debugger::StartAgent("test", kPort2);
+ ok = debugger->StartAgent("test", kPort2);
CHECK(ok);
- i::Debugger::WaitForAgent();
+ debugger->WaitForAgent();
i::Socket* client = i::OS::CreateSocket();
ok = client->Connect("localhost", port2_str);
CHECK(ok);
- i::Debugger::StopAgent();
+ debugger->StopAgent();
delete client;
// Test starting and stopping the agent with the required port already
// occoupied.
i::Socket* server = i::OS::CreateSocket();
server->Bind(kPort3);
- i::Debugger::StartAgent("test", kPort3);
- i::Debugger::StopAgent();
+ debugger->StartAgent("test", kPort3);
+ debugger->StopAgent();
delete server;
}
class DebuggerAgentProtocolServerThread : public i::Thread {
public:
- explicit DebuggerAgentProtocolServerThread(int port)
- : port_(port), server_(NULL), client_(NULL),
+ explicit DebuggerAgentProtocolServerThread(i::Isolate* isolate, int port)
+ : Thread(isolate, "DebuggerAgentProtocolServerThread"),
+ port_(port),
+ server_(NULL),
+ client_(NULL),
listening_(OS::CreateSemaphore(0)) {
}
~DebuggerAgentProtocolServerThread() {
// Close both sockets.
delete client_;
@@ -5874,11 +5929,11 @@
// Initialize the socket library.
i::Socket::Setup();
// Create a socket server to receive a debugger agent message.
DebuggerAgentProtocolServerThread* server =
- new DebuggerAgentProtocolServerThread(kPort);
+ new DebuggerAgentProtocolServerThread(i::Isolate::Current(), kPort);
server->Start();
server->WaitForListening();
// Connect.
i::Socket* client = i::OS::CreateSocket();
@@ -6373,21 +6428,22 @@
}
// Test that scripts collected are reported through the debug event listener.
TEST(ScriptCollectedEvent) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
break_point_hit_count = 0;
script_collected_count = 0;
v8::HandleScope scope;
DebugLocalContext env;
// Request the loaded scripts to initialize the debugger script cache.
- Debug::GetLoadedScripts();
+ debug->GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
script_collected_count = 0;
v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent,
v8::Undefined());
{
@@ -6395,11 +6451,11 @@
v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
}
// Do garbage collection to collect the script above which is no longer
// referenced.
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
CHECK_EQ(2, script_collected_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -6419,33 +6475,34 @@
// Test that GetEventContext doesn't fail and return empty handle for
// ScriptCollected events.
TEST(ScriptCollectedEventContext) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
script_collected_message_count = 0;
v8::HandleScope scope;
{ // Scope for the DebugLocalContext.
DebugLocalContext env;
// Request the loaded scripts to initialize the debugger script cache.
- Debug::GetLoadedScripts();
+ debug->GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
{
v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
}
}
// Do garbage collection to collect the script above which is no longer
// referenced.
- Heap::CollectAllGarbage(false);
+ HEAP->CollectAllGarbage(false);
CHECK_EQ(2, script_collected_message_count);
v8::Debug::SetMessageHandler2(NULL);
}
@@ -6589,10 +6646,11 @@
v8::Debug::SetMessageHandler2(NULL);
}
static void BreakMessageHandler(const v8::Debug::Message& message) {
+ i::Isolate* isolate = i::Isolate::Current();
if (message.IsEvent() && message.GetEvent() == v8::Break) {
// Count the number of breaks.
break_point_hit_count++;
v8::HandleScope scope;
@@ -6600,22 +6658,22 @@
SendContinueCommand();
} else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) {
v8::HandleScope scope;
- bool is_debug_break = i::StackGuard::IsDebugBreak();
+ bool is_debug_break = isolate->stack_guard()->IsDebugBreak();
// Force DebugBreak flag while serializer is working.
- i::StackGuard::DebugBreak();
+ isolate->stack_guard()->DebugBreak();
// Force serialization to trigger some internal JS execution.
v8::Handle<v8::String> json = message.GetJSON();
// Restore previous state.
if (is_debug_break) {
- i::StackGuard::DebugBreak();
+ isolate->stack_guard()->DebugBreak();
} else {
- i::StackGuard::Continue(i::DEBUGBREAK);
+ isolate->stack_guard()->Continue(i::DEBUGBREAK);
}
}
}
@@ -6840,18 +6898,19 @@
}
}
TEST(CallingContextIsNotDebugContext) {
+ v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
// Create and enter a debugee context.
v8::HandleScope scope;
DebugLocalContext env;
env.ExposeDebug();
// Save handles to the debugger and debugee contexts to be used in
// NamedGetterWithCallingContextCheck.
debugee_context = v8::Local<v8::Context>(*env);
- debugger_context = v8::Utils::ToLocal(Debug::debug_context());
+ debugger_context = v8::Utils::ToLocal(debug->debug_context());
// Create object with 'a' property accessor.
v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
named->SetAccessor(v8::String::New("a"),
NamedGetterWithCallingContextCheck);