Home | History | Annotate | Download | only in cctest

Lines Matching refs:v8

1 // Copyright 2012 the V8 project authors. All rights reserved.
32 #include "v8.h"
44 using ::v8::internal::EmbeddedVector;
45 using ::v8::internal::Object;
46 using ::v8::internal::OS;
47 using ::v8::internal::Handle;
48 using ::v8::internal::Heap;
49 using ::v8::internal::JSGlobalProxy;
50 using ::v8::internal::Code;
51 using ::v8::internal::Debug;
52 using ::v8::internal::Debugger;
53 using ::v8::internal::CommandMessage;
54 using ::v8::internal::CommandMessageQueue;
55 using ::v8::internal::StepAction;
56 using ::v8::internal::StepIn; // From StepAction enum
57 using ::v8::internal::StepNext; // From StepAction enum
58 using ::v8::internal::StepOut; // From StepAction enum
59 using ::v8::internal::Vector;
60 using ::v8::internal::StrLength;
72 ::v8::internal::Address expected,
74 ::v8::internal::Address value) {
87 ::v8::internal::Address unexpected,
89 ::v8::internal::Address value) {
127 // Helper class for creating a V8 enviromnent for running tests
131 v8::ExtensionConfiguration* extensions = 0,
132 v8::Handle<v8::ObjectTemplate> global_template =
133 v8::Handle<v8::ObjectTemplate>(),
134 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
135 : context_(v8::Context::New(extensions, global_template, global_object)) {
142 inline v8::Context* operator->() { return *context_; }
143 inline v8::Context* operator*() { return *context_; }
146 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
150 v8::Utils::OpenHandle(*context_)->security_token());
153 v8::Utils::OpenHandle(*context_->Global())));
154 Handle<v8::internal::String> debug_string =
158 ::v8::internal::kNonStrictMode);
162 v8::Persistent<v8::Context> context_;
170 static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env,
173 v8::Script::Compile(v8::String::New(source))->Run();
174 return v8::Local<v8::Function>::Cast(
175 (*env)->Global()->Get(v8::String::New(function_name)));
180 static v8::Local<v8::Function> CompileFunction(const char* source,
182 v8::Script::Compile(v8::String::New(source))->Run();
183 return v8::Local<v8::Function>::Cast(
184 v8::Context::GetCurrent()->Global()->Get(v8::String::New(function_name)));
189 static bool HasDebugInfo(v8::Handle<v8::Function> fun) {
190 Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun);
191 Handle<v8::internal::SharedFunctionInfo> shared(f->shared());
198 static int SetBreakPoint(Handle<v8::internal::JSFunction> fun, int position) {
200 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
201 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
204 Handle<Object>(v8::internal::Smi::FromInt(++break_point)),
212 static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) {
213 return SetBreakPoint(v8::Utils::OpenHandle(*fun), position);
226 v8::Handle<v8::String> str = v8::String::New(buffer.start());
227 return v8::Script::Compile(str)->Run()->Int32Value();
247 v8::TryCatch try_catch;
248 v8::Handle<v8::String> str = v8::String::New(buffer.start());
249 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
274 v8::TryCatch try_catch;
275 v8::Handle<v8::String> str = v8::String::New(buffer.start());
276 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
285 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
287 Handle<Object>(v8::internal::Smi::FromInt(break_point)));
298 v8::Script::Compile(v8::String::New(buffer.start()))->Run();
308 v8::Script::Compile(v8::String::New(buffer.start()))->Run();
318 v8::Script::Compile(v8::String::New(buffer.start()))->Run();
329 v8::Script::Compile(v8::String::New(buffer.start()))->Run();
340 v8::Script::Compile(v8::String::New(buffer.start()))->Run();
346 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
347 debug->ChangeBreakOnException(v8::internal::BreakException, caught);
348 debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught);
355 v8::Script::Compile(
356 v8::String::New("debug.Debug.setBreakOnException()"))->Run();
358 v8::Script::Compile(
359 v8::String::New("debug.Debug.clearBreakOnException()"))->Run();
362 v8::Script::Compile(
363 v8::String::New("debug.Debug.setBreakOnUncaughtException()"))->Run();
365 v8::Script::Compile(
366 v8::String::New("debug.Debug.clearBreakOnUncaughtException()"))->Run();
373 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
378 // This function is in namespace v8::internal to be friend with class
379 // v8::internal::Debug.
380 namespace v8 {
387 v8::internal::DebugInfoListNode* node = debug->debug_info_list_;
459 } } // namespace v8::internal
465 v8::Debug::ProcessDebugMessages();
467 v8::internal::CheckDebuggerUnloaded(check_functions);
473 class TestBreakLocationIterator: public v8::internal::BreakLocationIterator {
475 explicit TestBreakLocationIterator(Handle<v8::internal::DebugInfo> debug_info)
476 : BreakLocationIterator(debug_info, v8::internal::SOURCE_BREAK_LOCATIONS) {}
477 v8::internal::RelocIterator* it() { return reloc_iterator_; }
478 v8::internal::RelocIterator* it_original() {
488 int position, v8::internal::RelocInfo::Mode mode,
490 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
493 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle(
498 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
502 v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode();
503 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
504 actual_mode = v8::internal::RelocInfo::CODE_TARGET;
507 if (mode != v8::internal::RelocInfo::JS_RETURN) {
522 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
523 actual_mode = v8::internal::RelocInfo::CODE_TARGET;
526 if (mode == v8::internal::RelocInfo::JS_RETURN) {
544 v8::Local<v8::Function> frame_function_name;
553 v8::Local<v8::Function> frame_argument_name;
562 v8::Local<v8::Function> frame_argument_value;
571 v8::Local<v8::Function> frame_local_name;
580 v8::Local<v8::Function> frame_local_value;
589 v8::Local<v8::Function> frame_source_line;
598 v8::Local<v8::Function> frame_source_column;
607 v8::Local<v8::Function> frame_script_name;
616 v8::Local<v8::Function> frame_script_data;
625 v8::Local<v8::Function> compiled_script_data;
633 v8::Handle<v8::Function> frame_count;
651 static void DebugEventBreakPointHitCount(v8::DebugEvent event,
652 v8::Handle<v8::Object> exec_state,
653 v8::Handle<v8::Object> event_data,
654 v8::Handle<v8::Value> data) {
655 Debug* debug = v8::internal::Isolate::Current()->debug();
660 if (event == v8::Break) {
665 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
666 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
672 v8::Handle<v8::String> function_name(result->ToString());
680 v8::Handle<v8::Value> argv[argc] = { exec_state };
681 v8::Handle<v8::Value> result = frame_source_line->Call(exec_state,
690 v8::Handle<v8::Value> argv[argc] = { exec_state };
691 v8::Handle<v8::Value> result = frame_source_column->Call(exec_state,
700 v8::Handle<v8::Value> argv[argc] = { exec_state };
701 v8::Handle<v8::Value> result = frame_script_name->Call(exec_state,
707 v8::Handle<v8::String> script_name(result->ToString());
715 v8::Handle<v8::Value> argv[argc] = { exec_state };
716 v8::Handle<v8::Value> result = frame_script_data->Call(exec_state,
723 v8::Handle<v8::String> script_data(result->ToString());
733 } else if (event == v8::AfterCompile && !compiled_script_data.IsEmpty()) {
735 v8::Handle<v8::Value> argv[argc] = { event_data };
736 v8::Handle<v8::Value> result = compiled_script_data->Call(exec_state,
743 v8::Handle<v8::String> script_data(result->ToString());
762 static void DebugEventCounter(v8::DebugEvent event,
763 v8::Handle<v8::Object> exec_state,
764 v8::Handle<v8::Object> event_data,
765 v8::Handle<v8::Value> data) {
766 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
772 if (event == v8::Break) {
774 } else if (event == v8::Exception) {
778 v8::Local<v8::String> fun_name = v8::String::New("uncaught");
779 v8::Local<v8::Function> fun =
780 v8::Function::Cast(*event_data->Get(fun_name));
781 v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL);
791 v8::Handle<v8::Value> argv[kArgc] = { exec_state };
793 v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv);
809 v8::Handle<v8::Value> expected; // The expected result.
819 v8::Local<v8::Function> evaluate_check_function;
822 static void DebugEventEvaluate(v8::DebugEvent event,
823 v8::Handle<v8::Object> exec_state,
824 v8::Handle<v8::Object> event_data,
825 v8::Handle<v8::Value> data) {
826 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
830 if (event == v8::Break) {
833 v8::Handle<v8::Value> argv[argc] = { exec_state,
834 v8::String::New(checks[i].expr),
836 v8::Handle<v8::Value> result =
839 v8::String::AsciiValue ascii(checks[i].expected->ToString());
849 static void DebugEventRemoveBreakPoint(v8::DebugEvent event,
850 v8::Handle<v8::Object> exec_state,
851 v8::Handle<v8::Object> event_data,
852 v8::Handle<v8::Value> data) {
853 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
857 if (event == v8::Break) {
868 static void DebugEventStep(v8::DebugEvent event,
869 v8::Handle<v8::Object> exec_state,
870 v8::Handle<v8::Object> event_data,
871 v8::Handle<v8::Value> data) {
872 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
876 if (event == v8::Break) {
895 static void DebugEventStepSequence(v8::DebugEvent event,
896 v8::Handle<v8::Object> exec_state,
897 v8::Handle<v8::Object> event_data,
898 v8::Handle<v8::Value> data) {
899 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
903 if (event == v8::Break || event == v8::Exception) {
908 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
909 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
912 v8::String::AsciiValue function_name(result->ToString());
926 v8::DebugEvent event,
927 v8::Handle<v8::Object> exec_state,
928 v8::Handle<v8::Object> event_data,
929 v8::Handle<v8::Value> data) {
930 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
937 if (event == v8::Break) {
941 HEAP->CollectGarbage(v8::internal::NEW_SPACE);
952 static void DebugEventBreak(v8::DebugEvent event,
953 v8::Handle<v8::Object> exec_state,
954 v8::Handle<v8::Object> event_data,
955 v8::Handle<v8::Value> data) {
956 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
960 if (event == v8::Break) {
966 HEAP->CollectGarbage(v8::internal::NEW_SPACE);
969 v8::Debug::DebugBreak();
978 static void DebugEventBreakMax(v8::DebugEvent event,
979 v8::Handle<v8::Object> exec_state,
980 v8::Handle<v8::Object> event_data,
981 v8::Handle<v8::Value> data) {
982 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
986 if (event == v8::Break) {
995 v8::Handle<v8::Value> argv[kArgc] = { exec_state };
997 v8::Handle<v8::Value> result =
1003 v8::Debug::DebugBreak();
1007 v8::V8::TerminateExecution();
1029 static void MessageCallbackCount(v8::Handle<v8::Message> message,
1030 v8::Handle<v8::Value> data) {
1041 using ::v8::internal::Builtins;
1042 using ::v8::internal::Isolate;
1043 v8::HandleScope scope;
1049 v8::internal::RelocInfo::JS_RETURN,
1054 v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1060 v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1074 v8::internal::RelocInfo::CODE_TARGET,
1082 v8::internal::RelocInfo::CODE_TARGET,
1089 Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0);
1090 Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1);
1091 Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4);
1096 v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1102 v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1108 v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
1116 v8::HandleScope scope;
1119 v8::Local<v8::Function> foo =
1121 v8::Local<v8::Function> bar =
1124 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
1129 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
1134 CHECK_EQ(2, v8::internal::GetDebuggedFunctions()->length());
1139 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
1144 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
1153 v8::HandleScope scope;
1156 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1157 v8::Undefined());
1158 v8::Script::Compile(v8::String::New("function foo(){bar=0;}"))->Run();
1159 v8::Local<v8::Function> foo =
1160 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1178 v8::Debug::SetDebugEventListener(NULL);
1186 v8::HandleScope scope;
1188 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1189 v8::Undefined());
1190 v8::Script::Compile(v8::String::New("bar=1"))->Run();
1191 v8::Script::Compile(v8::String::New("function foo(){var x=bar;}"))->Run();
1192 v8::Local<v8::Function> foo =
1193 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1211 v8::Debug::SetDebugEventListener(NULL);
1219 v8::HandleScope scope;
1221 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1222 v8::Undefined());
1223 v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
1224 v8::Script::Compile(v8::String::New("function foo(){bar();}"))->Run();
1225 v8::Local<v8::Function> foo =
1226 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1244 v8::Debug::SetDebugEventListener(NULL);
1252 v8::HandleScope scope;
1254 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
1255 v8::Undefined());
1256 v8::Script::Compile(v8::String::New("function bar(){return 1;}"))->Run();
1257 v8::Script::Compile(v8::String::New("function foo(){return bar();}"))->Run();
1258 v8::Local<v8::Function> foo =
1259 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1277 v8::Debug::SetDebugEventListener(NULL);
1285 v8::HandleScope scope;
1287 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
1288 v8::Undefined());
1289 v8::Script::Compile(v8::String::New("function bar(){ this.x = 1;}"))->Run();
1290 v8::Script::Compile(v8::String::New(
1292 v8::Local<v8::Function> foo =
1293 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1311 v8::Debug::SetDebugEventListener(NULL);
1319 v8::HandleScope scope;
1332 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1333 v8::Undefined());
1334 v8::Script::Compile(v8::String::New("function foo(){}"))->Run();
1335 v8::Local<v8::Function> foo =
1336 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1358 v8::Debug::SetDebugEventListener(NULL);
1363 static void CallWithBreakPoints(v8::Local<v8::Object> recv,
1364 v8::Local<v8::Function> f,
1377 v8::HandleScope scope;
1380 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
1381 v8::Undefined());
1382 v8::Local<v8::Function> foo;
1409 v8::Debug::SetDebugEventListener(NULL);
1416 static void CallAndGC(v8::Local<v8::Object> recv,
1417 v8::Local<v8::Function> f) {
1426 HEAP->CollectGarbage(v8::internal::NEW_SPACE);
1441 v8::HandleScope scope;
1444 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1445 v8::Undefined());
1446 v8::Local<v8::Function> foo;
1491 v8::Debug::SetDebugEventListener(NULL);
1499 v8::HandleScope scope;
1503 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1504 v8::Undefined());
1505 v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
1506 v8::Script::Compile(v8::String::New("function foo(){bar();bar();}"))->Run();
1510 v8::Local<v8::Script> foo = v8::Script::Compile(v8::String::New("foo()"));
1542 v8::Debug::SetDebugEventListener(NULL);
1555 v8::HandleScope scope;
1559 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1560 v8::Undefined());
1562 v8::Local<v8::String> script = v8::String::New(
1582 v8::ScriptOrigin origin =
1583 v8::ScriptOrigin(v8::String::New("test"));
1584 v8::Script::Compile(script, &origin)->Run();
1585 v8::Local<v8::Function> f =
1586 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1587 v8::Local<v8::Function> g =
1588 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
1644 v8::Debug::SetDebugEventListener(NULL);
1659 v8::HandleScope scope;
1663 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1664 v8::Undefined());
1666 v8::Local<v8::String> source = v8::String::New(
1686 v8::ScriptOrigin origin =
1687 v8::ScriptOrigin(v8::String::New("test"));
1688 v8::Local<v8::Script> script = v8::Script::Compile(source, &origin);
1690 v8::Local<v8::Function> f =
1691 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1692 v8::Local<v8::Function> g =
1693 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
1752 v8::Debug::SetDebugEventListener(NULL);
1768 v8::HandleScope scope;
1772 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1773 v8::Undefined());
1775 v8::Local<v8::String> script = v8::String::New(
1781 v8::ScriptOrigin origin =
1782 v8::ScriptOrigin(v8::String::New("test"));
1783 v8::Script::Compile(script, &origin)->Run();
1784 v8::Local<v8::Function> f =
1785 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1808 v8::Script::Compile(script, &origin)->Run();
1809 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1817 v8::Debug::SetDebugEventListener(NULL);
1825 v8::HandleScope scope;
1829 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1830 v8::Undefined());
1832 v8::Local<v8::String> script = v8::String::New(
1842 v8::ScriptOrigin origin =
1843 v8::ScriptOrigin(v8::String::New("test"));
1844 v8::Script::Compile(script, &origin)->Run();
1845 v8::Local<v8::Function> f =
1846 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1870 v8::Script::Compile(script, &origin)->Run();
1871 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8
1879 v8::Debug::SetDebugEventListener(NULL);
1887 v8::HandleScope scope;
1891 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1892 v8::Undefined());
1894 v8::Local<v8::String> script = v8::String::New(
1900 v8::ScriptOrigin origin =
1901 v8::ScriptOrigin(v8::String::New("test"));
1902 v8::Script::Compile(script, &origin)->Run();
1903 v8::Local<v8::Function> f =
1904 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1925 v8::Script::Compile(script, &origin)->Run();
1926 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1934 v8::Debug::SetDebugEventListener(NULL);
1942 v8::HandleScope scope;
1946 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1947 v8::Undefined());
1949 v8::Local<v8::Function> f;
1950 v8::Local<v8::String> script = v8::String::New(
1959 v8::ScriptOrigin origin_1 = v8::ScriptOrigin(v8::String::New("1"));
1960 v8::ScriptOrigin origin_2 = v8::ScriptOrigin(v8::String::New("2"));
1966 v8::Script::Compile(script, &origin_1)->Run();
1967 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1976 v8::Script::Compile(script, &origin_2)->Run();
1977 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1985 v8::Script::Compile(script, &origin_1)->Run();
1986 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
1993 v8::Debug::SetDebugEventListener(NULL);
2001 v8::HandleScope scope;
2005 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2006 v8::Undefined());
2008 v8::Local<v8::Function> f;
2009 v8::Local<v8::String> script_f = v8::String::New(
2014 v8::Local<v8::Function> g;
2015 v8::Local<v8::String> script_g = v8::String::New(
2020 v8::ScriptOrigin origin =
2021 v8::ScriptOrigin(v8::String::New("test"));
2027 v8::Script::Compile(script_f, &origin)->Run();
2028 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2029 v8::Script::Compile(script_g, &origin)->Run();
2030 g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
2059 v8::Debug::SetDebugEventListener(NULL);
2067 v8::HandleScope scope;
2071 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2072 v8::Undefined());
2074 v8::Local<v8::Function> f;
2075 v8::Local<v8::String> script = v8::String::New(
2082 v8::ScriptOrigin origin(v8::String::New("test.html"),
2083 v8::Integer::New(7));
2090 v8::Script::Compile(script, &origin)->Run();
2091 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2115 v8::Debug::SetDebugEventListener(NULL);
2122 v8::HandleScope scope;
2131 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2132 v8::Undefined());
2134 v8::Local<v8::Function> f;
2135 v8::Local<v8::Function> g;
2136 v8::Local<v8::String> script = v8::String::New(
2158 v8::ScriptOrigin origin(v8::String::New("test.html"), v8::Integer::New(0));
2159 v8::Script::Compile(script, &origin)->Run();
2160 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2161 g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
2199 v8::Script::Compile(script, &origin)->Run();
2208 v8::Script::Compile(script, &origin)->Run();
2218 v8::Script::Compile(script, &origin)->Run();
2221 v8::Debug::SetDebugEventListener(NULL);
2228 v8::HandleScope scope;
2232 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2233 v8::Undefined());
2235 v8::Local<v8::String> script = v8::String::New(
2240 v8::Local<v8::Function> f;
2242 v8::HandleScope scope;
2243 v8::Script::Compile(script, v8::String::New("test.html"))->Run();
2245 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2258 v8::Script::Compile(script, v8::String::New("test.html"))->Run();
2263 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2266 v8::Debug::SetDebugEventListener(NULL);
2274 v8::HandleScope scope;
2278 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2279 v8::Undefined());
2281 v8::Local<v8::String> script_source = v8::String::New(
2289 v8::HandleScope scope;
2291 v8::Script::Compile(script_source, v8::String::New("test.html"))->Run();
2299 v8::Debug::SetDebugEventListener(NULL);
2307 v8::HandleScope scope;
2310 v8::Local<v8::Function> foo =
2315 v8::Debug::SetDebugEventListener(DebugEventRemoveBreakPoint, foo);
2325 v8::Debug::SetDebugEventListener(NULL);
2333 v8::HandleScope scope;
2335 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2336 v8::Undefined());
2337 v8::Script::Compile(v8::String::New("function bar(){debugger}"))->Run();
2338 v8::Script::Compile(v8::String::New(
2340 v8::Local<v8::Function> foo =
2341 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
2342 v8::Local<v8::Function> bar =
2343 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("bar")));
2353 v8::Debug::SetDebugEventListener(NULL);
2361 v8::HandleScope scope;
2363 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2364 v8::Undefined());
2365 v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run();
2366 v8::Local<v8::Function> foo =
2367 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
2380 v8::Debug::SetDebugEventListener(NULL);
2388 v8::HandleScope scope;
2397 v8::Debug::SetDebugEventListener(DebugEventEvaluate);
2402 {"x", v8::Undefined()},
2403 {"a", v8::Undefined()},
2404 {NULL, v8::Handle<v8::Value>()}
2407 {"x", v8::String::New("Hello, world!")},
2408 {"a", v8::Undefined()},
2409 {NULL, v8::Handle<v8::Value>()}
2412 {"x", v8::String::New("Hello, world!")},
2413 {"a", v8::String::New("Hello, world!")},
2414 {NULL, v8::Handle<v8::Value>()}
2421 v8::Local<v8::Function> foo = CompileFunction(&env,
2433 v8::Handle<v8::Value> argv_foo[1] = { v8::String::New("Hello, world!") };
2454 v8::Local<v8::Function> bar = CompileFunction(&env,
2473 v8::Handle<v8::Value> argv_bar_1[2] = {
2474 v8::Undefined(),
2475 v8::Number::New(barbar_break_position)
2482 v8::Handle<v8::Value> argv_bar_2[2] = {
2483 v8::String::New("Hello, world!"),
2484 v8::Number::New(barbar_break_position)
2491 v8::Handle<v8::Value> argv_bar_3[2] = {
2492 v8::String::New("Hello, world!"),
2493 v8::Number::New(barbar_break_position + 1)
2497 v8::Debug::SetDebugEventListener(NULL);
2502 // Does not use the V8 engine to convert strings, so it can be used
2585 v8::Debug::ClientData* client_data) {
2604 v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler);
2606 v8::HandleScope scope;
2612 v8::Script::Compile(v8::String::New(source))->Run();
2614 v8::Debug::ProcessDebugMessages();
2627 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_111, buffer));
2637 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_112, buffer));
2647 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_113, buffer));
2649 v8::Debug::ProcessDebugMessages();
2658 v8::Debug::SetMessageHandler(NULL);
2659 v8::Debug::SetDebugEventListener(NULL);
2666 v8::HandleScope scope;
2670 v8::Local<v8::Function> foo = CompileFunction(&env,
2680 v8::Debug::SetDebugEventListener(DebugEventStep);
2689 v8::Debug::SetDebugEventListener(NULL);
2693 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
2702 v8::Debug::SetDebugEventListener(NULL);
2709 v8::HandleScope scope;
2713 v8::Debug::SetDebugEventListener(DebugEventStep);
2717 v8::Local<v8::Function> foo = CompileFunction(
2731 v8::Local<v8::Array> a = v8::Array::New(10);
2733 a->Set(v8::Number::New(i), v8::Number::New(i));
2738 v8::Handle<v8::Value> args[kArgc] = { a };
2750 v8::Debug::SetDebugEventListener(NULL);
2757 v8::HandleScope scope;
2761 v8::Debug::SetDebugEventListener(DebugEventStep);
2765 v8::Local<v8::Function> foo = CompileFunction(
2778 v8::Local<v8::Array> a = v8::Array::New(10);
2780 a->Set(v8::Number::New(i), v8::Number::New(i));
2785 v8::Handle<v8::Value> args[kArgc] = { a };
2797 v8::Debug::SetDebugEventListener(NULL);
2804 v8::HandleScope scope;
2808 v8::Debug::SetDebugEventListener(DebugEventStep);
2811 v8::Local<v8::Function> foo = CompileFunction(
2841 v8::Debug::SetDebugEventListener(NULL);
2847 v8::HandleScope scope;
2851 v8::Debug::SetDebugEventListener(DebugEventStep);
2854 v8::Local<v8::Function> foo = CompileFunction(
2876 v8::Debug::SetDebugEventListener(NULL);
2889 v8::HandleScope scope;
2893 v8::Debug::SetDebugEventListener(DebugEventStep);
2896 v8::Local<v8::Function> foo = CompileFunction(&env,
2916 v8::Debug::SetDebugEventListener(NULL);
2920 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
2929 v8::Debug::SetDebugEventListener(NULL);
2935 v8::HandleScope scope;
2939 v8::Debug::SetDebugEventListener(DebugEventStep);
2951 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
2962 v8::Debug::SetDebugEventListener(NULL);
2968 v8::HandleScope scope;
2972 v8::Debug::SetDebugEventListener(DebugEventStep);
2984 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
2995 v8::Debug::SetDebugEventListener(NULL);
3001 v8::HandleScope scope;
3005 v8::Debug::SetDebugEventListener(DebugEventStep);
3020 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3026 v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
3033 v8::Handle<v8::Value> argv_false[argc] = { v8::False() };
3038 v8::Debug::SetDebugEventListener(NULL);
3044 v8::HandleScope scope;
3048 v8::Debug::SetDebugEventListener(DebugEventStep);
3069 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3075 v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(1) };
3082 v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(2) };
3089 v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(3) };
3094 v8::Debug::SetDebugEventListener(NULL);
3100 v8::HandleScope scope;
3104 v8::Debug::SetDebugEventListener(DebugEventStep);
3116 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3122 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3129 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3134 v8::Debug::SetDebugEventListener(NULL);
3140 v8::HandleScope scope;
3144 v8::Debug::SetDebugEventListener(DebugEventStep);
3156 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3162 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3169 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3174 v8::Debug::SetDebugEventListener(NULL);
3180 v8::HandleScope scope;
3184 v8::Debug::SetDebugEventListener(DebugEventStep);
3196 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3203 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3210 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3215 v8::Debug::SetDebugEventListener(NULL);
3221 v8::HandleScope scope;
3225 v8::Debug::SetDebugEventListener(DebugEventStep);
3243 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3244 v8::Handle<v8::Value> result;
3252 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3260 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3266 v8::Debug::SetDebugEventListener(NULL);
3272 v8::HandleScope scope;
3276 v8::Debug::SetDebugEventListener(DebugEventStep);
3294 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3295 v8::Handle<v8::Value> result;
3304 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3312 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3318 v8::Debug::SetDebugEventListener(NULL);
3324 v8::HandleScope scope;
3328 v8::Debug::SetDebugEventListener(DebugEventStep);
3332 v8::Local<v8::Function> foo;
3366 v8::Debug::SetDebugEventListener(NULL);
3372 v8::HandleScope scope;
3376 v8::Debug::SetDebugEventListener(DebugEventStep);
3386 env->Global()->Set(v8::String::New("b"), v8::Object::New());
3387 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3388 v8::Handle<v8::Value> result;
3397 v8::Debug::SetDebugEventListener(NULL);
3403 v8::HandleScope scope;
3407 v8::Debug::SetDebugEventListener(DebugEventStep);
3417 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3428 v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
3433 v8::Debug::SetDebugEventListener(NULL);
3439 v8::HandleScope scope;
3448 v8::Debug::SetDebugEventListener(DebugEventStepSequence);
3456 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3484 v8::Debug::SetDebugEventListener(NULL);
3490 v8::HandleScope scope;
3499 v8::Debug::SetDebugEventListener(DebugEventStepSequence);
3508 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3536 v8::Debug::SetDebugEventListener(NULL);
3542 v8::HandleScope scope;
3551 v8::Debug::SetDebugEventListener(DebugEventStepSequence);
3559 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3571 v8::Debug::SetDebugEventListener(NULL);
3578 v8::HandleScope scope;
3582 v8::Local<v8::Function> foo = CompileFunction(
3588 v8::Debug::SetDebugEventListener(DebugEventStep);
3597 v8::Debug::SetDebugEventListener(NULL);
3601 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
3609 v8::Debug::SetDebugEventListener(NULL);
3616 v8::HandleScope scope;
3620 v8::Local<v8::Function> foo = CompileFunction(
3627 v8::Debug::SetDebugEventListener(DebugEventStep);
3636 v8::Debug::SetDebugEventListener(NULL);
3640 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
3648 v8::Debug::SetDebugEventListener(NULL);
3655 v8::HandleScope scope;
3659 v8::Local<v8::Function> foo = CompileFunction(
3672 v8::Debug::SetDebugEventListener(DebugEventStep);
3683 v8::Handle<v8::Value> argv[argc] = { v8::True() };
3687 v8::Debug::SetDebugEventListener(NULL);
3691 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
3699 v8::Debug::SetDebugEventListener(NULL);
3706 v8::HandleScope scope;
3711 v8::Debug::SetDebugEventListener(DebugEventCounter);
3721 v8::ScriptOrigin origin(v8::String::New(script_name), v8::Integer::New(0));
3722 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(src),
3724 v8::Local<v8::Value> r = script->Run();
3730 v8::Debug::SetDebugEventListener(NULL);
3742 v8::HandleScope scope;
3746 v8::internal::Isolate::Current()->TraceException(false);
3750 v8::Local<v8::Function> caught =
3754 v8::Local<v8::Function> notCaught =
3757 v8::V8::AddMessageListener(MessageCallbackCount);
3758 v8::Debug::SetDebugEventListener(DebugEventCounter);
3876 v8::Debug::SetDebugEventListener(NULL);
3878 v8::V8::RemoveMessageListeners(MessageCallbackCount);
3883 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
3886 v8::HandleScope scope;
3892 v8::internal::Isolate::Current()->TraceException(false);
3897 v8::V8::AddMessageListener(MessageCallbackCount);
3898 v8::Debug::SetDebugEventListener(DebugEventCounter);
3910 v8::Script::Compile(v8::String::New("+++"));
3917 v8::Script::Compile(v8::String::New("x x"));
3924 v8::Script::Compile(v8::String::New("eval('+++')"))->Run();
3931 v8::Script::Compile(v8::String::New("eval('x x')"))->Run();
3940 v8::HandleScope scope;
3952 v8::Debug::SetDebugEventListener(DebugEventStepSequence);
3965 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3975 v8::Local<v8::Function> b = CompileFunction(&env, src, "b");
3984 v8::Local<v8::Function> d = CompileFunction(&env, src, "d");
4004 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
4024 v8::Debug::SetDebugEventListener(NULL);
4030 v8::HandleScope scope;
4036 CHECK(v8::internal::FLAG_verify_heap);
4040 v8::Debug::SetDebugEventListener(DebugEventBreak);
4047 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0");
4048 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1");
4049 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2");
4050 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3");
4053 v8::Handle<v8::Value> argv[] = { v8::Number::New(1),
4054 v8::Number::New(1),
4055 v8::Number::New(1),
4056 v8::Number::New(1) };
4065 v8::Debug::DebugBreak();
4080 v8::Debug::SetDebugEventListener(NULL);
4088 v8::HandleScope scope;
4092 v8::Debug::SetDebugEventListener(DebugEventCounter);
4096 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
4099 v8::Debug::DebugBreak();
4107 v8::Debug::DebugBreak();
4108 v8::internal::DisableBreak disable_break(true);
4117 v8::Debug::SetDebugEventListener(NULL);
4129 v8::HandleScope scope;
4132 v8::Debug::SetDebugEventListener(DebugEventCounter);
4135 v8::Debug::DebugBreak();
4140 v8::RegisterExtension(new v8::Extension("simpletest",
4143 v8::ExtensionConfiguration extensions(1, extension_names);
4144 v8::Persistent<v8::Context> context = v8::Context::New(&extensions);
4151 v8::Debug::SetDebugEventListener(NULL);
4155 static v8::Handle<v8::Array> NamedEnum(const v8::AccessorInfo&) {
4156 v8::Handle<v8::Array> result = v8::Array::New(3);
4157 result->Set(v8::Integer::New(0), v8::String::New("a"));
4158 result->Set(v8::Integer::New(1), v8::String::New("b"));
4159 result->Set(v8::Integer::New(2), v8::String::New("c"));
4164 static v8::Handle<v8::Array> IndexedEnum(const v8::AccessorInfo&) {
4165 v8::Handle<v8::Array> result = v8::Array::New(2);
4166 result->Set(v8::Integer::New(0), v8::Number::New(1));
4167 result->Set(v8::Integer::New(1), v8::Number::New(10));
4172 static v8::Handle<v8::Value> NamedGetter(v8::Local<v8::String> name,
4173 const v8::AccessorInfo& info) {
4174 v8::String::AsciiValue n(name);
4176 return v8::String::New("AA");
4178 return v8::String::New("BB");
4180 return v8::String::New("CC");
4182 return v8::Undefined();
4189 static v8::Handle<v8::Value> IndexedGetter(uint32_t index,
4190 const v8::AccessorInfo& info) {
4191 return v8::Number::New(index + 1);
4196 // Create a V8 environment with debug access.
4197 v8::HandleScope scope;
4202 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
4204 env->Global()->Set(v8::String::New("intercepted_named"),
4208 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New();
4214 env->Global()->Set(v8::String::New("intercepted_indexed"),
4218 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New();
4221 env->Global()->Set(v8::String::New("intercepted_both"), both->NewInstance());
4327 // Create a V8 environment with debug access.
4328 v8::HandleScope scope;
4332 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
4333 t0->InstanceTemplate()->Set(v8::String::New("x"), v8::Number::New(0));
4334 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
4336 t1->InstanceTemplate()->Set(v8::String::New("y"), v8::Number::New(1));
4337 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
4339 t2->InstanceTemplate()->Set(v8::String::New("z"), v8::Number::New(2));
4340 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
4341 t3->InstanceTemplate()->Set(v8::String::New("u"), v8::Number::New(3));
4344 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
4345 env->Global()->Set(v8::String::New("o0"), o0);
4346 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
4347 env->Global()->Set(v8::String::New("o1"), o1);
4348 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
4349 env->Global()->Set(v8::String::New("o2"), o2);
4350 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
4351 env->Global()->Set(v8::String::New("o3"), o3);
4376 o0->Set(v8::String::New("__proto__"), o1);
4387 o0->Set(v8::String::New("__proto__"), o2);
4403 o0->Set(v8::String::New("__proto__"), o3);
4421 static v8::Handle<v8::Value> ProtperyXNativeGetter(
4422 v8::Local<v8::String> property, const v8::AccessorInfo& info) {
4423 return v8::Integer::New(10);
4428 // Create a V8 environment with debug access.
4429 v8::HandleScope scope;
4433 v8::Handle<v8::String> name = v8::String::New("x");
4435 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
4437 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4440 env->Global()->Set(v8::String::New("instance"), named->NewInstance());
4458 static v8::Handle<v8::Value> ProtperyXNativeGetterThrowingError(
4459 v8::Local<v8::String> property, const v8::AccessorInfo& info) {
4465 // Create a V8 environment with debug access.
4466 v8::HandleScope scope;
4470 v8::Handle<v8::String> name = v8::String::New("x");
4472 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
4474 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4477 env->Global()->Set(v8::String::New("instance"), named->NewInstance());
4500 // Create a V8 environment with debug access.
4501 v8::HandleScope scope;
4507 v8::Script::Compile(v8::String::New(source))->Run();
4508 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
4509 env->Global()->Get(v8::String::New("obj")));
4511 obj->SetHiddenValue(v8::String::New("v8::test-debug::a"),
4512 v8::Int32::New(11));
4528 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
4529 t0->InstanceTemplate()->Set(v8::String::New("b"), v8::Number::New(2));
4531 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
4532 t1->InstanceTemplate()->Set(v8::String::New("c"), v8::Number::New(3));
4536 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
4537 protoObj->SetHiddenValue(v8::String::New("v8::test-debug::b"),
4538 v8::Int32::New(12));
4539 env->Global()->Set(v8::String::New("protoObj"), protoObj);
4540 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
4541 grandProtoObj->SetHiddenValue(v8::String::New("v8::test-debug::c"),
4542 v8::Int32::New(13));
4543 env->Global()->Set(v8::String::New("grandProtoObj"), grandProtoObj);
4546 protoObj->Set(v8::String::New("__proto__"), grandProtoObj);
4547 obj->Set(v8::String::New("__proto__"), protoObj);
4582 v8::internal::Mutex* lock_;
4583 v8::internal::Semaphore* sem_;
4631 v8::internal::Semaphore* semaphore_1;
4632 v8::internal::Semaphore* semaphore_2;
4737 // This is the debugger thread, that executes no v8 calls except
4739 class MessageQueueDebuggerThread : public v8::internal::Thread {
4747 v8::Debug::ClientData* client_data) {
4799 v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_1, buffer_1));
4800 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_2, buffer_2));
4801 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4802 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4803 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4823 v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_1, buffer_1));
4824 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_2, buffer_2));
4825 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_3, buffer_2));
4826 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_single_step, buffer_2));
4833 v8::Debug::SendCommand(buffer_1, AsciiToUtf16(command_2, buffer_1));
4834 v8::Debug::SendCommand(buffer_2, AsciiToUtf16(command_continue, buffer_2));
4843 // This thread runs the v8 engine.
4847 // Create a V8 environment
4848 v8::HandleScope scope;
4851 v8::Debug::SetMessageHandler(MessageHandler);
4871 class TestClientData : public v8::Debug::ClientData {
4930 const v8::Debug::Message& message) {
4939 // Create a V8 environment
4940 v8::HandleScope scope;
4944 v8::Debug::SetMessageHandler2(MessageHandlerCountingClientData);
4963 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer),
4965 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer), NULL);
4966 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer),
4968 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer),
4972 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer));
4983 * occupying the v8 thread by a break command from the
4990 class V8Thread : public v8::internal::Thread {
4996 class DebuggerThread : public v8::internal::Thread {
5003 static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) {
5005 return v8::Undefined();
5009 static void ThreadedMessageHandler(const v8::Debug::Message& message) {
5011 v8::String::Value json(message.GetJSON());
5042 v8::V8::Initialize();
5043 v8::HandleScope scope;
5045 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
5046 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5047 global_template->Set(v8::String::New("ThreadedAtBarrier1"),
5048 v8::FunctionTemplate::New(ThreadedAtBarrier1));
5049 v8::Handle<v8::Context> context = v8::Context::New(NULL, global_template);
5050 v8::Context::Scope context_scope(context);
5068 v8::Debug::DebugBreak();
5070 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5071 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5079 // Create a V8 environment
5096 class BreakpointsV8Thread : public v8::internal::Thread {
5102 class BreakpointsDebuggerThread : public v8::internal::Thread {
5118 static void BreakpointsMessageHandler(const v8::Debug::Message& message) {
5120 v8::String::Value json(message.GetJSON());
5155 v8::V8::Initialize();
5156 v8::HandleScope scope;
5158 v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler);
5229 // v8 thread initializes, runs source_1
5232 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5234 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5236 // V8 thread starts compiling source_2.
5240 // v8 thread runs source_2 to breakpoint in cat().
5246 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_3, buffer));
5247 // V8 thread hits breakpoint in dog().
5252 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_4, buffer));
5258 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_5, buffer));
5265 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_6, buffer));
5271 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer));
5277 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer));
5286 // Create a V8 environment
5307 static void DummyDebugEventListener(v8::DebugEvent event,
5308 v8::Handle<v8::Object> exec_state,
5309 v8::Handle<v8::Object> event_data,
5310 v8::Handle<v8::Value> data) {
5315 v8::Debug::SetDebugEventListener(DummyDebugEventListener);
5319 static void DummyMessageHandler(const v8::Debug::Message& message) {
5324 v8::Debug::SetMessageHandler2(DummyMessageHandler);
5329 v8::Debug::DebugBreak();
5337 v8::Debug::SendCommand(dummy_buffer, dummy_length);
5349 v8::Handle<v8::Function> debugger_call_with_data;
5362 v8::Handle<v8::Function> debugger_call_with_closure;
5366 static v8::Handle<v8::Value> CheckFrameCount(const v8::Arguments& args) {
5367 CHECK(v8::Debug::Call(frame_count)->IsNumber());
5369 v8::Debug::Call(frame_count)->Int32Value());
5370 return v8::Undefined();
5376 static v8::Handle<v8::Value> CheckSourceLine(const v8::Arguments& args) {
5377 CHECK(v8::Debug::Call(frame_source_line)->IsNumber());
5379 v8::Debug::Call(frame_source_line)->Int32Value());
5380 return v8::Undefined();
5387 static v8::Handle<v8::Value> CheckDataParameter(const v8::Arguments& args) {
5388 v8::Handle<v8::String> data = v8::String::New("Test");
5389 CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
5391 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
5392 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
5394 v8::TryCatch catcher;
5395 v8::Debug::Call(debugger_call_with_data);
5399 return v8::Undefined();
5404 static v8::Handle<v8::Value> CheckClosure(const v8::Arguments& args) {
5405 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber());
5406 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value());
5407 return v8::Undefined();
5415 v8::HandleScope scope;
5416 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
5417 global_template->Set(v8::String::New("CheckFrameCount"),
5418 v8::FunctionTemplate::New(CheckFrameCount));
5419 global_template->Set(v8::String::New("CheckSourceLine"),
5420 v8::FunctionTemplate::New(CheckSourceLine));
5421 global_template->Set(v8::String::New("CheckDataParameter"),
5422 v8::FunctionTemplate::New(CheckDataParameter));
5423 global_template->Set(v8::String::New("CheckClosure"),
5424 v8::FunctionTemplate::New(CheckClosure));
5425 v8::Handle<v8::Context> context = v8::Context::New(NULL, global_template);
5426 v8::Context::Scope context_scope(context);
5429 v8::Script::Compile(v8::String::New(frame_count_source))->Run();
5430 frame_count = v8::Local<v8::Function>::Cast(
5431 context->Global()->Get(v8::String::New("frame_count")));
5434 v8::Script::Compile(v8::String::New(frame_source_line_source))->Run();
5435 frame_source_line = v8::Local<v8::Function>::Cast(
5436 context->Global()->Get(v8::String::New("frame_source_line")));
5439 v8::Script::Compile(v8::String::New(debugger_call_with_data_source))->Run();
5440 debugger_call_with_data = v8::Local<v8::Function>::Cast(
5441 context->Global()->Get(v8::String::New("debugger_call_with_data")));
5444 debugger_call_with_closure = v8::Local<v8::Function>::Cast(
5445 v8::Script::Compile(
5446 v8::String::New(debugger_call_with_closure_source))->Run());
5450 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count));
5453 v8::Script::Compile(v8::String::New("CheckFrameCount(1)"))->Run();
5454 v8::Script::Compile(v8::String::New("function f() {"
5459 v8::Script::Compile(v8::String::New("CheckSourceLine(0)"))->Run();
5460 v8::Script::Compile(v8::String::New("function f() {\n"
5467 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run();
5470 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run();
5474 v8::ScriptOrigin origin(v8::String::New("test"),
5475 v8::Integer::New(7));
5476 v8::Script::Compile(v8::String::New("CheckSourceLine(7)"), &origin)->Run();
5477 v8::Script::Compile(v8::String::New("function f() {\n"
5488 const v8::Debug::Message& message) {
5489 if (message.IsEvent() && message.GetEvent() == v8::Break) {
5508 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
5509 v8::Undefined());
5511 v8::HandleScope scope;
5513 v8::Local<v8::Function> foo =
5515 v8::Local<v8::Function> bar =
5534 v8::Debug::SetDebugEventListener(NULL);
5539 v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount);
5541 v8::HandleScope scope;
5544 v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast(
5545 env->Global()->Get(v8::String::New("foo"))));
5559 v8::Debug::SetMessageHandler2(NULL);
5573 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer));
5579 static void MessageHandlerHitCount(const v8::Debug::Message& message) {
5583 v8::String::Value json(message.GetJSON());
5594 v8::HandleScope scope;
5601 v8::Debug::SetMessageHandler2(MessageHandlerHitCount);
5612 v8::Debug::SetMessageHandler(NULL);
5627 const v8::Debug::Message& message) {
5631 v8::Debug::SetMessageHandler(NULL);
5637 v8::HandleScope scope;
5644 v8::Debug::SetMessageHandler2(MessageHandlerClearingMessageHandler);
5662 class HostDispatchV8Thread : public v8::internal::Thread {
5668 class HostDispatchDebuggerThread : public v8::internal::Thread {
5676 static void HostDispatchMessageHandler(const v8::Debug::Message& message) {
5678 v8::String::Value json(message.GetJSON());
5700 v8::V8::Initialize();
5701 v8::HandleScope scope;
5705 v8::Debug::SetMessageHandler2(HostDispatchMessageHandler);
5706 v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */);
5727 // v8 thread initializes, runs source_1
5730 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
5733 // v8 thread starts compiling source_2.
5738 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer));
5747 // Create a V8 environment
5761 /* In this test, the V8 thread waits for a message from the debug thread.
5763 * which signals the V8 thread to wake up.
5766 class DebugMessageDispatchV8Thread : public v8::internal::Thread {
5772 class DebugMessageDispatchDebuggerThread : public v8::internal::Thread {
5788 v8::V8::Initialize();
5789 v8::HandleScope scope;
5793 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler);
5815 // Create a V8 environment
5830 v8::V8::Initialize();
6001 // Test for issue http://code.google.com/p/v8/issues/detail?id=289.
6004 class EmptyExternalStringResource : public v8::String::ExternalStringResource {
6011 ::v8::internal::EmbeddedVector<uint16_t, 1> empty_;
6016 v8::HandleScope scope;
6021 v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str);
6022 v8::Handle<v8::Script> evil_script(v8::Script::Compile(source));
6026 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
6043 CHECK_GT((*env)->Global()->Get(v8::String::New("count"))->Int32Value(), 8);
6049 v8::HandleScope scope;
6065 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
6066 v8::Undefined());
6069 v8::Local<v8::String> script = v8::String::New(
6074 v8::ScriptOrigin origin1 = v8::ScriptOrigin(v8::String::New("name"));
6075 v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1);
6076 script1->SetData(v8::String::New("data"));
6078 v8::Local<v8::Function> f;
6079 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6088 v8::Script::Compile(script, &origin1)->Run();
6089 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6095 v8::Local<v8::String> data_obj_source = v8::String::New(
6100 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run();
6101 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name"));
6102 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2);
6105 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6111 v8::Handle<v8::Script> script3 =
6112 v8::Script::Compile(script, &origin2, NULL,
6113 v8::String::New("in compile"));
6116 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6123 static v8::Persistent<v8::Context> expected_context;
6124 static v8::Handle<v8::Value> expected_context_data;
6128 static void ContextCheckMessageHandler(const v8::Debug::Message& message) {
6135 v8::String::Value json(message.GetJSON());
6149 v8::HandleScope scope;
6151 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
6154 v8::Persistent<v8::Context> context_1;
6155 v8::Persistent<v8::Context> context_2;
6156 v8::Handle<v8::ObjectTemplate> global_template =
6157 v8::Handle<v8::ObjectTemplate>();
6158 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>();
6159 context_1 = v8::Context::New(NULL, global_template, global_object);
6160 context_2 = v8::Context::New(NULL, global_template, global_object);
6167 v8::Handle<v8::String> data_1 = v8::String::New("1");
6168 v8::Handle<v8::String> data_2 = v8::String::New("2");
6179 v8::Context::Scope context_scope(context_1);
6182 v8::Local<v8::Function> f = CompileFunction(source, "f");
6189 v8::Context::Scope context_scope(context_2);
6192 v8::Local<v8::Function> f = CompileFunction(source, "f");
6199 v8::Debug::SetMessageHandler2(NULL);
6206 static void DebugBreakMessageHandler(const v8::Debug::Message& message) {
6208 if (message.IsEvent() && message.GetEvent() == v8::Break) {
6211 v8::Debug::DebugBreak();
6225 v8::HandleScope scope;
6228 v8::Debug::SetMessageHandler2(DebugBreakMessageHandler);
6233 v8::Local<v8::Function> f =
6234 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6235 v8::Local<v8::Function> g =
6236 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
6252 v8::DebugEvent event,
6253 v8::Handle<v8::Object> exec_state,
6254 v8::Handle<v8::Object> event_data,
6255 v8::Handle<v8::Value> data) {
6257 if (event == v8::Break) {
6264 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
6265 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
6271 v8::Handle<v8::String> function_name(result->ToString());
6278 v8::Debug::DebugBreak();
6286 v8::HandleScope scope;
6300 v8::Local<v8::Function> f = CompileFunction(script, "f");
6302 v8::Handle<v8::Value> argv[argc] = { v8::String::New(" /* xxx */ a=0;") };
6303 v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv);
6306 v8::Debug::SetDebugEventListener(DebugEventDebugBreak);
6307 v8::Debug::DebugBreak();
6321 v8::Persistent<v8::Context> context_1;
6322 v8::Handle<v8::ObjectTemplate> global_template =
6323 v8::Handle<v8::ObjectTemplate>();
6324 context_1 = v8::Context::New(NULL, global_template);
6330 v8::Handle<v8::String> data_1 = v8::String::New("1");
6339 v8::Context::Scope context_scope(context_1);
6342 v8::Local<v8::Function> f = CompileFunction(source, "f");
6353 v8::HandleScope scope;
6354 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
6360 v8::Debug::SetMessageHandler2(NULL);
6371 const v8::Debug::Message& message) {
6378 v8::String::Value json(message.GetJSON());
6396 v8::Debug::SendCommand(buffer, AsciiToUtf16(eval_command, buffer));
6416 v8::HandleScope scope;
6419 v8::Debug::SetMessageHandler2(DebugEvalContextCheckMessageHandler);
6428 v8::Debug::SetMessageHandler2(NULL);
6435 static void DebugEventScriptCollectedEvent(v8::DebugEvent event,
6436 v8::Handle<v8::Object> exec_state,
6437 v8::Handle<v8::Object> event_data,
6438 v8::Handle<v8::Value> data) {
6440 if (event == v8::ScriptCollected) {
6448 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
6451 v8::HandleScope scope;
6462 v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent,
6463 v8::Undefined());
6465 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
6466 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
6475 v8::Debug::SetDebugEventListener(NULL);
6482 static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) {
6484 if (message.IsEvent() && message.GetEvent() == v8::ScriptCollected) {
6486 v8::Handle<v8::Context> context = message.GetEventContext();
6495 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
6497 v8::HandleScope scope;
6509 v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
6511 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
6512 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
6522 v8::Debug::SetMessageHandler2(NULL);
6528 static void AfterCompileMessageHandler(const v8::Debug::Message& message) {
6531 if (message.GetEvent() == v8::AfterCompile) {
6533 } else if (message.GetEvent() == v8::Break) {
6543 v8::HandleScope scope;
6548 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6549 v8::Script::Compile(v8::String::New(script))->Run();
6550 v8::Debug::SetMessageHandler2(NULL);
6552 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6553 v8::Debug::DebugBreak();
6554 v8::Script::Compile(v8::String::New(script))->Run();
6557 v8::Debug::SetMessageHandler2(NULL);
6567 v8::HandleScope scope;
6572 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6573 v8::Script::Compile(v8::String::New(script))->Run();
6574 v8::Debug::SetMessageHandler2(NULL);
6576 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6577 v8::Debug::DebugBreak();
6578 v8::Local<v8::Function> f =
6579 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6583 v8::Debug::SetMessageHandler2(NULL);
6592 static void ExceptionMessageHandler(const v8::Debug::Message& message) {
6593 if (message.IsEvent() && message.GetEvent() == v8::Exception) {
6602 v8::HandleScope scope;
6611 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6612 v8::Script::Compile(v8::String::New(script))->Run();
6613 v8::Debug::SetMessageHandler2(NULL);
6615 v8::Debug::SetMessageHandler2(ExceptionMessageHandler);
6616 v8::Local<v8::Function> f =
6617 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
6621 v8::Debug::SetMessageHandler2(NULL);
6631 v8::HandleScope scope;
6644 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6646 v8::ScriptOrigin origin(
6647 v8::String::New(resource_name),
6648 v8::Integer::New(10),
6649 v8::Integer::New(1));
6652 v8::Script::Compile(v8::String::New(script), &origin)->Run();
6661 v8::Debug::SetMessageHandler2(NULL);
6665 static void BreakMessageHandler(const v8::Debug::Message& message) {
6667 if (message.IsEvent() && message.GetEvent() == v8::Break) {
6671 v8::HandleScope scope;
6675 } else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) {
6676 v8::HandleScope scope;
6698 v8::HandleScope scope;
6702 v8::Debug::SetMessageHandler2(BreakMessageHandler);
6705 v8::Debug::DebugBreak();
6709 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
6715 v8::Debug::DebugBreak();
6721 v8::Debug::SetMessageHandler2(NULL);
6728 static void CountingMessageHandler(const v8::Debug::Message& message) {
6734 v8::HandleScope scope;
6739 v8::Debug::SetMessageHandler2(CountingMessageHandler);
6749 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6752 v8::Debug::ProcessDebugMessages();
6758 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6759 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6761 v8::Debug::ProcessDebugMessages();
6766 v8::Debug::SetMessageHandler2(NULL);
6773 static void MessageHandler(const v8::Debug::Message& message) {
6775 v8::String::Value json(message.GetJSON());
6790 v8::HandleScope scope;
6793 v8::Debug::SetMessageHandler2(BacktraceData::MessageHandler);
6804 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6805 v8::Debug::ProcessDebugMessages();
6808 v8::Handle<v8::String> void0 = v8::String::New("void(0)");
6809 v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0);
6813 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
6818 v8::Debug::SetMessageHandler2(NULL);
6824 v8::HandleScope scope;
6826 v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja"));
6827 v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast(
6828 v8::Script::New(
6829 v8::String::New(
6835 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
6842 v8::HandleScope scope;
6846 v8::Local<v8::Function> foo = CompileFunction(
6854 v8::Debug::SetDebugEventListener(DebugEventBreakMax);
6857 v8::Debug::DebugBreak();
6868 v8::Debug::SetDebugEventListener(NULL);
6873 v8::Handle<v8::Context> debugee_context;
6874 v8::Handle<v8::Context> debugger_context;
6879 static v8::Handle<v8::Value> NamedGetterWithCallingContextCheck(
6880 v8::Local<v8::String> name,
6881 const v8::AccessorInfo& info) {
6882 CHECK_EQ(0, strcmp(*v8::String::AsciiValue(name), "a"));
6883 v8::Handle<v8::Context> current = v8::Context::GetCurrent();
6886 v8::Handle<v8::Context> calling = v8::Context::GetCalling();
6889 return v8::Int32::New(1);
6897 v8::DebugEvent event,
6898 v8::Handle<v8::Object> exec_state,
6899 v8::Handle<v8::Object> event_data,
6900 v8::Handle<v8::Value> data) {
6901 if (event == v8::Break) {
6903 CHECK(debugger_context == v8::Context::GetCurrent());
6904 v8::Handle<v8::Function> func(v8::Function::Cast(*CompileRun(
6910 v8::Handle<v8::Value> argv[argc] = { exec_state };
6911 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
6918 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
6920 v8::HandleScope scope;
6926 debugee_context = v8::Local<v8::Context>(*env);
6927 debugger_context = v8::Utils::ToLocal(debug->debug_context());
6930 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
6931 named->SetAccessor(v8::String::New("a"),
6933 env->Global()->Set(v8::String::New("obj"),
6937 v8::Debug::SetDebugEventListener(DebugEventGetAtgumentPropertyValue);
6940 v8::Local<v8::Function> foo = CompileFunction(
6950 v8::Debug::SetDebugEventListener(NULL);
6951 debugee_context = v8::Handle<v8::Context>();
6952 debugger_context = v8::Handle<v8::Context>();
6958 v8::HandleScope scope;
6959 v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
6960 v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
6965 static v8::Handle<v8::Value> expected_callback_data;
6966 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
6973 v8::HandleScope scope;
6974 expected_callback_data = v8::Int32::New(2010);
6975 v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
6977 expected_context = v8::Context::New();
6978 v8::Context::Scope context_scope(expected_context);
6979 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
6982 v8::Debug::SetDebugEventListener(NULL);
6983 expected_context_data = v8::Handle<v8::Value>();
6991 static void DebugEventBreakDataChecker(const v8::Debug::EventDetails& details) {
6992 if (details.GetEvent() == v8::BreakForCommand) {
6995 } else if (details.GetEvent() == v8::Break) {
7003 v8::HandleScope scope;
7005 v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker);
7013 v8::Debug::DebugBreakForCommand();
7014 v8::Script::Compile(v8::String::New("(function(x){return x;})(1);"))->Run();
7022 v8::Debug::DebugBreakForCommand(data1);
7023 v8::Script::Compile(v8::String::New("(function(x){return x+1;})(1);"))->Run();
7030 v8::Debug::DebugBreak();
7031 v8::Script::Compile(v8::String::New("(function(x){return x+2;})(1);"))->Run();
7039 v8::Debug::DebugBreak();
7040 v8::Debug::DebugBreakForCommand(data2);
7041 v8::Script::Compile(v8::String::New("(function(x){return x+3;})(1);"))->Run();
7049 v8::Debug::SetDebugEventListener(NULL);
7055 static void DebugEventBreakDeoptimize(v8::DebugEvent event,
7056 v8::Handle<v8::Object> exec_state,
7057 v8::Handle<v8::Object> event_data,
7058 v8::Handle<v8::Value> data) {
7059 if (event == v8::Break) {
7063 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
7064 v8::Handle<v8::Value> result =
7069 v8::Handle<v8::String> function_name(result->ToString());
7078 v8::Debug::DebugBreak();
7086 v8::HandleScope scope;
7101 v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize,
7102 v8::Undefined());
7105 v8::Script::Compile(v8::String::New("function bar(){}; bar()"))->Run();
7108 v8::Debug::DebugBreak();
7109 v8::Script::Compile(v8::String::New("bar()"))->Run();
7113 v8::Debug::SetDebugEventListener(NULL);
7117 static void DebugEventBreakWithOptimizedStack(v8::DebugEvent event,
7118 v8::Handle<v8::Object> exec_state,
7119 v8::Handle<v8::Object> event_data,
7120 v8::Handle<v8::Value> data) {
7121 if (event == v8::Break) {
7125 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) };
7127 v8::Handle<v8::Value> result =
7130 v8::Handle<v8::String> function_name(result->ToString());
7131 CHECK(function_name->Equals(v8::String::New("loop")));
7135 v8::Handle<v8::String> argument_name(result->ToString());
7136 CHECK(argument_name->Equals(v8::String::New("count")));
7148 v8::Handle<v8::String> local_name(result->ToString());
7149 CHECK(local_name->Equals(v8::String::New("local")));
7164 static v8::Handle<v8::Value> ScheduleBreak(const v8::Arguments& args) {
7165 v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack,
7166 v8::Undefined());
7167 v8::Debug::DebugBreak();
7168 return v8::Undefined();
7173 v8::HandleScope scope;
7188 v8::Handle<v8::FunctionTemplate> schedule_break_template =
7189 v8::FunctionTemplate::New(ScheduleBreak);
7190 v8::Handle<v8::Function> schedule_break =
7200 v8::Script::Compile(v8::String::New(src))->Run();
7233 v8::Debug::DebugBreak();
7239 CHECK(!v8::V8::IsExecutionTerminating());
7246 v8::HandleScope scope;
7250 v8::Debug::SetDebugEventListener(DebugEventBreakMax);
7284 v8::Debug::SetDebugEventListener(NULL);
7289 v8::Local<v8::Script> inline_script;
7291 static void DebugBreakInlineListener(v8::DebugEvent event,
7292 v8::Handle<v8::Object> exec_state,
7293 v8::Handle<v8::Object> event_data,
7294 v8::Handle<v8::Value> data) {
7295 if (event != v8::Break) return;
7300 i::Handle<i::Object> compiled_script = v8::Utils::OpenHandle(*inline_script);
7304 int break_id = v8
7308 v8::Local<v8::Value> result = CompileRun(script);
7317 v8::Local<v8::Value> result = CompileRun(script);
7321 v8::Debug::SetDebugEventListener(NULL);
7322 v8::V8::TerminateExecution();
7328 v8::HandleScope scope;
7344 v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
7345 inline_script = v8::Script::Compile(v8::String::New(source));