| Index: test/cctest/test-debug.cc
|
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
|
| index ef8466d65e4fa57b71af0d7351c9119909c1ba96..0f31c14ad6d0767d165bd2c45fb456b66a4c0592 100644
|
| --- a/test/cctest/test-debug.cc
|
| +++ b/test/cctest/test-debug.cc
|
| @@ -509,7 +509,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
|
| Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
|
| CHECK(Debug::HasDebugInfo(shared));
|
| TestBreakLocationIterator it1(Debug::GetDebugInfo(shared));
|
| - it1.FindBreakLocationFromPosition(position);
|
| + it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
|
| v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode();
|
| if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
|
| actual_mode = v8::internal::RelocInfo::CODE_TARGET;
|
| @@ -528,7 +528,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
|
| CHECK(!debug->HasDebugInfo(shared));
|
| CHECK(debug->EnsureDebugInfo(shared, fun));
|
| TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
|
| - it2.FindBreakLocationFromPosition(position);
|
| + it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
|
| actual_mode = it2.it()->rinfo()->rmode();
|
| if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
|
| actual_mode = v8::internal::RelocInfo::CODE_TARGET;
|
| @@ -820,6 +820,8 @@ struct EvaluateCheck {
|
| const char* expr; // An expression to evaluate when a break point is hit.
|
| v8::Handle<v8::Value> expected; // The expected result.
|
| };
|
| +
|
| +
|
| // Array of checks to do.
|
| struct EvaluateCheck* checks = NULL;
|
| // Source for The JavaScript function which can do the evaluation when a break
|
| @@ -1393,6 +1395,7 @@ static void CallWithBreakPoints(v8::Local<v8::Object> recv,
|
| }
|
| }
|
|
|
| +
|
| // Test GC during break point processing.
|
| TEST(GCDuringBreakPointProcessing) {
|
| break_point_hit_count = 0;
|
| @@ -2526,6 +2529,7 @@ static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) {
|
| if (eventDetails.GetEvent() == v8::Break) ++debugEventCount;
|
| }
|
|
|
| +
|
| // Test that the conditional breakpoints work event if code generation from
|
| // strings is prohibited in the debugee context.
|
| TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
|
| @@ -2571,6 +2575,7 @@ static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
|
| }
|
| }
|
|
|
| +
|
| // Test that the evaluation of expressions when a break point is hit generates
|
| // the correct results in case code generation from strings is disallowed in the
|
| // debugee context.
|
| @@ -2625,6 +2630,7 @@ int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) {
|
| return i;
|
| }
|
|
|
| +
|
| // Copies a 16-bit string to a C string by dropping the high byte of
|
| // each character. Does not check for buffer overflow.
|
| // Can be used in any thread. Requires string length as an input.
|
| @@ -2712,6 +2718,7 @@ static void DebugProcessDebugMessagesHandler(
|
| }
|
| }
|
|
|
| +
|
| // Test that the evaluation of expressions works even from ProcessDebugMessages
|
| // i.e. with empty stack.
|
| TEST(DebugEvaluateWithoutStack) {
|
| @@ -4141,6 +4148,7 @@ TEST(StepWithException) {
|
|
|
|
|
| TEST(DebugBreak) {
|
| + i::FLAG_stress_compaction = false;
|
| #ifdef VERIFY_HEAP
|
| i::FLAG_verify_heap = true;
|
| #endif
|
| @@ -4264,6 +4272,7 @@ TEST(NoBreakWhenBootstrapping) {
|
| CheckDebuggerUnloaded();
|
| }
|
|
|
| +
|
| static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
|
| v8::Handle<v8::Array> result = v8::Array::New(3);
|
| result->Set(v8::Integer::New(0), v8::String::New("a"));
|
| @@ -4708,6 +4717,7 @@ ThreadBarrier::ThreadBarrier(int num_threads)
|
| invalid_ = false; // A barrier may only be used once. Then it is invalid.
|
| }
|
|
|
| +
|
| // Do not call, due to race condition with Wait().
|
| // Could be resolved with Pthread condition variables.
|
| ThreadBarrier::~ThreadBarrier() {
|
| @@ -4716,6 +4726,7 @@ ThreadBarrier::~ThreadBarrier() {
|
| delete sem_;
|
| }
|
|
|
| +
|
| void ThreadBarrier::Wait() {
|
| lock_->Lock();
|
| CHECK(!invalid_);
|
| @@ -4735,6 +4746,7 @@ void ThreadBarrier::Wait() {
|
| }
|
| }
|
|
|
| +
|
| // A set containing enough barriers and semaphores for any of the tests.
|
| class Barriers {
|
| public:
|
| @@ -4844,6 +4856,7 @@ int GetSourceLineFromBreakEventMessage(char *message) {
|
| return res;
|
| }
|
|
|
| +
|
| /* Test MessageQueues */
|
| /* Tests the message queues that hold debugger commands and
|
| * response messages to the debugger. Fills queues and makes
|
| @@ -4875,6 +4888,7 @@ static void MessageHandler(const uint16_t* message, int length,
|
| message_queue_barriers.semaphore_1->Wait();
|
| }
|
|
|
| +
|
| void MessageQueueDebuggerThread::Run() {
|
| const int kBufferSize = 1000;
|
| uint16_t buffer_1[kBufferSize];
|
| @@ -5174,6 +5188,7 @@ void V8Thread::Run() {
|
| CompileRun(source);
|
| }
|
|
|
| +
|
| void DebuggerThread::Run() {
|
| const int kBufSize = 1000;
|
| uint16_t buffer[kBufSize];
|
| @@ -5208,6 +5223,7 @@ TEST(ThreadedDebugging) {
|
| debugger_thread.Join();
|
| }
|
|
|
| +
|
| /* Test RecursiveBreakpoints */
|
| /* In this test, the debugger evaluates a function with a breakpoint, after
|
| * hitting a breakpoint in another function. We do this with both values
|
| @@ -5399,6 +5415,7 @@ void BreakpointsDebuggerThread::Run() {
|
| v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer));
|
| }
|
|
|
| +
|
| void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
|
| i::FLAG_debugger_auto_break = true;
|
|
|
| @@ -5417,10 +5434,12 @@ void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
|
| breakpoints_debugger_thread.Join();
|
| }
|
|
|
| +
|
| TEST(RecursiveBreakpoints) {
|
| TestRecursiveBreakpointsGeneric(false);
|
| }
|
|
|
| +
|
| TEST(RecursiveBreakpointsGlobal) {
|
| TestRecursiveBreakpointsGeneric(true);
|
| }
|
| @@ -6269,8 +6288,6 @@ TEST(ContextData) {
|
| v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| v8::HandleScope scope(isolate);
|
|
|
| - v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
|
| -
|
| // Create two contexts.
|
| v8::Handle<v8::Context> context_1;
|
| v8::Handle<v8::Context> context_2;
|
| @@ -6280,6 +6297,8 @@ TEST(ContextData) {
|
| context_1 = v8::Context::New(isolate, NULL, global_template, global_object);
|
| context_2 = v8::Context::New(isolate, NULL, global_template, global_object);
|
|
|
| + v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
|
| +
|
| // Default data value is undefined.
|
| CHECK(context_1->GetEmbedderData(0)->IsUndefined());
|
| CHECK(context_2->GetEmbedderData(0)->IsUndefined());
|
| @@ -6437,7 +6456,8 @@ TEST(RegExpDebugBreak) {
|
|
|
|
|
| // Common part of EvalContextData and NestedBreakEventContextData tests.
|
| -static void ExecuteScriptForContextCheck() {
|
| +static void ExecuteScriptForContextCheck(
|
| + v8::Debug::MessageHandler2 message_handler) {
|
| // Create a context.
|
| v8::Handle<v8::Context> context_1;
|
| v8::Handle<v8::ObjectTemplate> global_template =
|
| @@ -6445,6 +6465,8 @@ static void ExecuteScriptForContextCheck() {
|
| context_1 =
|
| v8::Context::New(v8::Isolate::GetCurrent(), NULL, global_template);
|
|
|
| + v8::Debug::SetMessageHandler2(message_handler);
|
| +
|
| // Default data value is undefined.
|
| CHECK(context_1->GetEmbedderData(0)->IsUndefined());
|
|
|
| @@ -6464,6 +6486,8 @@ static void ExecuteScriptForContextCheck() {
|
| v8::Local<v8::Function> f = CompileFunction(source, "f");
|
| f->Call(context_1->Global(), 0, NULL);
|
| }
|
| +
|
| + v8::Debug::SetMessageHandler2(NULL);
|
| }
|
|
|
|
|
| @@ -6473,13 +6497,11 @@ static void ExecuteScriptForContextCheck() {
|
| // Message.GetEventContext.
|
| TEST(EvalContextData) {
|
| v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| - v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
|
|
|
| - ExecuteScriptForContextCheck();
|
| + ExecuteScriptForContextCheck(ContextCheckMessageHandler);
|
|
|
| // One time compile event and one time break event.
|
| CHECK_GT(message_handler_hit_count, 2);
|
| - v8::Debug::SetMessageHandler2(NULL);
|
| CheckDebuggerUnloaded();
|
| }
|
|
|
| @@ -6538,16 +6560,14 @@ TEST(NestedBreakEventContextData) {
|
| v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| break_count = 0;
|
| message_handler_hit_count = 0;
|
| - v8::Debug::SetMessageHandler2(DebugEvalContextCheckMessageHandler);
|
|
|
| - ExecuteScriptForContextCheck();
|
| + ExecuteScriptForContextCheck(DebugEvalContextCheckMessageHandler);
|
|
|
| // One time compile event and two times break event.
|
| CHECK_GT(message_handler_hit_count, 3);
|
|
|
| // One break from the source and another from the evaluate request.
|
| CHECK_EQ(break_count, 2);
|
| - v8::Debug::SetMessageHandler2(NULL);
|
| CheckDebuggerUnloaded();
|
| }
|
|
|
| @@ -6614,6 +6634,7 @@ static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) {
|
| // Test that GetEventContext doesn't fail and return empty handle for
|
| // ScriptCollected events.
|
| TEST(ScriptCollectedEventContext) {
|
| + i::FLAG_stress_compaction = false;
|
| v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| v8::internal::Debug* debug =
|
| reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
|
| @@ -6871,6 +6892,7 @@ static void CountingMessageHandler(const v8::Debug::Message& message) {
|
| counting_message_handler_counter++;
|
| }
|
|
|
| +
|
| // Test that debug messages get processed when ProcessDebugMessages is called.
|
| TEST(ProcessDebugMessages) {
|
| DebugLocalContext env;
|
| @@ -7110,14 +7132,15 @@ static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
|
| CHECK_EQ(expected_callback_data, details.GetCallbackData());
|
| }
|
|
|
| +
|
| // Check that event details contain context where debug event occured.
|
| TEST(DebugEventContext) {
|
| v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| v8::HandleScope scope(isolate);
|
| expected_callback_data = v8::Int32::New(2010);
|
| + expected_context = v8::Context::New(isolate);
|
| v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
|
| expected_callback_data);
|
| - expected_context = v8::Context::New(isolate);
|
| v8::Context::Scope context_scope(expected_context);
|
| v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
|
| expected_context.Clear();
|
|
|