Chromium Code Reviews| Index: test/cctest/test-debug.cc |
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
| index c0ea7072fed35bd782f377a8b2d974bc9d32dc98..1e674dc2bdf89bb7a451838c52b38226238b616b 100644 |
| --- a/test/cctest/test-debug.cc |
| +++ b/test/cctest/test-debug.cc |
| @@ -7286,4 +7286,57 @@ TEST(DebugBreakLoop) { |
| } |
|
Søren Gjesse
2012/01/30 08:59:28
I think this test could have been written in JavaS
|
| +class DebugBreakSendThread : public v8::internal::Thread { |
| + public: |
| + DebugBreakSendThread() : Thread("DebugBreakSendThread") { } |
| + virtual void Run() { |
| + // Wait for crankshaft to inline f() into g(); |
|
Søren Gjesse
2012/01/30 08:59:28
Having tests with sleeps in then is not a good ide
|
| + OS::Sleep(2000); |
| + v8::Debug::DebugBreak(); |
| + } |
| +}; |
| + |
| + |
| +static void DebugBreakInlineListener(v8::DebugEvent event, |
| + v8::Handle<v8::Object> exec_state, |
| + v8::Handle<v8::Object> event_data, |
| + v8::Handle<v8::Value> data) { |
| + if (event != v8::Break) return; |
| + |
| + int break_id = v8::internal::Isolate::Current()->debug()->break_id(); |
| + char script[128]; |
| + i::Vector<char> script_vector(script, sizeof(script)); |
| + OS::SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id); |
| + v8::Local<v8::Value> result = CompileRun(script); |
| + int frame_count = result->Int32Value(); |
| + int previous = -1; |
| + 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); |
| + v8::Local<v8::Value> result = CompileRun(script); |
| + ASSERT_NE(previous, result->Int32Value()); |
| + previous = result->Int32Value(); |
| + } |
| + |
| + v8::V8::TerminateExecution(); |
| +} |
| + |
| + |
| +TEST(DebugBreakInline) { |
| + i::FLAG_allow_natives_syntax = true; |
| + v8::HandleScope scope; |
| + DebugLocalContext env; |
| + const char* source = |
| + "function f() { for(var i=0; i<1000000; i++) { 1+1; } };\n" |
| + "function g() { while(true) {f();} };\n" |
| + "g();"; |
| + v8::Debug::SetDebugEventListener(DebugBreakInlineListener); |
| + DebugBreakSendThread debugbreak; |
| + debugbreak.Start(); |
| + CompileRun(source); |
| + v8::Debug::SetDebugEventListener(NULL); |
| +} |
| + |
| + |
| #endif // ENABLE_DEBUGGER_SUPPORT |