summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-debug.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-debug.cc')
-rw-r--r--deps/v8/test/cctest/test-debug.cc1243
1 files changed, 479 insertions, 764 deletions
diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc
index 85e4512ea..5c0b0f392 100644
--- a/deps/v8/test/cctest/test-debug.cc
+++ b/deps/v8/test/cctest/test-debug.cc
@@ -27,28 +27,27 @@
#include <stdlib.h>
-#include "v8.h"
-
-#include "api.h"
-#include "cctest.h"
-#include "compilation-cache.h"
-#include "debug.h"
-#include "deoptimizer.h"
-#include "frames.h"
-#include "platform.h"
-#include "platform/condition-variable.h"
-#include "platform/socket.h"
-#include "stub-cache.h"
-#include "utils.h"
-
-
-using ::v8::internal::Mutex;
-using ::v8::internal::LockGuard;
-using ::v8::internal::ConditionVariable;
-using ::v8::internal::Semaphore;
+#include "src/v8.h"
+
+#include "src/api.h"
+#include "src/base/platform/condition-variable.h"
+#include "src/base/platform/platform.h"
+#include "src/compilation-cache.h"
+#include "src/debug.h"
+#include "src/deoptimizer.h"
+#include "src/frames.h"
+#include "src/stub-cache.h"
+#include "src/utils.h"
+#include "test/cctest/cctest.h"
+
+
+using ::v8::base::Mutex;
+using ::v8::base::LockGuard;
+using ::v8::base::ConditionVariable;
+using ::v8::base::OS;
+using ::v8::base::Semaphore;
using ::v8::internal::EmbeddedVector;
using ::v8::internal::Object;
-using ::v8::internal::OS;
using ::v8::internal::Handle;
using ::v8::internal::Heap;
using ::v8::internal::JSGlobalProxy;
@@ -99,20 +98,19 @@ class DebugLocalContext {
v8::internal::Isolate* isolate =
reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate());
v8::internal::Factory* factory = isolate->factory();
- v8::internal::Debug* debug = isolate->debug();
// Expose the debug context global object in the global object for testing.
- debug->Load();
- debug->debug_context()->set_security_token(
+ CHECK(isolate->debug()->Load());
+ Handle<v8::internal::Context> debug_context =
+ isolate->debug()->debug_context();
+ 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 =
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
- v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string,
- Handle<Object>(debug->debug_context()->global_proxy(), isolate),
- DONT_ENUM,
- ::v8::internal::SLOPPY).Check();
+ v8::internal::Runtime::DefineObjectProperty(global, debug_string,
+ handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check();
}
private:
@@ -182,9 +180,9 @@ static int SetBreakPointFromJS(v8::Isolate* isolate,
const char* function_name,
int line, int position) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.setBreakPoint(%s,%d,%d)",
- function_name, line, position);
+ SNPrintF(buffer,
+ "debug.Debug.setBreakPoint(%s,%d,%d)",
+ function_name, line, position);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Handle<v8::String> str = v8::String::NewFromUtf8(isolate, buffer.start());
return v8::Script::Compile(str)->Run()->Int32Value();
@@ -197,14 +195,14 @@ static int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id,
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
if (column >= 0) {
// Column specified set script break point on precise location.
- OS::SNPrintF(buffer,
- "debug.Debug.setScriptBreakPointById(%d,%d,%d)",
- script_id, line, column);
+ SNPrintF(buffer,
+ "debug.Debug.setScriptBreakPointById(%d,%d,%d)",
+ script_id, line, column);
} else {
// Column not specified set script break point on line.
- OS::SNPrintF(buffer,
- "debug.Debug.setScriptBreakPointById(%d,%d)",
- script_id, line);
+ SNPrintF(buffer,
+ "debug.Debug.setScriptBreakPointById(%d,%d)",
+ script_id, line);
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
@@ -226,14 +224,14 @@ static int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate,
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
if (column >= 0) {
// Column specified set script break point on precise location.
- OS::SNPrintF(buffer,
- "debug.Debug.setScriptBreakPointByName(\"%s\",%d,%d)",
- script_name, line, column);
+ SNPrintF(buffer,
+ "debug.Debug.setScriptBreakPointByName(\"%s\",%d,%d)",
+ script_name, line, column);
} else {
// Column not specified set script break point on line.
- OS::SNPrintF(buffer,
- "debug.Debug.setScriptBreakPointByName(\"%s\",%d)",
- script_name, line);
+ SNPrintF(buffer,
+ "debug.Debug.setScriptBreakPointByName(\"%s\",%d)",
+ script_name, line);
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
@@ -260,9 +258,9 @@ static void ClearBreakPoint(int break_point) {
static void ClearBreakPointFromJS(v8::Isolate* isolate,
int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.clearBreakPoint(%d)",
- break_point_number);
+ SNPrintF(buffer,
+ "debug.Debug.clearBreakPoint(%d)",
+ break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -271,9 +269,9 @@ static void ClearBreakPointFromJS(v8::Isolate* isolate,
static void EnableScriptBreakPointFromJS(v8::Isolate* isolate,
int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.enableScriptBreakPoint(%d)",
- break_point_number);
+ SNPrintF(buffer,
+ "debug.Debug.enableScriptBreakPoint(%d)",
+ break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -282,9 +280,9 @@ static void EnableScriptBreakPointFromJS(v8::Isolate* isolate,
static void DisableScriptBreakPointFromJS(v8::Isolate* isolate,
int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.disableScriptBreakPoint(%d)",
- break_point_number);
+ SNPrintF(buffer,
+ "debug.Debug.disableScriptBreakPoint(%d)",
+ break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -294,9 +292,9 @@ static void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate,
int break_point_number,
const char* condition) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")",
- break_point_number, condition);
+ SNPrintF(buffer,
+ "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")",
+ break_point_number, condition);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -306,9 +304,9 @@ static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate,
int break_point_number,
int ignoreCount) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)",
- break_point_number, ignoreCount);
+ SNPrintF(buffer,
+ "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)",
+ break_point_number, ignoreCount);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -422,12 +420,6 @@ void CheckDebuggerUnloaded(bool check_functions) {
}
-void ForceUnloadDebugger() {
- CcTest::i_isolate()->debugger()->never_unload_debugger_ = false;
- CcTest::i_isolate()->debugger()->UnloadDebugger();
-}
-
-
} } // namespace v8::internal
@@ -1094,7 +1086,7 @@ TEST(BreakPointICStore) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function foo(){bar=0;}"))->Run();
v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
@@ -1116,7 +1108,7 @@ TEST(BreakPointICStore) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1126,7 +1118,7 @@ TEST(BreakPointICLoad) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar=1"))
->Run();
v8::Script::Compile(
@@ -1151,7 +1143,7 @@ TEST(BreakPointICLoad) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1161,7 +1153,7 @@ TEST(BreakPointICCall) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
@@ -1185,7 +1177,7 @@ TEST(BreakPointICCall) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1195,7 +1187,7 @@ TEST(BreakPointICCallWithGC) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){return 1;}"))
->Run();
@@ -1221,7 +1213,7 @@ TEST(BreakPointICCallWithGC) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1231,7 +1223,7 @@ TEST(BreakPointConstructCallWithGC) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function bar(){ this.x = 1;}"))
->Run();
@@ -1257,7 +1249,7 @@ TEST(BreakPointConstructCallWithGC) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1278,7 +1270,7 @@ TEST(BreakPointReturn) {
"frame_source_column");
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){}"))->Run();
v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
@@ -1304,7 +1296,7 @@ TEST(BreakPointReturn) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1327,7 +1319,7 @@ TEST(GCDuringBreakPointProcessing) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
@@ -1355,7 +1347,7 @@ TEST(GCDuringBreakPointProcessing) {
SetBreakPoint(foo, 0);
CallWithBreakPoints(env->Global(), foo, 1, 25);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1390,7 +1382,7 @@ TEST(BreakPointSurviveGC) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
@@ -1436,7 +1428,7 @@ TEST(BreakPointSurviveGC) {
CallAndGC(env->Global(), foo);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1448,7 +1440,7 @@ TEST(BreakPointThroughJavaScript) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
@@ -1490,7 +1482,7 @@ TEST(BreakPointThroughJavaScript) {
foo->Run();
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Make sure that the break point numbers are consecutive.
@@ -1507,7 +1499,7 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1592,7 +1584,7 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
g->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Make sure that the break point numbers are consecutive.
@@ -1611,7 +1603,7 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> source = v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1644,7 +1636,7 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Get the script id knowing that internally it is a 32 integer.
- int script_id = script->GetId();
+ int script_id = script->GetUnboundScript()->GetId();
// Call f and g without break points.
break_point_hit_count = 0;
@@ -1700,7 +1692,7 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
g->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Make sure that the break point numbers are consecutive.
@@ -1720,7 +1712,7 @@ TEST(EnableDisableScriptBreakPoint) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1766,7 +1758,7 @@ TEST(EnableDisableScriptBreakPoint) {
f->Call(env->Global(), 0, NULL);
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1778,7 +1770,7 @@ TEST(ConditionalScriptBreakPoint) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1829,7 +1821,7 @@ TEST(ConditionalScriptBreakPoint) {
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1841,7 +1833,7 @@ TEST(ScriptBreakPointIgnoreCount) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1885,7 +1877,7 @@ TEST(ScriptBreakPointIgnoreCount) {
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1897,7 +1889,7 @@ TEST(ScriptBreakPointReload) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
v8::Local<v8::String> script = v8::String::NewFromUtf8(
@@ -1949,7 +1941,7 @@ TEST(ScriptBreakPointReload) {
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1961,7 +1953,7 @@ TEST(ScriptBreakPointMultiple) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
v8::Local<v8::String> script_f =
@@ -2018,7 +2010,7 @@ TEST(ScriptBreakPointMultiple) {
g->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2030,7 +2022,7 @@ TEST(ScriptBreakPointLineOffset) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
v8::Local<v8::String> script = v8::String::NewFromUtf8(
@@ -2078,7 +2070,7 @@ TEST(ScriptBreakPointLineOffset) {
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2094,7 +2086,7 @@ TEST(ScriptBreakPointLine) {
frame_function_name_source,
"frame_function_name");
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
v8::Local<v8::Function> g;
@@ -2194,7 +2186,7 @@ TEST(ScriptBreakPointLine) {
v8::Script::Compile(script, &origin)->Run();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2205,7 +2197,7 @@ TEST(ScriptBreakPointLineTopLevel) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script =
v8::String::NewFromUtf8(env->GetIsolate(),
@@ -2241,7 +2233,7 @@ TEST(ScriptBreakPointLineTopLevel) {
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2253,7 +2245,7 @@ TEST(ScriptBreakPointTopLevelCrash) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::String> script_source =
v8::String::NewFromUtf8(env->GetIsolate(),
@@ -2276,7 +2268,7 @@ TEST(ScriptBreakPointTopLevelCrash) {
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2292,7 +2284,7 @@ TEST(RemoveBreakPointInBreak) {
debug_event_remove_break_point = SetBreakPoint(foo, 0);
// Register the debug event listener pasing the function
- v8::Debug::SetDebugEventListener2(DebugEventRemoveBreakPoint, foo);
+ v8::Debug::SetDebugEventListener(DebugEventRemoveBreakPoint, foo);
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
@@ -2302,7 +2294,7 @@ TEST(RemoveBreakPointInBreak) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2312,7 +2304,7 @@ TEST(DebuggerStatement) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){debugger}"))
->Run();
@@ -2332,7 +2324,7 @@ TEST(DebuggerStatement) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2342,7 +2334,7 @@ TEST(DebuggerStatementBreakpoint) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
->Run();
@@ -2360,7 +2352,7 @@ TEST(DebuggerStatementBreakpoint) {
CHECK_EQ(2, break_point_hit_count);
ClearBreakPoint(bp);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2378,7 +2370,7 @@ TEST(DebugEvaluate) {
evaluate_check_source,
"evaluate_check");
// Register the debug event listener
- v8::Debug::SetDebugEventListener2(DebugEventEvaluate);
+ v8::Debug::SetDebugEventListener(DebugEventEvaluate);
// Different expected vaules of x and a when in a break point (u = undefined,
// d = Hello, world!).
@@ -2479,7 +2471,7 @@ TEST(DebugEvaluate) {
};
bar->Call(env->Global(), 2, argv_bar_3);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2497,7 +2489,7 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(CheckDebugEvent);
+ v8::Debug::SetDebugEventListener(CheckDebugEvent);
v8::Local<v8::Function> foo = CompileFunction(&env,
"function foo(x) {\n"
@@ -2514,7 +2506,7 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, debugEventCount);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2544,7 +2536,7 @@ TEST(DebugEvaluateWithCodeGenerationDisallowed) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(CheckDebugEval);
+ v8::Debug::SetDebugEventListener(CheckDebugEval);
v8::Local<v8::Function> foo = CompileFunction(&env,
"var global = 'Global';\n"
@@ -2572,7 +2564,7 @@ TEST(DebugEvaluateWithCodeGenerationDisallowed) {
checkGlobalEvalFunction.Clear();
checkFrameEvalFunction.Clear();
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2630,7 +2622,7 @@ bool GetEvaluateStringResult(char *message, char* buffer, int buffer_size) {
if (len > buffer_size - 1) {
len = buffer_size - 1;
}
- OS::StrNCpy(buf, pos1, len);
+ StrNCpy(buf, pos1, len);
buffer[buffer_size - 1] = '\0';
return true;
}
@@ -2677,7 +2669,7 @@ static void DebugProcessDebugMessagesHandler(
// Test that the evaluation of expressions works even from ProcessDebugMessages
// i.e. with empty stack.
TEST(DebugEvaluateWithoutStack) {
- v8::Debug::SetMessageHandler2(DebugProcessDebugMessagesHandler);
+ v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler);
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
@@ -2733,8 +2725,8 @@ TEST(DebugEvaluateWithoutStack) {
0);
CHECK_EQ(strcmp("805", process_debug_messages_data.results[2].buffer), 0);
- v8::Debug::SetMessageHandler2(NULL);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2755,7 +2747,7 @@ TEST(DebugStepLinear) {
SetBreakPoint(foo, 3);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
step_action = StepIn;
break_point_hit_count = 0;
@@ -2764,11 +2756,11 @@ TEST(DebugStepLinear) {
// With stepping all break locations are hit.
CHECK_EQ(4, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
SetBreakPoint(foo, 3);
break_point_hit_count = 0;
@@ -2777,7 +2769,7 @@ TEST(DebugStepLinear) {
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2788,7 +2780,7 @@ TEST(DebugStepKeyedLoadLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping of keyed load. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2826,7 +2818,7 @@ TEST(DebugStepKeyedLoadLoop) {
// With stepping all break locations are hit.
CHECK_EQ(35, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2837,7 +2829,7 @@ TEST(DebugStepKeyedStoreLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping of keyed store. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2874,7 +2866,7 @@ TEST(DebugStepKeyedStoreLoop) {
// With stepping all break locations are hit.
CHECK_EQ(34, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2885,7 +2877,7 @@ TEST(DebugStepNamedLoadLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping of named load.
v8::Local<v8::Function> foo = CompileFunction(
@@ -2918,7 +2910,7 @@ TEST(DebugStepNamedLoadLoop) {
// With stepping all break locations are hit.
CHECK_EQ(55, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2928,7 +2920,7 @@ static void DoDebugStepNamedStoreLoop(int expected) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping of named store.
v8::Local<v8::Function> foo = CompileFunction(
@@ -2953,7 +2945,7 @@ static void DoDebugStepNamedStoreLoop(int expected) {
// With stepping all expected break locations are hit.
CHECK_EQ(expected, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -2970,7 +2962,7 @@ TEST(DebugStepLinearMixedICs) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(&env,
@@ -2993,11 +2985,11 @@ TEST(DebugStepLinearMixedICs) {
// With stepping all break locations are hit.
CHECK_EQ(11, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
SetBreakPoint(foo, 0);
break_point_hit_count = 0;
@@ -3006,7 +2998,7 @@ TEST(DebugStepLinearMixedICs) {
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3016,7 +3008,7 @@ TEST(DebugStepDeclarations) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3039,7 +3031,7 @@ TEST(DebugStepDeclarations) {
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3049,7 +3041,7 @@ TEST(DebugStepLocals) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3072,7 +3064,7 @@ TEST(DebugStepLocals) {
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3083,7 +3075,7 @@ TEST(DebugStepIf) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3116,7 +3108,7 @@ TEST(DebugStepIf) {
CHECK_EQ(5, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3127,7 +3119,7 @@ TEST(DebugStepSwitch) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3173,7 +3165,7 @@ TEST(DebugStepSwitch) {
CHECK_EQ(7, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3184,7 +3176,7 @@ TEST(DebugStepWhile) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3199,22 +3191,29 @@ TEST(DebugStepWhile) {
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
SetBreakPoint(foo, 8); // "var a = 0;"
+ // Looping 0 times. We still should break at the while-condition once.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_0[argc] = { v8::Number::New(isolate, 0) };
+ foo->Call(env->Global(), argc, argv_0);
+ CHECK_EQ(3, break_point_hit_count);
+
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(22, break_point_hit_count);
+ CHECK_EQ(23, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(202, break_point_hit_count);
+ CHECK_EQ(203, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3225,7 +3224,7 @@ TEST(DebugStepDoWhile) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3255,7 +3254,7 @@ TEST(DebugStepDoWhile) {
CHECK_EQ(202, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3266,7 +3265,7 @@ TEST(DebugStepFor) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3297,7 +3296,7 @@ TEST(DebugStepFor) {
CHECK_EQ(203, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3308,7 +3307,7 @@ TEST(DebugStepForContinue) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3349,7 +3348,7 @@ TEST(DebugStepForContinue) {
CHECK_EQ(457, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3360,7 +3359,7 @@ TEST(DebugStepForBreak) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3402,7 +3401,7 @@ TEST(DebugStepForBreak) {
CHECK_EQ(505, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3412,7 +3411,7 @@ TEST(DebugStepForIn) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3450,7 +3449,7 @@ TEST(DebugStepForIn) {
CHECK_EQ(8, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3460,7 +3459,7 @@ TEST(DebugStepWith) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3482,7 +3481,7 @@ TEST(DebugStepWith) {
CHECK_EQ(4, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3493,7 +3492,7 @@ TEST(DebugConditional) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3519,7 +3518,7 @@ TEST(DebugConditional) {
CHECK_EQ(5, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3534,7 +3533,7 @@ TEST(StepInOutSimple) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(DebugEventStepSequence);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3570,7 +3569,7 @@ TEST(StepInOutSimple) {
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3585,7 +3584,7 @@ TEST(StepInOutTree) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(DebugEventStepSequence);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3622,7 +3621,7 @@ TEST(StepInOutTree) {
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded(true);
}
@@ -3637,7 +3636,7 @@ TEST(StepInOutBranch) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(DebugEventStepSequence);
// Create a function for testing stepping. Run it to allow it to get
// optimized.
@@ -3657,7 +3656,7 @@ TEST(StepInOutBranch) {
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3674,7 +3673,7 @@ TEST(DebugStepNatives) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
step_action = StepIn;
break_point_hit_count = 0;
@@ -3683,11 +3682,11 @@ TEST(DebugStepNatives) {
// With stepping all break locations are hit.
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
@@ -3695,7 +3694,7 @@ TEST(DebugStepNatives) {
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3713,7 +3712,7 @@ TEST(DebugStepFunctionApply) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
step_action = StepIn;
break_point_hit_count = 0;
@@ -3722,11 +3721,11 @@ TEST(DebugStepFunctionApply) {
// With stepping all break locations are hit.
CHECK_EQ(7, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
@@ -3734,7 +3733,7 @@ TEST(DebugStepFunctionApply) {
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3759,7 +3758,7 @@ TEST(DebugStepFunctionCall) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStep);
+ v8::Debug::SetDebugEventListener(DebugEventStep);
step_action = StepIn;
// Check stepping where the if condition in bar is false.
@@ -3774,11 +3773,11 @@ TEST(DebugStepFunctionCall) {
foo->Call(env->Global(), argc, argv);
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
@@ -3786,7 +3785,7 @@ TEST(DebugStepFunctionCall) {
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3798,7 +3797,7 @@ TEST(PauseInScript) {
env.ExposeDebug();
// Register a debug event listener which counts.
- v8::Debug::SetDebugEventListener2(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(DebugEventCounter);
// Create a script that returns a function.
const char* src = "(function (evt) {})";
@@ -3819,7 +3818,7 @@ TEST(PauseInScript) {
CHECK_EQ(1, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -3845,7 +3844,7 @@ TEST(BreakOnException) {
CompileFunction(&env, "function notCaught(){throws();}", "notCaught");
v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener2(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(DebugEventCounter);
// Initial state should be no break on exceptions.
DebugEventCounterClear();
@@ -3963,7 +3962,7 @@ TEST(BreakOnException) {
CHECK_EQ(1, uncaught_exception_hit_count);
CHECK_EQ(1, message_callback_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
v8::V8::RemoveMessageListeners(MessageCallbackCount);
}
@@ -3983,7 +3982,7 @@ TEST(BreakOnCompileException) {
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener2(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(DebugEventCounter);
DebugEventCounterClear();
MessageCallbackCountClear();
@@ -4039,7 +4038,7 @@ TEST(StepWithException) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(DebugEventStepSequence);
// Create functions for testing stepping.
const char* src = "function a() { n(); }; "
@@ -4111,7 +4110,7 @@ TEST(StepWithException) {
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -4126,7 +4125,7 @@ TEST(DebugBreak) {
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreak);
+ v8::Debug::SetDebugEventListener(DebugEventBreak);
// Create a function for testing stepping.
const char* src = "function f0() {}"
@@ -4166,7 +4165,7 @@ TEST(DebugBreak) {
CHECK_EQ(4 * ARRAY_SIZE(argv), break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -4178,7 +4177,7 @@ TEST(DisableBreak) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener2(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(DebugEventCounter);
// Create a function for testing stepping.
const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}";
@@ -4195,7 +4194,7 @@ TEST(DisableBreak) {
{
v8::Debug::DebugBreak(env->GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
- v8::internal::DisableBreak disable_break(isolate, true);
+ v8::internal::DisableBreak disable_break(isolate->debug(), true);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
}
@@ -4204,7 +4203,7 @@ TEST(DisableBreak) {
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -4220,7 +4219,7 @@ TEST(NoBreakWhenBootstrapping) {
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener2(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(DebugEventCounter);
// Set the debug break flag.
v8::Debug::DebugBreak(isolate);
@@ -4239,7 +4238,7 @@ TEST(NoBreakWhenBootstrapping) {
CHECK_EQ(0, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -4374,15 +4373,15 @@ TEST(InterceptorPropertyMirror) {
// Check that the properties are interceptor properties.
for (int i = 0; i < 3; i++) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "named_values[%d] instanceof debug.PropertyMirror", i);
+ SNPrintF(buffer,
+ "named_values[%d] instanceof debug.PropertyMirror", i);
CHECK(CompileRun(buffer.start())->BooleanValue());
- OS::SNPrintF(buffer, "named_values[%d].propertyType()", i);
+ SNPrintF(buffer, "named_values[%d].propertyType()", i);
CHECK_EQ(v8::internal::INTERCEPTOR,
CompileRun(buffer.start())->Int32Value());
- OS::SNPrintF(buffer, "named_values[%d].isNative()", i);
+ SNPrintF(buffer, "named_values[%d].isNative()", i);
CHECK(CompileRun(buffer.start())->BooleanValue());
}
@@ -4393,8 +4392,8 @@ TEST(InterceptorPropertyMirror) {
// Check that the properties are interceptor properties.
for (int i = 0; i < 2; i++) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer,
- "indexed_values[%d] instanceof debug.PropertyMirror", i);
+ SNPrintF(buffer,
+ "indexed_values[%d] instanceof debug.PropertyMirror", i);
CHECK(CompileRun(buffer.start())->BooleanValue());
}
@@ -4405,7 +4404,7 @@ TEST(InterceptorPropertyMirror) {
// Check that the properties are interceptor properties.
for (int i = 0; i < 5; i++) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
- OS::SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i);
+ SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i);
CHECK(CompileRun(buffer.start())->BooleanValue());
}
@@ -4730,7 +4729,7 @@ class ThreadBarrier V8_FINAL {
Mutex mutex_;
int num_blocked_;
- STATIC_CHECK(N > 0);
+ STATIC_ASSERT(N > 0);
DISALLOW_COPY_AND_ASSIGN(ThreadBarrier);
};
@@ -4745,8 +4744,8 @@ class Barriers {
ThreadBarrier<2> barrier_3;
ThreadBarrier<2> barrier_4;
ThreadBarrier<2> barrier_5;
- v8::internal::Semaphore semaphore_1;
- v8::internal::Semaphore semaphore_2;
+ v8::base::Semaphore semaphore_1;
+ v8::base::Semaphore semaphore_2;
};
@@ -4846,10 +4845,10 @@ Barriers message_queue_barriers;
// This is the debugger thread, that executes no v8 calls except
// placing JSON debugger commands in the queue.
-class MessageQueueDebuggerThread : public v8::internal::Thread {
+class MessageQueueDebuggerThread : public v8::base::Thread {
public:
MessageQueueDebuggerThread()
- : Thread("MessageQueueDebuggerThread") { }
+ : Thread(Options("MessageQueueDebuggerThread")) {}
void Run();
};
@@ -4961,7 +4960,7 @@ TEST(MessageQueues) {
// Create a V8 environment
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler2(MessageHandler);
+ v8::Debug::SetMessageHandler(MessageHandler);
message_queue_debugger_thread.Start();
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
@@ -5055,7 +5054,7 @@ TEST(SendClientDataToHandler) {
v8::HandleScope scope(isolate);
TestClientData::ResetCounters();
handled_client_data_instances_count = 0;
- v8::Debug::SetMessageHandler2(MessageHandlerCountingClientData);
+ v8::Debug::SetMessageHandler(MessageHandlerCountingClientData);
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -5103,15 +5102,15 @@ TEST(SendClientDataToHandler) {
Barriers threaded_debugging_barriers;
-class V8Thread : public v8::internal::Thread {
+class V8Thread : public v8::base::Thread {
public:
- V8Thread() : Thread("V8Thread") { }
+ V8Thread() : Thread(Options("V8Thread")) {}
void Run();
};
-class DebuggerThread : public v8::internal::Thread {
+class DebuggerThread : public v8::base::Thread {
public:
- DebuggerThread() : Thread("DebuggerThread") { }
+ DebuggerThread() : Thread(Options("DebuggerThread")) {}
void Run();
};
@@ -5129,10 +5128,7 @@ static void ThreadedMessageHandler(const v8::Debug::Message& message) {
if (IsBreakEventMessage(print_buffer)) {
// Check that we are inside the while loop.
int source_line = GetSourceLineFromBreakEventMessage(print_buffer);
- // TODO(2047): This should really be 8 <= source_line <= 13; but we
- // currently have an off-by-one error when calculating the source
- // position corresponding to the program counter at the debug break.
- CHECK(7 <= source_line && source_line <= 13);
+ CHECK(8 <= source_line && source_line <= 13);
threaded_debugging_barriers.barrier_2.Wait();
}
}
@@ -5162,7 +5158,7 @@ void V8Thread::Run() {
v8::Isolate::Scope isolate_scope(isolate);
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
+ v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
v8::Handle<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(env->GetIsolate());
global_template->Set(
@@ -5218,16 +5214,16 @@ TEST(ThreadedDebugging) {
* breakpoint is hit when enabled, and missed when disabled.
*/
-class BreakpointsV8Thread : public v8::internal::Thread {
+class BreakpointsV8Thread : public v8::base::Thread {
public:
- BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { }
+ BreakpointsV8Thread() : Thread(Options("BreakpointsV8Thread")) {}
void Run();
};
-class BreakpointsDebuggerThread : public v8::internal::Thread {
+class BreakpointsDebuggerThread : public v8::base::Thread {
public:
explicit BreakpointsDebuggerThread(bool global_evaluate)
- : Thread("BreakpointsDebuggerThread"),
+ : Thread(Options("BreakpointsDebuggerThread")),
global_evaluate_(global_evaluate) {}
void Run();
@@ -5281,7 +5277,7 @@ void BreakpointsV8Thread::Run() {
v8::Isolate::Scope isolate_scope(isolate);
DebugLocalContext env;
v8::HandleScope scope(isolate);
- v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler);
+ v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
CompileRun(source_1);
breakpoints_barriers->barrier_1.Wait();
@@ -5438,7 +5434,7 @@ static void DummyDebugEventListener(
TEST(SetDebugEventListenerOnUninitializedVM) {
- v8::Debug::SetDebugEventListener2(DummyDebugEventListener);
+ v8::Debug::SetDebugEventListener(DummyDebugEventListener);
}
@@ -5447,7 +5443,7 @@ static void DummyMessageHandler(const v8::Debug::Message& message) {
TEST(SetMessageHandlerOnUninitializedVM) {
- v8::Debug::SetMessageHandler2(DummyMessageHandler);
+ v8::Debug::SetMessageHandler(DummyMessageHandler);
}
@@ -5501,13 +5497,12 @@ static void CheckDataParameter(
v8::String::NewFromUtf8(args.GetIsolate(), "Test");
CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
- CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
- CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
-
- v8::TryCatch catcher;
- v8::Debug::Call(debugger_call_with_data);
- CHECK(catcher.HasCaught());
- CHECK(catcher.Exception()->IsString());
+ for (int i = 0; i < 3; i++) {
+ v8::TryCatch catcher;
+ CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
+ CHECK(catcher.HasCaught());
+ CHECK(catcher.Exception()->IsString());
+ }
}
@@ -5639,7 +5634,7 @@ TEST(DebuggerUnload) {
// Set a debug event listener.
break_point_hit_count = 0;
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
{
v8::HandleScope scope(env->GetIsolate());
// Create a couple of functions for the test.
@@ -5664,12 +5659,12 @@ TEST(DebuggerUnload) {
// Remove the debug event listener without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded(true);
// Now set a debug message handler.
break_point_hit_count = 0;
- v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount);
+ v8::Debug::SetMessageHandler(MessageHandlerBreakPointHitCount);
{
v8::HandleScope scope(env->GetIsolate());
@@ -5689,7 +5684,7 @@ TEST(DebuggerUnload) {
// Remove the debug message handler without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded(true);
}
@@ -5732,7 +5727,7 @@ TEST(DebuggerClearMessageHandler) {
CheckDebuggerUnloaded();
// Set a debug message handler.
- v8::Debug::SetMessageHandler2(MessageHandlerHitCount);
+ v8::Debug::SetMessageHandler(MessageHandlerHitCount);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5743,7 +5738,7 @@ TEST(DebuggerClearMessageHandler) {
// Clear debug message handler.
message_handler_hit_count = 0;
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5762,7 +5757,7 @@ static void MessageHandlerClearingMessageHandler(
message_handler_hit_count++;
// Clear debug message handler.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
}
@@ -5775,7 +5770,7 @@ TEST(DebuggerClearMessageHandlerWhileActive) {
CheckDebuggerUnloaded();
// Set a debug message handler.
- v8::Debug::SetMessageHandler2(MessageHandlerClearingMessageHandler);
+ v8::Debug::SetMessageHandler(MessageHandlerClearingMessageHandler);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5788,344 +5783,6 @@ TEST(DebuggerClearMessageHandlerWhileActive) {
}
-/* Test DebuggerHostDispatch */
-/* In this test, the debugger waits for a command on a breakpoint
- * and is dispatching host commands while in the infinite loop.
- */
-
-class HostDispatchV8Thread : public v8::internal::Thread {
- public:
- HostDispatchV8Thread() : Thread("HostDispatchV8Thread") { }
- void Run();
-};
-
-class HostDispatchDebuggerThread : public v8::internal::Thread {
- public:
- HostDispatchDebuggerThread() : Thread("HostDispatchDebuggerThread") { }
- void Run();
-};
-
-Barriers* host_dispatch_barriers;
-
-static void HostDispatchMessageHandler(const v8::Debug::Message& message) {
- static char print_buffer[1000];
- v8::String::Value json(message.GetJSON());
- Utf16ToAscii(*json, json.length(), print_buffer);
-}
-
-
-static void HostDispatchDispatchHandler() {
- host_dispatch_barriers->semaphore_1.Signal();
-}
-
-
-void HostDispatchV8Thread::Run() {
- const char* source_1 = "var y_global = 3;\n"
- "function cat( new_value ) {\n"
- " var x = new_value;\n"
- " y_global = 4;\n"
- " x = 3 * x + 1;\n"
- " y_global = 5;\n"
- " return x;\n"
- "}\n"
- "\n";
- const char* source_2 = "cat(17);\n";
-
- v8::Isolate::Scope isolate_scope(CcTest::isolate());
- DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- // Set up message and host dispatch handlers.
- v8::Debug::SetMessageHandler2(HostDispatchMessageHandler);
- v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */);
-
- CompileRun(source_1);
- host_dispatch_barriers->barrier_1.Wait();
- host_dispatch_barriers->barrier_2.Wait();
- CompileRun(source_2);
-}
-
-
-void HostDispatchDebuggerThread::Run() {
- const int kBufSize = 1000;
- uint16_t buffer[kBufSize];
-
- const char* command_1 = "{\"seq\":101,"
- "\"type\":\"request\","
- "\"command\":\"setbreakpoint\","
- "\"arguments\":{\"type\":\"function\",\"target\":\"cat\",\"line\":3}}";
- const char* command_2 = "{\"seq\":102,"
- "\"type\":\"request\","
- "\"command\":\"continue\"}";
-
- v8::Isolate* isolate = CcTest::isolate();
- // v8 thread initializes, runs source_1
- host_dispatch_barriers->barrier_1.Wait();
- // 1: Set breakpoint in cat().
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
-
- host_dispatch_barriers->barrier_2.Wait();
- // v8 thread starts compiling source_2.
- // Break happens, to run queued commands and host dispatches.
- // Wait for host dispatch to be processed.
- host_dispatch_barriers->semaphore_1.Wait();
- // 2: Continue evaluation
- v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
-}
-
-
-TEST(DebuggerHostDispatch) {
- HostDispatchDebuggerThread host_dispatch_debugger_thread;
- HostDispatchV8Thread host_dispatch_v8_thread;
-
- // Create a V8 environment
- Barriers stack_allocated_host_dispatch_barriers;
- host_dispatch_barriers = &stack_allocated_host_dispatch_barriers;
-
- host_dispatch_v8_thread.Start();
- host_dispatch_debugger_thread.Start();
-
- host_dispatch_v8_thread.Join();
- host_dispatch_debugger_thread.Join();
-}
-
-
-/* Test DebugMessageDispatch */
-/* In this test, the V8 thread waits for a message from the debug thread.
- * The DebugMessageDispatchHandler is executed from the debugger thread
- * which signals the V8 thread to wake up.
- */
-
-class DebugMessageDispatchV8Thread : public v8::internal::Thread {
- public:
- DebugMessageDispatchV8Thread() : Thread("DebugMessageDispatchV8Thread") { }
- void Run();
-};
-
-class DebugMessageDispatchDebuggerThread : public v8::internal::Thread {
- public:
- DebugMessageDispatchDebuggerThread()
- : Thread("DebugMessageDispatchDebuggerThread") { }
- void Run();
-};
-
-Barriers* debug_message_dispatch_barriers;
-
-
-static void DebugMessageHandler() {
- debug_message_dispatch_barriers->semaphore_1.Signal();
-}
-
-
-void DebugMessageDispatchV8Thread::Run() {
- v8::Isolate::Scope isolate_scope(CcTest::isolate());
- DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- // Set up debug message dispatch handler.
- v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler);
-
- CompileRun("var y = 1 + 2;\n");
- debug_message_dispatch_barriers->barrier_1.Wait();
- debug_message_dispatch_barriers->semaphore_1.Wait();
- debug_message_dispatch_barriers->barrier_2.Wait();
-}
-
-
-void DebugMessageDispatchDebuggerThread::Run() {
- debug_message_dispatch_barriers->barrier_1.Wait();
- SendContinueCommand();
- debug_message_dispatch_barriers->barrier_2.Wait();
-}
-
-
-TEST(DebuggerDebugMessageDispatch) {
- DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread;
- DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread;
-
- // Create a V8 environment
- Barriers stack_allocated_debug_message_dispatch_barriers;
- debug_message_dispatch_barriers =
- &stack_allocated_debug_message_dispatch_barriers;
-
- debug_message_dispatch_v8_thread.Start();
- debug_message_dispatch_debugger_thread.Start();
-
- debug_message_dispatch_v8_thread.Join();
- debug_message_dispatch_debugger_thread.Join();
-}
-
-
-TEST(DebuggerAgent) {
- v8::V8::Initialize();
- i::Debugger* debugger = CcTest::i_isolate()->debugger();
- // Make sure these ports is not used by other tests to allow tests to run in
- // parallel.
- const int kPort1 = 5858 + FlagDependentPortOffset();
- const int kPort2 = 5857 + FlagDependentPortOffset();
- const int kPort3 = 5856 + FlagDependentPortOffset();
-
- // Make a string with the port2 number.
- const int kPortBufferLen = 6;
- char port2_str[kPortBufferLen];
- OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2);
-
- bool ok;
-
- // Test starting and stopping the agent without any client connection.
- debugger->StartAgent("test", kPort1);
- debugger->StopAgent();
- // Test starting the agent, connecting a client and shutting down the agent
- // with the client connected.
- ok = debugger->StartAgent("test", kPort2);
- CHECK(ok);
- debugger->WaitForAgent();
- i::Socket* client = new i::Socket;
- ok = client->Connect("localhost", port2_str);
- CHECK(ok);
- // It is important to wait for a message from the agent. Otherwise,
- // we can close the server socket during "accept" syscall, making it failing
- // (at least on Linux), and the test will work incorrectly.
- char buf;
- ok = client->Receive(&buf, 1) == 1;
- CHECK(ok);
- debugger->StopAgent();
- delete client;
-
- // Test starting and stopping the agent with the required port already
- // occoupied.
- i::Socket* server = new i::Socket;
- ok = server->Bind(kPort3);
- CHECK(ok);
-
- debugger->StartAgent("test", kPort3);
- debugger->StopAgent();
-
- delete server;
-}
-
-
-class DebuggerAgentProtocolServerThread : public i::Thread {
- public:
- explicit DebuggerAgentProtocolServerThread(int port)
- : Thread("DebuggerAgentProtocolServerThread"),
- port_(port),
- server_(NULL),
- client_(NULL),
- listening_(0) {
- }
- ~DebuggerAgentProtocolServerThread() {
- // Close both sockets.
- delete client_;
- delete server_;
- }
-
- void Run();
- void WaitForListening() { listening_.Wait(); }
- char* body() { return body_.get(); }
-
- private:
- int port_;
- i::SmartArrayPointer<char> body_;
- i::Socket* server_; // Server socket used for bind/accept.
- i::Socket* client_; // Single client connection used by the test.
- i::Semaphore listening_; // Signalled when the server is in listen mode.
-};
-
-
-void DebuggerAgentProtocolServerThread::Run() {
- bool ok;
-
- // Create the server socket and bind it to the requested port.
- server_ = new i::Socket;
- CHECK(server_ != NULL);
- ok = server_->Bind(port_);
- CHECK(ok);
-
- // Listen for new connections.
- ok = server_->Listen(1);
- CHECK(ok);
- listening_.Signal();
-
- // Accept a connection.
- client_ = server_->Accept();
- CHECK(client_ != NULL);
-
- // Receive a debugger agent protocol message.
- i::DebuggerAgentUtil::ReceiveMessage(client_);
-}
-
-
-TEST(DebuggerAgentProtocolOverflowHeader) {
- // Make sure this port is not used by other tests to allow tests to run in
- // parallel.
- const int kPort = 5860 + FlagDependentPortOffset();
- static const char* kLocalhost = "localhost";
-
- // Make a string with the port number.
- const int kPortBufferLen = 6;
- char port_str[kPortBufferLen];
- OS::SNPrintF(i::Vector<char>(port_str, kPortBufferLen), "%d", kPort);
-
- // Create a socket server to receive a debugger agent message.
- DebuggerAgentProtocolServerThread* server =
- new DebuggerAgentProtocolServerThread(kPort);
- server->Start();
- server->WaitForListening();
-
- // Connect.
- i::Socket* client = new i::Socket;
- CHECK(client != NULL);
- bool ok = client->Connect(kLocalhost, port_str);
- CHECK(ok);
-
- // Send headers which overflow the receive buffer.
- static const int kBufferSize = 1000;
- char buffer[kBufferSize];
-
- // Long key and short value: XXXX....XXXX:0\r\n.
- for (int i = 0; i < kBufferSize - 4; i++) {
- buffer[i] = 'X';
- }
- buffer[kBufferSize - 4] = ':';
- buffer[kBufferSize - 3] = '0';
- buffer[kBufferSize - 2] = '\r';
- buffer[kBufferSize - 1] = '\n';
- int result = client->Send(buffer, kBufferSize);
- CHECK_EQ(kBufferSize, result);
-
- // Short key and long value: X:XXXX....XXXX\r\n.
- buffer[0] = 'X';
- buffer[1] = ':';
- for (int i = 2; i < kBufferSize - 2; i++) {
- buffer[i] = 'X';
- }
- buffer[kBufferSize - 2] = '\r';
- buffer[kBufferSize - 1] = '\n';
- result = client->Send(buffer, kBufferSize);
- CHECK_EQ(kBufferSize, result);
-
- // Add empty body to request.
- const char* content_length_zero_header = "Content-Length:0\r\n";
- int length = StrLength(content_length_zero_header);
- result = client->Send(content_length_zero_header, length);
- CHECK_EQ(length, result);
- result = client->Send("\r\n", 2);
- CHECK_EQ(2, result);
-
- // Wait until data is received.
- server->Join();
-
- // Check for empty body.
- CHECK(server->body() == NULL);
-
- // Close the client before the server to avoid TIME_WAIT issues.
- client->Shutdown();
- delete client;
- delete server;
-}
-
-
// Test for issue http://code.google.com/p/v8/issues/detail?id=289.
// Make sure that DebugGetLoadedScripts doesn't return scripts
// with disposed external source.
@@ -6189,7 +5846,7 @@ TEST(ScriptNameAndData) {
frame_script_name_source,
"frame_script_name");
- v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
// Test function source.
v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(),
@@ -6282,7 +5939,7 @@ 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);
+ v8::Debug::SetMessageHandler(ContextCheckMessageHandler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
@@ -6321,7 +5978,7 @@ TEST(ContextData) {
// Two times compile event and two times break event.
CHECK_GT(message_handler_hit_count, 4);
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
}
@@ -6350,7 +6007,7 @@ TEST(DebugBreakInMessageHandler) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler2(DebugBreakMessageHandler);
+ v8::Debug::SetMessageHandler(DebugBreakMessageHandler);
// Test functions.
const char* script = "function f() { debugger; g(); } function g() { }";
@@ -6430,7 +6087,7 @@ TEST(RegExpDebugBreak) {
v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv);
CHECK_EQ(12, result->Int32Value());
- v8::Debug::SetDebugEventListener2(DebugEventDebugBreak);
+ v8::Debug::SetDebugEventListener(DebugEventDebugBreak);
v8::Debug::DebugBreak(env->GetIsolate());
result = f->Call(env->Global(), argc, argv);
@@ -6444,7 +6101,7 @@ TEST(RegExpDebugBreak) {
// Common part of EvalContextData and NestedBreakEventContextData tests.
static void ExecuteScriptForContextCheck(
- v8::Debug::MessageHandler2 message_handler) {
+ v8::Debug::MessageHandler message_handler) {
// Create a context.
v8::Handle<v8::Context> context_1;
v8::Handle<v8::ObjectTemplate> global_template =
@@ -6452,7 +6109,7 @@ static void ExecuteScriptForContextCheck(
context_1 =
v8::Context::New(CcTest::isolate(), NULL, global_template);
- v8::Debug::SetMessageHandler2(message_handler);
+ v8::Debug::SetMessageHandler(message_handler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
@@ -6475,7 +6132,7 @@ static void ExecuteScriptForContextCheck(
f->Call(context_1->Global(), 0, NULL);
}
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
}
@@ -6562,120 +6219,6 @@ TEST(NestedBreakEventContextData) {
}
-// Debug event listener which counts the script collected events.
-int script_collected_count = 0;
-static void DebugEventScriptCollectedEvent(
- const v8::Debug::EventDetails& event_details) {
- v8::DebugEvent event = event_details.GetEvent();
- // Count the number of breaks.
- if (event == v8::ScriptCollected) {
- script_collected_count++;
- }
-}
-
-
-// Test that scripts collected are reported through the debug event listener.
-TEST(ScriptCollectedEvent) {
- v8::internal::Debug* debug = CcTest::i_isolate()->debug();
- break_point_hit_count = 0;
- script_collected_count = 0;
- DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- // Request the loaded scripts to initialize the debugger script cache.
- debug->GetLoadedScripts();
-
- // Do garbage collection to ensure that only the script in this test will be
- // collected afterwards.
- CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
-
- script_collected_count = 0;
- v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent);
- {
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=1')"))->Run();
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=2')"))->Run();
- }
-
- // Do garbage collection to collect the script above which is no longer
- // referenced.
- CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
-
- CHECK_EQ(2, script_collected_count);
-
- v8::Debug::SetDebugEventListener2(NULL);
- CheckDebuggerUnloaded();
-}
-
-
-// Debug event listener which counts the script collected events.
-int script_collected_message_count = 0;
-static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) {
- // Count the number of scripts collected.
- if (message.IsEvent() && message.GetEvent() == v8::ScriptCollected) {
- script_collected_message_count++;
- v8::Handle<v8::Context> context = message.GetEventContext();
- CHECK(context.IsEmpty());
- }
-}
-
-
-// Test that GetEventContext doesn't fail and return empty handle for
-// ScriptCollected events.
-TEST(ScriptCollectedEventContext) {
- i::FLAG_stress_compaction = false;
- v8::Isolate* isolate = CcTest::isolate();
- v8::internal::Debug* debug =
- reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
- script_collected_message_count = 0;
- v8::HandleScope scope(isolate);
-
- v8::Persistent<v8::Context> context;
- {
- v8::HandleScope scope(isolate);
- context.Reset(isolate, v8::Context::New(isolate));
- }
-
- // Enter context. We can't have a handle to the context in the outer
- // scope, so we have to do it the hard way.
- {
- v8::HandleScope scope(isolate);
- v8::Local<v8::Context> local_context =
- v8::Local<v8::Context>::New(isolate, context);
- local_context->Enter();
- }
-
- // Request the loaded scripts to initialize the debugger script cache.
- debug->GetLoadedScripts();
-
- // Do garbage collection to ensure that only the script in this test will be
- // collected afterwards.
- CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
-
- v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=1')"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=2')"))->Run();
-
- // Leave context
- {
- v8::HandleScope scope(isolate);
- v8::Local<v8::Context> local_context =
- v8::Local<v8::Context>::New(isolate, context);
- local_context->Exit();
- }
- context.Reset();
-
- // Do garbage collection to collect the script above which is no longer
- // referenced.
- CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
-
- CHECK_EQ(2, script_collected_message_count);
-
- v8::Debug::SetMessageHandler2(NULL);
-}
-
-
// Debug event listener which counts the after compile events.
int after_compile_message_count = 0;
static void AfterCompileMessageHandler(const v8::Debug::Message& message) {
@@ -6698,18 +6241,18 @@ TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
after_compile_message_count = 0;
const char* script = "var a=1";
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
->Run();
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
->Run();
// Setting listener to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
// Compilation cache should be disabled when debugger is active.
@@ -6717,6 +6260,60 @@ TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
}
+// Syntax error event handler which counts a number of events.
+int compile_error_event_count = 0;
+
+static void CompileErrorEventCounterClear() {
+ compile_error_event_count = 0;
+}
+
+static void CompileErrorEventCounter(
+ const v8::Debug::EventDetails& event_details) {
+ v8::DebugEvent event = event_details.GetEvent();
+
+ if (event == v8::CompileError) {
+ compile_error_event_count++;
+ }
+}
+
+
+// Tests that syntax error event is sent as many times as there are scripts
+// with syntax error compiled.
+TEST(SyntaxErrorMessageOnSyntaxException) {
+ DebugLocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ // For this test, we want to break on uncaught exceptions:
+ ChangeBreakOnException(false, true);
+
+ v8::Debug::SetDebugEventListener(CompileErrorEventCounter);
+
+ CompileErrorEventCounterClear();
+
+ // Check initial state.
+ CHECK_EQ(0, compile_error_event_count);
+
+ // Throws SyntaxError: Unexpected end of input
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++"));
+ CHECK_EQ(1, compile_error_event_count);
+
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "/sel\\/: \\"));
+ CHECK_EQ(2, compile_error_event_count);
+
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')"));
+ CHECK_EQ(2, compile_error_event_count);
+
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');"));
+ CHECK_EQ(2, compile_error_event_count);
+
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "throw 1;"));
+ CHECK_EQ(2, compile_error_event_count);
+}
+
+
// Tests that break event is sent when message handler is reset.
TEST(BreakMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
@@ -6724,19 +6321,19 @@ TEST(BreakMessageWhenMessageHandlerIsReset) {
after_compile_message_count = 0;
const char* script = "function f() {};";
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
->Run();
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
// Compilation cache should be disabled when debugger is active.
@@ -6764,18 +6361,18 @@ TEST(ExceptionMessageWhenMessageHandlerIsReset) {
exception_event_count = 0;
const char* script = "function f() {throw new Error()};";
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
->Run();
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
- v8::Debug::SetMessageHandler2(ExceptionMessageHandler);
+ v8::Debug::SetMessageHandler(ExceptionMessageHandler);
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
CHECK_EQ(1, exception_event_count);
@@ -6799,7 +6396,7 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
after_compile_message_count = 0;
- v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
v8::ScriptOrigin origin(
v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
@@ -6817,7 +6414,7 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
}
@@ -6834,19 +6431,12 @@ static void BreakMessageHandler(const v8::Debug::Message& message) {
} else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) {
i::HandleScope scope(isolate);
- bool is_debug_break = isolate->stack_guard()->IsDebugBreak();
- // Force DebugBreak flag while serializer is working.
- isolate->stack_guard()->DebugBreak();
+ int current_count = break_point_hit_count;
// Force serialization to trigger some internal JS execution.
message.GetJSON();
- // Restore previous state.
- if (is_debug_break) {
- isolate->stack_guard()->DebugBreak();
- } else {
- isolate->stack_guard()->Continue(i::DEBUGBREAK);
- }
+ CHECK_EQ(current_count, break_point_hit_count);
}
}
@@ -6858,7 +6448,7 @@ TEST(NoDebugBreakInAfterCompileMessageHandler) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetMessageHandler2(BreakMessageHandler);
+ v8::Debug::SetMessageHandler(BreakMessageHandler);
// Set the debug break flag.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -6877,7 +6467,7 @@ TEST(NoDebugBreakInAfterCompileMessageHandler) {
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
}
@@ -6885,7 +6475,7 @@ TEST(NoDebugBreakInAfterCompileMessageHandler) {
static int counting_message_handler_counter;
static void CountingMessageHandler(const v8::Debug::Message& message) {
- counting_message_handler_counter++;
+ if (message.IsResponse()) counting_message_handler_counter++;
}
@@ -6897,7 +6487,7 @@ TEST(ProcessDebugMessages) {
counting_message_handler_counter = 0;
- v8::Debug::SetMessageHandler2(CountingMessageHandler);
+ v8::Debug::SetMessageHandler(CountingMessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6927,7 +6517,84 @@ TEST(ProcessDebugMessages) {
CHECK_GE(counting_message_handler_counter, 2);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+class SendCommandThread : public v8::base::Thread {
+ public:
+ explicit SendCommandThread(v8::Isolate* isolate)
+ : Thread(Options("SendCommandThread")),
+ semaphore_(0),
+ isolate_(isolate) {}
+
+ static void ProcessDebugMessages(v8::Isolate* isolate, void* data) {
+ v8::Debug::ProcessDebugMessages();
+ reinterpret_cast<v8::base::Semaphore*>(data)->Signal();
+ }
+
+ virtual void Run() {
+ semaphore_.Wait();
+ const int kBufferSize = 1000;
+ uint16_t buffer[kBufferSize];
+ const char* scripts_command =
+ "{\"seq\":0,"
+ "\"type\":\"request\","
+ "\"command\":\"scripts\"}";
+ int length = AsciiToUtf16(scripts_command, buffer);
+ // Send scripts command.
+
+ for (int i = 0; i < 100; i++) {
+ CHECK_EQ(i, counting_message_handler_counter);
+ // Queue debug message.
+ v8::Debug::SendCommand(isolate_, buffer, length);
+ // Synchronize with the main thread to force message processing.
+ isolate_->RequestInterrupt(ProcessDebugMessages, &semaphore_);
+ semaphore_.Wait();
+ }
+
+ v8::V8::TerminateExecution(isolate_);
+ }
+
+ void StartSending() {
+ semaphore_.Signal();
+ }
+
+ private:
+ v8::base::Semaphore semaphore_;
+ v8::Isolate* isolate_;
+};
+
+
+static SendCommandThread* send_command_thread_ = NULL;
+
+static void StartSendingCommands(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ send_command_thread_->StartSending();
+}
+
+
+TEST(ProcessDebugMessagesThreaded) {
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ counting_message_handler_counter = 0;
+
+ v8::Debug::SetMessageHandler(CountingMessageHandler);
+ send_command_thread_ = new SendCommandThread(isolate);
+ send_command_thread_->Start();
+
+ v8::Handle<v8::FunctionTemplate> start =
+ v8::FunctionTemplate::New(isolate, StartSendingCommands);
+ env->Global()->Set(v8_str("start"), start->GetFunction());
+
+ CompileRun("start(); while (true) { }");
+
+ CHECK_EQ(100, counting_message_handler_counter);
+
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
}
@@ -6955,7 +6622,7 @@ TEST(Backtrace) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetMessageHandler2(BacktraceData::MessageHandler);
+ v8::Debug::SetMessageHandler(BacktraceData::MessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6989,7 +6656,7 @@ TEST(Backtrace) {
CHECK_EQ(BacktraceData::frame_counter, 1);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler2(NULL);
+ v8::Debug::SetMessageHandler(NULL);
CheckDebuggerUnloaded();
}
@@ -7029,7 +6696,7 @@ TEST(DebugBreakFunctionApply) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(DebugEventBreakMax);
// Set the debug break flag before calling the code using function.apply.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -7043,7 +6710,7 @@ TEST(DebugBreakFunctionApply) {
// When keeping the debug break several break will happen.
CHECK_GT(break_point_hit_count, 1);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -7112,7 +6779,7 @@ TEST(CallingContextIsNotDebugContext) {
named->NewInstance());
// Register the debug event listener
- v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue);
+ v8::Debug::SetDebugEventListener(DebugEventGetAtgumentPropertyValue);
// Create a function that invokes debugger.
v8::Local<v8::Function> foo = CompileFunction(
@@ -7125,7 +6792,7 @@ TEST(CallingContextIsNotDebugContext) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
debugee_context = v8::Handle<v8::Context>();
debugger_context = v8::Handle<v8::Context>();
CheckDebuggerUnloaded();
@@ -7134,9 +6801,12 @@ TEST(CallingContextIsNotDebugContext) {
TEST(DebugContextIsPreservedBetweenAccesses) {
v8::HandleScope scope(CcTest::isolate());
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
- CHECK_EQ(*context1, *context2);
+ CHECK(v8::Utils::OpenHandle(*context1).is_identical_to(
+ v8::Utils::OpenHandle(*context2)));
+ v8::Debug::SetDebugEventListener(NULL);
}
@@ -7153,13 +6823,13 @@ TEST(DebugEventContext) {
v8::HandleScope scope(isolate);
expected_context = v8::Context::New(isolate);
expected_callback_data = v8::Int32::New(isolate, 2010);
- v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
+ v8::Debug::SetDebugEventListener(DebugEventContextChecker,
expected_callback_data);
v8::Context::Scope context_scope(expected_context);
v8::Script::Compile(
v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
expected_context.Clear();
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
expected_context_data = v8::Handle<v8::Value>();
CheckDebuggerUnloaded();
}
@@ -7183,7 +6853,7 @@ TEST(DebugEventBreakData) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker);
+ v8::Debug::SetDebugEventListener(DebugEventBreakDataChecker);
TestClientData::constructor_call_counter = 0;
TestClientData::destructor_call_counter = 0;
@@ -7191,7 +6861,7 @@ TEST(DebugEventBreakData) {
expected_break_data = NULL;
was_debug_event_called = false;
was_debug_break_called = false;
- v8::Debug::DebugBreakForCommand(NULL, isolate);
+ v8::Debug::DebugBreakForCommand(isolate, NULL);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x;})(1);"))
->Run();
@@ -7202,7 +6872,7 @@ TEST(DebugEventBreakData) {
expected_break_data = data1;
was_debug_event_called = false;
was_debug_break_called = false;
- v8::Debug::DebugBreakForCommand(data1, isolate);
+ v8::Debug::DebugBreakForCommand(isolate, data1);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x+1;})(1);"))
->Run();
@@ -7224,7 +6894,7 @@ TEST(DebugEventBreakData) {
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreak(isolate);
- v8::Debug::DebugBreakForCommand(data2, isolate);
+ v8::Debug::DebugBreakForCommand(isolate, data2);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x+3;})(1);"))
->Run();
@@ -7235,7 +6905,7 @@ TEST(DebugEventBreakData) {
CHECK_EQ(TestClientData::constructor_call_counter,
TestClientData::destructor_call_counter);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -7289,7 +6959,7 @@ TEST(DeoptimizeDuringDebugBreak) {
// This tests lazy deoptimization bailout for the stack check, as the first
// time in function bar when using debug break and no break points will be at
// the initial stack check.
- v8::Debug::SetDebugEventListener2(DebugEventBreakDeoptimize);
+ v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize);
// Compile and run function bar which will optimize it for some flag settings.
v8::Script::Compile(v8::String::NewFromUtf8(
@@ -7302,7 +6972,7 @@ TEST(DeoptimizeDuringDebugBreak) {
CHECK(debug_event_break_deoptimize_done);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
}
@@ -7357,7 +7027,7 @@ static void DebugEventBreakWithOptimizedStack(
static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Debug::SetDebugEventListener2(DebugEventBreakWithOptimizedStack);
+ v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack);
v8::Debug::DebugBreak(args.GetIsolate());
}
@@ -7415,9 +7085,9 @@ static void TestDebugBreakInLoop(const char* loop_head,
terminate_after_max_break_point_hit = true;
EmbeddedVector<char, 1024> buffer;
- OS::SNPrintF(buffer,
- "function f() {%s%s%s}",
- loop_head, loop_bodies[i], loop_tail);
+ SNPrintF(buffer,
+ "function f() {%s%s%s}",
+ loop_head, loop_bodies[i], loop_tail);
// Function with infinite loop.
CompileRun(buffer.start());
@@ -7440,7 +7110,7 @@ TEST(DebugBreakLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener2(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(DebugEventBreakMax);
// Create a function for getting the frame count when hitting the break.
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
@@ -7474,7 +7144,7 @@ TEST(DebugBreakLoop) {
TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -7496,7 +7166,7 @@ static void DebugBreakInlineListener(
int break_id = CcTest::i_isolate()->debug()->break_id();
char script[128];
i::Vector<char> script_vector(script, sizeof(script));
- OS::SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
+ SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
v8::Local<v8::Value> result = CompileRun(script);
int frame_count = result->Int32Value();
@@ -7505,12 +7175,12 @@ static void DebugBreakInlineListener(
for (int i = 0; i < frame_count; i++) {
// The 5. element in the returned array of GetFrameDetails contains the
// source position of that frame.
- OS::SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i);
+ SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i);
v8::Local<v8::Value> result = CompileRun(script);
CHECK_EQ(expected_line_number[i],
i::Script::GetLineNumber(source_script, result->Int32Value()));
}
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
v8::V8::TerminateExecution(CcTest::isolate());
}
@@ -7533,7 +7203,7 @@ TEST(DebugBreakInline) {
"g(false); \n"
"%OptimizeFunctionOnNextCall(g); \n"
"g(true);";
- v8::Debug::SetDebugEventListener2(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
inline_script =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source));
inline_script->Run();
@@ -7567,7 +7237,7 @@ TEST(Regress131642) {
// on the stack.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugEventStepNext);
+ v8::Debug::SetDebugEventListener(DebugEventStepNext);
// We step through the first script. It exits through an exception. We run
// this inside a new frame to record a different FP than the second script
@@ -7579,7 +7249,7 @@ TEST(Regress131642) {
const char* script_2 = "[0].forEach(function() { });";
CompileRun(script_2);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
}
@@ -7596,15 +7266,15 @@ TEST(DebuggerCreatesContextIffActive) {
v8::HandleScope scope(env->GetIsolate());
CHECK_EQ(1, CountNativeContexts());
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CompileRun("debugger;");
CHECK_EQ(1, CountNativeContexts());
- v8::Debug::SetDebugEventListener2(NopListener);
+ v8::Debug::SetDebugEventListener(NopListener);
CompileRun("debugger;");
CHECK_EQ(2, CountNativeContexts());
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
}
@@ -7612,7 +7282,7 @@ TEST(LiveEditEnabled) {
v8::internal::FLAG_allow_natives_syntax = true;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetLiveEditEnabled(true, env->GetIsolate());
+ v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true);
CompileRun("%LiveEditCompareStrings('', '')");
}
@@ -7621,7 +7291,7 @@ TEST(LiveEditDisabled) {
v8::internal::FLAG_allow_natives_syntax = true;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
+ v8::Debug::SetLiveEditEnabled(env->GetIsolate(), false);
CompileRun("%LiveEditCompareStrings('', '')");
}
@@ -7634,7 +7304,7 @@ TEST(PrecompiledFunction) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener2(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
v8::Local<v8::Function> break_here =
CompileFunction(&env, "function break_here(){}", "break_here");
@@ -7651,12 +7321,12 @@ TEST(PrecompiledFunction) {
"}; \n"
"a = b = c = 2; \n"
"bar(); \n";
- v8::Local<v8::Value> result = PreCompileCompileRun(source);
+ v8::Local<v8::Value> result = ParserCacheCompileRun(source);
CHECK(result->IsString());
v8::String::Utf8Value utf8(result);
CHECK_EQ("bar", *utf8);
- v8::Debug::SetDebugEventListener2(NULL);
+ v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -7675,7 +7345,7 @@ static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(DebugBreakStackTrace) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener2(DebugBreakStackTraceListener);
+ v8::Debug::SetDebugEventListener(DebugBreakStackTraceListener);
v8::Handle<v8::FunctionTemplate> add_debug_break_template =
v8::FunctionTemplate::New(env->GetIsolate(), AddDebugBreak);
v8::Handle<v8::Function> add_debug_break =
@@ -7690,3 +7360,48 @@ TEST(DebugBreakStackTrace) {
" }"
"})()");
}
+
+
+v8::base::Semaphore terminate_requested_semaphore(0);
+v8::base::Semaphore terminate_fired_semaphore(0);
+bool terminate_already_fired = false;
+
+
+static void DebugBreakTriggerTerminate(
+ const v8::Debug::EventDetails& event_details) {
+ if (event_details.GetEvent() != v8::Break || terminate_already_fired) return;
+ terminate_requested_semaphore.Signal();
+ // Wait for at most 2 seconds for the terminate request.
+ CHECK(terminate_fired_semaphore.WaitFor(v8::base::TimeDelta::FromSeconds(2)));
+ terminate_already_fired = true;
+}
+
+
+class TerminationThread : public v8::base::Thread {
+ public:
+ explicit TerminationThread(v8::Isolate* isolate)
+ : Thread(Options("terminator")), isolate_(isolate) {}
+
+ virtual void Run() {
+ terminate_requested_semaphore.Wait();
+ v8::V8::TerminateExecution(isolate_);
+ terminate_fired_semaphore.Signal();
+ }
+
+ private:
+ v8::Isolate* isolate_;
+};
+
+
+TEST(DebugBreakOffThreadTerminate) {
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
+ TerminationThread terminator(isolate);
+ terminator.Start();
+ v8::TryCatch try_catch;
+ v8::Debug::DebugBreak(isolate);
+ CompileRun("while (true);");
+ CHECK(try_catch.HasTerminated());
+}