1659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org// Copyright 2012 the V8 project authors. All rights reserved. 29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Redistribution and use in source and binary forms, with or without 39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// modification, are permitted provided that the following conditions are 49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// met: 59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions of source code must retain the above copyright 79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// notice, this list of conditions and the following disclaimer. 89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions in binary form must reproduce the above 99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// copyright notice, this list of conditions and the following 109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// disclaimer in the documentation and/or other materials provided 119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// with the distribution. 129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Neither the name of Google Inc. nor the names of its 139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// contributors may be used to endorse or promote products derived 149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// from this software without specific prior written permission. 159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#include <stdlib.h> 299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 30196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/v8.h" 319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 32196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/api.h" 335de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.org#include "src/base/platform/condition-variable.h" 345de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.org#include "src/base/platform/platform.h" 35196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/compilation-cache.h" 36196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/debug.h" 37196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/deoptimizer.h" 38196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/frames.h" 39196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "src/utils.h" 40196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org#include "test/cctest/cctest.h" 419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 42b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org 435de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.orgusing ::v8::base::Mutex; 445de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.orgusing ::v8::base::LockGuard; 455de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.orgusing ::v8::base::ConditionVariable; 465de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.orgusing ::v8::base::OS; 475de0074a922429f5e0ec2cf140c2d2989bf88140yangguo@chromium.orgusing ::v8::base::Semaphore; 48b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.orgusing ::v8::internal::EmbeddedVector; 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Object; 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Handle; 519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Heap; 525a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.orgusing ::v8::internal::JSGlobalProxy; 539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Code; 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Debug; 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::Debugger; 563a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.orgusing ::v8::internal::CommandMessage; 573a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.orgusing ::v8::internal::CommandMessageQueue; 58639bac0c5319f96e1bbe3399fb7f7f37344928bddslomov@chromium.orgusing ::v8::internal::StackFrame; 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::StepAction; 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::StepIn; // From StepAction enum 619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::StepNext; // From StepAction enum 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comusing ::v8::internal::StepOut; // From StepAction enum 6365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgusing ::v8::internal::Vector; 64c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.orgusing ::v8::internal::StrLength; 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Size of temp buffer for formatting small strings. 679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#define SMALL_STRING_BUFFER_SIZE 80 689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- H e l p e r C l a s s e s 709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Helper class for creating a V8 enviromnent for running tests 739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass DebugLocalContext { 749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com public: 759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com inline DebugLocalContext( 76a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0, 77a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org v8::Handle<v8::ObjectTemplate> global_template = 78a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org v8::Handle<v8::ObjectTemplate>(), 79a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) 80a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org : scope_(isolate), 81a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org context_(v8::Context::New(isolate, extensions, global_template, 82a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org global_object)) { 83a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org context_->Enter(); 84a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org } 85a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org inline DebugLocalContext( 869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ExtensionConfiguration* extensions = 0, 879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::ObjectTemplate> global_template = 889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::ObjectTemplate>(), 899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) 90528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org : scope_(CcTest::isolate()), 91a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org context_(v8::Context::New(CcTest::isolate(), extensions, 92a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org global_template, global_object)) { 939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com context_->Enter(); 949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com inline ~DebugLocalContext() { 969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com context_->Exit(); 979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 98f95d4b920abb640ab0986d138ad559a7d3b91d04danno@chromium.org inline v8::Local<v8::Context> context() { return context_; } 999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com inline v8::Context* operator->() { return *context_; } 1009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com inline v8::Context* operator*() { return *context_; } 101f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org inline v8::Isolate* GetIsolate() { return context_->GetIsolate(); } 1029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com inline bool IsReady() { return !context_.IsEmpty(); } 1039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com void ExposeDebug() { 10409d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org v8::internal::Isolate* isolate = 10509d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); 106d4be0f0c0edfc0a0b46e745055c3dc497c0ffcb5verwaest@chromium.org v8::internal::Factory* factory = isolate->factory(); 1079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Expose the debug context global object in the global object for testing. 1086a4d394882dba70a85567fb90ffd4f428a9eb170machenbach@chromium.org CHECK(isolate->debug()->Load()); 1096a4d394882dba70a85567fb90ffd4f428a9eb170machenbach@chromium.org Handle<v8::internal::Context> debug_context = 1106a4d394882dba70a85567fb90ffd4f428a9eb170machenbach@chromium.org isolate->debug()->debug_context(); 1116a4d394882dba70a85567fb90ffd4f428a9eb170machenbach@chromium.org debug_context->set_security_token( 1125a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org v8::Utils::OpenHandle(*context_)->security_token()); 1135a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org 1145a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( 1159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Utils::OpenHandle(*context_->Global()))); 1169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<v8::internal::String> debug_string = 1172c81ceb7f1e1ccf5f304be0646f4c1375941a7f2machenbach@chromium.org factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("debug")); 118248dd43badb99ffce44eae2d767cda3cefaad521machenbach@chromium.org v8::internal::Runtime::DefineObjectProperty(global, debug_string, 119248dd43badb99ffce44eae2d767cda3cefaad521machenbach@chromium.org handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check(); 1209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 12183e168294456ca2f02db421a635f7d5f5d023966kmillikin@chromium.org 1229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com private: 12357ff881caeb2e15b46ac9e4dfc00e378f7c5f929ulan@chromium.org v8::HandleScope scope_; 12457ff881caeb2e15b46ac9e4dfc00e378f7c5f929ulan@chromium.org v8::Local<v8::Context> context_; 1259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com}; 1269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- H e l p e r F u n c t i o n s 1299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Compile and run the supplied source and return the fequested function. 1329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic v8::Local<v8::Function> CompileFunction(DebugLocalContext* env, 1339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const char* source, 1349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const char* function_name) { 135f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) 136f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 137f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org return v8::Local<v8::Function>::Cast((*env)->Global()->Get( 138f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), function_name))); 1399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1419085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org 1429085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org// Compile and run the supplied source and return the requested function. 143f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate, 144f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org const char* source, 1459085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org const char* function_name) { 146f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run(); 147a2c0c1516848536a514b3178d2c040b7df0ceb5bmachenbach@chromium.org v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global(); 1489085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org return v8::Local<v8::Function>::Cast( 149f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org global->Get(v8::String::NewFromUtf8(isolate, function_name))); 1509085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org} 1519085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org 1529085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.org 1539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Is there any debug info for the function? 1549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic bool HasDebugInfo(v8::Handle<v8::Function> fun) { 1559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun); 1569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); 1579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return Debug::HasDebugInfo(shared); 1589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Set a break point in a function and return the associated break point 1629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// number. 1639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic int SetBreakPoint(Handle<v8::internal::JSFunction> fun, int position) { 1649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com static int break_point = 0; 16509d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org v8::internal::Isolate* isolate = fun->GetIsolate(); 16609d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org v8::internal::Debug* debug = isolate->debug(); 167ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org debug->SetBreakPoint( 1685a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org fun, 16909d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org Handle<Object>(v8::internal::Smi::FromInt(++break_point), isolate), 1705ad5acef6bd4ebc785f946d8bcc2a88b1e031827ricow@chromium.org &position); 1719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return break_point; 1729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Set a break point in a function and return the associated break point 1769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// number. 1779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic int SetBreakPoint(v8::Handle<v8::Function> fun, int position) { 1789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return SetBreakPoint(v8::Utils::OpenHandle(*fun), position); 1799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Set a break point in a function using the Debug object and return the 1839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// associated break point number. 184f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic int SetBreakPointFromJS(v8::Isolate* isolate, 185f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org const char* function_name, 1869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int line, int position) { 187b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 18870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 18970ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.setBreakPoint(%s,%d,%d)", 19070ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org function_name, line, position); 1919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 192f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Handle<v8::String> str = v8::String::NewFromUtf8(isolate, buffer.start()); 193b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org return v8::Script::Compile(str)->Run()->Int32Value(); 1949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1977be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org// Set a break point in a script identified by id using the global Debug object. 198f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id, 199f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int line, int column) { 200b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 2019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (column >= 0) { 2029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Column specified set script break point on precise location. 20370ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 20470ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.setScriptBreakPointById(%d,%d,%d)", 20570ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org script_id, line, column); 2069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 2079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Column not specified set script break point on line. 20870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 20970ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.setScriptBreakPointById(%d,%d)", 21070ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org script_id, line); 2117be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 2127be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 2137be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org { 2147be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org v8::TryCatch try_catch; 215f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Handle<v8::String> str = 216f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(isolate, buffer.start()); 2177be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); 2183a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org CHECK(!try_catch.HasCaught()); 2197be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org return value->Int32Value(); 2207be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } 2217be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org} 2227be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 2237be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 2247be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org// Set a break point in a script identified by name using the global Debug 2257be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org// object. 226f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate, 227f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org const char* script_name, int line, 228f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int column) { 2297be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 2307be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org if (column >= 0) { 2317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Column specified set script break point on precise location. 23270ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 23370ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.setScriptBreakPointByName(\"%s\",%d,%d)", 23470ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org script_name, line, column); 2357be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org } else { 2367be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Column not specified set script break point on line. 23770ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 23870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.setScriptBreakPointByName(\"%s\",%d)", 23970ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org script_name, line); 2409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 2419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 2425a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org { 2435a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org v8::TryCatch try_catch; 244f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Handle<v8::String> str = 245f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(isolate, buffer.start()); 2465a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); 2473a37e9b96c768f6b5b6b09542e1cb1a1ece7a022ager@chromium.org CHECK(!try_catch.HasCaught()); 2485a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org return value->Int32Value(); 2495a8ca6c70c6fc9716f18f6223c98d1fef5752cf6kasperl@chromium.org } 2509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 2519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Clear a break point. 2549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void ClearBreakPoint(int break_point) { 255528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Isolate* isolate = CcTest::i_isolate(); 25609d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org v8::internal::Debug* debug = isolate->debug(); 257ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org debug->ClearBreakPoint( 25809d7ab5aba54ebac170eac755664c45eefb0be7dulan@chromium.org Handle<Object>(v8::internal::Smi::FromInt(break_point), isolate)); 2599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 2609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Clear a break point using the global Debug object. 263f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void ClearBreakPointFromJS(v8::Isolate* isolate, 264f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int break_point_number) { 265b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 26670ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 26770ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.clearBreakPoint(%d)", 26870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org break_point_number); 2699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 270f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); 2719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 2729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 274f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void EnableScriptBreakPointFromJS(v8::Isolate* isolate, 275f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int break_point_number) { 276b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 27770ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 27870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.enableScriptBreakPoint(%d)", 27970ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org break_point_number); 2809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 281f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); 2829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 2839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 285f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void DisableScriptBreakPointFromJS(v8::Isolate* isolate, 286f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int break_point_number) { 287b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 28870ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 28970ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.disableScriptBreakPoint(%d)", 29070ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org break_point_number); 2919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 292f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); 2939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 2949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 296f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate, 297f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int break_point_number, 2989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const char* condition) { 299b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 30070ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 30170ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", 30270ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org break_point_number, condition); 3039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 304f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); 3059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 308f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate, 309f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int break_point_number, 3109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int ignoreCount) { 311b912362e2b2e704d09faac4290e027fd744bf587kasperl@chromium.org EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 31270ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org SNPrintF(buffer, 31370ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", 31470ec1a2160dd946b9578d04d97d631a6d4ab4f8cbmeurer@chromium.org break_point_number, ignoreCount); 3159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; 316f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); 3179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Change break on exception. 3219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void ChangeBreakOnException(bool caught, bool uncaught) { 322528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 323ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org debug->ChangeBreakOnException(v8::internal::BreakException, caught); 324ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); 3259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Change break on exception using the global Debug object. 329f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.orgstatic void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught, 330f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org bool uncaught) { 3319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (caught) { 3329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile( 333f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(isolate, "debug.Debug.setBreakOnException()")) 334f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 3359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 3369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile( 337f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(isolate, "debug.Debug.clearBreakOnException()")) 338f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 3399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (uncaught) { 3419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile( 342f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8( 343f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org isolate, "debug.Debug.setBreakOnUncaughtException()"))->Run(); 3449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 3459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile( 346f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8( 347f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org isolate, "debug.Debug.clearBreakOnUncaughtException()"))->Run(); 3489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Prepare to step to next break location. 3539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void PrepareStep(StepAction step_action) { 354528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 355639bac0c5319f96e1bbe3399fb7f7f37344928bddslomov@chromium.org debug->PrepareStep(step_action, 1, StackFrame::NO_ID); 3569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// This function is in namespace v8::internal to be friend with class 3609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// v8::internal::Debug. 36171affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.orgnamespace v8 { 36271affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.orgnamespace internal { 3639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Collect the currently debugged functions. 3659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comHandle<FixedArray> GetDebuggedFunctions() { 366528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org Debug* debug = CcTest::i_isolate()->debug(); 367ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org 368ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org v8::internal::DebugInfoListNode* node = debug->debug_info_list_; 3699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Find the number of debugged functions. 3719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int count = 0; 3729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com while (node) { 3739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com count++; 3749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com node = node->next(); 3759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Allocate array for the debugged functions 3789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<FixedArray> debugged_functions = 379528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->factory()->NewFixedArray(count); 3809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run through the debug info objects and collect all functions. 3829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com count = 0; 3839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com while (node) { 3849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com debugged_functions->set(count++, *node->debug_info()); 3859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com node = node->next(); 3869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 3879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return debugged_functions; 3899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 3909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 3919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 392381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org// Check that the debugger has been fully unloaded. 393381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgvoid CheckDebuggerUnloaded(bool check_functions) { 394381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // Check that the debugger context is cleared and that there is no debug 395381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // information stored for the debugger. 396528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); 397528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_); 398381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 399381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // Collect garbage to ensure weak handles are cleared. 400528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 401528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); 402381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 403381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // Iterate the head and check that there are no debugger related objects left. 404528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org HeapIterator iterator(CcTest::heap()); 405b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 406381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CHECK(!obj->IsDebugInfo()); 407381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CHECK(!obj->IsBreakPointInfo()); 408381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 409381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // If deep check of functions is requested check that no debug break code 410381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org // is left in all functions. 411381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (check_functions) { 412381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (obj->IsJSFunction()) { 413381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org JSFunction* fun = JSFunction::cast(obj); 414381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) { 415381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org RelocInfo::Mode rmode = it.rinfo()->rmode(); 416381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org if (RelocInfo::IsCodeTarget(rmode)) { 417381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CHECK(!Debug::IsDebugBreak(it.rinfo()->target_address())); 418381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } else if (RelocInfo::IsJSReturn(rmode)) { 419381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CHECK(!Debug::IsDebugBreakAtReturn(it.rinfo())); 420381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 421381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 422381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 423381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 424381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org } 425381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org} 426381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 427381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 4289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} } // namespace v8::internal 4299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 430381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 431381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org// Check that the debugger has been fully unloaded. 432381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.orgstatic void CheckDebuggerUnloaded(bool check_functions = false) { 433b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org // Let debugger to unload itself synchronously 434b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org v8::Debug::ProcessDebugMessages(); 435b302e56e5b70c4504faa2adf4ec3efb64a9d3e38sgjesse@chromium.org 436381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org v8::internal::CheckDebuggerUnloaded(check_functions); 437381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org} 438381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 439381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 4409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Inherit from BreakLocationIterator to get access to protected parts for 4419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// testing. 4429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comclass TestBreakLocationIterator: public v8::internal::BreakLocationIterator { 4439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com public: 4449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com explicit TestBreakLocationIterator(Handle<v8::internal::DebugInfo> debug_info) 4459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com : BreakLocationIterator(debug_info, v8::internal::SOURCE_BREAK_LOCATIONS) {} 4469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::internal::RelocIterator* it() { return reloc_iterator_; } 4479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::internal::RelocIterator* it_original() { 4489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return reloc_iterator_original_; 4499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com}; 4519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 4529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 4539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Compile a function, set a break point and check that the call at the break 4549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// location in the code is the expected debug_break function. 4559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvoid CheckDebugBreakFunction(DebugLocalContext* env, 4569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const char* source, const char* name, 457236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org int position, v8::internal::RelocInfo::Mode mode, 4589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Code* debug_break) { 459528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 460ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org 4619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Create function and set the break point. 4629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( 4639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com *CompileFunction(env, source, name)); 4649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp = SetBreakPoint(fun, position); 4659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 4669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Check that the debug break function is as expected. 4679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); 4689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(Debug::HasDebugInfo(shared)); 4699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); 47093a47f4837f2137c8d8349250fd8e91da3108126jkummerow@chromium.org it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); 4718e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode(); 4728e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { 4738e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org actual_mode = v8::internal::RelocInfo::CODE_TARGET; 4748e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org } 4758e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org CHECK_EQ(mode, actual_mode); 476236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org if (mode != v8::internal::RelocInfo::JS_RETURN) { 4779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(debug_break, 4788bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address())); 4799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 480911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org CHECK(Debug::IsDebugBreakAtReturn(it1.it()->rinfo())); 4819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 4839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Clear the break point and check that the debug break function is no longer 4849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // there 4859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp); 486ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK(!debug->HasDebugInfo(shared)); 4875a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org CHECK(debug->EnsureDebugInfo(shared, fun)); 4889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); 48993a47f4837f2137c8d8349250fd8e91da3108126jkummerow@chromium.org it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); 4908e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org actual_mode = it2.it()->rinfo()->rmode(); 4918e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { 4928e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org actual_mode = v8::internal::RelocInfo::CODE_TARGET; 4938e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org } 4948e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org CHECK_EQ(mode, actual_mode); 495236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org if (mode == v8::internal::RelocInfo::JS_RETURN) { 496911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo())); 4979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 4989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 4999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- D e b u g E v e n t H a n d l e r s 5029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- 5039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- The different tests uses a number of debug event handlers. 5049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- 5059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 507a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which picks out the function 508a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// name of a frame. 5099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comconst char* frame_function_name_source = 510a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "function frame_function_name(exec_state, frame_number) {" 511a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org " return exec_state.frame(frame_number).func().name();" 5129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "}"; 5139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comv8::Local<v8::Function> frame_function_name; 5149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 5158bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 516a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which pick out the name of the 517a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// first argument of a frame. 518a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgconst char* frame_argument_name_source = 519a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "function frame_argument_name(exec_state, frame_number) {" 520a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org " return exec_state.frame(frame_number).argumentName(0);" 521a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "}"; 522a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgv8::Local<v8::Function> frame_argument_name; 523a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 524a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 525a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which pick out the value of the 526a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// first argument of a frame. 527a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgconst char* frame_argument_value_source = 528a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "function frame_argument_value(exec_state, frame_number) {" 529a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org " return exec_state.frame(frame_number).argumentValue(0).value_;" 530a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "}"; 531a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgv8::Local<v8::Function> frame_argument_value; 532a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 533a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 534a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which pick out the name of the 535a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// first argument of a frame. 536a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgconst char* frame_local_name_source = 537a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "function frame_local_name(exec_state, frame_number) {" 538a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org " return exec_state.frame(frame_number).localName(0);" 539a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "}"; 540a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgv8::Local<v8::Function> frame_local_name; 541a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 542a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 543a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which pick out the value of the 544a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// first argument of a frame. 545a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgconst char* frame_local_value_source = 546a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "function frame_local_value(exec_state, frame_number) {" 547a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org " return exec_state.frame(frame_number).localValue(0).value_;" 548a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org "}"; 549a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.orgv8::Local<v8::Function> frame_local_value; 550a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 551a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org 552a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which picks out the source line for the 5532d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org// top frame. 5542d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgconst char* frame_source_line_source = 5552d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "function frame_source_line(exec_state) {" 5562d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org " return exec_state.frame(0).sourceLine();" 5572d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "}"; 5582d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgv8::Local<v8::Function> frame_source_line; 5592d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 5602d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 561a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which picks out the source column for the 5622d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org// top frame. 5632d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgconst char* frame_source_column_source = 5642d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "function frame_source_column(exec_state) {" 5652d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org " return exec_state.frame(0).sourceColumn();" 5662d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "}"; 5672d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgv8::Local<v8::Function> frame_source_column; 5682d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 5692d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 570a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which picks out the script name for the 57165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org// top frame. 57265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgconst char* frame_script_name_source = 57365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org "function frame_script_name(exec_state) {" 57465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org " return exec_state.frame(0).func().script().name();" 57565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org "}"; 57665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgv8::Local<v8::Function> frame_script_name; 57765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 57865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 579a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org// Source for the JavaScript function which returns the number of frames. 5808bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgstatic const char* frame_count_source = 5818bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org "function frame_count(exec_state) {" 5828bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org " return exec_state.frameCount();" 5838bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org "}"; 5848bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgv8::Handle<v8::Function> frame_count; 5858bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 5868bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 5879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Global variable to store the last function hit - used by some tests. 5889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comchar last_function_hit[80]; 5899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 590ca2f2040e0e1a10df95bec18e69499f85f4c1316machenbach@chromium.org// Global variable to store the name for last script hit - used by some tests. 59165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.orgchar last_script_name_hit[80]; 59265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 5932d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org// Global variables to store the last source position - used by some tests. 5942d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgint last_source_line = -1; 5952d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.orgint last_source_column = -1; 5962d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 5979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which counts the break points which have been hit. 5989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comint break_point_hit_count = 0; 599ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.orgint break_point_hit_count_deoptimize = 0; 600662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventBreakPointHitCount( 601662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 602662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 603662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 604528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Isolate* isolate = CcTest::i_isolate(); 605876cca833d7212e476250d102cad185cdcfa9dfesvenpanne@chromium.org Debug* debug = isolate->debug(); 6068bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 607ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 6088bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 6099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Count the number of breaks. 6109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 6119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 6129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (!frame_function_name.IsEmpty()) { 6139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Get the name of the function. 614a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org const int argc = 2; 6150f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org v8::Handle<v8::Value> argv[argc] = { 6160f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org exec_state, v8::Integer::New(CcTest::isolate(), 0) 6170f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org }; 6189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 6199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com argc, argv); 6209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (result->IsUndefined()) { 6219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com last_function_hit[0] = '\0'; 6229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 6239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(result->IsString()); 6249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::String> function_name(result->ToString()); 62557ff881caeb2e15b46ac9e4dfc00e378f7c5f929ulan@chromium.org function_name->WriteUtf8(last_function_hit); 6269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 6279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 6282d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 6292d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org if (!frame_source_line.IsEmpty()) { 6302d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org // Get the source line. 6312d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org const int argc = 1; 6322d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org v8::Handle<v8::Value> argv[argc] = { exec_state }; 6332d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org v8::Handle<v8::Value> result = frame_source_line->Call(exec_state, 6342d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org argc, argv); 6352d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org CHECK(result->IsNumber()); 6362d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org last_source_line = result->Int32Value(); 6372d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 6382d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 6392d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org if (!frame_source_column.IsEmpty()) { 6402d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org // Get the source column. 6412d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org const int argc = 1; 6422d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org v8::Handle<v8::Value> argv[argc] = { exec_state }; 6432d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org v8::Handle<v8::Value> result = frame_source_column->Call(exec_state, 6442d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org argc, argv); 6452d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org CHECK(result->IsNumber()); 6462d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org last_source_column = result->Int32Value(); 6472d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org } 64865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 64965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if (!frame_script_name.IsEmpty()) { 65065dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org // Get the script name of the function script. 65165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org const int argc = 1; 65265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org v8::Handle<v8::Value> argv[argc] = { exec_state }; 65365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org v8::Handle<v8::Value> result = frame_script_name->Call(exec_state, 65465dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org argc, argv); 65565dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org if (result->IsUndefined()) { 65665dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org last_script_name_hit[0] = '\0'; 65765dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } else { 65865dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org CHECK(result->IsString()); 65965dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org v8::Handle<v8::String> script_name(result->ToString()); 66057ff881caeb2e15b46ac9e4dfc00e378f7c5f929ulan@chromium.org script_name->WriteUtf8(last_script_name_hit); 66165dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } 66265dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org } 66365dad4b091d2925543c6326db635d0f7cf9e1edcager@chromium.org 664ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // Perform a full deoptimization when the specified number of 665ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // breaks have been hit. 666ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org if (break_point_hit_count == break_point_hit_count_deoptimize) { 667876cca833d7212e476250d102cad185cdcfa9dfesvenpanne@chromium.org i::Deoptimizer::DeoptimizeAll(isolate); 668ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org } 6699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 6709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 6719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 6729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 6738bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// Debug event handler which counts a number of events and collects the stack 6748bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org// height if there is a function compiled for that. 6759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comint exception_hit_count = 0; 6769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comint uncaught_exception_hit_count = 0; 6778bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.orgint last_js_stack_height = -1; 6786313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.orgv8::Handle<v8::Function> debug_event_listener_callback; 6796313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.orgint debug_event_listener_callback_result; 6809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 6819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void DebugEventCounterClear() { 6829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 6839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com exception_hit_count = 0; 6849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com uncaught_exception_hit_count = 0; 6859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 6869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 687662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventCounter( 688662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 689662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 690662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 691662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> event_data = event_details.GetEventData(); 692528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 693ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org 6948bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 695ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 6968bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 6979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Count the number of breaks. 6989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 6999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 7009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else if (event == v8::Exception) { 7019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com exception_hit_count++; 7029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Check whether the exception was uncaught. 704f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> fun_name = 705f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(CcTest::isolate(), "uncaught"); 7069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> fun = 707f95d4b920abb640ab0986d138ad559a7d3b91d04danno@chromium.org v8::Local<v8::Function>::Cast(event_data->Get(fun_name)); 708f95d4b920abb640ab0986d138ad559a7d3b91d04danno@chromium.org v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL); 7099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (result->IsTrue()) { 7109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com uncaught_exception_hit_count++; 7119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7138bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7148bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // Collect the JavsScript stack height if the function frame_count is 7158bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // compiled. 7168bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org if (!frame_count.IsEmpty()) { 7178bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org static const int kArgc = 1; 7188bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org v8::Handle<v8::Value> argv[kArgc] = { exec_state }; 7198bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // Using exec_state as receiver is just to have a receiver. 7206313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv); 7218bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org last_js_stack_height = result->Int32Value(); 7228bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org } 7236313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org 7246313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org // Run callback from DebugEventListener and check the result. 7256313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org if (!debug_event_listener_callback.IsEmpty()) { 7266313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org v8::Handle<v8::Value> result = 7276313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org debug_event_listener_callback->Call(event_data, 0, NULL); 7286313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org CHECK(!result.IsEmpty()); 7296313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org CHECK_EQ(debug_event_listener_callback_result, result->Int32Value()); 7306313e220249748eb26e1ddcee2bbe857fef03b42machenbach@chromium.org } 7319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 7329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which evaluates a number of expressions when a break 7359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// point is hit. Each evaluated expression is compared with an expected value. 7369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// For this debug event handler to work the following two global varaibles 7379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// must be initialized. 7389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// checks: An array of expressions and expected results 7399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// evaluate_check_function: A JavaScript function (see below) 7409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Structure for holding checks to do. 7429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstruct EvaluateCheck { 7439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const char* expr; // An expression to evaluate when a break point is hit. 7449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> expected; // The expected result. 7459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com}; 746e0e1b0d3e70c933d36ed381d511e9fda39f2a751mstarzinger@chromium.org 747e0e1b0d3e70c933d36ed381d511e9fda39f2a751mstarzinger@chromium.org 7489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Array of checks to do. 7499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstruct EvaluateCheck* checks = NULL; 7509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Source for The JavaScript function which can do the evaluation when a break 7519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// point is hit. 7529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comconst char* evaluate_check_source = 7539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function evaluate_check(exec_state, expr, expected) {" 7549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " return exec_state.frame(0).evaluate(expr).value() === expected;" 7559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "}"; 7569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comv8::Local<v8::Function> evaluate_check_function; 7579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// The actual debug event described by the longer comment above. 759662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventEvaluate( 760662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 761662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 762662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 763528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 7648bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 765ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 7668bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 76806b2696801712948b665372a38f96b1f10be6997machenbach@chromium.org break_point_hit_count++; 7699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; checks[i].expr != NULL; i++) { 7709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com const int argc = 3; 771f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Handle<v8::Value> argv[argc] = { 772f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org exec_state, 773f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(CcTest::isolate(), checks[i].expr), 774f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org checks[i].expected}; 7759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> result = 7769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com evaluate_check_function->Call(exec_state, argc, argv); 7779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (!result->IsTrue()) { 778906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org v8::String::Utf8Value utf8(checks[i].expected->ToString()); 779906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8); 7809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 7839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 7849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 7869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// This debug event listener removes a breakpoint in a function 7879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comint debug_event_remove_break_point = 0; 788662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventRemoveBreakPoint( 789662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 790662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 791662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Value> data = event_details.GetCallbackData(); 792528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 7938bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 794ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 7958bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 7969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 7979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 798659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CHECK(data->IsFunction()); 7999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(debug_event_remove_break_point); 8009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 8029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which counts break points hit and performs a step 8059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// afterwards. 8069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comStepAction step_action = StepIn; // Step action to perform when stepping. 807662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventStep( 808662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 809662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 810528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 8118bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 812ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 8138bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 8149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 8159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 8169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com PrepareStep(step_action); 8179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 8199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which counts break points hit and performs a step 8229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// afterwards. For each call the expected function is checked. 8239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// For this debug event handler to work the following two global varaibles 8249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// must be initialized. 8259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// expected_step_sequence: An array of the expected function call sequence. 8269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// frame_function_name: A JavaScript function (see below). 8279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// String containing the expected function call sequence. Note: this only works 8299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// if functions have name length of one. 8309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comconst char* expected_step_sequence = NULL; 8319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// The actual debug event described by the longer comment above. 833662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventStepSequence( 834662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 835662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 836662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 837528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 8388bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 839ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 8408bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 8419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break || event == v8::Exception) { 8429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Check that the current function is the expected. 8439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(break_point_hit_count < 844c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org StrLength(expected_step_sequence)); 845a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org const int argc = 2; 8460f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org v8::Handle<v8::Value> argv[argc] = { 8470f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org exec_state, v8::Integer::New(CcTest::isolate(), 0) 8480f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org }; 8499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 8509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com argc, argv); 8519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(result->IsString()); 852906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org v8::String::Utf8Value function_name(result->ToString()); 853c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org CHECK_EQ(1, StrLength(*function_name)); 8549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ((*function_name)[0], 8559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com expected_step_sequence[break_point_hit_count]); 8569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Perform step. 8589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 8599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com PrepareStep(step_action); 8609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 8629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which performs a garbage collection. 8659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void DebugEventBreakPointCollectGarbage( 866662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 867662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 868528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 8698bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 870ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 8718bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 8729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Perform a garbage collection when break point is hit and continue. Based 8739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // on the number of break points hit either scavenge or mark compact 8749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // collector is used. 8759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 8769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 8779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (break_point_hit_count % 2 == 0) { 8789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Scavenge. 879528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); 8809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } else { 881d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org // Mark sweep compact. 882528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 8839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 8859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 8869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 8889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Debug event handler which re-issues a debug break and calls the garbage 8899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// collector to have the heap verified. 890662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventBreak( 891662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 892662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 893528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 8948bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org // When hitting a debug event listener there must be a break set. 895ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 8968bb60585bafbf81564e6b30fcf18c82615a76f95ager@chromium.org 8979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com if (event == v8::Break) { 8989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Count the number of breaks. 8999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count++; 9009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run the garbage collector to enforce heap verification if option 9029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // --verify-heap is set. 903528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); 9049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set the break flag again to come back here as soon as possible. 906528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::Debug::DebugBreak(CcTest::isolate()); 9079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 9089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 9099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 911c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org// Debug event handler which re-issues a debug break until a limit has been 912c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org// reached. 913c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.orgint max_break_point_hit_count = 0; 914f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.orgbool terminate_after_max_break_point_hit = false; 915662436e7b124b3535773535c671c53db322070b5verwaest@chromium.orgstatic void DebugEventBreakMax( 916662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org const v8::Debug::EventDetails& event_details) { 917662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::DebugEvent event = event_details.GetEvent(); 918662436e7b124b3535773535c671c53db322070b5verwaest@chromium.org v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 919528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::Isolate* v8_isolate = CcTest::isolate(); 920528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::internal::Isolate* isolate = CcTest::i_isolate(); 921876cca833d7212e476250d102cad185cdcfa9dfesvenpanne@chromium.org v8::internal::Debug* debug = isolate->debug(); 922c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org // When hitting a debug event listener there must be a break set. 923ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org CHECK_NE(debug->break_id(), 0); 924c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org 925f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org if (event == v8::Break) { 926f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org if (break_point_hit_count < max_break_point_hit_count) { 927f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org // Count the number of breaks. 928f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org break_point_hit_count++; 929c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org 930ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // Collect the JavsScript stack height if the function frame_count is 931ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // compiled. 932ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org if (!frame_count.IsEmpty()) { 933ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org static const int kArgc = 1; 934ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org v8::Handle<v8::Value> argv[kArgc] = { exec_state }; 935ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // Using exec_state as receiver is just to have a receiver. 936ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org v8::Handle<v8::Value> result = 937ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org frame_count->Call(exec_state, kArgc, argv); 938ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org last_js_stack_height = result->Int32Value(); 939ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org } 940ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org 941f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org // Set the break flag again to come back here as soon as possible. 942528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::Debug::DebugBreak(v8_isolate); 943ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org 944f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org } else if (terminate_after_max_break_point_hit) { 945f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org // Terminate execution after the last break if requested. 946528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org v8::V8::TerminateExecution(v8_isolate); 947f0ac72dfa39ec827de605aafc57d4834237aa7f3whesse@chromium.org } 948ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org 949ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // Perform a full deoptimization when the specified number of 950ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org // breaks have been hit. 951ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org if (break_point_hit_count == break_point_hit_count_deoptimize) { 952876cca833d7212e476250d102cad185cdcfa9dfesvenpanne@chromium.org i::Deoptimizer::DeoptimizeAll(isolate); 953ddda9e81d3175130f2029c0e1205d265a00c32edjkummerow@chromium.org } 954c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org } 955c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org} 956c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org 957c4c927273ae2b690c4a015b4640a2a469c9a1a69ager@chromium.org 9589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- M e s s a g e C a l l b a c k 9599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Message callback which counts the number of messages. 9629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comint message_callback_count = 0; 9639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void MessageCallbackCountClear() { 9659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com message_callback_count = 0; 9669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 9679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void MessageCallbackCount(v8::Handle<v8::Message> message, 9699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Handle<v8::Value> data) { 9709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com message_callback_count++; 9719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 9729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// --- T h e A c t u a l T e s t s 9759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that the debug break function is the expected one for different kinds 9789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// of break locations. 9799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(DebugStub) { 9809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com using ::v8::internal::Builtins; 981ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org using ::v8::internal::Isolate; 9829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 9832bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 9849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 9859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CheckDebugBreakFunction(&env, 9869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f1(){}", "f1", 9879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 0, 988236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org v8::internal::RelocInfo::JS_RETURN, 9899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com NULL); 9909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CheckDebugBreakFunction(&env, 9919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f2(){x=1;}", "f2", 9929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 0, 9939cbaabda8b4daeb06759ace10c926ab55bb69d7bulan@chromium.org v8::internal::RelocInfo::CODE_TARGET, 994528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->builtins()->builtin( 9957979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org Builtins::kStoreIC_DebugBreak)); 9969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CheckDebugBreakFunction(&env, 9979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f3(){var a=x;}", "f3", 9989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 0, 9999cbaabda8b4daeb06759ace10c926ab55bb69d7bulan@chromium.org v8::internal::RelocInfo::CODE_TARGET, 1000528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->builtins()->builtin( 10017979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org Builtins::kLoadIC_DebugBreak)); 10029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1003236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org// TODO(1240753): Make the test architecture independent or split 1004236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org// parts of the debugger into architecture dependent files. This 1005236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org// part currently disabled as it is not portable between IA32/ARM. 10069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Currently on ICs for keyed store/load on ARM. 10079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#if !defined (__arm__) && !defined(__thumb__) 10089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CheckDebugBreakFunction( 10099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com &env, 10109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f4(){var index='propertyName'; var a={}; a[index] = 'x';}", 10119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "f4", 10129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 0, 1013236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org v8::internal::RelocInfo::CODE_TARGET, 1014528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->builtins()->builtin( 10157979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org Builtins::kKeyedStoreIC_DebugBreak)); 10169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CheckDebugBreakFunction( 10179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com &env, 10189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f5(){var index='propertyName'; var a={}; return a[index];}", 10199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "f5", 10209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 0, 1021236ad9617a7359a463144a6ebeb5431a70f769cfager@chromium.org v8::internal::RelocInfo::CODE_TARGET, 1022528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->builtins()->builtin( 10237979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org Builtins::kKeyedLoadIC_DebugBreak)); 10249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com#endif 10259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1026f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org CheckDebugBreakFunction( 1027f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org &env, 1028f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org "function f6(a){return a==null;}", 1029f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org "f6", 1030f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org 0, 1031f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org v8::internal::RelocInfo::CODE_TARGET, 1032528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::i_isolate()->builtins()->builtin( 1033f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org Builtins::kCompareNilIC_DebugBreak)); 1034f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org 10359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Check the debug break code stubs for call ICs with different number of 10369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // parameters. 1037a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // TODO(verwaest): XXX update test. 1038a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0); 1039a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1); 1040a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4); 1041a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org 1042a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // CheckDebugBreakFunction(&env, 1043a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // "function f4_0(){x();}", "f4_0", 1044a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // 0, 1045a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // v8::internal::RelocInfo::CODE_TARGET, 1046a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // *debug_break_0); 1047a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org 1048a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // CheckDebugBreakFunction(&env, 1049a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // "function f4_1(){x(1);}", "f4_1", 1050a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // 0, 1051a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // v8::internal::RelocInfo::CODE_TARGET, 1052a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // *debug_break_1); 1053a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org 1054a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // CheckDebugBreakFunction(&env, 1055a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // "function f4_4(){x(1,2,3,4);}", "f4_4", 1056a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // 0, 1057a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // v8::internal::RelocInfo::CODE_TARGET, 1058a03ba1e53fa6a04b8e56747536f226380bb6269bmachenbach@chromium.org // *debug_break_4); 10599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 10609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that the debug info in the VM is in sync with the functions being 10639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// debugged. 10649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(DebugInfo) { 10659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 10662bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 10679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Create a couple of functions for the test. 10689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> foo = 10699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CompileFunction(&env, "function foo(){}", "foo"); 10709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> bar = 10719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CompileFunction(&env, "function bar(){}", "bar"); 10729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Initially no functions are debugged. 10739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length()); 10749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(foo)); 10759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(bar)); 10769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // One function (foo) is debugged. 10779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp1 = SetBreakPoint(foo, 0); 10789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length()); 10799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(HasDebugInfo(foo)); 10809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(bar)); 10819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Two functions are debugged. 10829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp2 = SetBreakPoint(bar, 0); 10839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, v8::internal::GetDebuggedFunctions()->length()); 10849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(HasDebugInfo(foo)); 10859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(HasDebugInfo(bar)); 10869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // One function (bar) is debugged. 10879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp1); 10889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length()); 10899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(foo)); 10909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(HasDebugInfo(bar)); 10919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // No functions are debugged. 10929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp2); 10939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length()); 10949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(foo)); 10959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK(!HasDebugInfo(bar)); 10969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 10979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 10999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that a break point can be set at an IC store location. 11009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(BreakPointICStore) { 11019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 11029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 11032bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 1104381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org 1105aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 1106f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1107f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function foo(){bar=0;}"))->Run(); 1108f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1109f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 11109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 11149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run with breakpoint 11169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp = SetBreakPoint(foo, 0); 11179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 11199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp); 11249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1127aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1128381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 11299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 11309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that a break point can be set at an IC load location. 11339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(BreakPointICLoad) { 11349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 11359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 11362bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 1137aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 1138f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar=1")) 1139f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 1140f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1141f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){var x=bar;}")) 1142f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 1143f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1144f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 11459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 11499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1150ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org // Run with breakpoint. 11519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp = SetBreakPoint(foo, 0); 11529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 11549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp); 11599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1162aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1163381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 11649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 11659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that a break point can be set at an IC call location. 11689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(BreakPointICCall) { 11699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 11709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 11712bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 1172aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 1173f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1174f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run(); 1175f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1176f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function foo(){bar();}"))->Run(); 1177f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1178f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 11799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 11839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1184ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org // Run with breakpoint 11859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp = SetBreakPoint(foo, 0); 11869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 11889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 11919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 11929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp); 11939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 11949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 11959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1196aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1197381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 11989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 11999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 120165fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org// Test that a break point can be set at an IC call location and survive a GC. 120265fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.orgTEST(BreakPointICCallWithGC) { 120365fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org break_point_hit_count = 0; 120465fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org DebugLocalContext env; 12052bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 1206aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage); 1207f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1208f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){return 1;}")) 1209f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 1210f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1211f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function foo(){return bar();}")) 1212f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 1213f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1214f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 121565fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 121665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org // Run without breakpoints. 121765fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 1218d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(0, break_point_hit_count); 1219d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1220d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org // Run with breakpoint. 1221d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org int bp = SetBreakPoint(foo, 0); 1222d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 1223d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(1, break_point_hit_count); 1224d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 1225d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(2, break_point_hit_count); 1226d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1227d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org // Run without breakpoints. 1228d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org ClearBreakPoint(bp); 1229d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org foo->Call(env->Global(), 0, NULL); 1230d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(2, break_point_hit_count); 1231d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1232aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1233d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CheckDebuggerUnloaded(); 1234d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org} 1235d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1236d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1237d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org// Test that a break point can be set at an IC call location and survive a GC. 1238d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.orgTEST(BreakPointConstructCallWithGC) { 1239d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org break_point_hit_count = 0; 1240d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org DebugLocalContext env; 12412bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 1242aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage); 1243f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1244f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function bar(){ this.x = 1;}")) 1245f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 1246f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1247f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), 1248f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function foo(){return new bar(1).x;}"))->Run(); 1249f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1250f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 1251d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org 1252d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org // Run without breakpoints. 1253d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 125465fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(0, break_point_hit_count); 125565fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 125665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org // Run with breakpoint. 125765fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org int bp = SetBreakPoint(foo, 0); 125865fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 125965fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(1, break_point_hit_count); 126065fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); 126165fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(2, break_point_hit_count); 126265fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 126365fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org // Run without breakpoints. 126465fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org ClearBreakPoint(bp); 126565fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org foo->Call(env->Global(), 0, NULL); 126665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CHECK_EQ(2, break_point_hit_count); 126765fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 1268aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 126965fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org CheckDebuggerUnloaded(); 127065fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org} 127165fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 127265fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org 12739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that a break point can be set at a return store location. 12749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(BreakPointReturn) { 12759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 12769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 12772bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 12782d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 12792d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org // Create a functions for checking the source line and column when hitting 12802d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org // a break point. 12812d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org frame_source_line = CompileFunction(&env, 12822d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org frame_source_line_source, 12832d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "frame_source_line"); 12842d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org frame_source_column = CompileFunction(&env, 12852d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org frame_source_column_source, 12862d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org "frame_source_column"); 12872d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 12882d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org 1289aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 1290f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1291f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){}"))->Run(); 1292f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 1293f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 12949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 12969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 12979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 12989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 12999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run with breakpoint 13009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int bp = SetBreakPoint(foo, 0); 13019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 13029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 13032d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org CHECK_EQ(0, last_source_line); 1304e90029b96bc4097e0f14d33cc086030d7ad5007awhesse@chromium.org CHECK_EQ(15, last_source_column); 13059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 13069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 13072d18d10b30bbe822dcb5e2d6e90fd7863496243ckasperl@chromium.org CHECK_EQ(0, last_source_line); 1308e90029b96bc4097e0f14d33cc086030d7ad5007awhesse@chromium.org CHECK_EQ(15, last_source_column); 13099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 13119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com ClearBreakPoint(bp); 13129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Call(env->Global(), 0, NULL); 13139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 13149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1315aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1316381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 13179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comstatic void CallWithBreakPoints(v8::Local<v8::Object> recv, 13219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> f, 13229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int break_point_count, 13239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com int call_count) { 13249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 13259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < call_count; i++) { 13269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(recv, 0, NULL); 13279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ((i + 1) * break_point_count, break_point_hit_count); 13289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1331e0e1b0d3e70c933d36ed381d511e9fda39f2a751mstarzinger@chromium.org 13329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test GC during break point processing. 13339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(GCDuringBreakPointProcessing) { 13349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 13359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 13362bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 13379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1338aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage); 13399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> foo; 13409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC store break point with garbage collection. 13429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); 13439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SetBreakPoint(foo, 0); 13449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CallWithBreakPoints(env->Global(), foo, 1, 10); 13459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC load break point with garbage collection. 13479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); 13489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SetBreakPoint(foo, 0); 13499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CallWithBreakPoints(env->Global(), foo, 1, 10); 13509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC call break point with garbage collection. 13529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo"); 13539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SetBreakPoint(foo, 0); 13549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CallWithBreakPoints(env->Global(), foo, 1, 10); 13559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test return break point with garbage collection. 13579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo = CompileFunction(&env, "function foo(){}", "foo"); 13589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com SetBreakPoint(foo, 0); 13599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CallWithBreakPoints(env->Global(), foo, 1, 25); 13609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13612356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org // Test debug break slot break point with garbage collection. 13622356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org foo = CompileFunction(&env, "function foo(){var a;}", "foo"); 13632356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org SetBreakPoint(foo, 0); 13642356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org CallWithBreakPoints(env->Global(), foo, 1, 25); 13652356e6fbe66ac3aa027b61cb43a3c3619b3c3a5evegorov@chromium.org 1366aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1367381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 13689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Call the function three times with different garbage collections in between 13729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// and make sure that the break point survives. 1373c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.orgstatic void CallAndGC(v8::Local<v8::Object> recv, 1374c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com v8::Local<v8::Function> f) { 13759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 13769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < 3; i++) { 13789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call function. 13799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(recv, 0, NULL); 13809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1 + i * 3, break_point_hit_count); 13819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Scavenge and call function. 1383528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); 13849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(recv, 0, NULL); 13859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2 + i * 3, break_point_hit_count); 13869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Mark sweep (and perhaps compact) and call function. 1388528ce02b8680a3ab6d75c7079f180a4016c69b7amachenbach@chromium.org CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 13899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(recv, 0, NULL); 13909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(3 + i * 3, break_point_hit_count); 13919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 13929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 13939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 13949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1395c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// Test that a break point can be set at a return store location. 1396c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comTEST(BreakPointSurviveGC) { 13979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 13989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 13992bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 14009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1401aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 14029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> foo; 14039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC store break point with garbage collection. 1405c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org { 1406659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CompileFunction(&env, "function foo(){}", "foo"); 1407c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); 1408c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org SetBreakPoint(foo, 0); 1409c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org } 1410c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com CallAndGC(env->Global(), foo); 14119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC load break point with garbage collection. 1413c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org { 1414659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CompileFunction(&env, "function foo(){}", "foo"); 1415c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); 1416c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org SetBreakPoint(foo, 0); 1417c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org } 1418c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com CallAndGC(env->Global(), foo); 14199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test IC call break point with garbage collection. 1421c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org { 1422659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CompileFunction(&env, "function foo(){}", "foo"); 1423c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org foo = CompileFunction(&env, 1424c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org "function bar(){};function foo(){bar();}", 1425c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org "foo"); 1426c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org SetBreakPoint(foo, 0); 1427c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org } 1428c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com CallAndGC(env->Global(), foo); 14299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Test return break point with garbage collection. 1431c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org { 1432659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CompileFunction(&env, "function foo(){}", "foo"); 1433c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org foo = CompileFunction(&env, "function foo(){}", "foo"); 1434c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org SetBreakPoint(foo, 0); 1435c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org } 1436c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com CallAndGC(env->Global(), foo); 1437c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org 1438c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org // Test non IC break point with garbage collection. 1439c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org { 1440659ceec4628056d3c6e7076c850fba1c412cbb8ayangguo@chromium.org CompileFunction(&env, "function foo(){}", "foo"); 1441c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); 1442c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org SetBreakPoint(foo, 0); 1443c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org } 1444c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com CallAndGC(env->Global(), foo); 1445c4e51ac6d26b42753a57a4a9e4a419243b50151clrn@chromium.org 14469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1447aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1448381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 14499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 14509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that break points can be set using the global Debug object. 14539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(BreakPointThroughJavaScript) { 14549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 14559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 14562bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 14579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 14589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1459aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 1460f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile( 1461f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run(); 1462f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1463f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function foo(){bar();bar();}")) 1464f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ->Run(); 14659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // 012345678901234567890 14669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // 1 2 14679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Break points are set at position 3 and 9 1468f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Script> foo = 1469f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "foo()")); 14709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 14729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 14749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run with one breakpoint 1476f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int bp1 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 3); 14779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 14799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 14819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run with two breakpoints 1483f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int bp2 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 9); 14849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(4, break_point_hit_count); 14869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(6, break_point_hit_count); 14889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run with one breakpoint 1490f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), bp2); 14919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(7, break_point_hit_count); 14939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(8, break_point_hit_count); 14959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 14969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Run without breakpoints. 1497f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), bp1); 14989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com foo->Run(); 14999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(8, break_point_hit_count); 15009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1501aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1502381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 15039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Make sure that the break point numbers are consecutive. 15059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, bp1); 15069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, bp2); 15079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 15089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15107be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org// Test that break points on scripts identified by name can be set using the 15117be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org// global Debug object. 15127be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgTEST(ScriptBreakPointByNameThroughJavaScript) { 15139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 15149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 15152bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 15169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 15179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1518aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 15199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1520f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 1521f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 15229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f() {\n" 15239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " function h() {\n" 15249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " a = 0; // line 2\n" 15259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " }\n" 15269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " b = 1; // line 4\n" 15279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " return h();\n" 15289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "}\n" 15299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "\n" 15309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function g() {\n" 15319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " function h() {\n" 15329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " a = 0;\n" 15339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " }\n" 15349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " b = 2; // line 12\n" 15359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " h();\n" 15369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " b = 3; // line 14\n" 15379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " f(); // line 15\n" 15389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "}"); 15399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get the two functions. 15419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ScriptOrigin origin = 1542f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 15439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1544f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 1545f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 1546f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( 1547f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); 15489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g without break points. 15509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 15519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 15539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 15549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 15559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g with break point on line 12. 1557f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0); 15589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 15599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 15619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 15629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 15639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Remove the break point again. 15659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 1566f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp1); 15679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 15699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 15709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 15719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g with break point on line 2. 1573f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp2 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 2, 0); 15749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 15759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 15779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 15789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 15799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g with break point on line 2, 4, 12, 14 and 15. 1581f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp3 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 4, 0); 1582f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp4 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0); 1583f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp5 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 14, 0); 1584f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp6 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 15, 0); 15859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 15869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 15889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 15899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(7, break_point_hit_count); 15909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 15917be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Remove all the break points again. 15929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 1593f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp2); 1594f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp3); 1595f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp4); 1596f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp5); 1597f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp6); 15989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 15999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 16009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 16019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 16029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1603aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 16047be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CheckDebuggerUnloaded(); 16057be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16067be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Make sure that the break point numbers are consecutive. 16077be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(1, sbp1); 16087be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(2, sbp2); 16097be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(3, sbp3); 16107be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(4, sbp4); 16117be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(5, sbp5); 16127be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(6, sbp6); 16137be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org} 16147be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16157be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16167be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.orgTEST(ScriptBreakPointByIdThroughJavaScript) { 16177be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 16187be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org DebugLocalContext env; 16192bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 16207be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org env.ExposeDebug(); 16217be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 1622aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 16237be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 1624f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> source = v8::String::NewFromUtf8( 1625f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 16267be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org "function f() {\n" 16277be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " function h() {\n" 16287be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " a = 0; // line 2\n" 16297be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " }\n" 16307be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " b = 1; // line 4\n" 16317be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " return h();\n" 16327be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org "}\n" 16337be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org "\n" 16347be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org "function g() {\n" 16357be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " function h() {\n" 16367be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " a = 0;\n" 16377be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " }\n" 16387be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " b = 2; // line 12\n" 16397be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " h();\n" 16407be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " b = 3; // line 14\n" 16417be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org " f(); // line 15\n" 16427be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org "}"); 16437be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16447be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Compile the script and get the two functions. 16457be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org v8::ScriptOrigin origin = 1646f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 16477be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org v8::Local<v8::Script> script = v8::Script::Compile(source, &origin); 16487be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org script->Run(); 1649f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 1650f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 1651f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( 1652f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); 16537be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16547be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Get the script id knowing that internally it is a 32 integer. 16551e2d50cf3d94ff48285da107b7a9da1ad0fc873dmachenbach@chromium.org int script_id = script->GetUnboundScript()->GetId(); 16567be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16577be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Call f and g without break points. 16587be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 16597be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 16607be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 16617be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org g->Call(env->Global(), 0, NULL); 16627be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 16637be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16647be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Call f and g with break point on line 12. 1665f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp1 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0); 16667be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 16677be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 16687be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 16699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 16709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 16719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16727be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Remove the break point again. 16737be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 1674f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp1); 16757be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 16767be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 16777be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org g->Call(env->Global(), 0, NULL); 16787be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 16797be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16807be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Call f and g with break point on line 2. 1681f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp2 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 2, 0); 16827be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 16837be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 16847be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(1, break_point_hit_count); 16859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 16869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 16879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 16887be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Call f and g with break point on line 2, 4, 12, 14 and 15. 1689f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp3 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 4, 0); 1690f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp4 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0); 1691f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp5 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 14, 0); 1692f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp6 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 15, 0); 16937be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 16947be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 16957be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(2, break_point_hit_count); 16967be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org g->Call(env->Global(), 0, NULL); 16977be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(7, break_point_hit_count); 16987be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 16997be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org // Remove all the break points again. 17007be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org break_point_hit_count = 0; 1701f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp2); 1702f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp3); 1703f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp4); 1704f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp5); 1705f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp6); 17067be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org f->Call(env->Global(), 0, NULL); 17077be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 17087be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org g->Call(env->Global(), 0, NULL); 17097be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org CHECK_EQ(0, break_point_hit_count); 17107be3c996bea370e151c9fe4ecf7f779cdc5f87adkasperl@chromium.org 1711aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1712381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 17139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Make sure that the break point numbers are consecutive. 17159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, sbp1); 17169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, sbp2); 17179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(3, sbp3); 17189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(4, sbp4); 17199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(5, sbp5); 17209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(6, sbp6); 17219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 17229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test conditional script break points. 17259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(EnableDisableScriptBreakPoint) { 17269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 17279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 17282bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 17299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 17309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1731aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 17329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1733f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 1734f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 17359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f() {\n" 17369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " a = 0; // line 1\n" 17379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "};"); 17389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get function f. 17409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ScriptOrigin origin = 1741f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 17429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1743f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 1744f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 17459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set script break point on line 1 (in function f). 1747f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); 17489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f while enabeling and disabling the script break point. 17509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 17519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 17539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1754f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org DisableScriptBreakPointFromJS(env->GetIsolate(), sbp); 17559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 17579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1758f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org EnableScriptBreakPointFromJS(env->GetIsolate(), sbp); 17599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 17619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1762f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org DisableScriptBreakPointFromJS(env->GetIsolate(), sbp); 17639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 17659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Reload the script and get f again checking that the disabeling survives. 17679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1768f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1769f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 17709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 17729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1773f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org EnableScriptBreakPointFromJS(env->GetIsolate(), sbp); 17749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 17759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(3, break_point_hit_count); 17769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1777aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1778381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 17799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 17809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 17829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test conditional script break points. 17839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ConditionalScriptBreakPoint) { 17849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 17859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 17862bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 17879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 17889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1789aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 17909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1791f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 1792f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 17939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "count = 0;\n" 17949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f() {\n" 17959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " g(count++); // line 2\n" 17969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "};\n" 17979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function g(x) {\n" 17989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " var a=x; // line 5\n" 17999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "};"); 18009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get function f. 18029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ScriptOrigin origin = 1803f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 18049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1805f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 1806f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 18079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set script break point on line 5 (in function g). 1809f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 5, 0); 18109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f with different conditions on the script break point. 18129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 1813f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "false"); 18149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 18169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1817f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "true"); 18189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 18219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1822f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0"); 18239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < 10; i++) { 18259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(5, break_point_hit_count); 18289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Reload the script and get f again checking that the condition survives. 18309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1831f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1832f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 18339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < 10; i++) { 18369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(5, break_point_hit_count); 18399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1840aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1841381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 18429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 18439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test ignore count on script break points. 18469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ScriptBreakPointIgnoreCount) { 18479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 18492bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 18509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 18519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1852aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 18539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1854f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 1855f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 18569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f() {\n" 18579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " a = 0; // line 1\n" 18589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "};"); 18599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get function f. 18619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ScriptOrigin origin = 1862f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 18639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1864f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 1865f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 18669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set script break point on line 1 (in function f). 1868f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); 18699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f with different ignores on the script break point. 18719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 1872f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1); 18739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 18759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 18779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1878f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5); 18799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < 10; i++) { 18819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(5, break_point_hit_count); 18849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Reload the script and get f again checking that the ignore survives. 18869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 1887f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1888f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 18899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 18909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 18919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com for (int i = 0; i < 10; i++) { 18929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 18939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com } 18949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(5, break_point_hit_count); 18959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1896aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1897381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 18989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 18999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test that script break points survive when a script is reloaded. 19029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ScriptBreakPointReload) { 19039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 19049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 19052bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 19069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 19079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1908aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 19099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> f; 1911f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 1912f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 19139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "function f() {\n" 19149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " function h() {\n" 19159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " a = 0; // line 2\n" 19169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " }\n" 19179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " b = 1; // line 4\n" 19189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com " return h();\n" 19199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "}"); 19209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1921f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin origin_1 = 1922f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "1")); 1923f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin origin_2 = 1924f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "2")); 19259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set a script break point before the script is loaded. 1927f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org SetScriptBreakPointByNameFromJS(env->GetIsolate(), "1", 2, 0); 19289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get the function. 19309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin_1)->Run(); 1931f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1932f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 19339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that the script break point is active. 19359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 19369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 19379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 19389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script again with a different script data and get the 19409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // function. 19419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin_2)->Run(); 1942f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1943f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 19449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that no break points are set. 19469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 19479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 19489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 19499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script again and get the function. 19519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin_1)->Run(); 1952f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1953f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 19549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that the script break point is active. 19569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 19579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 19589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 19599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1960aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 1961381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 19629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 19639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test when several scripts has the same script data 19669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ScriptBreakPointMultiple) { 19679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 19689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 19692bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 19709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 19719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1972aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 19739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> f; 1975f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script_f = 1976f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), 1977f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function f() {\n" 1978f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org " a = 0; // line 1\n" 1979f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "}"); 19809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> g; 1982f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script_g = 1983f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), 1984f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function g() {\n" 1985f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org " b = 0; // line 1\n" 1986f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "}"); 19879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::ScriptOrigin origin = 1989f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); 19909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set a script break point before the scripts are loaded. 1992f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); 19939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 19949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the scripts with same script data and get the functions. 19959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script_f, &origin)->Run(); 1996f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 1997f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 19989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script_g, &origin)->Run(); 1999f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org g = v8::Local<v8::Function>::Cast( 2000f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); 20019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g and check that the script break point is active. 20039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 20069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 20079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 20089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Clear the script break point. 2010f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp); 20119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g and check that the script break point is no longer active. 20139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 20169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 20179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 20189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set script break point with the scripts loaded. 2020f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); 20219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and g and check that the script break point is active. 20239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 20269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com g->Call(env->Global(), 0, NULL); 20279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 20289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2029aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 2030381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 20319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 20329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test the script origin which has both name and line offset. 20359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ScriptBreakPointLineOffset) { 20369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 20382bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 20399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 20409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2041aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 20429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> f; 2044f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = v8::String::NewFromUtf8( 2045f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->GetIsolate(), 2046f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function f() {\n" 2047f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org " a = 0; // line 8 as this script has line offset 7\n" 2048f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org " b = 0; // line 9 as this script has line offset 7\n" 2049f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "}"); 20509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Create script origin both name and line offset. 2052f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::ScriptOrigin origin( 2053f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), 20540f13e74b7310d8b14f19c6b93b36ff95059f97f6ulan@chromium.org v8::Integer::New(env->GetIsolate(), 7)); 20559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set two script break points before the script is loaded. 2057f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp1 = 2058f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0); 2059f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org int sbp2 = 2060f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); 20619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Compile the script and get the function. 20639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Script::Compile(script, &origin)->Run(); 2064f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org f = v8::Local<v8::Function>::Cast( 2065f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 20669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that the script break point is active. 20689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(2, break_point_hit_count); 20719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Clear the script break points. 2073f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp1); 2074f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org ClearBreakPointFromJS(env->GetIsolate(), sbp2); 20759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that no script break points are active. 20779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(0, break_point_hit_count); 20809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Set a script break point with the script loaded. 2082f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); 20839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Call f and check that the script break point is active. 20859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com break_point_hit_count = 0; 20869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com f->Call(env->Global(), 0, NULL); 20879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com CHECK_EQ(1, break_point_hit_count); 20889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2089aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(NULL); 2090381abbb58260f2fc7d346d0e2f83d0f132a4c14bager@chromium.org CheckDebuggerUnloaded(); 20919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 20929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 20949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test script break points set on lines. 20959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comTEST(ScriptBreakPointLine) { 20969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com DebugLocalContext env; 20972bda543d75374afd8d7e98f56ca99a57ae1b7bd1svenpanne@chromium.org v8::HandleScope scope(env->GetIsolate()); 20989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com env.ExposeDebug(); 20999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 21009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com // Create a function for checking the function when hitting a break point. 21019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com frame_function_name = CompileFunction(&env, 21029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com frame_function_name_source, 21039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com "frame_function_name"); 21049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 2105aa107b240dc43417fae8469b5c1b0f1ec9f98400machenbach@chromium.org v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 21069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 21079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> f; 21089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com v8::Local<v8::Function> g; 2109f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::Local<v8::String> script = 2110f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org v8::String::NewFromUtf8(env->GetIsolate(), 2111f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "a = 0 // line 0\n" 2112f9841897146bc10dbb3c45f0632bb79254602c75machenbach@chromium.org "function f() {\n" 2113f9841897146bc10dbb3c45f0632bb79254602c75