OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7278 TestDebugBreakInLoop("do {", loop_bodies, "} while (a == 1)"); | 7278 TestDebugBreakInLoop("do {", loop_bodies, "} while (a == 1)"); |
7279 | 7279 |
7280 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); | 7280 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); |
7281 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); | 7281 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); |
7282 | 7282 |
7283 // Get rid of the debug event listener. | 7283 // Get rid of the debug event listener. |
7284 v8::Debug::SetDebugEventListener(NULL); | 7284 v8::Debug::SetDebugEventListener(NULL); |
7285 CheckDebuggerUnloaded(); | 7285 CheckDebuggerUnloaded(); |
7286 } | 7286 } |
7287 | 7287 |
7288 | 7288 |
Søren Gjesse
2012/01/30 08:59:28
I think this test could have been written in JavaS
| |
7289 class DebugBreakSendThread : public v8::internal::Thread { | |
7290 public: | |
7291 DebugBreakSendThread() : Thread("DebugBreakSendThread") { } | |
7292 virtual void Run() { | |
7293 // 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
| |
7294 OS::Sleep(2000); | |
7295 v8::Debug::DebugBreak(); | |
7296 } | |
7297 }; | |
7298 | |
7299 | |
7300 static void DebugBreakInlineListener(v8::DebugEvent event, | |
7301 v8::Handle<v8::Object> exec_state, | |
7302 v8::Handle<v8::Object> event_data, | |
7303 v8::Handle<v8::Value> data) { | |
7304 if (event != v8::Break) return; | |
7305 | |
7306 int break_id = v8::internal::Isolate::Current()->debug()->break_id(); | |
7307 char script[128]; | |
7308 i::Vector<char> script_vector(script, sizeof(script)); | |
7309 OS::SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id); | |
7310 v8::Local<v8::Value> result = CompileRun(script); | |
7311 int frame_count = result->Int32Value(); | |
7312 int previous = -1; | |
7313 for (int i = 0; i < frame_count; i++) { | |
7314 // The 5. element in the returned array of GetFrameDetails contains the | |
7315 // source position of that frame. | |
7316 OS::SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i); | |
7317 v8::Local<v8::Value> result = CompileRun(script); | |
7318 ASSERT_NE(previous, result->Int32Value()); | |
7319 previous = result->Int32Value(); | |
7320 } | |
7321 | |
7322 v8::V8::TerminateExecution(); | |
7323 } | |
7324 | |
7325 | |
7326 TEST(DebugBreakInline) { | |
7327 i::FLAG_allow_natives_syntax = true; | |
7328 v8::HandleScope scope; | |
7329 DebugLocalContext env; | |
7330 const char* source = | |
7331 "function f() { for(var i=0; i<1000000; i++) { 1+1; } };\n" | |
7332 "function g() { while(true) {f();} };\n" | |
7333 "g();"; | |
7334 v8::Debug::SetDebugEventListener(DebugBreakInlineListener); | |
7335 DebugBreakSendThread debugbreak; | |
7336 debugbreak.Start(); | |
7337 CompileRun(source); | |
7338 v8::Debug::SetDebugEventListener(NULL); | |
7339 } | |
7340 | |
7341 | |
7289 #endif // ENABLE_DEBUGGER_SUPPORT | 7342 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |